QzOrderMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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.kmall.schedule.dao.QzOrderMapper">
  4. <select id="queryrderUnEvaluateList" resultType="map">
  5. SELECT
  6. a.id AS order_id,
  7. a.order_sn,
  8. c.goods_name,
  9. a.form_id,
  10. u.weixin_openid AS open_id
  11. FROM
  12. mall_order a
  13. LEFT JOIN mall_comment b ON a.id = b.order_id
  14. LEFT JOIN mall_order_goods c ON c.order_id = a.id
  15. LEFT JOIN mall_user u ON a.user_id = u.id
  16. WHERE
  17. b.id IS NULL
  18. AND a.confirm_time > date_add(now(), INTERVAL - 1 DAY)
  19. AND a.confirm_time IS NOT NULL
  20. </select>
  21. <select id="queryPastOrderList" resultType="map">
  22. SELECT b.product_id,b.number,c.stock_num,c.id as storeRelaId
  23. FROM mall_order a
  24. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  25. LEFT JOIN mall_product_store_rela c ON b.product_id = c.product_id
  26. AND c.store_id = a.store_id
  27. WHERE 1 = 1
  28. AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
  29. AND a.order_status in (0,100) and a.order_type = 1 AND a.is_onffline_order = 0
  30. </select>
  31. <update id="unpayPastUpdate">
  32. UPDATE mall_order a
  33. SET order_status=101,shipping_status=0,pay_status=0
  34. WHERE 1 = 1
  35. AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
  36. AND a.order_status = 0 and a.order_type = 1 AND a.is_onffline_order = 0
  37. </update>
  38. <update id="updateStockNum" parameterType="map">
  39. update mall_product_store_rela a
  40. <set>
  41. <if test="stock_num != null">a.`stock_num` = #{stock_num},</if>
  42. </set>
  43. where a.id = #{id}
  44. </update>
  45. <select id="queryRefundOrderList" resultType="map">
  46. select a.pay_transaction_id,a.merch_order_sn,a.order_sn,a.order_status,a.pay_status,f.out_refund_no,f.refund_id,f.order_id,f.id 'orderRefundId',a.is_onffline_order,
  47. a.order_sn_wx,a.pay_flag
  48. from mall_order a
  49. inner join mall_order_refund f on a.id = f.order_id where (f.out_refund_no is null or f.refund_id is null
  50. or f.refund_time is null or f.wechat_refund_status_des is null) and a.order_status = '401' and f.refund_status
  51. in (2,5)
  52. </select>
  53. <select id="queryPayingOrderList" resultType="map">
  54. select a.pay_transaction_id,a.order_sn,a.order_status,a.pay_status,a.id 'order_id',a.merch_order_sn,date_format(a.add_time,'%Y-%m-%d %H:%i:%s') as add_time,
  55. b.product_id,b.number,c.stock_num,c.id as storeRelaId,a.pay_flag
  56. from mall_order a
  57. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  58. LEFT JOIN mall_product_store_rela c ON b.product_id = c.product_id
  59. AND c.store_id = a.store_id where (a.order_status in ('0','100','201') and a.pay_status in (0,1,2)) and pay_id is not null
  60. and (a.pay_transaction_id = '' or a.pay_transaction_id is null or a.pay_time is null or a.pay_time = '')
  61. AND a.is_onffline_order = 0 and a.pay_flag = 'weixin'
  62. </select>
  63. <select id="queryPinganPayingOrderList" resultType="map">
  64. select a.pay_transaction_id,a.order_sn,a.order_status,a.pay_status,a.id 'order_id',a.merch_order_sn,date_format(a.add_time,'%Y-%m-%d %H:%i:%s') as add_time,
  65. b.product_id,b.number,c.stock_num,c.id as storeRelaId,a.pay_flag
  66. from mall_order a
  67. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  68. LEFT JOIN mall_product_store_rela c ON b.product_id = c.product_id
  69. AND c.store_id = a.store_id where (a.order_status in ('0','100','201') and a.pay_status in (0,1,2)) and pay_id is not null
  70. and (a.pay_transaction_id = '' or a.pay_transaction_id is null or a.pay_time is null or a.pay_time = '')
  71. AND a.is_onffline_order = 0 and a.pay_flag = 'pingan'
  72. </select>
  73. <update id="updateOrderInfo" parameterType="map">
  74. UPDATE mall_order a
  75. <set>
  76. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  77. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  78. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  79. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  80. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  81. <if test="payTime != null">a.pay_time = #{payTime},</if>
  82. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  83. <if test="feeType != null">a.fee_type = #{feeType},</if>
  84. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  85. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  86. <if test="rate != null">a.rate = #{rate},</if>
  87. </set>
  88. WHERE 1 = 1
  89. AND a.id = #{orderId}
  90. </update>
  91. <update id="updateOrderProcessRecord" parameterType="map">
  92. UPDATE mall_order_process_record a
  93. <set>
  94. <if test="payTime != null">a.pay_succ_time = #{payTime}</if>
  95. </set>
  96. WHERE 1 = 1
  97. AND a.order_sn = #{orderSn}
  98. </update>
  99. <update id="updateOrderRefund" parameterType="map">
  100. UPDATE mall_order_refund a
  101. <set>
  102. <if test="refundId != null">a.refund_id = #{refundId},</if>
  103. <if test="refundMoney != null">a.refund_money = #{refundMoney},</if>
  104. <if test="refundStatus != null">a.refund_status = #{refundStatus},</if>
  105. <if test="refundRecvAccout != null">a.refund_recv_accout = #{refundRecvAccout},</if>
  106. <if test="refundTime != null">a.refund_time = #{refundTime},</if>
  107. <if test="wechat_refund_status_des != null">a.wechat_refund_status_des = #{wechat_refund_status_des},</if>
  108. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  109. <if test="feeType != null">a.fee_type = #{feeType},</if>
  110. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  111. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  112. <if test="rate != null">a.rate = #{rate},</if>
  113. </set>
  114. WHERE 1 = 1
  115. AND a.out_refund_no = #{orderRefundId}
  116. </update>
  117. <select id="queryShipmentOrderList" resultType="map">
  118. SELECT a.order_sn,a.order_status,a.pay_status,a.id 'orderId',a.merch_order_sn,date_format(r.customs_succ_time,'%Y-%m-%d %H:%i:%s') as customs_succ_time
  119. FROM `mall_order` a inner join mall_order_process_record r on a.order_sn=r.order_sn where order_status='300'
  120. and shipping_status ='1' and a.order_biz_type in(10,02) AND r.customs_succ_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -7 DAY) AND a.is_onffline_order = 0
  121. </select>
  122. <select id="queryShipmentBondedOrderList" resultType="map">
  123. SELECT a.order_sn,a.order_status,a.pay_status,a.id 'orderId',a.merch_order_sn,date_format(r.shipment_succ_time,'%Y-%m-%d %H:%i:%s') as shipment_succ_time
  124. FROM `mall_order` a inner join mall_order_process_record r on a.order_sn=r.order_sn where order_status='300' and shipping_status ='1'
  125. and a.order_biz_type in(00,11) AND r.shipment_succ_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -7 DAY) AND a.is_onffline_order = 0
  126. </select>
  127. <update id="updateShipmentOrder" parameterType="map">
  128. update mall_order set order_status ='301', shipping_status='2',confirm_time=now() where id=#{orderId}
  129. </update>
  130. <select id="queryReceiptOrderList" resultType="map">
  131. select o.user_id 'userId',o.id 'orderId',g.product_id'productId',g.goods_specification_name_value 'goodsSpecificationNameValue', g.goods_id 'goodsId',
  132. g.goods_name 'goodsName',confirm_time FROM `mall_order` o inner join mall_order_goods g on o.id = g.order_id
  133. where order_status='301' and shipping_status ='2' and comment_count=0 AND confirm_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -30 DAY) AND o.is_onffline_order = 0
  134. </select>
  135. <update id="updateReceiptOrderByCommentCount">
  136. update mall_order set comment_count = 1 where
  137. order_status='301' and shipping_status ='2' and comment_count=0 AND confirm_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -30 DAY)
  138. </update>
  139. <update id="insertComment" parameterType="map">
  140. insert into mall_comment(
  141. `type_id`,
  142. `value_id`,
  143. `user_id`,
  144. `order_id`,
  145. `product_id`,
  146. `goods_specification_name_value`,
  147. `status`,
  148. `content`,
  149. `eval_level`,
  150. `value_name`,
  151. `goods_level`,
  152. `create_time`,
  153. `mod_time`)
  154. values(
  155. #{typeId},
  156. #{valueId},
  157. #{userId},
  158. #{orderId},
  159. #{productId},
  160. #{goodsSpecificationNameValue},
  161. #{status},
  162. #{content},
  163. #{evalLevel},
  164. #{valueName},
  165. #{goodsLevel},
  166. #{createTime},
  167. #{modTime})
  168. </update>
  169. <insert id="insertPinganResponseDto" parameterType="map">
  170. insert into pingan_response(
  171. `id`,
  172. `out_no`,
  173. `req_interface`,
  174. `errcode`,
  175. `msg`,
  176. `data`,
  177. `sign`,
  178. `datajson`,
  179. `timestamp`,
  180. `create_time`,
  181. `tstm`)
  182. values(
  183. #{id},
  184. #{outNo},
  185. #{reqInterface},
  186. #{errcode},
  187. #{msg},
  188. #{data},
  189. #{sign},
  190. #{datajson},
  191. #{timestamp},
  192. #{createTime},
  193. #{tstm})
  194. </insert>
  195. <select id="queryOrder" resultType="map">
  196. select id,order_status
  197. from mall_order
  198. WHERE order_sn = #{orderSn}
  199. </select>
  200. <select id="queryWXPaySuccessRecords" resultType="map">
  201. select id,out_trade_no_wx
  202. from mall_order_wxpay_record
  203. WHERE out_trade_no = #{orderSn} AND trade_state='SUCCESS'
  204. </select>
  205. <update id="updatePayOrderByOutNo" parameterType="map">
  206. update pingan_pay_order
  207. <set>
  208. <if test="pmtName != null">`pmt_name` = #{pmtName}, </if>
  209. <if test="pmtTag != null">`pmt_tag` = #{pmtTag}, </if>
  210. <if test="ordMctId != null">`ord_mct_id` = #{ordMctId}, </if>
  211. <if test="ordShopId != null">`ord_currency` = #{ordShopId}, </if>
  212. <if test="ordCurrency != null">`ord_shop_id` = #{ordCurrency}, </if>
  213. <if test="currencySign != null">`currency_sign` = #{currencySign}, </if>
  214. <if test="ordNo != null">`ord_no` = #{ordNo}, </if>
  215. <if test="ordType != null">`ord_type` = #{ordType}, </if>
  216. <if test="originalAmount != null">`original_amount` = #{originalAmount}, </if>
  217. <if test="discountAmount != null">`discount_amount` = #{discountAmount}, </if>
  218. <if test="ignoreAmount != null">`ignore_amount` = #{ignoreAmount}, </if>
  219. <if test="tradeAccount != null">`trade_account` = #{tradeAccount}, </if>
  220. <if test="tradeNo != null">`trade_no` = #{tradeNo}, </if>
  221. <if test="tradeAmount != null">`trade_amount` = #{tradeAmount}, </if>
  222. <if test="tradeQrcode != null">`trade_qrcode` = #{tradeQrcode}, </if>
  223. <if test="amount != null">`amount` = #{amount}, </if>
  224. <if test="tradeTime != null">`trade_time` = #{tradeTime}, </if>
  225. <if test="tradePayTime != null">`trade_pay_time` = #{tradePayTime}, </if>
  226. <if test="payTime != null">`pay_time` = #{payTime}, </if>
  227. <if test="status != null">`status` = #{status}, </if>
  228. <if test="tradeResult != null">`trade_result` = #{tradeResult}, </if>
  229. <if test="jsapiPayUrl != null">`jsapi_pay_url` = #{jsapiPayUrl}, </if>
  230. <if test="randStr != null">`rand_str` = #{randStr}, </if>
  231. <if test="appid != null">`appId` = #{appid}, </if>
  232. <if test="noncestr != null">`nonceStr` = #{noncestr}, </if>
  233. <if test="signtype != null">`signType` = #{signtype}, </if>
  234. <if test="prepayId != null">`prepay_id` = #{prepayId}, </if>
  235. <if test="paysign != null">`paySign` = #{paysign}, </if>
  236. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  237. <if test="createTime != null">`create_time` = #{createTime}, </if>
  238. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  239. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  240. <if test="tstm != null">`tstm` = #{tstm}</if>
  241. </set>
  242. where `out_no` = #{outNo}
  243. </update>
  244. </mapper>