KwpSettlementLogisticsMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.sckw.payment.dao.KwpSettlementLogisticsMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.payment.model.KwpSettlementLogistics">
  5. <!--@mbg.generated-->
  6. <!--@Table kwp_settlement_logistics-->
  7. <id column="id" jdbcType="BIGINT" property="id"/>
  8. <result column="ent_id" jdbcType="BIGINT" property="entId"/>
  9. <result column="l_ledger_id" jdbcType="BIGINT" property="lLedgerId"/>
  10. <result column="sl_order_no" jdbcType="VARCHAR" property="slOrderNo"/>
  11. <result column="name" jdbcType="VARCHAR" property="name"/>
  12. <result column="total_price" jdbcType="DECIMAL" property="totalPrice"/>
  13. <result column="actual_price" jdbcType="DECIMAL" property="actualPrice"/>
  14. <result column="receipt_time" jdbcType="TIMESTAMP" property="receiptTime"/>
  15. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  16. <result column="audit_user" jdbcType="VARCHAR" property="auditUser"/>
  17. <result column="audit_phone" jdbcType="VARCHAR" property="auditPhone"/>
  18. <result column="success_user" jdbcType="VARCHAR" property="successUser"/>
  19. <result column="success_phone" jdbcType="VARCHAR" property="successPhone"/>
  20. <result column="status" jdbcType="INTEGER" property="status"/>
  21. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  22. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  23. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  24. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  25. <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
  26. </resultMap>
  27. <sql id="Base_Column_List">
  28. id,
  29. ent_id,
  30. l_ledger_id,
  31. sl_order_no,
  32. name,
  33. total_price,
  34. actual_price,
  35. receipt_time,
  36. remark,
  37. audit_user,
  38. audit_phone,
  39. success_user,
  40. success_phone,
  41. status,
  42. create_by,
  43. create_time,
  44. update_by,
  45. update_time,
  46. del_flag
  47. </sql>
  48. <sql id="Join_Column_List">
  49. s.id,
  50. s.ent_id as entId,
  51. s.l_ledger_id as lLedgerId,
  52. s.sl_order_no as slOrderNo,
  53. s.name,
  54. s.total_price as totalPrice,
  55. s.actual_price as actualPrice,
  56. s.receipt_time as receiptTime,
  57. s.remark,
  58. s.audit_user as auditUser,
  59. s.audit_phone as auditPhone,
  60. s.success_user as successUser,
  61. s.success_phone as successPhone,
  62. s.status,
  63. s.create_by as createBy,
  64. s.create_time as createTime,
  65. s.update_by as updateBy,
  66. s.update_time as updateTime,
  67. s.del_flag as delFlag
  68. </sql>
  69. <!-- 连表筛选准备 -->
  70. <sql id="settlementLogisticsSelect">
  71. select l.name as ledgerName,
  72. l.l_ledger_no as lLedgerNo,
  73. l.trading as ledgerTrading,
  74. l.settle_price as ledgerSettlePrice,
  75. l.url as attachmentUrl,
  76. lu.unit_type as unitType,
  77. lu.firm_name as CustomerName,
  78. <include refid="Join_Column_List"/>
  79. from kwp_settlement_logistics s
  80. left join kwp_ledger_logistics l on s.l_ledger_id = l.id
  81. left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  82. </sql>
  83. <!-- 连表筛选准备 -->
  84. <sql id="settlementLogisticsSelectSum">
  85. select count(l.id) total,
  86. sum(l.settle_price) as actualReceivable,
  87. sum(s.actual_price) as currentReceipt
  88. from kwp_settlement_logistics s
  89. left join kwp_ledger_logistics l on s.l_ledger_id = l.id
  90. left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  91. </sql>
  92. <!-- 根据连表,查询条件准备 -->
  93. <sql id="settlementLogisticsSelectWhere">
  94. <if test="settlementReq.status != null">
  95. and s.status = #{settlementReq.status}
  96. </if>
  97. <if test="settlementReq.unitType != null">
  98. and lu.unit_type = #{settlementReq.unitType}
  99. </if>
  100. <if test="settlementReq.entId != null">
  101. and lu.top_ent_id = #{settlementReq.entId}
  102. </if>
  103. <if test="settlementReq.startCreateTime != null and settlementReq.endCreateTime != null">
  104. and s.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
  105. </if>
  106. <if test="settlementReq.startReceiptTime != null and settlementReq.endReceiptTime != null">
  107. and s.receipt_time between #{settlementReq.startReceiptTime,jdbcType=TIMESTAMP} and #{settlementReq.endReceiptTime,jdbcType=TIMESTAMP}
  108. </if>
  109. <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
  110. and l.name like concat('%'
  111. , #{settlementReq.keywords}
  112. , '%')
  113. and lu.firm_name like concat('%'
  114. , #{settlementReq.keywords}
  115. , '%')
  116. </if>
  117. </sql>
  118. <!-- 结算运费-物流订单列表 -->
  119. <select id="pageSelect" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
  120. <include refid="settlementLogisticsSelect"/>
  121. <where>
  122. l.del_flag = 0
  123. and s.del_flag = 0
  124. and lu.del_flag = 0
  125. <include refid="settlementLogisticsSelectWhere"/>
  126. </where>
  127. order by s.update_time desc
  128. </select>
  129. <!-- 结算运费-物流订单列表合计 -->
  130. <select id="selectSum" resultType="com.sckw.payment.model.vo.res.SettlementLogisticsSumVo">
  131. select a.*, (a.actualReceivable - a.currentReceipt) AS remainingReceivables From (
  132. <include refid="settlementLogisticsSelectSum"/>
  133. <where>
  134. l.del_flag = 0
  135. and s.del_flag = 0
  136. and lu.del_flag = 0
  137. <include refid="settlementLogisticsSelectWhere"/>
  138. </where>
  139. ) a
  140. </select>
  141. <!-- 结算运费-物流订单列表头部汇总数 -->
  142. <select id="getCountList" resultType="java.lang.Long">
  143. select count(s.id) as num
  144. from kwp_settlement_logistics s
  145. left join kwp_ledger_logistics l on s.l_ledger_id = l.id
  146. left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  147. <where>
  148. l.del_flag = 0
  149. and s.del_flag = 0
  150. and lu.del_flag = 0
  151. <include refid="settlementLogisticsSelectWhere"/>
  152. </where>
  153. </select>
  154. <!-- 根据结算物流订单id查详情 -->
  155. <select id="detail" parameterType="java.lang.Long"
  156. resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
  157. select l.name as ledgerName,
  158. l.l_ledger_no as lLedgerNo,
  159. l.trading as ledgerTrading,
  160. l.settle_price as ledgerSettlePrice,
  161. l.url as attachmentUrl,
  162. lu.unit_type as unitType,
  163. lu.firm_name as CustomerName,
  164. <include refid="Join_Column_List"/>
  165. from kwp_settlement_logistics s
  166. left join kwp_ledger_logistics l on s.l_ledger_id = l.id
  167. left join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  168. where s.id = #{id,jdbcType=BIGINT}
  169. <if test="unitType != null">
  170. and lu.unit_type = #{unitType}
  171. </if>
  172. </select>
  173. <!-- 根据多个结算运费物流订单id查订单,用于导出 -->
  174. <select id="selectLogisticsList" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
  175. <include refid="settlementLogisticsSelect"/>
  176. <where>
  177. l.del_flag = 0
  178. and s.del_flag = 0
  179. and lu.del_flag = 0
  180. <include refid="settlementLogisticsSelectWhere"/>
  181. <if test="ids != null and ids.size() > 0">
  182. and s.id in
  183. <foreach collection="ids" item="id" close=")" open="(" separator=",">
  184. #{id,jdbcType=BIGINT}
  185. </foreach>
  186. </if>
  187. </where>
  188. order by s.update_time desc
  189. </select>
  190. </mapper>