BizWaybillCostDetailsMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.logistics.mapper.BizWaybillCostDetailsMapper">
  6. <resultMap type="com.ruoyi.logistics.domain.BizWaybillCostDetails" id="BizWaybillCostDetailsResult">
  7. <result property="waybillDetailId" column="waybill_detail_id" />
  8. <result property="waybillId" column="waybill_id" />
  9. <result property="externalWaybillNo" column="external_waybill_no" />
  10. <result property="feeItemCode" column="fee_item_code" />
  11. <result property="feeItemName" column="fee_item_name" />
  12. <result property="feeName" column="fee_name" />
  13. <result property="amount" column="amount" />
  14. <result property="rateAmount" column="rate_amount" />
  15. <result property="adjustAmount" column="adjust_amount" />
  16. <result property="remark" column="remark" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateTime" column="update_time" />
  19. <result property="deptId" column="dept_id" />
  20. <result property="userId" column="user_id" />
  21. <result property="delFlag" column="del_flag" />
  22. <result property="createBy" column="create_by" />
  23. <result property="updateBy" column="update_by" />
  24. <result property="orderType" column="order_type" />
  25. <result property="senderCity" column="sender_city" />
  26. <result property="receiverCity" column="receiver_city" />
  27. <result property="signTime" column="sign_time" />
  28. <result property="goodsWeight" column="goods_weight" />
  29. <result property="productCode" column="product_code" />
  30. <result property="userName" column="user_name" />
  31. <result property="summaryMonth" column="summaryMonth" />
  32. </resultMap>
  33. <sql id="selectBizWaybillCostDetailsVo">
  34. SELECT
  35. a.waybill_detail_id,
  36. b.sign_time,
  37. b.external_waybill_no,
  38. b.sender_city,
  39. b.receiver_city,
  40. b.goods_weight,
  41. b.order_type,
  42. b.product_code,
  43. u.nick_name,
  44. a.waybill_id,
  45. a.external_waybill_no,
  46. a.fee_item_code,
  47. a.fee_item_name,
  48. ifnull( a.adjust_amount, a.rate_amount ) rate_amount,
  49. DATE_FORMAT( b.sign_time, '%Y.%m' ) summaryMonth,
  50. a.remark,
  51. a.create_time,
  52. a.update_time,
  53. a.dept_id,
  54. a.del_flag,
  55. a.create_by,
  56. a.update_by,u.nick_name user_name
  57. FROM
  58. biz_waybill_cost_details a
  59. LEFT JOIN biz_waybill_order b ON a.waybill_id = b.waybill_id
  60. LEFT JOIN sys_user u ON b.user_id = u.user_id
  61. LEFT JOIN sys_dept d ON a.dept_id = d.dept_id
  62. </sql>
  63. <select id="selectBizWaybillCostDetailsList" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails" resultMap="BizWaybillCostDetailsResult">
  64. <include refid="selectBizWaybillCostDetailsVo"/>
  65. <where>
  66. b.order_status = 5
  67. <if test="summaryMonth != null "> AND DATE_FORMAT( b.sign_time, '%Y.%m' ) = #{summaryMonth}</if>
  68. <if test="deptId != null "> AND a.dept_id = #{deptId}</if>
  69. <if test="externalWaybillNo != null and externalWaybillNo != ''"> and a.external_waybill_no = #{externalWaybillNo}</if>
  70. ${params.dataScope}
  71. <!-- <if test="waybillId != null "> and waybill_id = #{waybillId}</if>
  72. <if test="feeItemCode != null and feeItemCode != ''"> and fee_item_code = #{feeItemCode}</if>
  73. <if test="feeItemName != null and feeItemName != ''"> and fee_item_name like concat('%', #{feeItemName}, '%')</if>
  74. <if test="feeName != null and feeName != ''"> and fee_name like concat('%', #{feeName}, '%')</if>
  75. <if test="amount != null "> and amount = #{amount}</if>
  76. <if test="rateAmount != null "> and rate_amount = #{rateAmount}</if>
  77. <if test="adjustAmount != null "> and adjust_amount = #{adjustAmount}</if>
  78. <if test="deptId != null "> and dept_id = #{deptId}</if>
  79. <if test="userId != null "> and user_id = #{userId}</if>-->
  80. </where>
  81. </select>
  82. <select id="detaillist" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails" resultMap="BizWaybillCostDetailsResult">
  83. <include refid="selectBizWaybillCostDetailsVo"/>
  84. <where>
  85. <if test="waybillId != null "> and a.waybill_id = #{waybillId}</if>
  86. </where>
  87. </select>
  88. <select id="selectBizWaybillCostDetailsListByWx" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails" resultMap="BizWaybillCostDetailsResult">
  89. select waybill_detail_id, waybill_id, external_waybill_no, fee_item_code, fee_item_name, fee_name, amount, rate_amount, adjust_amount, remark, create_time, update_time, dept_id, user_id, del_flag, create_by, update_by from biz_waybill_cost_details
  90. <where>
  91. <if test="waybillId != null "> and waybill_id = #{waybillId}</if>
  92. <!-- <if test="externalWaybillNo != null and externalWaybillNo != ''"> and external_waybill_no = #{externalWaybillNo}</if>
  93. <if test="feeItemCode != null and feeItemCode != ''"> and fee_item_code = #{feeItemCode}</if>
  94. <if test="feeItemName != null and feeItemName != ''"> and fee_item_name like concat('%', #{feeItemName}, '%')</if>
  95. <if test="feeName != null and feeName != ''"> and fee_name like concat('%', #{feeName}, '%')</if>
  96. <if test="amount != null "> and amount = #{amount}</if>
  97. <if test="rateAmount != null "> and rate_amount = #{rateAmount}</if>
  98. <if test="adjustAmount != null "> and adjust_amount = #{adjustAmount}</if>
  99. <if test="deptId != null "> and dept_id = #{deptId}</if>
  100. <if test="userId != null "> and user_id = #{userId}</if>-->
  101. </where>
  102. </select>
  103. <select id="getAccountAdjustmentById" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails" resultMap="BizWaybillCostDetailsResult">
  104. SELECT
  105. a.waybill_detail_id,
  106. b.sign_time,
  107. b.external_waybill_no,
  108. b.sender_city,
  109. b.receiver_city,
  110. b.goods_weight,
  111. b.order_type,
  112. b.product_code,
  113. a.waybill_id,
  114. a.external_waybill_no,
  115. a.fee_item_code,
  116. a.fee_item_name,
  117. ifnull( a.adjust_amount, a.rate_amount ) rate_amount,
  118. DATE_FORMAT( b.sign_time, '%Y.%m' ) summaryMonth,
  119. a.remark,
  120. a.create_time,
  121. a.update_time,
  122. a.dept_id,
  123. a.update_by,u.nick_name user_name
  124. FROM
  125. biz_waybill_cost_details a
  126. LEFT JOIN biz_waybill_order b ON a.waybill_id = b.waybill_id
  127. LEFT JOIN sys_user u ON b.user_id = u.user_id
  128. LEFT JOIN sys_dept d ON a.dept_id = d.dept_id
  129. <where>
  130. <if test="waybillDetailId != null "> and a.waybill_detail_id = #{waybillDetailId}</if>
  131. </where>
  132. </select>
  133. <select id="selectBizWaybillCostDetailsByWaybillDetailId" parameterType="Long" resultMap="BizWaybillCostDetailsResult">
  134. <include refid="selectBizWaybillCostDetailsVo"/>
  135. where a.waybill_detail_id = #{waybillDetailId}
  136. </select>
  137. <insert id="upsertBizWaybillCostDetails" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails" useGeneratedKeys="true" keyProperty="waybillDetailId">
  138. INSERT INTO biz_waybill_cost_details (
  139. waybill_id,
  140. external_waybill_no,
  141. fee_item_code,
  142. fee_item_name,
  143. fee_name,
  144. amount,
  145. rate_amount,
  146. adjust_amount,
  147. remark,
  148. create_time,
  149. update_time,
  150. dept_id,
  151. user_id,
  152. del_flag,
  153. create_by,
  154. update_by
  155. ) VALUES (
  156. #{waybillId},
  157. #{externalWaybillNo},
  158. #{feeItemCode},
  159. #{feeItemName},
  160. #{feeName},
  161. #{amount},
  162. #{rateAmount},
  163. #{adjustAmount},
  164. #{remark},
  165. #{createTime},
  166. #{updateTime},
  167. #{deptId},
  168. #{userId},
  169. #{delFlag},
  170. #{createBy},
  171. #{updateBy}
  172. )
  173. ON DUPLICATE KEY UPDATE
  174. amount = #{amount},
  175. rate_amount = #{rateAmount},
  176. adjust_amount = #{adjustAmount},
  177. del_flag = #{delFlag},
  178. update_time = #{updateTime},
  179. update_by = #{updateBy}
  180. </insert>
  181. <insert id="insertBizWaybillCostDetails" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails" useGeneratedKeys="true" keyProperty="waybillDetailId">
  182. insert into biz_waybill_cost_details
  183. <trim prefix="(" suffix=")" suffixOverrides=",">
  184. <if test="waybillId != null">waybill_id,</if>
  185. <if test="externalWaybillNo != null">external_waybill_no,</if>
  186. <if test="feeItemCode != null">fee_item_code,</if>
  187. <if test="feeItemName != null">fee_item_name,</if>
  188. <if test="feeName != null">fee_name,</if>
  189. <if test="amount != null">amount,</if>
  190. <if test="rateAmount != null">rate_amount,</if>
  191. <if test="adjustAmount != null">adjust_amount,</if>
  192. <if test="remark != null">remark,</if>
  193. <if test="createTime != null">create_time,</if>
  194. <if test="updateTime != null">update_time,</if>
  195. <if test="deptId != null">dept_id,</if>
  196. <if test="userId != null">user_id,</if>
  197. <if test="delFlag != null">del_flag,</if>
  198. <if test="createBy != null">create_by,</if>
  199. <if test="updateBy != null">update_by,</if>
  200. </trim>
  201. <trim prefix="values (" suffix=")" suffixOverrides=",">
  202. <if test="waybillId != null">#{waybillId},</if>
  203. <if test="externalWaybillNo != null">#{externalWaybillNo},</if>
  204. <if test="feeItemCode != null">#{feeItemCode},</if>
  205. <if test="feeItemName != null">#{feeItemName},</if>
  206. <if test="feeName != null">#{feeName},</if>
  207. <if test="amount != null">#{amount},</if>
  208. <if test="rateAmount != null">#{rateAmount},</if>
  209. <if test="adjustAmount != null">#{adjustAmount},</if>
  210. <if test="remark != null">#{remark},</if>
  211. <if test="createTime != null">#{createTime},</if>
  212. <if test="updateTime != null">#{updateTime},</if>
  213. <if test="deptId != null">#{deptId},</if>
  214. <if test="userId != null">#{userId},</if>
  215. <if test="delFlag != null">#{delFlag},</if>
  216. <if test="createBy != null">#{createBy},</if>
  217. <if test="updateBy != null">#{updateBy},</if>
  218. </trim>
  219. </insert>
  220. <update id="updateBizWaybillCostDetails" parameterType="com.ruoyi.logistics.domain.BizWaybillCostDetails">
  221. update biz_waybill_cost_details
  222. <trim prefix="SET" suffixOverrides=",">
  223. <if test="waybillId != null">waybill_id = #{waybillId},</if>
  224. <if test="externalWaybillNo != null">external_waybill_no = #{externalWaybillNo},</if>
  225. <if test="feeItemCode != null">fee_item_code = #{feeItemCode},</if>
  226. <if test="feeItemName != null">fee_item_name = #{feeItemName},</if>
  227. <if test="feeName != null">fee_name = #{feeName},</if>
  228. <if test="amount != null">amount = #{amount},</if>
  229. <if test="rateAmount != null">rate_amount = #{rateAmount},</if>
  230. <if test="adjustAmount != null">adjust_amount = #{adjustAmount},</if>
  231. <if test="remark != null">remark = #{remark},</if>
  232. <if test="createTime != null">create_time = #{createTime},</if>
  233. <if test="updateTime != null">update_time = #{updateTime},</if>
  234. <if test="deptId != null">dept_id = #{deptId},</if>
  235. <if test="userId != null">user_id = #{userId},</if>
  236. <if test="delFlag != null">del_flag = #{delFlag},</if>
  237. <if test="createBy != null">create_by = #{createBy},</if>
  238. <if test="updateBy != null">update_by = #{updateBy},</if>
  239. </trim>
  240. where waybill_detail_id = #{waybillDetailId}
  241. </update>
  242. <delete id="deleteBizWaybillCostDetailsByWaybillDetailId" parameterType="Long">
  243. delete from biz_waybill_cost_details where waybill_detail_id = #{waybillDetailId}
  244. </delete>
  245. <delete id="deleteBizWaybillCostDetailsByWaybillDetailIds" parameterType="String">
  246. delete from biz_waybill_cost_details where waybill_detail_id in
  247. <foreach item="waybillDetailId" collection="array" open="(" separator="," close=")">
  248. #{waybillDetailId}
  249. </foreach>
  250. </delete>
  251. <select id="selectBizWaybillCostDetailsSum" parameterType="BizWaybillCostDetails" resultType="java.math.BigDecimal">
  252. select coalesce(sum(coalesce(adjust_amount, rate_amount)), 0)
  253. from biz_waybill_cost_details bwcd
  254. left join sys_user u on bwcd.user_id = u.user_id
  255. left join sys_dept d on bwcd.dept_id = d.dept_id
  256. <where>
  257. <!-- 数据范围过滤 -->
  258. ${params.dataScope}
  259. </where>
  260. </select>
  261. </mapper>