KwpSettlementLogisticsMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 trading,
  74. l.settle_price as ledgerSettlePrice,
  75. l.url as attachmentUrl,
  76. lu2.unit_type as unitType,
  77. lu2.firm_name as firmName,
  78. <include refid="Join_Column_List"/>
  79. from kwp_settlement_logistics s
  80. inner join kwp_ledger_logistics l on s.l_ledger_id = l.id
  81. inner join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  82. inner join kwp_ledger_logistics_unit lu2 on s.l_ledger_id = lu2.l_ledger_id
  83. </sql>
  84. <!-- 连表筛选准备 -->
  85. <sql id="settlementLogisticsSelectSum">
  86. select count(l.id) total,
  87. sum(l.settle_price) as actualReceivable,
  88. sum(s.actual_price) as currentReceipt
  89. from kwp_settlement_logistics s
  90. inner join kwp_ledger_logistics l on s.l_ledger_id = l.id
  91. inner join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  92. inner join kwp_ledger_logistics_unit lu2 on s.l_ledger_id = lu2.l_ledger_id
  93. </sql>
  94. <!-- 根据连表,查询条件准备 -->
  95. <sql id="settlementLogisticsSelectWhere">
  96. <if test="settlementReq.status != null and settlementReq.status != 0">
  97. and s.status = #{settlementReq.status}
  98. </if>
  99. <if test="settlementReq.unitType != null">
  100. and lu.unit_type = #{settlementReq.unitType,jdbcType=INTEGER}
  101. </if>
  102. <if test="settlementReq.unitTypeTwo != null">
  103. and lu2.unit_type = #{settlementReq.unitTypeTwo,jdbcType=INTEGER}
  104. </if>
  105. <if test="settlementReq.entId != null">
  106. and lu2.top_ent_id = #{settlementReq.entId,jdbcType=INTEGER}
  107. </if>
  108. <if test="settlementReq.trading != null and settlementReq.trading != ''">
  109. and l.trading = #{settlementReq.trading,jdbcType=VARCHAR}
  110. </if>
  111. <if test="settlementReq.startCreateTime != null and settlementReq.endCreateTime != null">
  112. and s.create_time between #{settlementReq.startCreateTime,jdbcType=TIMESTAMP} and #{settlementReq.endCreateTime,jdbcType=TIMESTAMP}
  113. </if>
  114. <if test="settlementReq.startReceiptTime != null and settlementReq.endReceiptTime != null">
  115. and s.receipt_time between #{settlementReq.startReceiptTime,jdbcType=TIMESTAMP} and #{settlementReq.endReceiptTime,jdbcType=TIMESTAMP}
  116. </if>
  117. <if test="settlementReq.keywords != null and settlementReq.keywords != ''">
  118. and ( and l.name like concat('%'
  119. , #{settlementReq.keywords,jdbcType=VARCHAR}
  120. , '%')
  121. or lu2.firm_name like concat('%'
  122. , #{settlementReq.keywords,jdbcType=VARCHAR}
  123. , '%')
  124. )
  125. </if>
  126. </sql>
  127. <!-- 结算运费-物流订单列表 -->
  128. <select id="pageSelect" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
  129. <include refid="settlementLogisticsSelect"/>
  130. <where>
  131. l.del_flag = 0
  132. and s.del_flag = 0
  133. and lu.del_flag = 0
  134. and lu2.del_flag = 0
  135. <include refid="settlementLogisticsSelectWhere"/>
  136. </where>
  137. order by s.update_time desc
  138. </select>
  139. <!-- 结算运费-物流订单列表合计 -->
  140. <select id="selectSum" resultType="com.sckw.payment.model.vo.res.SettlementLogisticsSumVo">
  141. select a.*, (a.actualReceivable - a.currentReceipt) AS remainingReceivables From (
  142. <include refid="settlementLogisticsSelectSum"/>
  143. <where>
  144. l.del_flag = 0
  145. and s.del_flag = 0
  146. and lu.del_flag = 0
  147. and lu2.del_flag = 0
  148. <include refid="settlementLogisticsSelectWhere"/>
  149. </where>
  150. ) a
  151. </select>
  152. <!-- 结算运费-物流订单列表头部汇总数 -->
  153. <select id="getCountList" resultType="java.lang.Long">
  154. select count(s.id) as num
  155. from kwp_settlement_logistics s
  156. inner join kwp_ledger_logistics l on s.l_ledger_id = l.id
  157. inner join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  158. inner join kwp_ledger_logistics_unit lu2 on s.l_ledger_id = lu2.l_ledger_id
  159. <where>
  160. l.del_flag = 0
  161. and s.del_flag = 0
  162. and lu.del_flag = 0
  163. and lu2.del_flag = 0
  164. <include refid="settlementLogisticsSelectWhere"/>
  165. </where>
  166. </select>
  167. <!-- 根据结算物流订单id查详情 -->
  168. <select id="detail" parameterType="java.lang.Long"
  169. resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
  170. select l.name as ledgerName,
  171. l.l_ledger_no as lLedgerNo,
  172. l.trading as trading,
  173. l.settle_price as settlePrice,
  174. l.url as attachmentUrl,
  175. lu.unit_type as unitType,
  176. lu2.firm_name as firmName,
  177. <include refid="Join_Column_List"/>
  178. from kwp_settlement_logistics s
  179. inner join kwp_ledger_logistics l on s.l_ledger_id = l.id
  180. inner join kwp_ledger_logistics_unit lu on s.l_ledger_id = lu.l_ledger_id
  181. inner join kwp_ledger_logistics_unit lu2 on s.l_ledger_id = lu2.l_ledger_id
  182. where s.id = #{id,jdbcType=BIGINT}
  183. <if test="unitType != null">
  184. and lu.unit_type = #{unitType,jdbcType=INTEGER}
  185. </if>
  186. <if test="unitTypeTwo != null">
  187. and lu2.unit_type = #{unitTypeTwo,jdbcType=INTEGER}
  188. </if>
  189. </select>
  190. <!-- 根据多个结算运费物流订单id查订单,用于导出 -->
  191. <select id="selectLogisticsList" resultType="com.sckw.payment.model.dto.SettlementLogisticsDto">
  192. <include refid="settlementLogisticsSelect"/>
  193. <where>
  194. l.del_flag = 0
  195. and s.del_flag = 0
  196. and lu.del_flag = 0
  197. and lu2.del_flag = 0
  198. <include refid="settlementLogisticsSelectWhere"/>
  199. <if test="ids != null and ids.size() > 0">
  200. and s.id in
  201. <foreach collection="ids" item="id" close=")" open="(" separator=",">
  202. #{id,jdbcType=BIGINT}
  203. </foreach>
  204. </if>
  205. </where>
  206. order by s.update_time desc
  207. </select>
  208. <select id="getListById" resultType="com.sckw.payment.model.dto.LedgerUnitDto">
  209. select kltu.top_ent_id,
  210. kltu.ent_id,
  211. kltu.unit_type
  212. from kwp_settlement_logistics kst
  213. inner join kwp_ledger_logistics klt on kst.l_ledger_id = klt.id and klt.del_flag = 0
  214. inner join kwp_ledger_logistics_unit kltu on klt.id = kltu.l_ledger_id and kltu.del_flag = 0
  215. <where>
  216. kst.del_flag = 0
  217. and kst.id = #{id,jdbcType=BIGINT}
  218. </where>
  219. </select>
  220. </mapper>