OrderRefundMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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.caimei365.order.mapper.OrderRefundMapper">
  4. <insert id="insertCmRefundRecord">
  5. insert into cm_refundmoney_record
  6. (refundAmount, orderRequestNo, shopOrderId)
  7. values (#{refundAmount}, #{orderRequestNo}, #{shopOrderId})
  8. </insert>
  9. <insert id="insertReturns" keyColumn="id" keyProperty="id"
  10. parameterType="com.caimei365.order.model.vo.CmReturnedPurchase" useGeneratedKeys="true">
  11. INSERT INTO cm_returned_purchase(returnedNo,
  12. orderID,
  13. shopOrderId,
  14. userID,
  15. status,
  16. returnedWay,
  17. payType,
  18. operatingOrderStatus,
  19. bankAccountName,
  20. bankAccountNo,
  21. openBank,
  22. bankAccountType,
  23. returnedPurchaseFee,
  24. refundFee,
  25. refundBalanceFee,
  26. refundOnlineFee,
  27. refundOfflineFee,
  28. remarks,
  29. reviewRemarks,
  30. applicationUserID,
  31. returnTime,
  32. reviewUserID,
  33. confirmReturnTime,
  34. refundType)
  35. VALUES (#{returnedNo},
  36. #{orderId},
  37. #{shopOrderId},
  38. #{userId},
  39. #{status},
  40. #{returnedWay},
  41. #{payType},
  42. #{operatingOrderStatus},
  43. #{bankAccountName},
  44. #{bankAccountNo},
  45. #{openBank},
  46. #{bankAccountType},
  47. #{returnedPurchaseFee},
  48. #{refundFee},
  49. #{refundBalanceFee},
  50. #{refundOnlineFee},
  51. #{refundOfflineFee},
  52. #{remarks},
  53. #{reviewRemarks},
  54. #{applicationUserId},
  55. #{returnTime},
  56. #{reviewUserId},
  57. #{confirmReturnTime},
  58. #{refundType})
  59. </insert>
  60. <insert id="insertReturnProduct">
  61. insert into cm_returned_purchase_product(returnedID, productID, orderProductID, shopOrderID, shopID,
  62. applicationReturnedNum, applicationCancelNum, actualReturnedNum,
  63. actualCancelNum)
  64. (SELECT #{id},
  65. productId,
  66. orderProductId,
  67. shopOrderId,
  68. shopId,
  69. num + presentNum,
  70. num + presentNum,
  71. num + presentNum,
  72. num + presentNum
  73. FROM cm_order_product
  74. WHERE shopOrderId = #{shopOrderId})
  75. </insert>
  76. <insert id="insertTransfer">
  77. insert into cm_refund_transfer(transferType, transferTime, transferAmount, orderRequestNo, shopOrderId)
  78. values (1, now(), #{money}, #{orderRequestNo}, #{shopOrderId})
  79. </insert>
  80. <update id="updateSecondProduct">
  81. UPDATE cm_second_hand_detail
  82. SET sold = 0
  83. WHERE productID IN (SELECT productId FROM cm_order_product WHERE shoporderid = #{shopOrderId})
  84. </update>
  85. <update id="updateShopOrder">
  86. update cm_shop_order
  87. set refundStatus = 3,
  88. shopStatus = 5
  89. where shopOrderID = #{shopOrderId}
  90. </update>
  91. <update id="updateUser">
  92. update user
  93. set ableUserMoney = #{ableUserMoney},
  94. userMoney = #{userMoney},
  95. userBeans = #{userBeans}
  96. where userId = #{userId}
  97. </update>
  98. <update id="updateReturn">
  99. update cm_returned_purchase_product
  100. set returnedID = #{id}
  101. where shopOrderId = #{shopOrderId}
  102. </update>
  103. <update id="updateReturnMoney">
  104. update cm_returned_purchase
  105. set refundOfflineFee = #{refundOfflineFee},
  106. refundFee = #{refundFee},
  107. refundBalanceFee = #{refundBalanceFee},
  108. refundOnlineFee = #{refundOnlineFee},
  109. returnedPurchaseFee = #{returnedPurchaseFee},
  110. delFlag = #{delFlag}
  111. where id = #{id}
  112. </update>
  113. <update id="updateOrderRefund">
  114. update cm_order
  115. set refundType = #{refundType}
  116. where orderId = #{orderId}
  117. </update>
  118. <select id="findPayWays" resultType="com.caimei365.order.model.po.OrderReceiptRelationPo">
  119. select cro.relationType,
  120. cro.receiptID,
  121. cro.shopOrderId,
  122. cro.orderId,
  123. cro.mbOrderId,
  124. cro.orderRequestNo,
  125. cro.splitStatus,
  126. cro.associateAmount,
  127. cro.delFlag,
  128. cdr.payType,
  129. cdr.payWay
  130. from cm_receipt_order_relation cro
  131. left join cm_discern_receipt cdr on cro.receiptID = cdr.id
  132. where cro.shopOrderId = #{shopOrderId}
  133. </select>
  134. <select id="findOrder" resultType="com.caimei365.order.model.vo.OrderVo">
  135. select secondHandOrderFlag, status, co.orderId, co.userId, co.payTotalFee
  136. from cm_order co
  137. left join cm_shop_order cso on co.orderId = cso.orderId
  138. where cso.shopOrderID = #{shopOrderId}
  139. </select>
  140. <select id="findSplitCodeEmail" resultType="java.lang.String">
  141. select email
  142. from cm_shop_email
  143. where splitCode = #{splitCode}
  144. </select>
  145. <select id="findUser" resultType="com.caimei365.order.model.vo.UserVo">
  146. select userId, clubId, ableUserMoney, userMoney, userBeans
  147. from user
  148. where userId = #{userId}
  149. </select>
  150. <select id="findByBeansType" resultType="java.lang.Integer">
  151. SELECT SUM(num)
  152. FROM user_beans_history
  153. WHERE orderId = #{orderId}
  154. AND beansType = 5
  155. </select>
  156. <select id="findLowOrder" resultType="com.caimei365.order.model.po.UserBeansHistoryPo">
  157. select userId, type, beansType, orderId, num, addTime
  158. from user_beans_history
  159. where orderId = #{orderId}
  160. and delFlag = 0
  161. and type = 2
  162. and beansType = 15
  163. </select>
  164. <select id="findRefundShopOrder" resultType="com.caimei365.order.model.vo.CmReturnedPurchase">
  165. SELECT COUNT(DISTINCT shopOrderId) as shopCount, shopOrderId, returnedId as id
  166. FROM cm_returned_purchase_product
  167. GROUP BY returnedID
  168. HAVING COUNT(DISTINCT shopOrderId) > 1
  169. </select>
  170. <select id="findReturnd" resultType="com.caimei365.order.model.vo.CmReturnedPurchase">
  171. select id,
  172. returnedNo,
  173. orderId,
  174. userId,
  175. status,
  176. returnedWay,
  177. payType,
  178. operatingOrderStatus,
  179. bankAccountName,
  180. bankAccountNo,
  181. openBank,
  182. bankAccountType,
  183. returnedPurchaseFee,
  184. refundFee,
  185. refundBalanceFee,
  186. refundOnlineFee,
  187. refundOfflineFee,
  188. image1,
  189. image2,
  190. image3,
  191. image4,
  192. image5,
  193. reviewImage1,
  194. reviewImage2,
  195. reviewImage3,
  196. reviewImage4,
  197. reviewImage5,
  198. remarks,
  199. reviewRemarks,
  200. applicationUserId,
  201. returnTime,
  202. reviewUserId,
  203. confirmReturnTime,
  204. delFlag,
  205. refundType
  206. from cm_returned_purchase
  207. where id = #{id}
  208. </select>
  209. <select id="findReturnShops" resultType="java.lang.Integer">
  210. select distinct shopOrderId
  211. from cm_returned_purchase_product
  212. where returnedID = #{id}
  213. </select>
  214. <select id="findShopOrderRefundCount" resultType="java.lang.Integer">
  215. select count(*)
  216. from cm_shop_order
  217. where refundStatus = 1
  218. and orderID = #{orderId}
  219. </select>
  220. <select id="findOrderRelationByNo" resultType="com.caimei365.order.model.po.OrderReceiptRelationPo">
  221. select cso.splitCode,cror.associateAmount,cror.orderRequestNo,cror.shopOrderId
  222. from cm_receipt_order_relation cror
  223. left join cm_shop_order cso on cror.shopOrderId = cso.shopOrderId
  224. where cror.orderRequestNo = #{orderRequestNo}
  225. </select>
  226. </mapper>