OrderMapper.xml 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  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.yami.shop.dao.OrderMapper">
  4. <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.Order">
  5. <id column="order_id" jdbcType="BIGINT" property="orderId"/>
  6. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  7. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  8. <result column="channel_id" jdbcType="BIGINT" property="channelId"/>
  9. <result column="channel_name" jdbcType="VARCHAR" property="channelName"/>
  10. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  11. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  12. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  13. <result column="total" jdbcType="DECIMAL" property="total"/>
  14. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  15. <result column="pay_type" jdbcType="INTEGER" property="payType"/>
  16. <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
  17. <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
  18. <result column="dvy_status" jdbcType="VARCHAR" property="dvyStatus"/>
  19. <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
  20. <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
  21. <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
  22. <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
  23. <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  24. <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
  25. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  26. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  27. <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
  28. <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
  29. <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
  30. <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
  31. <result column="is_payed" jdbcType="BIT" property="isPayed"/>
  32. <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
  33. <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
  34. <result column="member_discount_amount" jdbcType="DECIMAL" property="memberDiscountAmount"/>
  35. <result column="member_discount_desc" jdbcType="VARCHAR" property="memberDiscountDesc"/>
  36. <result column="close_type" jdbcType="INTEGER" property="closeType"/>
  37. <result column="user_mobile" jdbcType="VARCHAR" property="userMobile"/>
  38. <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
  39. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  40. <result column="split_status" property="splitStatus"/>
  41. <result column="auto_split" property="autoSplit"/>
  42. <result column="order_level" property="orderLevel"/>
  43. <result column="order_split_number" property="orderSplitNumber"/>
  44. <result column="order_split_status" property="orderSplitStatus"/>
  45. <result column="consigneeAddress" property="consigneeAddress"/>
  46. </resultMap>
  47. <resultMap id="MyOrderMap" type="com.yami.shop.bean.app.dto.MyOrderDto">
  48. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  49. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  50. <result column="order_type" jdbcType="VARCHAR" property="orderType"/>
  51. <result column="refund_type" jdbcType="INTEGER" property="refundType"/>
  52. <result column="return_money_sts" jdbcType="INTEGER" property="returnMoneySts"/>
  53. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  54. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  55. <result column="latitude" property="latitude"/>
  56. <result column="longitude" property="longitude"/>
  57. <result column="create_time" property="createTime"/>
  58. <result column="hb_order_status" property="hbOrderStatus"/>
  59. <result column="hb_logistic_status" property="hbLogisticStatus"/>
  60. <result column="offset_points" property="offsetPoints"/>
  61. <result column="pay_time" property="payTime"/>
  62. <result column="dvy_type" property="dvyType"/>
  63. <result column="comm_sts" property="commSts"/>
  64. <collection property="orderItemDtos" ofType="com.yami.shop.bean.app.dto.MyOrderItemDto">
  65. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  66. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  67. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  68. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  69. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  70. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  71. <result column="price" jdbcType="DECIMAL" property="price"/>
  72. <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
  73. <result column="order_item_id" property="orderItemId"/>
  74. <result column="comm_sts" property="commSts"/>
  75. <result column="rec_time" property="recTime"/>
  76. </collection>
  77. </resultMap>
  78. <resultMap id="MyOrderItemMap" type="com.yami.shop.bean.app.dto.MyOrderItemDto">
  79. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  80. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  81. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  82. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  83. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  84. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  85. <result column="price" jdbcType="DECIMAL" property="price"/>
  86. <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
  87. <result column="order_item_id" property="orderItemId"/>
  88. <result column="comm_sts" property="commSts"/>
  89. <result column="rec_time" property="recTime"/>
  90. </resultMap>
  91. <resultMap type="com.yami.shop.bean.model.Order" id="orderAndOrderItemMap">
  92. <id column="order_id" jdbcType="BIGINT" property="orderId"/>
  93. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  94. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  95. <result column="channel_id" jdbcType="BIGINT" property="channelId"/>
  96. <result column="channel_name" jdbcType="VARCHAR" property="channelName"/>
  97. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  98. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  99. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  100. <result column="hb_order_status" jdbcType="VARCHAR" property="hbOrderStatus"/>
  101. <result column="dvy_status" jdbcType="VARCHAR" property="dvyStatus"/>
  102. <result column="total" jdbcType="DECIMAL" property="total"/>
  103. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  104. <result column="pay_type" jdbcType="INTEGER" property="payType"/>
  105. <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
  106. <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
  107. <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
  108. <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
  109. <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
  110. <result column="platform_amount" jdbcType="DECIMAL" property="platformAmount"/>
  111. <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  112. <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
  113. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  114. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  115. <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
  116. <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
  117. <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
  118. <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
  119. <result column="is_payed" jdbcType="BIT" property="isPayed"/>
  120. <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
  121. <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
  122. <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
  123. <result column="member_discount_amount" jdbcType="DECIMAL" property="memberDiscountAmount"/>
  124. <result column="member_discount_desc" jdbcType="VARCHAR" property="memberDiscountDesc"/>
  125. <result column="order_type" jdbcType="INTEGER" property="orderType"/>
  126. <result column="close_type" jdbcType="INTEGER" property="closeType"/>
  127. <result column="consignee_name" jdbcType="INTEGER" property="consigneeName"/>
  128. <result column="consignee_mobile" jdbcType="INTEGER" property="consigneeMobile"/>
  129. <result column="consignee_address" jdbcType="INTEGER" property="consigneeAddress"/>
  130. <result column="latitude" jdbcType="INTEGER" property="latitude"/>
  131. <result column="longitude" jdbcType="INTEGER" property="longitude"/>
  132. <result column="self_pick_code" jdbcType="VARCHAR" property="selfPickCode"/>
  133. <collection property="orderItems" ofType="com.yami.shop.bean.model.OrderItem">
  134. <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
  135. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  136. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  137. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  138. <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
  139. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  140. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  141. <result column="oi_prod_name" jdbcType="VARCHAR" property="prodName"/>
  142. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  143. <result column="price" jdbcType="DECIMAL" property="price"/>
  144. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  145. <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
  146. <!--<result column="platform_amount" jdbcType="DECIMAL" property="platformAmount"/>-->
  147. <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
  148. <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
  149. <result column="distribution_card_no" property="distributionCardNo"/>
  150. <result column="basket_date" property="basketDate"/>
  151. <result column="share_reduce" property="shareReduce"/>
  152. <result column="member_discount_share_amount" property="memberDiscountShareAmount"/>
  153. <result column="distribution_amount" property="distributionAmount"/>
  154. <result column="distribution_parent_amount" property="distributionParentAmount"/>
  155. <result column="return_money_sts" property="returnMoneySts"/>
  156. <result column="oi_actual_total" property="actualTotal"/>
  157. </collection>
  158. </resultMap>
  159. <resultMap type="com.yami.shop.bean.model.Order" id="orderAndOrderItemAndUserAddrMap">
  160. <id column="order_id" jdbcType="BIGINT" property="orderId"/>
  161. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  162. <result column="order_prod_name" jdbcType="VARCHAR" property="prodName"/>
  163. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  164. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  165. <result column="total" jdbcType="DECIMAL" property="total"/>
  166. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  167. <result column="pay_type" jdbcType="INTEGER" property="payType"/>
  168. <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
  169. <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
  170. <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
  171. <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
  172. <result column="nick_name" jdbcType="BIGINT" property="nickName"/>
  173. <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
  174. <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
  175. <result column="order_type" jdbcType="INTEGER" property="orderType"/>
  176. <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  177. <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
  178. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  179. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  180. <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
  181. <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
  182. <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
  183. <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
  184. <result column="is_payed" jdbcType="BIT" property="isPayed"/>
  185. <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
  186. <result column="pay_score" jdbcType="INTEGER" property="score"/>
  187. <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
  188. <result column="member_discount_amount" jdbcType="DECIMAL" property="memberDiscountAmount"/>
  189. <result column="member_discount_desc" jdbcType="VARCHAR" property="memberDiscountDesc"/>
  190. <result column="close_type" jdbcType="INTEGER" property="closeType"/>
  191. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  192. <result column="pay_score" jdbcType="INTEGER" property="payScore"/>
  193. <result column="user_mobile" jdbcType="VARCHAR" property="userMobile"/>
  194. <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
  195. <result column="qnh_order_id" jdbcType="VARCHAR" property="qnhOrderId"/>
  196. <result column="qnh_order_status" jdbcType="VARCHAR" property="qnhOrderStatus"/>
  197. <result column="dvy_status" jdbcType="INTEGER" property="dvyStatus"/>
  198. <association property="userAddrOrder" javaType="com.yami.shop.bean.model.UserAddrOrder">
  199. <id column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  200. <result column="province" jdbcType="VARCHAR" property="province"/>
  201. <result column="city" jdbcType="VARCHAR" property="city"/>
  202. <result column="area" jdbcType="VARCHAR" property="area"/>
  203. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  204. <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
  205. <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
  206. <result column="address" jdbcType="VARCHAR" property="address"/>
  207. <result column="address_name" jdbcType="VARCHAR" property="addressName"/>
  208. <result column="address_detail" jdbcType="VARCHAR" property="addrDetail"/>
  209. </association>
  210. <collection property="orderItems" ofType="com.yami.shop.bean.model.OrderItem">
  211. <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
  212. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  213. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  214. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  215. <!-- <result column="prod_name" jdbcType="BIGINT" property="prodName"/>-->
  216. <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
  217. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  218. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  219. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  220. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  221. <result column="price" jdbcType="DECIMAL" property="price"/>
  222. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  223. <result column="oi_actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  224. <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
  225. <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
  226. <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
  227. <result column="item_status" jdbcType="INTEGER" property="status"/>
  228. <result column="distribution_card_no" property="distributionCardNo"/>
  229. <result column="basket_date" property="basketDate"/>
  230. <result column="share_reduce" property="shareReduce"/>
  231. <result column="member_discount_share_amount" property="memberDiscountShareAmount"/>
  232. <result column="platform_share_reduce" property="platformShareReduce"/>
  233. <result column="oi_return_money_sts" property="returnMoneySts"/>
  234. <result column="oi_status" property="status"/>
  235. </collection>
  236. </resultMap>
  237. <select id="getOrderByOrderNumber" resultType="com.yami.shop.bean.model.Order">
  238. select *
  239. from tz_order o
  240. where o.order_number = #{orderNumber}
  241. </select>
  242. <select id="listUnRefundOrderAndOrderItems" resultMap="orderAndOrderItemMap">
  243. select o.*, oi.*, tor.return_money_sts, oi.prod_name oi_prod_name, oi.actual_total as oi_actual_total
  244. from tz_order o
  245. join tz_order_item oi on o.order_number = oi.order_number
  246. left join tz_order_refund tor on tor.order_id = o.order_id
  247. where o.hb_order_status = #{orderStatus}
  248. and (refund_status IS NULL OR o.refund_status &lt;&gt; 1)
  249. and o.dvy_time &lt; #{lessThanUpdateTime}
  250. </select>
  251. <select id="selectCancelOrders" resultMap="orderAndOrderItemMap">
  252. select o.*, oi.*, oi.prod_name oi_prod_name, oi.actual_total as oi_actual_total
  253. from tz_order o
  254. join tz_order_item oi on o.order_number = oi.order_number
  255. where o.hb_order_status = #{orderStatus}
  256. and o.create_time &lt; #{lessThanUpdateTime}
  257. </select>
  258. <update id="cancelOrders">
  259. update tz_order set `hb_order_status`=60,cancel_reason = #{cancelReason}, cancel_time =
  260. NOW(),update_time=NOW(),close_type=4 where order_id in
  261. <foreach collection="orders" item="order" open="(" close=")" separator=",">
  262. #{order.orderId}
  263. </foreach>
  264. </update>
  265. <update id="receiptOrder">
  266. update tz_order set `hb_order_status`= 80,finally_time = NOW(),update_time=NOW() where order_id in
  267. <foreach collection="orders" item="order" open="(" close=")" separator=",">
  268. #{order.orderId}
  269. </foreach>
  270. </update>
  271. <update id="updateByToPaySuccess">
  272. update tz_order set `hb_order_status` = 20,is_payed =1,update_time=NOW(),pay_time=NOW(),pay_type =#{payType}
  273. where dvy_type=3 and
  274. order_number in
  275. <foreach collection="orderNumbers" item="orderNumber" separator="," open="(" close=")">
  276. #{orderNumber}
  277. </foreach>
  278. </update>
  279. <update id="updateByToPaySuccessDelivery">
  280. update tz_order set `hb_order_status` = 1,is_payed =1,update_time=NOW(),pay_time=NOW(),pay_type =#{payType}
  281. where dvy_type=1 and
  282. order_number in
  283. <foreach collection="orderNumbers" item="orderNumber" separator="," open="(" close=")">
  284. #{orderNumber}
  285. </foreach>
  286. </update>
  287. <select id="listOrdersDetialByOrder" resultMap="orderAndOrderItemAndUserAddrMap">
  288. select o.*,oi.*,oi.prod_name as item_prod_name,o.prod_name as order_prod_name,uao.* ,o.hb_order_status as
  289. oi_status
  290. from tz_order o
  291. left join tz_order_item oi on o.order_number = oi.order_number
  292. left join tz_user_addr_order uao on o.addr_order_id = uao.addr_order_id
  293. where o.order_id in (
  294. select * from (
  295. select o.order_id from tz_order o
  296. left join tz_shop_detail sd on o.shop_id = sd.shop_id
  297. where 1=1
  298. <if test="order.orderNumber != null and order.orderNumber != ''">
  299. and o.order_number like concat('%',#{order.orderNumber},'%')
  300. </if>
  301. <if test="order.hb_order_status != null">
  302. and o.hb_order_status = #{order.orderStatus}
  303. </if>
  304. <if test="order.shopId != null">
  305. and o.shop_id = #{order.shopId}
  306. </if>
  307. <if test="order.isPayed != null">
  308. and o.is_payed = #{order.isPayed}
  309. and o.hb_order_status != 60
  310. </if>
  311. <if test="startTime != null">
  312. and o.create_time &gt; #{startTime}
  313. </if>
  314. <if test="endTime != null">
  315. and o.create_time &lt; #{endTime}
  316. </if>
  317. <if test="order.shopName != null">
  318. and sd.shop_name like concat("%",#{order.shopName},"%")
  319. </if>
  320. ORDER BY o.create_time DESC
  321. )
  322. AS limittable) ORDER BY o.create_time DESC
  323. </select>
  324. <select id="getOrderCountByShopId" resultType="com.yami.shop.bean.param.OrderPayParam">
  325. SELECT SUM(actual_total) as payActualTotal,COUNT(DISTINCT user_id) as payUserCount,
  326. COUNT(*) as payOrderCount
  327. FROM tz_order o
  328. <where>
  329. <if test="shopId != null">
  330. and o.shop_id = #{shopId}
  331. </if>
  332. <if test="startTime != null">
  333. and o.pay_time &gt;= #{startTime}
  334. </if>
  335. <if test="endTime != null">
  336. and o.pay_time &lt;= #{endTime}
  337. </if>
  338. AND o.is_payed =1
  339. </where>
  340. </select>
  341. <select id="getPayOrderByTime" resultType="com.yami.shop.bean.param.OrderPayParam">
  342. SELECT dates, MAX(orderCount) AS payOrderCount,MAX(payActualTotal) as payActualTotal FROM(
  343. SELECT @cdate := DATE_ADD(@cdate,INTERVAL - 1 DAY) dates ,0 AS 'orderCount',0 AS 'payActualTotal'
  344. FROM (SELECT @cdate :=DATE_ADD(CURDATE(),INTERVAL + 1 DAY) FROM tz_user) t1
  345. <where>
  346. <if test="startTime != null">
  347. and @cdate >= #{startTime}
  348. </if>
  349. </where>
  350. UNION ALL
  351. SELECT DATE_FORMAT(o.pay_time, '%Y-%m-%d') AS dates,COUNT(*) AS orderCount,SUM(actual_total) AS payActualTotal
  352. FROM tz_order o
  353. <where>
  354. <if test="shopId != null">
  355. and o.shop_id = #{shopId}
  356. </if>
  357. <if test="startTime != null">
  358. and o.pay_time &gt;= #{startTime}
  359. </if>
  360. <if test="endTime != null">
  361. and o.pay_time &lt;= #{endTime}
  362. </if>
  363. AND o.is_payed =1
  364. </where>
  365. GROUP BY dates) _tmpAllTable GROUP BY dates
  366. ORDER BY dates
  367. </select>
  368. <select id="getActualTotalByHour" resultType="com.yami.shop.bean.param.OrderPayParam">
  369. SELECT DATE_FORMAT(o.pay_time, '%k') AS dates,SUM(actual_total) as payActualTotal
  370. FROM tz_order o
  371. <where>
  372. <if test="shopId != null">
  373. and o.shop_id = #{shopId}
  374. </if>
  375. <if test="startTime != null">
  376. and o.pay_time &gt;= #{startTime}
  377. </if>
  378. <if test="endTime != null">
  379. and o.pay_time &lt;= #{endTime}
  380. </if>
  381. AND o.is_payed =1
  382. </where>
  383. GROUP BY dates
  384. </select>
  385. <select id="getActualTotalByDay" resultType="com.yami.shop.bean.param.OrderPayParam">
  386. SELECT DATE_FORMAT(o.pay_time, '%Y-%m-%d') AS payDay,SUM(actual_total) as payActualTotal
  387. FROM tz_order o
  388. <where>
  389. <if test="shopId != null">
  390. and o.shop_id = #{shopId}
  391. </if>
  392. <if test="startTime != null">
  393. and o.pay_time &gt;= #{startTime}
  394. </if>
  395. <if test="endTime != null">
  396. and o.pay_time &lt;= #{endTime}
  397. </if>
  398. AND o.is_payed =1
  399. </where>
  400. GROUP BY payDay
  401. </select>
  402. <select id="listOrdersDetialByOrderParam" resultMap="orderAndOrderItemAndUserAddrMap">
  403. SELECT *,oi.prod_name as item_prod_name,oi.actual_total as oi_actual_total,IF(r.refund_type =
  404. 2,r.return_money_sts,IF(ar.refund_type = 1,ar.return_money_sts,NULL)) AS oi_return_money_sts,
  405. temp.prod_name as order_prod_name,temp.hb_order_status as oi_status, IF(os.pay_score IS NULL,0,os.pay_score) as
  406. pay_score
  407. FROM
  408. (
  409. SELECT o.*,sd.shop_name,uao.receiver,uao.mobile,u.user_mobile,u.nick_name FROM tz_order o
  410. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  411. LEFT JOIN tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
  412. LEFT JOIN tz_user u on u.user_id=o.user_id
  413. <where>
  414. <!-- <if test="orderParam.type!=null and orderParam.type==1 and orderParam.content != null and orderParam.content != ''">-->
  415. <!-- and o.order_number = #{orderParam.content}-->
  416. <!-- </if>-->
  417. <if test="orderParam.parentOrderNumber != null and orderParam.parentOrderNumber != ''">
  418. and o.parent_order_number = #{orderParam.parentOrderNumber}
  419. </if>
  420. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  421. and o.order_number = #{orderParam.orderNumber}
  422. </if>
  423. <if test="orderParam.hbOrderStatus != null">
  424. and o.hb_order_status = #{orderParam.hbOrderStatus}
  425. </if>
  426. <if test="orderParam.dvyType != null">
  427. and o.dvy_type = #{orderParam.dvyType}
  428. </if>
  429. <if test="orderParam.channelId != null">
  430. and o.channel_id = #{orderParam.channelId}
  431. </if>
  432. <if test="orderParam.shopId != null">
  433. and o.shop_id = #{orderParam.shopId}
  434. </if>
  435. <if test="orderParam.isPayed != null">
  436. and o.is_payed = #{orderParam.isPayed}
  437. and o.hb_order_status != 60
  438. </if>
  439. <if test="orderParam.startTime != null">
  440. and o.create_time &gt; #{orderParam.startTime}
  441. </if>
  442. <if test="orderParam.endTime != null">
  443. and o.create_time &lt; #{orderParam.endTime}
  444. </if>
  445. <if test="orderParam.orderType != null">
  446. and o.order_type = #{orderParam.orderType}
  447. </if>
  448. <if test="orderParam.orderType == null">
  449. and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
  450. </if>
  451. <if test="orderParam.shopName != null">
  452. and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
  453. </if>
  454. <if test="orderParam.refundStatus == 0">
  455. and o.refund_status IS NULL
  456. </if>
  457. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  458. and o.refund_status = #{orderParam.refundStatus}
  459. </if>
  460. <if test="orderParam.prodName != null">
  461. and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
  462. </if>
  463. </where>
  464. ORDER BY o.create_time DESC
  465. LIMIT #{adapter.begin} , #{adapter.size}
  466. ) AS temp
  467. LEFT JOIN tz_order_item oi ON temp.order_number = oi.order_number
  468. <!--连接单个物品退款的退款信息-->
  469. LEFT JOIN tz_order_refund r ON r.order_item_id = oi.order_item_id AND r.refund_type = 2 AND r.return_money_sts
  470. &gt; 0 AND r.return_money_sts &lt; 6
  471. <!--连接整单退款的退款信息-->
  472. LEFT JOIN tz_order_refund ar ON ar.order_id = temp.order_id AND ar.refund_type = 1 AND ar.return_money_sts &gt;
  473. 0 AND ar.return_money_sts &lt; 6
  474. LEFT JOIN tz_order_settlement os ON temp.order_number = os.order_number
  475. ORDER BY temp.create_time DESC
  476. </select>
  477. <select id="deliverList" resultMap="BaseResultMap">
  478. SELECT a.*,b.receiver,b.mobile user_mobile,c.shop_name FROM tz_order a
  479. LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
  480. LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
  481. left join tz_user d on a.user_id = d.user_id
  482. <where>
  483. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  484. and a.order_number = #{orderParam.orderNumber}
  485. </if>
  486. <if test="orderParam.parentOrderNumber != null and orderParam.parentOrderNumber != ''">
  487. and a.parent_order_number = #{orderParam.parentOrderNumber}
  488. </if>
  489. <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
  490. and a.channel_id in
  491. <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
  492. #{channelId}
  493. </foreach>
  494. </if>
  495. <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
  496. and a.dvy_type = #{orderParam.dvyType}
  497. </if>
  498. <if test="orderParam.userAttrType != null and orderParam.userAttrType != '' and orderParam.userAttrType != 0">
  499. AND d.user_attr_type = #{orderParam.userAttrType}
  500. </if>
  501. <if test="orderParam.shopId != null">
  502. and a.shop_id = #{orderParam.shopId}
  503. </if>
  504. <if test="orderParam.startTime != null">
  505. and a.create_time &gt; #{orderParam.startTime}
  506. </if>
  507. <if test="orderParam.endTime != null">
  508. and a.create_time &lt; #{orderParam.endTime}
  509. </if>
  510. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  511. and a.refund_status = #{orderParam.refundStatus}
  512. </if>
  513. <if test="orderParam.receiver != null">
  514. and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
  515. </if>
  516. <if test="orderParam.userMobile != null">
  517. and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
  518. </if>
  519. <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
  520. <if test="orderParam.orderStatus == 'all'">
  521. AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
  522. </if>
  523. <if test="orderParam.orderStatus == 'paddingPay'">
  524. AND a.hb_order_status in (0)
  525. </if>
  526. <if test="orderParam.orderStatus == 'paddingShipped'">
  527. AND a.hb_order_status in (1)
  528. </if>
  529. <if test="orderParam.orderStatus == 'paddingReceived'">
  530. AND a.hb_order_status in (20,30,40,70)
  531. </if>
  532. <if test="orderParam.orderStatus == 'completed'">
  533. AND a.hb_order_status in (80)
  534. </if>
  535. <if test="orderParam.orderStatus == 'cancel'">
  536. AND a.hb_order_status in (50,60)
  537. </if>
  538. <if test="orderParam.orderStatus == 'split'">
  539. AND a.hb_order_status in (1,20) and a.split_status in(2,3)
  540. </if>
  541. </if>
  542. <if test="orderParam.orderSplitStatus != null">
  543. and a.order_split_Status = #{orderParam.orderSplitStatus}
  544. </if>
  545. <if test="orderParam.autoSplit != null">
  546. and a.auto_split = #{orderParam.autoSplit}
  547. </if>
  548. <if test="orderParam.splitStatus != null">
  549. <if test="orderParam.splitStatus != 2">
  550. and a.split_status = #{orderParam.splitStatus}
  551. </if>
  552. </if>
  553. <if test="orderParam.orderLevel != null">
  554. and a.order_level = #{orderParam.orderLevel}
  555. </if>
  556. </where>
  557. order by a.create_time desc,a.order_id desc
  558. </select>
  559. <select id="countOrderDetial" resultType="long">
  560. SELECT count(0)
  561. FROM tz_order o
  562. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  563. JOIN tz_user_addr_order uao
  564. ON o.addr_order_id = uao.addr_order_id
  565. <where>
  566. o.delete_status = 0
  567. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  568. and o.order_number = #{orderParam.orderNumber}
  569. </if>
  570. <if test="orderParam.hbOrderStatus != null">
  571. and o.hb_order_status = #{orderParam.hbOrderStatus}
  572. </if>
  573. <if test="orderParam.shopId != null">
  574. and o.shop_id = #{orderParam.shopId}
  575. </if>
  576. <if test="orderParam.channelId != null">
  577. and o.channel_id = #{orderParam.channelId}
  578. </if>
  579. <if test="orderParam.dvyType != null">
  580. and o.dvy_type = #{orderParam.dvyType}
  581. </if>
  582. <if test="orderParam.isPayed != null">
  583. and o.is_payed = #{orderParam.isPayed}
  584. and o.hb_order_status != 60
  585. </if>
  586. <if test="orderParam.startTime != null">
  587. and o.create_time &gt; #{orderParam.startTime}
  588. </if>
  589. <if test="orderParam.endTime != null">
  590. and o.create_time &lt; #{orderParam.endTime}
  591. </if>
  592. <if test="orderParam.orderType != null">
  593. and o.order_type = #{orderParam.orderType}
  594. </if>
  595. <if test="orderParam.orderType == null">
  596. and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
  597. </if>
  598. <if test="orderParam.shopName != null">
  599. and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
  600. </if>
  601. <if test="orderParam.refundStatus == 0">
  602. and o.refund_status IS NULL
  603. </if>
  604. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  605. and o.refund_status = #{orderParam.refundStatus}
  606. </if>
  607. <if test="orderParam.prodName != null">
  608. and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
  609. </if>
  610. <if test="orderParam.receiver != null">
  611. and uao.receiver LIKE concat("%",#{orderParam.receiver},"%")
  612. </if>
  613. <if test="orderParam.mobile != null">
  614. and uao.mobile LIKE concat("%",#{orderParam.mobile},"%")
  615. </if>
  616. </where>
  617. </select>
  618. <select id="calculateUserInShopData" resultType="com.yami.shop.bean.distribution.UserShoppingDataDto">
  619. select count(o.order_number) as expense_number,
  620. ifnull(SUM(o.actual_total), 0) as expense_amount
  621. from tz_order o
  622. where o.user_id = #{userId}
  623. and o.shop_id = #{shopId}
  624. and (o.hb_order_status = 45 or o.hb_order_status = 80)
  625. </select>
  626. <select id="listMyOrderByUserIdAndStatus" resultMap="MyOrderMap">
  627. SELECT
  628. o.order_type,o.actual_total,o.order_number,o.freight_amount,o.create_time,o.order_id,
  629. o.hb_order_status,
  630. o.hb_logistic_status,
  631. o.offset_points,
  632. o.pay_time,
  633. o.dvy_type,
  634. o.comm_sts,
  635. (SELECT r.refund_type FROM tz_order_refund r WHERE r.order_id =o.order_id ORDER BY r.update_time DESC LIMIT 0,1)
  636. AS refund_type,
  637. (SELECT r.return_money_sts FROM tz_order_refund r WHERE r.order_id =o.order_id ORDER BY r.update_time DESC LIMIT
  638. 0,1) AS return_money_sts,
  639. oi.pic,oi.price,oi.prod_name,oi.pic,oi.sku_name,ifnull(oi.use_score,0) as
  640. use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
  641. sd.shop_id,sd.shop_name,oi.actual_total as oi_actual_total,ad.longitude,ad.latitude
  642. FROM (
  643. SELECT temp.order_type,
  644. temp.hb_order_status,
  645. temp.hb_logistic_status,
  646. temp.offset_points,
  647. temp.pay_time,
  648. temp.dvy_type,
  649. temp.comm_sts,
  650. temp.order_id, temp.create_time,
  651. temp.freight_amount,temp.order_number,temp.actual_total,temp.shop_id,temp.addr_order_id FROM tz_order temp
  652. WHERE temp.user_id = #{userId} and temp.delete_status=0
  653. and (temp.order_level != 0 OR temp.split_status != 4) and (temp.order_level != 1 OR temp.split_status != 3)
  654. <if test="status != null">
  655. AND
  656. <choose>
  657. <when test="20 == status">
  658. temp.hb_order_status IN (1,20,30,40,50,70)
  659. </when>
  660. <otherwise>
  661. temp.hb_order_status = #{status}
  662. </otherwise>
  663. </choose>
  664. </if>
  665. <if test="dvyType != null">
  666. AND temp.dvy_type = #{dvyType}
  667. </if>
  668. ORDER BY temp.create_time DESC
  669. LIMIT #{adapter.begin} , #{adapter.size}
  670. )AS o
  671. JOIN tz_order_item oi ON o.order_number = oi.order_number
  672. left join tz_shop_detail sd on o.shop_id = sd.shop_id
  673. left join tz_order_refund tor on o.order_id = tor.order_id
  674. left join tz_user_addr_order ad on o.addr_order_id = ad.addr_order_id
  675. ORDER BY o.create_time DESC
  676. </select>
  677. <select id="countMyOrderByUserIdAndStatus" resultType="Long">
  678. SELECT count(temp.order_id) FROM tz_order temp
  679. WHERE temp.user_id = #{userId} and temp.delete_status = 0
  680. <if test="status != null">
  681. <if test="20 == status">
  682. and temp.hb_order_status IN (1,20,30,40,50,70)
  683. </if>
  684. <if test="20 != status">
  685. AND temp.hb_order_status = #{status}
  686. </if>
  687. </if>
  688. and (temp.order_level != 0 OR temp.split_status != 4) and (temp.order_level != 1 OR temp.split_status != 3)
  689. </select>
  690. <update id="deleteOrders">
  691. UPDATE tz_order SET `delete_status`=2,update_time=NOW()
  692. WHERE order_id IN
  693. <foreach collection="orders" item="order" open="(" close=")" separator=",">
  694. #{order.orderId}
  695. </foreach>
  696. </update>
  697. <select id="getOrderCount" resultType="com.yami.shop.bean.app.dto.OrderCountData">
  698. SELECT COUNT(o.order_id) all_count,
  699. COUNT(CASE WHEN o.hb_order_status = 0 THEN o.order_id ELSE NULL END) AS unPay,
  700. COUNT(CASE WHEN o.hb_order_status = 1 THEN o.order_id ELSE NULL END) AS payed,
  701. COUNT(CASE
  702. WHEN o.hb_order_status in (1, 20, 30, 40, 50, 70) THEN o.order_id
  703. ELSE NULL END) AS consignment,
  704. COUNT(CASE WHEN o.hb_order_status = 40 THEN o.order_id ELSE NULL END) AS confirm,
  705. COUNT(CASE WHEN o.hb_order_status = 80 THEN o.order_id ELSE NULL END) AS success,
  706. COUNT(CASE WHEN o.hb_order_status = 60 THEN o.order_id ELSE NULL END) AS `close`
  707. FROM tz_order o
  708. WHERE o.user_id = #{userId}
  709. AND o.delete_status = 0
  710. and (o.order_level != 0 OR o.split_status != 4)
  711. and (o.order_level != 1 OR o.split_status != 3)
  712. </select>
  713. <update id="cancelSeckillOrderByTime">
  714. UPDATE tz_order o JOIN (
  715. SELECT so.order_number FROM tz_seckill_order so JOIN
  716. tz_seckill s ON s.seckill_id = so.seckill_id
  717. AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(so.`create_time`))/60 &gt; s.`max_cancel_time` and so.state = 0 ) t
  718. ON o.order_number = t.order_number
  719. SET o.`hb_order_status`=60, o.cancel_time = NOW(), o.update_time=NOW()
  720. </update>
  721. <update id="updateToWaitGroup">
  722. UPDATE tz_order
  723. SET hb_order_status = 7,
  724. update_time=NOW()
  725. WHERE order_number = #{orderNumber}
  726. </update>
  727. <update id="updateToWaitDelivery">
  728. UPDATE tz_order
  729. SET `hb_order_status` = 20,
  730. `update_time` = NOW()
  731. WHERE `order_number` IN
  732. (SELECT order_number
  733. FROM (SELECT o.`order_number`
  734. FROM tz_order o
  735. LEFT JOIN tz_group_order go
  736. ON go.`order_number` = o.`order_number`
  737. LEFT JOIN tz_group_team gt ON gt.`group_team_id` = go.`group_team_id`
  738. WHERE gt.`group_team_id` = #{groupTeamId}) temp)
  739. </update>
  740. <select id="getOrderByOrderNumberAndUserId" resultType="com.yami.shop.bean.model.Order">
  741. select o.*
  742. from tz_order o
  743. where o.order_number = #{orderNumber}
  744. and o.user_id = #{userId}
  745. </select>
  746. <select id="getOrderAndOrderItemByOrderNumber" resultMap="orderAndOrderItemMap">
  747. select o.*, oi.*, oi.prod_name oi_prod_name, oi.actual_total as oi_actual_total
  748. from tz_order o
  749. left join tz_order_item oi on o.order_number = oi.order_number
  750. where o.order_number = #{orderNumber}
  751. </select>
  752. <select id="hasBuySuccessProd" resultType="java.lang.Integer">
  753. select count(*)
  754. from tz_order_item oi
  755. join tz_order o on o.order_number = oi.order_number
  756. where o.user_id = #{userId}
  757. and o.hb_order_status = 50
  758. and oi.prod_id = #{prodId}
  759. </select>
  760. <select id="listMyOrderByParams" resultMap="MyOrderMap">
  761. SELECT
  762. o.order_type,o.actual_total,
  763. oi.pic,oi.price,oi.prod_id,oi.prod_name,oi.sku_name,ifnull(oi.use_score,0) as
  764. use_score,oi.prod_count,oi.order_item_id,o.hb_order_status,o.order_number,oi.comm_sts,
  765. sd.shop_id,sd.shop_name
  766. FROM (
  767. SELECT temp.order_type, temp.create_time,
  768. temp.order_number,temp.actual_total,temp.hb_order_status,temp.shop_id,prod_name
  769. FROM tz_order temp
  770. WHERE temp.user_id = #{userId} and temp.delete_status = 0
  771. <if test="status != null and status != 0">
  772. AND temp.hb_order_status = #{status}
  773. </if>
  774. <if test="orderNumber != null and orderNumber != ''">
  775. AND temp.order_number LIKE CONCAT("%",#{orderNumber},"%")
  776. </if>
  777. <if test="orderType == 0">
  778. AND (temp.order_type = 0 or temp.order_type is null)
  779. </if>
  780. <if test="orderType != null and orderType !='' and orderType != 0">
  781. AND temp.order_type = #{orderType}
  782. </if>
  783. <if test="orderTimeStatus == 1 or orderTimeStatus == 2">
  784. AND temp.create_time &gt;= #{preTime}
  785. </if>
  786. <if test="orderTimeStatus == 3">
  787. AND temp.create_time &lt;= #{preTime}
  788. </if>
  789. <if test="orderName != null and orderName != ''">
  790. AND temp.prod_name LIKE concat('%',#{orderName},'%')
  791. </if>
  792. ORDER BY temp.create_time DESC
  793. LIMIT #{adapter.begin} , #{adapter.size}
  794. )AS o
  795. JOIN tz_order_item oi ON o.order_number = oi.order_number
  796. LEFT JOIN tz_shop_detail sd on o.shop_id = sd.shop_id
  797. ORDER BY o.create_time DESC
  798. </select>
  799. <select id="countMyOrderByParams" resultType="Long">
  800. SELECT COUNT(*) FROM(
  801. SELECT
  802. count(1)
  803. FROM tz_order o
  804. JOIN tz_order_item oi ON o.order_number = oi.order_number
  805. join tz_shop_detail sd on o.shop_id = sd.shop_id
  806. WHERE o.user_id = #{userId} and o.delete_status = 0
  807. <if test="status != null and status != 0">
  808. AND o.hb_order_status = #{status}
  809. </if>
  810. <if test="orderNumber != null and orderNumber != ''">
  811. AND o.order_number LIKE CONCAT("%",#{orderNumber},"%")
  812. </if>
  813. <if test="orderType == 0">
  814. AND (o.order_type = 0 or o.order_type is null)
  815. </if>
  816. <if test="orderType != null and orderType !='' and orderType != 0">
  817. AND o.order_type = #{orderType}
  818. </if>
  819. <if test="orderTimeStatus == 1 or orderTimeStatus == 2">
  820. AND o.create_time &gt;= #{preTime}
  821. </if>
  822. <if test="orderTimeStatus == 3">
  823. AND o.create_time &lt;= #{preTime}
  824. </if>
  825. <if test="orderName != null and orderName != ''">
  826. AND (o.prod_name LIKE concat('%',#{orderName},'%') OR oi.prod_name LIKE concat('%',#{orderName},'%'))
  827. </if>
  828. GROUP BY o.order_number
  829. ) AS temp
  830. </select>
  831. <select id="listOrdersDetialByOrderInfo" resultMap="orderAndOrderItemAndUserAddrMap">
  832. SELECT *,oi.prod_name,uao.address,uao.address_name,uao.addr_detail as item_prod_name,oi.actual_total as
  833. oi_actual_total,temp.prod_name as order_prod_name,temp.hb_order_status as oi_status
  834. FROM
  835. (
  836. SELECT o.*,sd.shop_name FROM tz_order o
  837. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  838. <where>
  839. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  840. and o.order_number = #{orderParam.orderNumber}
  841. </if>
  842. <if test="orderParam.status != null">
  843. and o.hb_order_status = #{orderParam.status}
  844. </if>
  845. <if test="orderParam.shopId != null">
  846. and o.shop_id = #{orderParam.shopId}
  847. </if>
  848. <if test="orderParam.isPayed != null">
  849. and o.is_payed = #{orderParam.isPayed}
  850. and o.hb_order_status != 60
  851. </if>
  852. <if test="orderParam.startTime != null">
  853. and o.create_time &gt; #{orderParam.startTime}
  854. </if>
  855. <if test="orderParam.endTime != null">
  856. and o.create_time &lt; #{orderParam.endTime}
  857. </if>
  858. <if test="orderParam.orderType != null">
  859. and o.order_type = #{orderParam.orderType}
  860. </if>
  861. <if test="orderParam.orderType == null">
  862. and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
  863. </if>
  864. <if test="orderParam.shopName != null">
  865. and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
  866. </if>
  867. <if test="orderParam.refundStatus == 0">
  868. and o.refund_status IS NULL
  869. </if>
  870. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  871. and o.refund_status = #{orderParam.refundStatus}
  872. </if>
  873. <if test="orderParam.prodName != null">
  874. and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
  875. </if>
  876. </where>
  877. ORDER BY o.create_time DESC
  878. ) AS temp
  879. LEFT JOIN tz_order_item oi
  880. ON temp.order_number = oi.order_number
  881. LEFT JOIN tz_user_addr_order uao
  882. ON temp.addr_order_id = uao.addr_order_id
  883. <where>
  884. <if test="orderParam.receiver != null">
  885. and uao.receiver LIKE concat("%",#{orderParam.receiver},"%")
  886. </if>
  887. <if test="orderParam.mobile != null">
  888. and uao.mobile LIKE concat("%",#{orderParam.mobile},"%")
  889. </if>
  890. </where>
  891. ORDER BY temp.create_time DESC
  892. </select>
  893. <select id="getOrderPayInfoByOrderNumber" resultMap="orderAndOrderItemMap">
  894. SELECT o.*,oi.prod_name as oi_prod_name,oi.actual_total as oi_actual_total,oi.use_score
  895. FROM tz_order o
  896. LEFT JOIN tz_order_item oi ON oi.order_number = o.order_number
  897. WHERE o.order_number IN
  898. <foreach collection="orderNumberList" item="orderNumber" separator="," open="(" close=")">
  899. #{orderNumber}
  900. </foreach>
  901. </select>
  902. <select id="getOrderDetailByOrderNumberAndShopId" resultMap="orderAndOrderItemAndUserAddrMap">
  903. SELECT o.*,oi.prod_name as item_prod_name,oi.*,uao.*,u.`nick_name`,u.user_mobile,o.hb_order_status as oi_status,
  904. IF(o.refund_type = 1,
  905. o.rms,r.return_money_sts) AS oi_return_money_sts
  906. FROM (
  907. SELECT temp.*,tr.refund_type,tr.return_money_sts rms
  908. FROM tz_order temp
  909. LEFT JOIN tz_order_refund tr ON tr.order_id = temp.order_id AND tr.return_money_sts &gt; 0 AND
  910. tr.return_money_sts &lt; 6
  911. WHERE temp.order_number =#{orderNumber}
  912. <if test="shopId != null">
  913. and temp.shop_id =#{shopId}
  914. </if>
  915. ) as o
  916. LEFT JOIN tz_order_item oi ON oi.order_number = o.order_number
  917. LEFT JOIN tz_order_refund r ON r.order_item_id = oi.order_item_id AND r.return_money_sts &gt; 0 AND
  918. r.return_money_sts &lt; 6
  919. LEFT JOIN tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
  920. LEFT JOIN tz_user u ON u.user_id = o.user_id
  921. </select>
  922. <select id="OrderCommentByUserIdAndStatus" resultMap="MyOrderMap">
  923. SELECT o.order_type,
  924. o.actual_total,
  925. o.hb_order_status,
  926. o.order_number,
  927. o.freight_amount,
  928. o.create_time,
  929. pc.rec_time,
  930. oi.pic,
  931. oi.price,
  932. oi.prod_name,
  933. oi.pic,
  934. oi.sku_name,
  935. oi.use_score,
  936. oi.prod_id,
  937. oi.rec_time,
  938. oi.prod_count,
  939. oi.order_item_id,
  940. oi.comm_sts,
  941. sd.shop_id,
  942. sd.shop_name,
  943. oi.actual_total as oi_actual_total
  944. FROM (SELECT DISTINCT temp.order_type,
  945. temp.create_time,
  946. temp.freight_amount,
  947. temp.order_number,
  948. temp.actual_total,
  949. temp.hb_order_status,
  950. temp.shop_id
  951. FROM tz_order temp
  952. JOIN tz_order_item toi ON temp.order_number = toi.order_number AND toi.comm_sts = #{isComm}
  953. WHERE temp.user_id = #{userId}
  954. and temp.delete_status = 0
  955. AND temp.hb_order_status = 80
  956. ORDER BY temp.create_time DESC
  957. LIMIT #{adapter.begin}, #{adapter.size}) AS o
  958. JOIN tz_order_item oi ON o.order_number = oi.order_number AND oi.comm_sts = #{isComm}
  959. left JOIN tz_prod_comm pc ON pc.order_item_id = oi.order_item_id
  960. left join tz_shop_detail sd on o.shop_id = sd.shop_id
  961. ORDER BY o.create_time DESC
  962. </select>
  963. <select id="orderItemCommentByUserIdAndStatus" resultMap="MyOrderItemMap">
  964. SELECT
  965. pc.rec_time,oi.pic,oi.price,oi.prod_name,oi.order_number,oi.pic,oi.sku_name,oi.use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
  966. oi.actual_total as oi_actual_total
  967. FROM tz_order o
  968. left JOIN tz_order_item oi ON o.order_number = oi.order_number
  969. left JOIN tz_prod_comm pc ON pc.order_item_id = oi.order_item_id
  970. where oi.comm_sts = #{isComm} and o.user_id = #{userId}
  971. <if test="isComm == 1">
  972. AND o.hb_order_status = 80
  973. </if>
  974. ORDER BY pc.rec_time DESC
  975. LIMIT #{adapter.begin} , #{adapter.size}
  976. </select>
  977. <select id="countOrderItemComment" resultType="long">
  978. SELECT count(*)
  979. FROM tz_order o
  980. left JOIN tz_order_item oi ON o.order_number = oi.order_number
  981. where oi.comm_sts = #{isComm} and o.user_id = #{userId}
  982. <if test="isComm == 1">
  983. AND o.hb_order_status = 80
  984. </if>
  985. </select>
  986. <select id="statusCount" resultType="integer">
  987. SELECT count(a.order_id) FROM `tz_order` a
  988. LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
  989. LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
  990. left join tz_user d on a.user_id = d.user_id
  991. <where>
  992. hb_order_status in
  993. <foreach collection="status" item="status" separator="," open="(" close=")">
  994. #{status}
  995. </foreach>
  996. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  997. and a.order_number = #{orderParam.orderNumber}
  998. </if>
  999. <if test="orderParam.parentOrderNumber != null and orderParam.parentOrderNumber != ''">
  1000. and a.parent_order_number = #{orderParam.parentOrderNumber}
  1001. </if>
  1002. <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
  1003. and a.channel_id in
  1004. <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
  1005. #{channelId}
  1006. </foreach>
  1007. </if>
  1008. <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
  1009. and a.dvy_type = #{orderParam.dvyType}
  1010. </if>
  1011. <if test="orderParam.userAttrType != null and orderParam.userAttrType != '' and orderParam.userAttrType != 0">
  1012. AND d.user_attr_type = #{orderParam.userAttrType}
  1013. </if>
  1014. <if test="orderParam.shopId != null">
  1015. and a.shop_id = #{orderParam.shopId}
  1016. </if>
  1017. <if test="orderParam.startTime != null">
  1018. and a.create_time &gt; #{orderParam.startTime}
  1019. </if>
  1020. <if test="orderParam.endTime != null">
  1021. and a.create_time &lt; #{orderParam.endTime}
  1022. </if>
  1023. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  1024. and a.refund_status = #{orderParam.refundStatus}
  1025. </if>
  1026. <if test="orderParam.receiver != null">
  1027. and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
  1028. </if>
  1029. <if test="orderParam.userMobile != null">
  1030. and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
  1031. </if>
  1032. <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
  1033. <if test="orderParam.orderStatus == 'all'">
  1034. AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
  1035. </if>
  1036. <if test="orderParam.orderStatus == 'paddingPay'">
  1037. AND a.hb_order_status in (0)
  1038. </if>
  1039. <if test="orderParam.orderStatus == 'paddingShipped'">
  1040. AND a.hb_order_status in (1)
  1041. </if>
  1042. <if test="orderParam.orderStatus == 'paddingReceived'">
  1043. AND a.hb_order_status in (20,30,40,70)
  1044. </if>
  1045. <if test="orderParam.orderStatus == 'completed'">
  1046. AND a.hb_order_status in (80)
  1047. </if>
  1048. <if test="orderParam.orderStatus == 'cancel'">
  1049. AND a.hb_order_status in (50,60)
  1050. </if>
  1051. </if>
  1052. <if test="orderParam.orderSplitStatus != null">
  1053. and a.order_split_Status = #{orderParam.orderSplitStatus}
  1054. </if>
  1055. <if test="orderParam.autoSplit != null">
  1056. and a.auto_split = #{orderParam.autoSplit}
  1057. </if>
  1058. <if test="orderParam.splitStatus != null">
  1059. <if test="orderParam.splitStatus == 2">
  1060. and a.split_status in (2,3)
  1061. </if>
  1062. <if test="orderParam.splitStatus != 2">
  1063. and a.split_status = #{orderParam.splitStatus}
  1064. </if>
  1065. </if>
  1066. <if test="orderParam.orderLevel != null">
  1067. and a.order_level = #{orderParam.orderLevel}
  1068. </if>
  1069. </where>
  1070. </select>
  1071. <select id="selectOrderCount" resultType="com.yami.shop.bean.param.OrderCountParam">
  1072. SELECT
  1073. count(1) as allCount,
  1074. count(case when hb_order_status = 0 then 1 end) as payedCount,
  1075. count(case when hb_order_status = 20 then 1 end) as readyCount,
  1076. count(case when hb_order_status = 30 then 1 end) as deliveryCount,
  1077. count(case when hb_order_status = 40 then 1 end) as shippingCount,
  1078. count(case when hb_order_status = 50 then 1 end) as cancelAuditCount,
  1079. count(case when hb_order_status = 60 then 1 end) as canceledCount,
  1080. count(case when hb_order_status = 70 then 1 end) as arrivedCount,
  1081. count(case when hb_order_status = 80 then 1 end) as completedCount
  1082. FROM tz_order
  1083. <where>
  1084. delete_status = 0
  1085. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  1086. and o.order_number = #{orderParam.orderNumber}
  1087. </if>
  1088. <if test="orderParam.hbOrderStatus != null">
  1089. and o.hb_order_status = #{orderParam.hbOrderStatus}
  1090. </if>
  1091. <if test="orderParam.dvyType != null">
  1092. and o.dvy_type = #{orderParam.dvyType}
  1093. </if>
  1094. <if test="orderParam.channelId != null">
  1095. and o.channel_id = #{orderParam.channelId}
  1096. </if>
  1097. <if test="orderParam.shopId != null">
  1098. and o.shop_id = #{orderParam.shopId}
  1099. </if>
  1100. <if test="orderParam.startTime != null">
  1101. and o.create_time &gt; #{orderParam.startTime}
  1102. </if>
  1103. <if test="orderParam.endTime != null">
  1104. and o.create_time &lt; #{orderParam.endTime}
  1105. </if>
  1106. <if test="orderParam.orderType != null">
  1107. and o.order_type = #{orderParam.orderType}
  1108. </if>
  1109. <if test="orderParam.refundStatus == 0">
  1110. and o.refund_status IS NULL
  1111. </if>
  1112. </where>
  1113. </select>
  1114. <select id="deliveryOrder" resultMap="BaseResultMap">
  1115. SELECT o.*, sd.shop_name,ch.channel_name
  1116. FROM tz_order o
  1117. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  1118. LEFT JOIN tz_channel ch ON o.channel_id = ch.id
  1119. join tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
  1120. <where>
  1121. o.delete_status = 0 AND o.dvy_type = #{orderParam.dvyType}
  1122. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  1123. AND o.order_number LIKE concat('%', #{orderParam.orderNumber}, '%')
  1124. </if>
  1125. <if test="orderParam.mobile != null and orderParam.mobile != ''">
  1126. AND uao.mobile LIKE concat('%', #{orderParam.mobile}, '%')
  1127. </if>
  1128. <if test="orderParam.receiver != null and orderParam.receiver != ''">
  1129. AND uao.receiver LIKE concat('%', #{orderParam.receiver}, '%')
  1130. </if>
  1131. <if test="orderParam.startTime != null">
  1132. AND o.create_time &gt;= #{orderParam.startTime}
  1133. </if>
  1134. <if test="orderParam.endTime != null">
  1135. AND o.create_time &lt;= #{orderParam.endTime}
  1136. </if>
  1137. <if test="orderParam.channelId != null">
  1138. AND o.channel_id = #{orderParam.channelId}
  1139. </if>
  1140. <if test="orderParam.shopId != null">
  1141. AND o.shopId = #{orderParam.shopId}
  1142. </if>
  1143. <if test="orderParam.hbOrderStatus != null">
  1144. <if test="orderParam.hbOrderStatus == 0">
  1145. AND o.hb_order_status = 0
  1146. </if>
  1147. <if test="orderParam.hbOrderStatus == 20">
  1148. AND o.hb_order_status = 20
  1149. </if>
  1150. <if test="orderParam.hbOrderStatus == 70">
  1151. AND o.hb_order_status in (30,40,70)
  1152. </if>
  1153. <if test="orderParam.hbOrderStatus == 80">
  1154. AND o.hb_order_status = 80
  1155. </if>
  1156. <if test="orderParam.hbOrderStatus == 60">
  1157. AND o.hb_order_status in (50, 60)
  1158. </if>
  1159. </if>
  1160. </where>
  1161. ORDER BY o.create_time DESC
  1162. </select>
  1163. <select id="findList" resultMap="BaseResultMap">
  1164. SELECT a.*,b.receiver,b.mobile user_mobile,c.shop_name,d.channel_name, CONCAT(b.address,b.address_name, b.addr_detail) as consigneeAddress FROM tz_order a
  1165. LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
  1166. LEFT JOIN tz_shop_detail c on a.shop_id=c.shop_id
  1167. LEFT JOIN tz_channel d on a.channel_id=d.id
  1168. left join tz_user e on a.user_id = e.user_id
  1169. <where>
  1170. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  1171. and a.order_number = #{orderParam.orderNumber}
  1172. </if>
  1173. <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
  1174. and a.channel_id in
  1175. <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
  1176. #{channelId}
  1177. </foreach>
  1178. </if>
  1179. <if test="orderParam.userAttrType != null and orderParam.userAttrType != '' and orderParam.userAttrType != 0">
  1180. AND e.user_attr_type = #{orderParam.userAttrType}
  1181. </if>
  1182. <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
  1183. and a.dvy_type = #{orderParam.dvyType}
  1184. </if>
  1185. <if test="orderParam.shopId != null">
  1186. and a.shop_id = #{orderParam.shopId}
  1187. </if>
  1188. <if test="orderParam.startTime != null">
  1189. and a.create_time &gt; #{orderParam.startTime}
  1190. </if>
  1191. <if test="orderParam.endTime != null">
  1192. and a.create_time &lt; #{orderParam.endTime}
  1193. </if>
  1194. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  1195. and a.refund_status = #{orderParam.refundStatus}
  1196. </if>
  1197. <if test="orderParam.receiver != null">
  1198. and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
  1199. </if>
  1200. <if test="orderParam.userMobile != null">
  1201. and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
  1202. </if>
  1203. <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
  1204. <if test="orderParam.orderStatus == 'all'">
  1205. AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
  1206. </if>
  1207. <if test="orderParam.orderStatus == 'paddingPay'">
  1208. AND a.hb_order_status in (0)
  1209. </if>
  1210. <if test="orderParam.orderStatus == 'paddingShipped'">
  1211. AND a.hb_order_status in (1)
  1212. </if>
  1213. <if test="orderParam.orderStatus == 'paddingReceived'">
  1214. AND a.hb_order_status in (20,30,40,70)
  1215. </if>
  1216. <if test="orderParam.orderStatus == 'completed'">
  1217. AND a.hb_order_status in (80)
  1218. </if>
  1219. <if test="orderParam.orderStatus == 'cancel'">
  1220. AND a.hb_order_status in (50,60)
  1221. </if>
  1222. </if>
  1223. </where>
  1224. order by a.create_time desc,a.order_id desc
  1225. </select>
  1226. <select id="orderCount" resultType="com.yami.shop.bean.vo.OrderCountVo">
  1227. select count(1) as orderTotal,
  1228. sum(orderMoney) as orderMoneyTotal,
  1229. sum(shopMoney) as shopMoneyTotal,
  1230. sum(carriageMoney) as carriageMoneyTotal,
  1231. sum(orderMoney) as payMoneyTotal,
  1232. ROUND(sum(pointsMoney) / 100,2) as pointsMoneyTotal,
  1233. sum(money) as moneyTotal
  1234. from (
  1235. select
  1236. a.order_number,
  1237. a.total as orderMoney,
  1238. sum(c.product_total_amount) as shopMoney,
  1239. IFNUll(a.freight_amount,0) as carriageMoney,
  1240. IFNUll(a.offset_points,0) as pointsMoney,
  1241. IFNUll(a.actual_total,0) as money
  1242. FROM tz_order a
  1243. LEFT JOIN tz_user_addr_order b on a.addr_order_id=b.addr_order_id
  1244. LEFT JOIN tz_order_item c on a.order_number =c.order_number
  1245. left join tz_user e on a.user_id = e.user_id
  1246. <where>
  1247. and a.delete_status =0
  1248. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  1249. and a.order_number = #{orderParam.orderNumber}
  1250. </if>
  1251. <if test="orderParam.parentOrderNumber != null and orderParam.parentOrderNumber != ''">
  1252. and a.parent_order_number = #{orderParam.parentOrderNumber}
  1253. </if>
  1254. <if test="orderParam.channelIdList != null and !orderParam.channelIdList.isEmpty()">
  1255. and a.channel_id in
  1256. <foreach collection="orderParam.channelIdList" item="channelId" open="(" close=")" separator=",">
  1257. #{channelId}
  1258. </foreach>
  1259. </if>
  1260. <if test="orderParam.userAttrType != null and orderParam.userAttrType != '' and orderParam.userAttrType != 0">
  1261. AND e.user_attr_type = #{orderParam.userAttrType}
  1262. </if>
  1263. <if test="orderParam.dvyType != null and orderParam.dvyType != ''">
  1264. and a.dvy_type = #{orderParam.dvyType}
  1265. </if>
  1266. <if test="orderParam.shopId != null">
  1267. and a.shop_id = #{orderParam.shopId}
  1268. </if>
  1269. <if test="orderParam.startTime != null">
  1270. and a.create_time &gt; #{orderParam.startTime}
  1271. </if>
  1272. <if test="orderParam.endTime != null">
  1273. and a.create_time &lt; #{orderParam.endTime}
  1274. </if>
  1275. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  1276. and a.refund_status = #{orderParam.refundStatus}
  1277. </if>
  1278. <if test="orderParam.receiver != null">
  1279. and b.receiver LIKE concat("%",#{orderParam.receiver},"%")
  1280. </if>
  1281. <if test="orderParam.userMobile != null">
  1282. and b.mobile LIKE concat("%",#{orderParam.userMobile},"%")
  1283. </if>
  1284. <if test="orderParam.orderStatus != null and orderParam.orderStatus != ''">
  1285. <if test="orderParam.orderStatus == 'all'">
  1286. AND a.hb_order_status in (0, 1,20,30,40,50,60,70,80)
  1287. </if>
  1288. <if test="orderParam.orderStatus == 'paddingPay'">
  1289. AND a.hb_order_status in (0)
  1290. </if>
  1291. <if test="orderParam.orderStatus == 'paddingShipped'">
  1292. AND a.hb_order_status in (1)
  1293. </if>
  1294. <if test="orderParam.orderStatus == 'paddingReceived'">
  1295. AND a.hb_order_status in (20,30,40,70)
  1296. </if>
  1297. <if test="orderParam.orderStatus == 'completed'">
  1298. AND a.hb_order_status in (80)
  1299. </if>
  1300. <if test="orderParam.orderStatus == 'cancel'">
  1301. AND a.hb_order_status in (50,60)
  1302. </if>
  1303. </if>
  1304. </where>
  1305. group by a.order_number
  1306. ) m
  1307. </select>
  1308. <select id="getRiderInfo" resultType="java.lang.String">
  1309. SELECT CONCAT('骑手:',courier_name,',电话:', SUBSTRING_INDEX(courier_phone, ',', 1)) info
  1310. FROM `tz_order_rider_location` WHERE order_number=#{orderNumber}
  1311. </select>
  1312. </mapper>