QzOrderMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. a.store_id,g.merch_sn,g.sell_volume 'goods_sell_volume',c.sell_volume 'store_sell_volume'
  24. FROM mall_order a
  25. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  26. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  27. AND c.store_id = a.store_id
  28. left join mall_goods g on g.id=c.goods_id and g.merch_sn=c.merch_sn
  29. left join third_merchant_biz mb on mb.third_party_merch_code=g.third_party_merch_code and mb.merch_sn=g.merch_sn
  30. WHERE 1 = 1
  31. AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
  32. AND a.order_status in (0,100) and a.order_type = 1 AND a.is_onffline_order = 0
  33. </select>
  34. <update id="unpayPastUpdate">
  35. UPDATE mall_order a
  36. SET order_status=101,shipping_status=0,pay_status=0
  37. WHERE 1 = 1
  38. AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
  39. AND a.order_status = 0 and a.order_type = 1 AND a.is_onffline_order = 0
  40. </update>
  41. <update id="updateStockNum" parameterType="map">
  42. update mall_product_store_rela a
  43. <set>
  44. <if test="stock_num != null">a.`stock_num` = #{stock_num},</if>
  45. <if test="sell_volume != null">a.`sell_volume` = #{sell_volume},</if>
  46. </set>
  47. where a.id = #{id}
  48. </update>
  49. <update id="updateGoodsStockNum" parameterType="map">
  50. update mall_goods a
  51. <set>
  52. <if test="goods_number != null">a.`goods_number` = #{goods_number},</if>
  53. <if test="sell_volume != null">a.`sell_volume` = #{sell_volume},</if>
  54. </set>
  55. where a.id = #{id}
  56. </update>
  57. <insert id="saveStoreMngChange" parameterType="com.kmall.schedule.entity.StoreMngChangeJobEntity">
  58. insert into mall_store_mng_change(
  59. `store_change_num`,
  60. `store_original_num`,
  61. `store_valid_num`,
  62. `merch_sn`,
  63. `store_id`,
  64. `goods_id`,
  65. `is_valid`,
  66. `change_type`,
  67. `change_reason`,
  68. `creater_sn`,
  69. `create_time`,
  70. `moder_sn`,
  71. `mod_time`,
  72. `tstm`)
  73. values(
  74. #{storeChangeNum},
  75. #{storeOriginalNum},
  76. #{storeValidNum},
  77. #{merchSn},
  78. #{storeId},
  79. #{goodsId},
  80. #{isValid},
  81. #{changeType},
  82. #{changeReason},
  83. #{createrSn},
  84. #{createTime},
  85. #{moderSn},
  86. #{modTime},
  87. #{tstm})
  88. </insert>
  89. <insert id="saveMngChange" parameterType="com.kmall.schedule.entity.MngChangeJobEntity">
  90. insert into mall_mng_change(
  91. `change_num`,
  92. `original_num`,
  93. `valid_num`,
  94. `merch_sn`,
  95. `third_party_merch_code`,
  96. `goods_id`,
  97. `is_valid`,
  98. `change_type`,
  99. `change_reason`,
  100. `creater_sn`,
  101. `create_time`,
  102. `moder_sn`,
  103. `mod_time`,
  104. `tstm`)
  105. values(
  106. #{changeNum},
  107. #{originalNum},
  108. #{validNum},
  109. #{merchSn},
  110. #{thirdPartyMerchCode},
  111. #{goodsId},
  112. #{isValid},
  113. #{changeType},
  114. #{changeReason},
  115. #{createrSn},
  116. #{createTime},
  117. #{moderSn},
  118. #{modTime},
  119. #{tstm})
  120. </insert>
  121. <select id="queryRefundOrderList" resultType="map">
  122. 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,
  123. a.order_sn_wx,a.pay_flag,a.store_id,a.merch_sn
  124. from mall_order a
  125. 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
  126. or f.refund_time is null or f.wechat_refund_status_des is null) and a.order_status = '401' and f.refund_status
  127. in (2,5)
  128. </select>
  129. <select id="queryPayingOrderList" resultType="map">
  130. 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,
  131. 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,
  132. a.store_id,g.merch_sn,mb.third_party_merch_code,g.sell_volume 'goods_sell_volume',c.sell_volume 'store_sell_volume'
  133. from mall_order a
  134. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  135. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  136. AND c.store_id = a.store_id
  137. left join mall_goods g on g.id=c.goods_id and g.merch_sn=c.merch_sn
  138. left join third_merchant_biz mb on mb.third_party_merch_code=g.third_party_merch_code and mb.merch_sn=g.merch_sn
  139. where (a.order_status in ('0','100','201') and a.pay_status in (0,1,2)) and pay_id is not null
  140. and (a.pay_transaction_id = '' or a.pay_transaction_id is null or a.pay_time is null or a.pay_time = '')
  141. AND a.is_onffline_order = 0 and a.pay_flag = 'weixin'
  142. </select>
  143. <select id="queryPinganPayingOrderList" resultType="map">
  144. 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,
  145. 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,
  146. a.store_id,g.merch_sn,mb.third_party_merch_code,g.sell_volume 'goods_sell_volume',c.sell_volume 'store_sell_volume'
  147. from mall_order a
  148. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  149. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  150. AND c.store_id = a.store_id
  151. left join mall_goods g on g.id=c.goods_id and g.merch_sn=c.merch_sn
  152. left join third_merchant_biz mb on mb.third_party_merch_code=g.third_party_merch_code and mb.merch_sn=g.merch_sn
  153. where (a.order_status in ('0','100','201') and a.pay_status in (0,1,2)) and pay_id is not null
  154. and (a.pay_transaction_id = '' or a.pay_transaction_id is null or a.pay_time is null or a.pay_time = '')
  155. AND a.is_onffline_order = 0 and a.pay_flag = 'pingan'
  156. </select>
  157. <update id="updateOrderInfo" parameterType="map">
  158. UPDATE mall_order a
  159. <set>
  160. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  161. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  162. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  163. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  164. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  165. <if test="payTime != null">a.pay_time = #{payTime},</if>
  166. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  167. <if test="feeType != null">a.fee_type = #{feeType},</if>
  168. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  169. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  170. <if test="rate != null">a.rate = #{rate},</if>
  171. </set>
  172. WHERE 1 = 1
  173. AND a.id = #{orderId}
  174. </update>
  175. <update id="updateOrderProcessRecord" parameterType="map">
  176. UPDATE mall_order_process_record a
  177. <set>
  178. <if test="payTime != null">a.pay_succ_time = #{payTime}</if>
  179. </set>
  180. WHERE 1 = 1
  181. AND a.order_sn = #{orderSn}
  182. </update>
  183. <update id="updateOrderRefund" parameterType="map">
  184. UPDATE mall_order_refund a
  185. <set>
  186. <if test="refundId != null">a.refund_id = #{refundId},</if>
  187. <if test="refundMoney != null">a.refund_money = #{refundMoney},</if>
  188. <if test="refundStatus != null">a.refund_status = #{refundStatus},</if>
  189. <if test="refundRecvAccout != null">a.refund_recv_accout = #{refundRecvAccout},</if>
  190. <if test="refundTime != null">a.refund_time = #{refundTime},</if>
  191. <if test="wechat_refund_status_des != null">a.wechat_refund_status_des = #{wechat_refund_status_des},</if>
  192. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  193. <if test="feeType != null">a.fee_type = #{feeType},</if>
  194. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  195. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  196. <if test="rate != null">a.rate = #{rate},</if>
  197. </set>
  198. WHERE 1 = 1
  199. AND a.out_refund_no = #{orderRefundId}
  200. </update>
  201. <select id="queryShipmentOrderList" resultType="map">
  202. 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
  203. FROM `mall_order` a inner join mall_order_process_record r on a.order_sn=r.order_sn where order_status='300'
  204. 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
  205. </select>
  206. <select id="queryShipmentBondedOrderList" resultType="map">
  207. 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
  208. 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'
  209. 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
  210. </select>
  211. <update id="updateShipmentOrder" parameterType="map">
  212. update mall_order set order_status ='301', shipping_status='2',confirm_time=now() where id=#{orderId}
  213. </update>
  214. <select id="queryReceiptOrderList" resultType="map">
  215. select o.user_id 'userId',o.id 'orderId',g.product_id'productId',g.goods_specification_name_value 'goodsSpecificationNameValue', g.goods_id 'goodsId',
  216. g.goods_name 'goodsName',confirm_time FROM `mall_order` o inner join mall_order_goods g on o.id = g.order_id
  217. 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
  218. </select>
  219. <update id="updateReceiptOrderByCommentCount">
  220. update mall_order set comment_count = 1 where
  221. order_status='301' and shipping_status ='2' and comment_count=0 AND confirm_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -30 DAY)
  222. </update>
  223. <insert id="insertComment" parameterType="map">
  224. insert into mall_comment(
  225. `type_id`,
  226. `value_id`,
  227. `user_id`,
  228. `order_id`,
  229. `product_id`,
  230. `goods_specification_name_value`,
  231. `status`,
  232. `content`,
  233. `eval_level`,
  234. `value_name`,
  235. `goods_level`,
  236. `create_time`,
  237. add_time,
  238. `mod_time`)
  239. values(
  240. #{typeId},
  241. #{valueId},
  242. #{userId},
  243. #{orderId},
  244. #{productId},
  245. #{goodsSpecificationNameValue},
  246. #{status},
  247. #{content},
  248. #{evalLevel},
  249. #{valueName},
  250. #{goodsLevel},
  251. #{createTime},
  252. #{addTime},
  253. #{modTime})
  254. </insert>
  255. <insert id="insertPinganResponseDto" parameterType="map">
  256. insert into pingan_response(
  257. `id`,
  258. `out_no`,
  259. `req_interface`,
  260. `errcode`,
  261. `msg`,
  262. `data`,
  263. `sign`,
  264. `datajson`,
  265. `timestamp`,
  266. `create_time`,
  267. `tstm`)
  268. values(
  269. #{id},
  270. #{outNo},
  271. #{reqInterface},
  272. #{errcode},
  273. #{msg},
  274. #{data},
  275. #{sign},
  276. #{datajson},
  277. #{timestamp},
  278. #{createTime},
  279. #{tstm})
  280. </insert>
  281. <select id="queryOrder" resultType="map">
  282. select id,order_status
  283. from mall_order
  284. WHERE order_sn = #{orderSn}
  285. </select>
  286. <select id="queryWXPaySuccessRecords" resultType="map">
  287. select id,out_trade_no_wx
  288. from mall_order_wxpay_record
  289. WHERE out_trade_no = #{orderSn} AND trade_state='SUCCESS'
  290. </select>
  291. <update id="updatePayOrderByOutNo" parameterType="map">
  292. update pingan_pay_order
  293. <set>
  294. <if test="pmtName != null">`pmt_name` = #{pmtName}, </if>
  295. <if test="pmtTag != null">`pmt_tag` = #{pmtTag}, </if>
  296. <if test="ordMctId != null">`ord_mct_id` = #{ordMctId}, </if>
  297. <if test="ordShopId != null">`ord_currency` = #{ordShopId}, </if>
  298. <if test="ordCurrency != null">`ord_shop_id` = #{ordCurrency}, </if>
  299. <if test="currencySign != null">`currency_sign` = #{currencySign}, </if>
  300. <if test="ordNo != null">`ord_no` = #{ordNo}, </if>
  301. <if test="ordType != null">`ord_type` = #{ordType}, </if>
  302. <if test="originalAmount != null">`original_amount` = #{originalAmount}, </if>
  303. <if test="discountAmount != null">`discount_amount` = #{discountAmount}, </if>
  304. <if test="ignoreAmount != null">`ignore_amount` = #{ignoreAmount}, </if>
  305. <if test="tradeAccount != null">`trade_account` = #{tradeAccount}, </if>
  306. <if test="tradeNo != null">`trade_no` = #{tradeNo}, </if>
  307. <if test="tradeAmount != null">`trade_amount` = #{tradeAmount}, </if>
  308. <if test="tradeQrcode != null">`trade_qrcode` = #{tradeQrcode}, </if>
  309. <if test="amount != null">`amount` = #{amount}, </if>
  310. <if test="tradeTime != null">`trade_time` = #{tradeTime}, </if>
  311. <if test="tradePayTime != null">`trade_pay_time` = #{tradePayTime}, </if>
  312. <if test="payTime != null">`pay_time` = #{payTime}, </if>
  313. <if test="status != null">`status` = #{status}, </if>
  314. <if test="tradeResult != null">`trade_result` = #{tradeResult}, </if>
  315. <if test="jsapiPayUrl != null">`jsapi_pay_url` = #{jsapiPayUrl}, </if>
  316. <if test="randStr != null">`rand_str` = #{randStr}, </if>
  317. <if test="appid != null">`appId` = #{appid}, </if>
  318. <if test="noncestr != null">`nonceStr` = #{noncestr}, </if>
  319. <if test="signtype != null">`signType` = #{signtype}, </if>
  320. <if test="prepayId != null">`prepay_id` = #{prepayId}, </if>
  321. <if test="paysign != null">`paySign` = #{paysign}, </if>
  322. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  323. <if test="createTime != null">`create_time` = #{createTime}, </if>
  324. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  325. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  326. <if test="tstm != null">`tstm` = #{tstm}</if>
  327. </set>
  328. where `out_no` = #{outNo}
  329. </update>
  330. </mapper>