You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
8.5 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  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.example.demo.mapper.cash.CashCollectionMapper">
  4. <insert id="add" parameterType="com.example.demo.domain.entity.CashRecord"
  5. useGeneratedKeys="true" keyProperty="id">
  6. insert into
  7. cash_record(order_type,jwcode,name,market,activity,
  8. order_code,goods_name,good_num,
  9. payment_currency,payment_amount,received_market,
  10. pay_type,pay_time,status,submitter_id,
  11. voucher,remark)
  12. values(#{orderType},#{jwcode},#{name},#{market},#{activity},
  13. #{orderCode},#{goodsName},#{goodNum},#{paymentCurrency},
  14. #{paymentAmount},#{receivedMarket},#{payType},#{payTime},
  15. #{status},#{submitterId},#{voucher},#{remark})
  16. </insert>
  17. <!--更新订单状态-->
  18. <update id="updateStatus">
  19. update cash_record
  20. set status=#{status}
  21. where order_code=#{orderCode}
  22. </update>
  23. <!--更新订单-->
  24. <update id="updateByOrderCode">
  25. UPDATE cash_record
  26. <set>
  27. jwcode = #{cashRecord.jwcode},
  28. name = #{cashRecord.name},
  29. market = #{cashRecord.market},
  30. activity = #{cashRecord.activity},
  31. goods_name = #{cashRecord.goodsName},
  32. good_num = #{cashRecord.goodNum},
  33. payment_currency = #{cashRecord.paymentCurrency},
  34. payment_amount = #{cashRecord.paymentAmount},
  35. received_market = #{cashRecord.receivedMarket},
  36. pay_type = #{cashRecord.payType},
  37. pay_time = #{cashRecord.payTime},
  38. voucher = #{cashRecord.voucher},
  39. remark = #{cashRecord.remark},
  40. status = 0,
  41. </set>
  42. WHERE order_code = #{cashRecord.orderCode}
  43. AND status = 5
  44. </update>
  45. <!--补全手续费等字段-->
  46. <update id="complete">
  47. UPDATE cash_record
  48. <set>
  49. <if test="cashRecord.handlingCharge != null and cashRecord.handlingCharge!=''">
  50. handling_charge = #{cashRecord.handlingCharge},
  51. </if>
  52. <if test="cashRecord.receivedCurrency != null and cashRecord.receivedCurrency != ''">
  53. received_currency = #{cashRecord.receivedCurrency},
  54. </if>
  55. <if test="cashRecord.receivedAmount != null">
  56. received_amount = #{cashRecord.receivedAmount},
  57. </if>
  58. <if test="cashRecord.receivedTime != null">
  59. received_time = #{cashRecord.receivedTime},
  60. </if>
  61. <if test="cashRecord.receivedRemark != null and cashRecord.receivedRemark != ''">
  62. received_remark = #{cashRecord.receivedRemark},
  63. </if>
  64. <if test="cashRecord.paymentCurrency != null and cashRecord.paymentCurrency != ''">
  65. payment_currency = #{cashRecord.paymentCurrency},
  66. </if>
  67. <!-- 关键:null 就不拼这一列 -->
  68. <if test="cashRecord.paymentAmount != null">
  69. payment_amount = #{cashRecord.paymentAmount},
  70. </if>
  71. <if test="cashRecord.bankCode != null and cashRecord.bankCode != ''">
  72. bank_code = #{cashRecord.bankCode},
  73. </if>
  74. <!-- 只有 这些字段全部非空才更新状态 -->
  75. status = CASE
  76. WHEN
  77. handling_charge IS NOT NULL
  78. AND received_currency IS NOT NULL AND received_currency != ''
  79. AND received_amount IS NOT NULL
  80. AND received_time IS NOT NULL
  81. AND received_remark IS NOT NULL AND received_remark != ''
  82. AND payment_currency IS NOT NULL AND payment_currency != ''
  83. AND payment_amount IS NOT NULL
  84. AND bank_code IS NOT NULL AND bank_code != ''
  85. THEN 4
  86. ELSE status
  87. END
  88. </set>
  89. WHERE order_code = #{cashRecord.orderCode}
  90. AND status IN (1, 3)
  91. </update>
  92. <!--根据jwcode获取所属地区-->
  93. <select id="getMarketByJwcode" resultType="java.lang.String">
  94. select market from user where jwcode=#{jwcode}
  95. </select>
  96. <!--根据订单号获取订单id与状态-->
  97. <select id="selectByOrderCode" resultType="com.example.demo.domain.entity.CashRecord">
  98. select id ,status
  99. from cash_record
  100. where order_code=#{orderCode}
  101. </select>
  102. <!--多条件查询收款订单列表-->
  103. <select id="selectCollection1" resultType="com.example.demo.domain.vo.cash.CashCollection">
  104. select cr.id,cr.jwcode,cr.name,cr.market,
  105. m.name as marketName,cr.activity,cr.order_code,cr.bank_code,
  106. cr.goods_name,cr.good_num,cr.permanent_gold,cr.free_gold,cr.payment_currency,cr.payment_amount/100 as paymentAmount,
  107. cr.received_currency,cr.received_amount/100 as receivedAmount,cr.handling_charge/100 as handlingCharge,
  108. cr.received_market,cr.pay_type,cr.pay_time,cr.received_time,
  109. cr.status,cr.submitter_id,cr.voucher,cr.remark,cr.reject_reason,
  110. cr.audit_id,cr.create_time,cr.update_time,cr.audit_time,
  111. a1.admin_name as submitterName,
  112. a2.admin_name as auditName
  113. from cash_record cr
  114. left join admin a1 on cr.submitter_id = a1.id
  115. left join admin a2 on cr.audit_id = a2.id
  116. left join market m on m.id = cr.market
  117. <where>
  118. 1 = 1
  119. <if test="cashCollection.market != null and cashCollection.market != ''">
  120. AND cr.market = #{cashCollection.market}
  121. </if>
  122. <if test="cashCollection.jwcode != null and cashCollection.jwcode!=''">
  123. AND cr.jwcode = #{cashCollection.jwcode}
  124. </if>
  125. <if test="cashCollection.name!=null and cashCollection.name !=''">
  126. AND cr.name like concat('%',#{cashCollection.name},'%')
  127. </if>
  128. <if test="cashCollection.submitterId!=null and cashCollection.submitterId !=''">
  129. AND cr.submitter_id = #{cashCollection.submitterId}
  130. </if>
  131. <if test="cashCollection.receivedMarket!=null and cashCollection.receivedMarket!=''">
  132. AND cr.received_market = #{cashCollection.receivedMarket}
  133. </if>
  134. <if test="cashCollection.activity!=null and cashCollection.activity!=''">
  135. AND cr.activity like concat('%',#{cashCollection.activity},'%')
  136. </if>
  137. <if test="cashCollection.goodsName!=null and cashCollection.goodsName!=''">
  138. AND cr.goods_name like concat('%',#{cashCollection.goodsName},'%')
  139. </if>
  140. <if test="cashCollection.payType!=null and cashCollection.payType!=''">
  141. AND cr.pay_type = #{cashCollection.payType}
  142. </if>
  143. <if test="cashCollection.status != null">
  144. AND cr.status IN
  145. <foreach collection="cashCollection.status.toString().toCharArray()" item="digit" open="(" separator="," close=")">
  146. #{digit}
  147. </foreach>
  148. </if>
  149. <if test="cashCollection.startTime!=null and cashCollection.endTime!=null">
  150. AND cr.pay_time between #{cashCollection.startTime} and #{cashCollection.endTime}
  151. </if>
  152. and cr.order_type=1
  153. </where>
  154. <choose>
  155. <when test="cashCollection.sortField != null and cashCollection.sortField.length > 0 or cashCollection.sortOrder != null and cashCollection.sortOrder.length > 0">
  156. ORDER BY ${cashCollection.sortField} ${cashCollection.sortOrder}
  157. </when>
  158. <otherwise>
  159. ORDER BY update_time DESC
  160. </otherwise>
  161. </choose>
  162. </select>
  163. <select id="selectAuditByOrderCode" resultType="com.example.demo.domain.entity.CashRecord">
  164. select status,order_code from cash_record where order_code=#{orderCode}
  165. </select>
  166. <!--根据精网号获取姓名-->
  167. <select id="getNameByJwcode" resultType="java.lang.String">
  168. select name from user where jwcode=#{jwcode}
  169. </select>
  170. <select id="getMarketNameByJwcode" resultType="java.lang.String">
  171. select m.name from user u left join market m on u.market=m.id
  172. where u.jwcode=#{jwcode}</select>
  173. <select id="getActivityList" resultType="java.lang.String">
  174. select distinct activity from cash_record
  175. </select>
  176. </mapper>