QzOrderMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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
  23. b.product_id,
  24. b.number,
  25. c.stock_num,
  26. c.id AS storeRelaId,
  27. g.goods_number,
  28. g.id goods_id,
  29. g.goods_biz_type,
  30. a.store_id,
  31. g.merch_sn,
  32. g.sell_volume 'goods_sell_volume',
  33. c.sell_volume 'store_sell_volume',
  34. a.id 'orderId',
  35. mb.is_stock_share 'isStockShare',
  36. mb.third_party_merch_code,
  37. mb.is_supplier_goods 'isSupplierGoods',
  38. mb2.third_party_merch_code 'supplierThirdMerchCode',
  39. mb2.is_stock_share 'isStockShareBySuppler'
  40. FROM
  41. mall_order a
  42. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  43. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  44. AND c.store_id = a.store_id
  45. LEFT JOIN mall_goods g ON g.id = c.goods_id
  46. AND g.merch_sn = c.merch_sn
  47. LEFT JOIN third_merchant_biz mb2 ON mb2.third_party_merch_code = g.third_party_merch_code
  48. AND mb2.merch_sn = g.merch_sn
  49. LEFT JOIN mall_store s ON s.id = c.store_id
  50. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = s.third_party_merch_code
  51. AND mb.merch_sn = s.merch_sn
  52. WHERE
  53. 1 = 1
  54. AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
  55. AND a.order_status in (0,100) and a.order_type = 1 AND a.is_onffline_order = 0
  56. </select>
  57. <update id="unpayPastUpdate">
  58. UPDATE mall_order a
  59. SET order_status=101,shipping_status=0,pay_status=0
  60. WHERE 1 = 1
  61. AND a.add_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -15 MINUTE)
  62. AND a.order_status = 0 and a.order_type = 1 AND a.is_onffline_order = 0
  63. </update>
  64. <update id="updateStockNum" parameterType="map">
  65. update mall_product_store_rela a
  66. <set>
  67. <if test="stock_num != null">a.`stock_num` = #{stock_num},</if>
  68. <if test="sell_volume != null">a.`sell_volume` = #{sell_volume},</if>
  69. </set>
  70. where a.id = #{id}
  71. </update>
  72. <update id="updateGoodsStockNum" parameterType="map">
  73. update mall_goods a
  74. <set>
  75. <if test="goods_number != null">a.`goods_number` = #{goods_number},</if>
  76. <if test="sell_volume != null">a.`sell_volume` = #{sell_volume},</if>
  77. </set>
  78. where a.id = #{id}
  79. </update>
  80. <insert id="saveStoreMngChange" parameterType="com.kmall.schedule.entity.StoreMngChangeJobEntity">
  81. insert into mall_store_mng_change(
  82. `store_change_num`,
  83. `store_original_num`,
  84. `store_valid_num`,
  85. `merch_sn`,
  86. `store_id`,
  87. `goods_id`,
  88. `is_valid`,
  89. `change_type`,
  90. `change_reason`,
  91. `creater_sn`,
  92. `create_time`,
  93. `moder_sn`,
  94. `mod_time`,
  95. `tstm`)
  96. values(
  97. #{storeChangeNum},
  98. #{storeOriginalNum},
  99. #{storeValidNum},
  100. #{merchSn},
  101. #{storeId},
  102. #{goodsId},
  103. #{isValid},
  104. #{changeType},
  105. #{changeReason},
  106. #{createrSn},
  107. #{createTime},
  108. #{moderSn},
  109. #{modTime},
  110. #{tstm})
  111. </insert>
  112. <insert id="saveMngChange" parameterType="com.kmall.schedule.entity.MngChangeJobEntity">
  113. insert into mall_mng_change(
  114. `change_num`,
  115. `original_num`,
  116. `valid_num`,
  117. `merch_sn`,
  118. `third_party_merch_code`,
  119. `goods_id`,
  120. `is_valid`,
  121. `change_type`,
  122. `change_reason`,
  123. `creater_sn`,
  124. `create_time`,
  125. `moder_sn`,
  126. `mod_time`,
  127. `tstm`)
  128. values(
  129. #{changeNum},
  130. #{originalNum},
  131. #{validNum},
  132. #{merchSn},
  133. #{thirdPartyMerchCode},
  134. #{goodsId},
  135. #{isValid},
  136. #{changeType},
  137. #{changeReason},
  138. #{createrSn},
  139. #{createTime},
  140. #{moderSn},
  141. #{modTime},
  142. #{tstm})
  143. </insert>
  144. <select id="queryRefundOrderList" resultType="map">
  145. SELECT
  146. a.pay_transaction_id,
  147. a.merch_order_sn,
  148. a.order_sn,
  149. a.order_status,
  150. a.pay_status,
  151. f.out_refund_no,
  152. f.refund_id,
  153. f.order_id 'orderId',
  154. f.id 'orderRefundId',
  155. a.is_onffline_order,
  156. a.order_sn_wx,
  157. a.pay_flag,
  158. a.store_id,
  159. a.merch_sn,
  160. g.goods_number,
  161. b.number,
  162. c.stock_num,
  163. c.id AS storeRelaId,
  164. g.id goods_id,
  165. g.goods_biz_type,
  166. g.sell_volume 'goods_sell_volume',
  167. c.sell_volume 'store_sell_volume',
  168. mb.is_stock_share 'isStockShare',
  169. mb.third_party_merch_code,
  170. mb.is_supplier_goods 'isSupplierGoods',
  171. mb2.third_party_merch_code 'supplierThirdMerchCode',
  172. mb2.is_stock_share 'isStockShareBySuppler'
  173. FROM
  174. mall_order a
  175. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  176. INNER JOIN mall_order_refund f ON a.id = f.order_id
  177. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  178. AND c.store_id = a.store_id
  179. left join mall_goods g on g.id=c.goods_id and g.merch_sn=c.merch_sn
  180. left join third_merchant_biz mb2 on mb2.third_party_merch_code=g.third_party_merch_code and mb2.merch_sn=g.merch_sn
  181. LEFT JOIN mall_store s ON s.id = c.store_id
  182. left join third_merchant_biz mb on mb.third_party_merch_code=s.third_party_merch_code and mb.merch_sn=s.merch_sn
  183. WHERE
  184. ( f.out_refund_no IS NULL OR f.refund_id IS NULL OR f.refund_time IS NULL OR f.wechat_refund_status_des IS NULL )
  185. AND a.order_status = '401'
  186. AND f.refund_status IN ( 2, 5 )
  187. </select>
  188. <select id="queryPayingOrderList" resultType="map">
  189. SELECT
  190. a.pay_transaction_id,
  191. a.order_sn,
  192. a.order_status,
  193. a.pay_status,
  194. a.id 'orderId',
  195. a.merch_order_sn,
  196. date_format( a.add_time, '%Y-%m-%d %H:%i:%s' ) AS add_time,
  197. b.product_id,
  198. b.number,
  199. c.stock_num,
  200. c.id AS storeRelaId,
  201. a.pay_flag,
  202. g.goods_number,
  203. g.id goods_id,
  204. g.goods_biz_type,
  205. a.store_id,
  206. g.merch_sn,
  207. mb.third_party_merch_code,
  208. g.sell_volume 'goods_sell_volume',
  209. c.sell_volume 'store_sell_volume',
  210. mb.is_stock_share 'isStockShare',
  211. mb.third_party_merch_code,
  212. mb.is_supplier_goods 'isSupplierGoods',
  213. mb2.third_party_merch_code 'supplierThirdMerchCode',
  214. mb2.is_stock_share 'isStockShareBySuppler'
  215. FROM
  216. mall_order a
  217. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  218. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  219. AND c.store_id = a.store_id
  220. LEFT JOIN mall_goods g ON g.id = c.goods_id
  221. AND g.merch_sn = c.merch_sn
  222. LEFT JOIN third_merchant_biz mb2 ON mb2.third_party_merch_code = g.third_party_merch_code
  223. AND mb2.merch_sn = g.merch_sn
  224. LEFT JOIN mall_store s ON s.id = c.store_id
  225. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = s.third_party_merch_code
  226. AND mb.merch_sn = s.merch_sn
  227. WHERE
  228. ( a.order_status IN ( '0', '100', '201' ) AND a.pay_status IN ( 0, 1, 2 ) )
  229. AND pay_id IS NOT NULL
  230. AND ( a.pay_transaction_id = '' OR a.pay_transaction_id IS NULL OR a.pay_time IS NULL OR a.pay_time = '' )
  231. AND a.is_onffline_order = 0
  232. AND a.pay_flag = 'weixin'
  233. </select>
  234. <select id="queryPinganPayingOrderList" resultType="map">
  235. SELECT
  236. a.pay_transaction_id,
  237. a.order_sn,
  238. a.order_status,
  239. a.pay_status,
  240. a.id 'orderId',
  241. a.merch_order_sn,
  242. date_format( a.add_time, '%Y-%m-%d %H:%i:%s' ) AS add_time,
  243. b.product_id,
  244. b.number,
  245. c.stock_num,
  246. c.id AS storeRelaId,
  247. a.pay_flag,
  248. g.goods_number,
  249. g.id goods_id,
  250. g.goods_biz_type,
  251. a.store_id,
  252. g.merch_sn,
  253. mb.third_party_merch_code,
  254. g.sell_volume 'goods_sell_volume',
  255. c.sell_volume 'store_sell_volume',
  256. mb.is_stock_share 'isStockShare',
  257. mb.third_party_merch_code,
  258. mb.is_supplier_goods 'isSupplierGoods',
  259. mb2.third_party_merch_code 'supplierThirdMerchCode',
  260. mb2.is_stock_share 'isStockShareBySuppler'
  261. FROM
  262. mall_order a
  263. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  264. LEFT JOIN mall_product_store_rela c ON b.goods_id = c.goods_id
  265. AND c.store_id = a.store_id
  266. LEFT JOIN mall_goods g ON g.id = c.goods_id
  267. AND g.merch_sn = c.merch_sn
  268. LEFT JOIN third_merchant_biz mb2 ON mb2.third_party_merch_code = g.third_party_merch_code
  269. AND mb2.merch_sn = g.merch_sn
  270. LEFT JOIN mall_store s ON s.id = c.store_id
  271. LEFT JOIN third_merchant_biz mb ON mb.third_party_merch_code = s.third_party_merch_code
  272. AND mb.merch_sn = s.merch_sn
  273. WHERE
  274. ( a.order_status IN ( '0', '100', '201' ) AND a.pay_status IN ( 0, 1, 2 ) )
  275. AND pay_id IS NOT NULL
  276. AND ( a.pay_transaction_id = '' OR a.pay_transaction_id IS NULL OR a.pay_time IS NULL OR a.pay_time = '' )
  277. AND a.is_onffline_order = 0
  278. AND a.pay_flag = 'pingan'
  279. </select>
  280. <update id="updateOrderInfo" parameterType="map">
  281. UPDATE mall_order a
  282. <set>
  283. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  284. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  285. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  286. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  287. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  288. <if test="payTime != null">a.pay_time = #{payTime},</if>
  289. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  290. <if test="feeType != null">a.fee_type = #{feeType},</if>
  291. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  292. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  293. <if test="rate != null">a.rate = #{rate},</if>
  294. </set>
  295. WHERE 1 = 1
  296. AND a.id = #{orderId}
  297. </update>
  298. <update id="updateOrderProcessRecord" parameterType="map">
  299. UPDATE mall_order_process_record a
  300. <set>
  301. <if test="payTime != null">a.pay_succ_time = #{payTime}</if>
  302. </set>
  303. WHERE 1 = 1
  304. AND a.order_sn = #{orderSn}
  305. </update>
  306. <update id="updateOrderRefund" parameterType="map">
  307. UPDATE mall_order_refund a
  308. <set>
  309. <if test="refundId != null">a.refund_id = #{refundId},</if>
  310. <if test="refundMoney != null">a.refund_money = #{refundMoney},</if>
  311. <if test="refundStatus != null">a.refund_status = #{refundStatus},</if>
  312. <if test="refundRecvAccout != null">a.refund_recv_accout = #{refundRecvAccout},</if>
  313. <if test="refundTime != null">a.refund_time = #{refundTime},</if>
  314. <if test="wechat_refund_status_des != null">a.wechat_refund_status_des = #{wechat_refund_status_des},</if>
  315. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  316. <if test="feeType != null">a.fee_type = #{feeType},</if>
  317. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  318. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  319. <if test="rate != null">a.rate = #{rate},</if>
  320. </set>
  321. WHERE 1 = 1
  322. AND a.out_refund_no = #{orderRefundId}
  323. </update>
  324. <select id="queryShipmentOrderList" resultType="map">
  325. 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
  326. FROM `mall_order` a inner join mall_order_process_record r on a.order_sn=r.order_sn where order_status='300'
  327. 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
  328. </select>
  329. <select id="queryShipmentBondedOrderList" resultType="map">
  330. 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
  331. 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'
  332. 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
  333. </select>
  334. <update id="updateShipmentOrder" parameterType="map">
  335. update mall_order set order_status ='301', shipping_status='2',confirm_time=now() where id=#{orderId}
  336. </update>
  337. <select id="queryReceiptOrderList" resultType="map">
  338. select o.user_id 'userId',o.id 'orderId',g.product_id'productId',g.goods_specification_name_value 'goodsSpecificationNameValue', g.goods_id 'goodsId',
  339. g.goods_name 'goodsName',confirm_time FROM `mall_order` o inner join mall_order_goods g on o.id = g.order_id
  340. 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
  341. </select>
  342. <update id="updateReceiptOrderByCommentCount">
  343. update mall_order set comment_count = 1 where
  344. order_status='301' and shipping_status ='2' and comment_count=0 AND confirm_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -30 DAY)
  345. </update>
  346. <insert id="insertComment" parameterType="map">
  347. insert into mall_comment(
  348. `type_id`,
  349. `value_id`,
  350. `user_id`,
  351. `order_id`,
  352. `product_id`,
  353. `goods_specification_name_value`,
  354. `status`,
  355. `content`,
  356. `eval_level`,
  357. `value_name`,
  358. `goods_level`,
  359. `create_time`,
  360. add_time,
  361. `mod_time`)
  362. values(
  363. #{typeId},
  364. #{valueId},
  365. #{userId},
  366. #{orderId},
  367. #{productId},
  368. #{goodsSpecificationNameValue},
  369. #{status},
  370. #{content},
  371. #{evalLevel},
  372. #{valueName},
  373. #{goodsLevel},
  374. #{createTime},
  375. #{addTime},
  376. #{modTime})
  377. </insert>
  378. <insert id="insertPinganResponseDto" parameterType="map">
  379. insert into pingan_response(
  380. `id`,
  381. `out_no`,
  382. `req_interface`,
  383. `errcode`,
  384. `msg`,
  385. `data`,
  386. `sign`,
  387. `datajson`,
  388. `timestamp`,
  389. `create_time`,
  390. `tstm`)
  391. values(
  392. #{id},
  393. #{outNo},
  394. #{reqInterface},
  395. #{errcode},
  396. #{msg},
  397. #{data},
  398. #{sign},
  399. #{datajson},
  400. #{timestamp},
  401. #{createTime},
  402. #{tstm})
  403. </insert>
  404. <select id="queryOrder" resultType="map">
  405. select id,order_status
  406. from mall_order
  407. WHERE order_sn = #{orderSn}
  408. </select>
  409. <select id="queryWXPaySuccessRecords" resultType="map">
  410. select id,out_trade_no_wx
  411. from mall_order_wxpay_record
  412. WHERE out_trade_no = #{orderSn} AND trade_state='SUCCESS'
  413. </select>
  414. <update id="updatePayOrderByOutNo" parameterType="map">
  415. update pingan_pay_order
  416. <set>
  417. <if test="pmtName != null">`pmt_name` = #{pmtName}, </if>
  418. <if test="pmtTag != null">`pmt_tag` = #{pmtTag}, </if>
  419. <if test="ordMctId != null">`ord_mct_id` = #{ordMctId}, </if>
  420. <if test="ordShopId != null">`ord_currency` = #{ordShopId}, </if>
  421. <if test="ordCurrency != null">`ord_shop_id` = #{ordCurrency}, </if>
  422. <if test="currencySign != null">`currency_sign` = #{currencySign}, </if>
  423. <if test="ordNo != null">`ord_no` = #{ordNo}, </if>
  424. <if test="ordType != null">`ord_type` = #{ordType}, </if>
  425. <if test="originalAmount != null">`original_amount` = #{originalAmount}, </if>
  426. <if test="discountAmount != null">`discount_amount` = #{discountAmount}, </if>
  427. <if test="ignoreAmount != null">`ignore_amount` = #{ignoreAmount}, </if>
  428. <if test="tradeAccount != null">`trade_account` = #{tradeAccount}, </if>
  429. <if test="tradeNo != null">`trade_no` = #{tradeNo}, </if>
  430. <if test="tradeAmount != null">`trade_amount` = #{tradeAmount}, </if>
  431. <if test="tradeQrcode != null">`trade_qrcode` = #{tradeQrcode}, </if>
  432. <if test="amount != null">`amount` = #{amount}, </if>
  433. <if test="tradeTime != null">`trade_time` = #{tradeTime}, </if>
  434. <if test="tradePayTime != null">`trade_pay_time` = #{tradePayTime}, </if>
  435. <if test="payTime != null">`pay_time` = #{payTime}, </if>
  436. <if test="status != null">`status` = #{status}, </if>
  437. <if test="tradeResult != null">`trade_result` = #{tradeResult}, </if>
  438. <if test="jsapiPayUrl != null">`jsapi_pay_url` = #{jsapiPayUrl}, </if>
  439. <if test="randStr != null">`rand_str` = #{randStr}, </if>
  440. <if test="appid != null">`appId` = #{appid}, </if>
  441. <if test="noncestr != null">`nonceStr` = #{noncestr}, </if>
  442. <if test="signtype != null">`signType` = #{signtype}, </if>
  443. <if test="prepayId != null">`prepay_id` = #{prepayId}, </if>
  444. <if test="paysign != null">`paySign` = #{paysign}, </if>
  445. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  446. <if test="createTime != null">`create_time` = #{createTime}, </if>
  447. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  448. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  449. <if test="tstm != null">`tstm` = #{tstm}</if>
  450. </set>
  451. where `out_no` = #{outNo}
  452. </update>
  453. <select id="queryReceiptOrderByDistList" resultType="map">
  454. SELECT
  455. o.user_id 'userId',
  456. o.id 'orderId',
  457. o.order_sn 'orderSn',
  458. g.goods_id 'goodsId',
  459. g.goods_name 'goodsName',
  460. o.store_id,
  461. g.retail_price 'goodsPrice' ,
  462. a.third_merch_sn 'thirdMerchSn',
  463. a.supplier_id 'supplierId',
  464. a.dist_id 'distId',
  465. a.dist_flag 'distFlag',
  466. a.dist_chnl_id 'distChnlId',
  467. a.alloc_type 'allocType',
  468. a.expend_dist_ids 'expendDistIds',
  469. a.expend_dist_lines 'expendDistLines',
  470. g.is_dist_sell_scan 'isDistSellScan',
  471. g.id 'orderGoodsId',
  472. o.store_id 'storeId',
  473. a.sell_alloc_history_id sell_alloc_history_id
  474. FROM
  475. `mall_order` o
  476. left JOIN mall_order_goods g ON o.id = g.order_id
  477. inner join mk_dist_sell_allocation sa on g.goods_id = sa.goods_id and o.store_id = sa.store_id
  478. inner join mk_dist_sell_allocation_history a on a.sell_alloc_history_id = sa.sell_alloc_history_id
  479. WHERE
  480. order_status = '301'
  481. AND shipping_status = '2'
  482. AND o.is_onffline_order = 0 AND g.is_dist_sell_scan = 0 order by sell_alloc_history_id
  483. </select>
  484. <select id="queryThirdMerchantBySn" resultType="map">
  485. select s.is_dist_sell_start from third_merchant_biz s where s.third_merch_sn = #{thirdMerchSn}
  486. </select>
  487. <select id="queryMkDistHierById" resultType="map" parameterType="map">
  488. select s.dist_id 'distId',s.dist_hier_name 'distHierName',s.hier_lvl 'hierLvl' from mk_dist_hier s
  489. where s.dist_id = #{distId} and s.dist_chnl_id = #{distChnlId}
  490. </select>
  491. <update id="updateOrderGoodsIsScan" parameterType="map">
  492. update mall_order_goods set is_dist_sell_scan = #{isDistSellScan} where id=#{orderGoodsId}
  493. </update>
  494. <select id="queryUserCouponByOrderId" resultType="map">
  495. select id 'couponId' from mall_user_coupon where order_id = #{orderId}
  496. </select>
  497. <update id="cancelUserCouponOrder" parameterType="map">
  498. update mall_user_coupon
  499. <set>
  500. `used_time` = null,
  501. `order_id` = 0,
  502. is_used= 0
  503. </set>
  504. where id = #{id}
  505. </update>
  506. <select id="queryUserCampByOrderId" resultType="map">
  507. select user_camp_id 'userCampId' from mall_user_camp_minus where order_id = #{orderId}
  508. </select>
  509. <update id="cancelUserCampOrder" parameterType="map">
  510. update mall_user_camp_minus
  511. <set>
  512. `used_time` = null,
  513. `order_id` = 0,
  514. is_used = 0
  515. </set>
  516. where user_camp_id = #{userCampId}
  517. </update>
  518. <select id="queryOrderIdByOrderGoodsList" resultType="map">
  519. SELECT
  520. order_id,p.id 'storeRelaId'
  521. FROM
  522. mall_order_goods g
  523. LEFT JOIN mall_order o ON o.id = g.order_id
  524. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  525. LEFT JOIN mall_product_store_rela p ON p.store_id = o.store_id
  526. AND p.goods_id = gs.id where o.pay_status = 2
  527. AND is_onffline_order = 0
  528. </select>
  529. <select id="queryOrderCountByIdAndPayStatus" resultType="map">
  530. SELECT
  531. count(g.number) 'sellVolume'
  532. FROM
  533. mall_order_goods g
  534. LEFT JOIN mall_order o ON o.id = g.order_id
  535. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  536. LEFT JOIN mall_product_store_rela p ON p.store_id = o.store_id
  537. AND p.goods_id = gs.id where o.pay_status = 2
  538. AND is_onffline_order = 0 and p.id= #{storeRelaId}
  539. </select>
  540. <select id="queryGoodsListByIsShareStock" resultType="map">
  541. SELECT g.id 'goodsId',g.goods_number 'goodsNumber',g.merch_sn 'merchSn' FROM mall_goods g where g.is_goods_share_stock = 0
  542. </select>
  543. <select id="queryStoreRelaListByGoodsId" resultType="map">
  544. SELECT p.id 'storeRelaId',p.stock_num 'stockNum',p.store_id 'storeId' FROM mall_product_store_rela p where p.goods_id = #{goodsId}
  545. </select>
  546. <update id="updateByGoodsShareStock" parameterType="map">
  547. update mall_goods
  548. <set>
  549. is_goods_share_stock = #{isGoodsShareStock}
  550. </set>
  551. where id = #{goodsId}
  552. </update>
  553. </mapper>