1
0

QzOrderMapper.xml 13 KB

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