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.

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