1
0

QzOrderMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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,a.order_sn_wx
  47. from mall_order a
  48. 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
  49. or f.refund_time is null or f.wechat_refund_status_des is null) and a.order_status = '401' and f.refund_status
  50. in (2,5)
  51. </select>
  52. <select id="queryPayingOrderList" resultType="map">
  53. 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,
  54. b.product_id,b.number,c.stock_num,c.id as storeRelaId
  55. from mall_order a
  56. LEFT JOIN mall_order_goods b ON a.id = b.order_id
  57. LEFT JOIN mall_product_store_rela c ON b.product_id = c.product_id
  58. AND c.store_id = a.store_id where (a.order_status in ('100','201') and a.pay_status in (1,2))
  59. and (a.pay_transaction_id = '' or a.pay_transaction_id is null or a.pay_time is null or a.pay_time = '')
  60. AND a.is_onffline_order = 0
  61. </select>
  62. <update id="updateOrderInfo" parameterType="map">
  63. UPDATE mall_order a
  64. <set>
  65. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  66. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  67. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  68. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  69. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  70. <if test="payTime != null">a.pay_time = #{payTime},</if>
  71. </set>
  72. WHERE 1 = 1
  73. AND a.id = #{orderId}
  74. </update>
  75. <update id="updateOrderRefund" parameterType="map">
  76. UPDATE mall_order_refund a
  77. <set>
  78. <if test="refundId != null">a.refund_id = #{refundId},</if>
  79. <if test="refundMoney != null">a.refund_money = #{refundMoney},</if>
  80. <if test="refundStatus != null">a.refund_status = #{refundStatus},</if>
  81. <if test="refundRecvAccout != null">a.refund_recv_accout = #{refundRecvAccout},</if>
  82. <if test="refundTime != null">a.refund_time = #{refundTime},</if>
  83. <if test="wechat_refund_status_des != null">a.wechat_refund_status_des = #{wechat_refund_status_des},</if>
  84. </set>
  85. WHERE 1 = 1
  86. AND a.out_refund_no = #{orderRefundId}
  87. </update>
  88. <select id="queryShipmentOrderList" resultType="map">
  89. 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
  90. FROM `mall_order` a inner join mall_order_process_record r on a.order_sn=r.order_sn where order_status='300'
  91. 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
  92. </select>
  93. <select id="queryShipmentBondedOrderList" resultType="map">
  94. 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
  95. 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'
  96. 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
  97. </select>
  98. <update id="updateShipmentOrder" parameterType="map">
  99. update mall_order set order_status ='301', shipping_status='2',confirm_time=now() where id=#{orderId}
  100. </update>
  101. <select id="queryReceiptOrderList" resultType="map">
  102. select o.user_id 'userId',o.id 'orderId',g.product_id'productId',g.goods_specification_name_value 'goodsSpecificationNameValue', g.goods_id 'goodsId',
  103. g.goods_name 'goodsName',confirm_time FROM `mall_order` o inner join mall_order_goods g on o.id = g.order_id
  104. 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
  105. </select>
  106. <update id="updateReceiptOrderByCommentCount">
  107. update mall_order set comment_count = 1 where
  108. order_status='301' and shipping_status ='2' and comment_count=0 AND confirm_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -30 DAY)
  109. </update>
  110. <update id="insertComment" parameterType="map">
  111. insert into mall_comment(
  112. `type_id`,
  113. `value_id`,
  114. `user_id`,
  115. `order_id`,
  116. `product_id`,
  117. `goods_specification_name_value`,
  118. `status`,
  119. `content`,
  120. `eval_level`,
  121. `value_name`,
  122. `goods_level`,
  123. `create_time`,
  124. `mod_time`)
  125. values(
  126. #{typeId},
  127. #{valueId},
  128. #{userId},
  129. #{orderId},
  130. #{productId},
  131. #{goodsSpecificationNameValue},
  132. #{status},
  133. #{content},
  134. #{evalLevel},
  135. #{valueName},
  136. #{goodsLevel},
  137. #{createTime},
  138. #{modTime})
  139. </update>
  140. <select id="queryOrder" resultType="map">
  141. select id,order_status
  142. from mall_order
  143. WHERE order_sn = #{orderSn}
  144. </select>
  145. <select id="queryWXPaySuccessRecords" resultType="map">
  146. select id,out_trade_no_wx
  147. from mall_order_wxpay_record
  148. WHERE out_trade_no = #{orderSn} AND trade_state='SUCCESS'
  149. </select>
  150. </mapper>