OrderMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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.gree.mall.manager.commonmapper.OrderMapper">
  4. <select id="selectByQueryMsg" resultType="com.gree.mall.manager.bean.order.OrderDetailListBean">
  5. select
  6. o.order_id as orderId,
  7. od.goods_name as goodsName,
  8. CONCAT(od.goods_spec_name,'(',od.goods_spec_value,')') as goodsSpecValue,
  9. od.num as num,
  10. od.price as price,
  11. od.pay_amount as payAmount,
  12. od.work_order_type,
  13. o.rece_user_name as receUserName,
  14. o.rece_phone as recePhone,
  15. CONCAT(o.province,o.city,o.area,o.street,o.rece_address,o.house_no) as address,
  16. o.order_status as orderStatus,
  17. o.refund_flag as refundFlag,
  18. od.refund_amount as refundAmount,
  19. od.refund_num as refundNum,
  20. o.remark as remark,
  21. o.create_time as createTime,
  22. o.pay_time,
  23. o.user_name as userName,
  24. o.worker_name as workerName,
  25. o.buyer_msg as buyerMsg,
  26. o.remark as remark,
  27. o.websit_name as websitName,
  28. CONCAT( o.worker_name,'/',o.websit_name) as workerNameWithWebsitName,
  29. od.share_amount as shareAmount ,
  30. u.nick_name as nickName,
  31. u.mobile as mobile,
  32. o.promotion_group_id as promotionGroupId,
  33. GROUP_CONCAT(odr.worker_order_no) workerOrderNo,
  34. o.comment_goods as commentGoods,
  35. o.comment_service as commentService,
  36. o.comment_express as commentExpress,
  37. o.worker_phone,
  38. o.promotion_package_goods,
  39. gs.goods_code,
  40. o.is_add_corp
  41. from order_detail od
  42. join order_info o on od.order_id = o.order_id
  43. left join goods_spec gs on gs.goods_spec_id = od.goods_spec_id
  44. LEFT join `user` u on o.promotion_group_user_id=u.user_id
  45. LEFT JOIN order_request odr on odr.order_id=o.order_id
  46. <where>
  47. <if test="userId != null and userId != ''">
  48. and o.user_id=#{userId}
  49. </if>
  50. <if test="orderId != null and orderId != ''">
  51. and o.order_id like CONCAT('%',#{orderId},'%')
  52. </if>
  53. <if test="productName != null and productName != ''">
  54. and o.order_title like CONCAT('%',#{productName},'%')
  55. </if>
  56. <if test="userName != null and userName != ''">
  57. and (o.rece_user_name like CONCAT('%',#{userName},'%') or o.user_name like CONCAT('%',#{userName},'%') )
  58. </if>
  59. <if test="phone != null and phone != ''">
  60. and (o.phone like CONCAT('%',#{phone},'%') or o.rece_phone like CONCAT('%',#{phone},'%') or o.worker_phone like CONCAT('%',#{phone},'%'))
  61. </if>
  62. <if test="exchangeCode != null and exchangeCode != ''">
  63. and o.exchange_code like CONCAT('%',#{exchangeCode},'%')
  64. </if>
  65. <if test="orderStatus != null and orderStatus != ''">
  66. and o.order_status = #{orderStatus}
  67. </if>
  68. <if test="orderStatus != null and orderStatus=='DFH'">
  69. and od.refund_num = 0
  70. </if>
  71. <if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != ''">
  72. and (o.create_time between #{startCreateTime} and #{endCreateTime})
  73. </if>
  74. <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
  75. and (o.pay_time between #{startPayTime} and #{endPayTime})
  76. </if>
  77. <if test="promotionGroupId != null and promotionGroupId != ''">
  78. and o.promotion_group_id=#{promotionGroupId}
  79. </if>
  80. <if test="promotionGroupUserId != null and promotionGroupUserId != ''">
  81. and o.promotion_group_user_id=#{promotionGroupUserId}
  82. </if>
  83. <if test="promotionFullPieceId != null and promotionFullPieceId !=''">
  84. and o.promotion_full_piece_id=#{promotionFullPieceId}
  85. </if>
  86. <if test="websitId != null and websitId !=''">
  87. and o.websit_id = #{websitId}
  88. </if>
  89. <if test="goodsId != null and goodsId !=''">
  90. and o.promotion_package_goods_id = #{goodsId}
  91. </if>
  92. <if test="companyWechatIds != null and companyWechatIds.size > 0">
  93. and o.company_wechat_id in
  94. <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
  95. #{item}
  96. </foreach>
  97. </if>
  98. <if test="websitIds != null and websitIds.size > 0">
  99. and o.websit_id in
  100. <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
  101. #{item}
  102. </foreach>
  103. </if>
  104. </where>
  105. GROUP BY od.order_detail_id
  106. order by o.create_time desc
  107. </select>
  108. <select id="abnormalDispatchOrder" resultType="com.gree.mall.manager.plus.entity.OrderInfo">
  109. SELECT DISTINCT * from (
  110. SELECT o.*
  111. from order_detail od
  112. LEFT JOIN order_info o on od.order_id=o.order_id
  113. LEFT JOIN order_request oq on oq.order_id=o.order_id
  114. WHERE o.work_order=1 and od.work_order_type='REPAIR' AND oq.order_request_id is NULL and (o.order_status='YFH' or o.order_status='OVER')
  115. UNION
  116. SELECT o.*
  117. from order_detail od
  118. LEFT JOIN order_info o on od.order_id=o.order_id
  119. LEFT JOIN order_request oq on oq.order_id=o.order_id
  120. WHERE o.work_order=1 and od.work_order_type='INSTALL' AND oq.order_request_id is NULL and o.order_status='OVER'
  121. ) a
  122. <where>
  123. <if test="userId != null and userId != ''">
  124. and user_id=#{userId}
  125. </if>
  126. <if test="orderId != null and orderId != ''">
  127. and order_id like CONCAT('%',#{orderId},'%')
  128. </if>
  129. <if test="productName != null and productName != ''">
  130. and order_title like CONCAT('%',#{productName},'%')
  131. </if>
  132. <if test="userName != null and userName != ''">
  133. and (rece_user_name like CONCAT('%',#{userName},'%') or user_name like CONCAT('%',#{userName},'%') )
  134. </if>
  135. <if test="phone != null and phone != ''">
  136. and (phone like CONCAT('%',#{phone},'%') or rece_phone like CONCAT('%',#{phone},'%') or worker_phone like CONCAT('%',#{phone},'%'))
  137. </if>
  138. <if test="exchangeCode != null and exchangeCode != ''">
  139. and exchange_code like CONCAT('%',#{exchangeCode},'%')
  140. </if>
  141. <if test="orderStatus != null and orderStatus != ''">
  142. and order_status = #{orderStatus}
  143. </if>
  144. <if test="startCreateTime != null and startCreateTime != '' and endCreateTime != null and endCreateTime != ''">
  145. and (create_time between #{startCreateTime} and #{endCreateTime})
  146. </if>
  147. <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
  148. and (pay_time between #{startPayTime} and #{endPayTime})
  149. </if>
  150. <if test="isNegative == '2'.toString()">
  151. and comment_express &gt; 2 and comment_service &gt; 2 and comment_goods &gt; 2
  152. </if>
  153. <if test="isNegative == '0'.toString()">
  154. and comment_express = 0 and comment_service = 0 and comment_goods = 0
  155. </if>
  156. <if test="isNegative == '1'.toString()">
  157. and (comment_express &gt; 0 and comment_service &gt; 0 and comment_goods &gt; 0
  158. and (
  159. comment_express &lt; 3 or comment_service &lt; 3 or comment_goods &lt; 3
  160. )
  161. )
  162. </if>
  163. <if test="isNegative == '3'.toString()">
  164. and comment_express &gt; 0 and comment_service &gt; 0 and comment_goods &gt; 0
  165. </if>
  166. <if test="companyWechatIds != null and companyWechatIds.size > 0">
  167. and company_wechat_id in
  168. <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
  169. #{item}
  170. </foreach>
  171. </if>
  172. <if test="websitIds != null and websitIds.size > 0">
  173. and websit_id in
  174. <foreach item="item" index="index" collection="websitIds" open="(" separator="," close=")">
  175. #{item}
  176. </foreach>
  177. </if>
  178. </where>
  179. order by create_time desc
  180. </select>
  181. <select id="orderDelivery" resultType="com.gree.mall.manager.bean.order.OrderDeliveryVO">
  182. SELECT
  183. ${ex.selected}
  184. FROM order_delivery a
  185. ${ex.query}
  186. <if test="companyWechatIds != null and companyWechatIds.size > 0">
  187. AND a.company_wechat_id IN
  188. <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
  189. #{item}
  190. </foreach>
  191. </if>
  192. <if test="storageIds != null and storageIds.size > 0">
  193. AND a.storage_stock_id IN
  194. <foreach item="item" index="index" collection="storageIds" open="(" separator="," close=")">
  195. #{item}
  196. </foreach>
  197. </if>
  198. <if test="ex.orderBy == null or ex.orderBy ==''">
  199. ORDER BY a.create_time DESC
  200. </if>
  201. ${ex.orderBy}
  202. </select>
  203. <select id="statusCount" resultType="com.gree.mall.manager.bean.order.OrderStatusCountBean">
  204. SELECT
  205. SUM(IF(a.order_status = 'DQR', 1, 0)) AS 'dqr',
  206. SUM(IF(a.order_status = 'DJH', 1, 0)) AS 'djh',
  207. SUM(IF(a.order_status = 'JHZ', 1, 0)) AS 'jhz',
  208. SUM(IF(a.order_status = 'DFH', 1, 0)) AS 'dfh',
  209. SUM(IF(a.order_status = 'DPS', 1, 0)) AS 'dps',
  210. SUM(IF(a.order_status = 'PSDQ', 1, 0)) AS 'psdq',
  211. SUM(IF(a.order_status = 'PSZ', 1, 0)) AS 'psz',
  212. SUM(IF(a.order_status = 'DTK', 1, 0)) AS 'dtk'
  213. FROM
  214. order_info a
  215. WHERE
  216. a.order_status IN ('DQR', 'DJH', 'JHZ', 'DFH', 'DPS', 'PSDQ', 'PSZ', 'DTK')
  217. <if test="companyWechatIds != null and companyWechatIds.size > 0">
  218. AND a.company_wechat_id in
  219. <foreach item="item" index="index" collection="companyWechatIds" open="(" separator="," close=")">
  220. #{item}
  221. </foreach>
  222. </if>
  223. <if test="storageIds != null and storageIds.size > 0">
  224. AND a.pick_storage_id in
  225. <foreach item="item" index="index" collection="storageIds" open="(" separator="," close=")">
  226. #{item}
  227. </foreach>
  228. </if>
  229. </select>
  230. </mapper>