1
0

QzOrderMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. <update id="updateOrderInfo" parameterType="map">
  64. UPDATE mall_order a
  65. <set>
  66. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  67. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  68. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  69. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  70. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  71. <if test="payTime != null">a.pay_time = #{payTime},</if>
  72. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  73. <if test="feeType != null">a.fee_type = #{feeType},</if>
  74. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  75. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  76. <if test="rate != null">a.rate = #{rate},</if>
  77. </set>
  78. WHERE 1 = 1
  79. AND a.id = #{orderId}
  80. </update>
  81. <update id="updateOrderRefund" parameterType="map">
  82. UPDATE mall_order_refund a
  83. <set>
  84. <if test="refundId != null">a.refund_id = #{refundId},</if>
  85. <if test="refundMoney != null">a.refund_money = #{refundMoney},</if>
  86. <if test="refundStatus != null">a.refund_status = #{refundStatus},</if>
  87. <if test="refundRecvAccout != null">a.refund_recv_accout = #{refundRecvAccout},</if>
  88. <if test="refundTime != null">a.refund_time = #{refundTime},</if>
  89. <if test="wechat_refund_status_des != null">a.wechat_refund_status_des = #{wechat_refund_status_des},</if>
  90. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  91. <if test="feeType != null">a.fee_type = #{feeType},</if>
  92. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  93. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  94. <if test="rate != null">a.rate = #{rate},</if>
  95. </set>
  96. WHERE 1 = 1
  97. AND a.out_refund_no = #{orderRefundId}
  98. </update>
  99. <select id="queryShipmentOrderList" resultType="map">
  100. 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
  101. FROM `mall_order` a inner join mall_order_process_record r on a.order_sn=r.order_sn where order_status='300'
  102. 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
  103. </select>
  104. <select id="queryShipmentBondedOrderList" resultType="map">
  105. 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
  106. 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'
  107. 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
  108. </select>
  109. <update id="updateShipmentOrder" parameterType="map">
  110. update mall_order set order_status ='301', shipping_status='2',confirm_time=now() where id=#{orderId}
  111. </update>
  112. <select id="queryReceiptOrderList" resultType="map">
  113. select o.user_id 'userId',o.id 'orderId',g.product_id'productId',g.goods_specification_name_value 'goodsSpecificationNameValue', g.goods_id 'goodsId',
  114. g.goods_name 'goodsName',confirm_time FROM `mall_order` o inner join mall_order_goods g on o.id = g.order_id
  115. 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
  116. </select>
  117. <update id="updateReceiptOrderByCommentCount">
  118. update mall_order set comment_count = 1 where
  119. order_status='301' and shipping_status ='2' and comment_count=0 AND confirm_time <![CDATA[ < ]]> DATE_ADD(now(),INTERVAL -30 DAY)
  120. </update>
  121. <update id="insertComment" parameterType="map">
  122. insert into mall_comment(
  123. `type_id`,
  124. `value_id`,
  125. `user_id`,
  126. `order_id`,
  127. `product_id`,
  128. `goods_specification_name_value`,
  129. `status`,
  130. `content`,
  131. `eval_level`,
  132. `value_name`,
  133. `goods_level`,
  134. `create_time`,
  135. `mod_time`)
  136. values(
  137. #{typeId},
  138. #{valueId},
  139. #{userId},
  140. #{orderId},
  141. #{productId},
  142. #{goodsSpecificationNameValue},
  143. #{status},
  144. #{content},
  145. #{evalLevel},
  146. #{valueName},
  147. #{goodsLevel},
  148. #{createTime},
  149. #{modTime})
  150. </update>
  151. <select id="queryOrder" resultType="map">
  152. select id,order_status
  153. from mall_order
  154. WHERE order_sn = #{orderSn}
  155. </select>
  156. <select id="queryWXPaySuccessRecords" resultType="map">
  157. select id,out_trade_no_wx
  158. from mall_order_wxpay_record
  159. WHERE out_trade_no = #{orderSn} AND trade_state='SUCCESS'
  160. </select>
  161. </mapper>