OrderMapper.xml 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  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="prod_name" jdbcType="VARCHAR" property="prodName"/>
  8. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  9. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  10. <result column="total" jdbcType="DECIMAL" property="total"/>
  11. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  12. <result column="pay_type" jdbcType="INTEGER" property="payType"/>
  13. <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
  14. <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
  15. <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
  16. <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
  17. <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
  18. <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
  19. <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  20. <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
  21. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  22. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  23. <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
  24. <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
  25. <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
  26. <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
  27. <result column="is_payed" jdbcType="BIT" property="isPayed"/>
  28. <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
  29. <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
  30. <result column="close_type" jdbcType="INTEGER" property="closeType"/>
  31. </resultMap>
  32. <resultMap id="MyOrderMap" type="com.yami.shop.bean.app.dto.MyOrderDto">
  33. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  34. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  35. <result column="order_type" jdbcType="VARCHAR" property="orderType"/>
  36. <result column="refund_type" jdbcType="INTEGER" property="refundType"/>
  37. <result column="return_money_sts" jdbcType="INTEGER" property="returnMoneySts"/>
  38. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  39. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  40. <result column="latitude" property="latitude"/>
  41. <result column="longitude" property="longitude"/>
  42. <result column="create_time" property="createTime"/>
  43. <result column="hb_order_status" property="hbOrderStatus"/>
  44. <result column="hb_logistic_status" property="hbLogisticStatus"/>
  45. <result column="offset_points" property="offsetPoints"/>
  46. <result column="pay_time" property="payTime"/>
  47. <collection property="orderItemDtos" ofType="com.yami.shop.bean.app.dto.MyOrderItemDto">
  48. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  49. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  50. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  51. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  52. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  53. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  54. <result column="price" jdbcType="DECIMAL" property="price"/>
  55. <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
  56. <result column="order_item_id" property="orderItemId"/>
  57. <result column="comm_sts" property="commSts"/>
  58. <result column="rec_time" property="recTime"/>
  59. </collection>
  60. </resultMap>
  61. <resultMap id="MyOrderItemMap" type="com.yami.shop.bean.app.dto.MyOrderItemDto">
  62. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  63. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  64. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  65. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  66. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  67. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  68. <result column="price" jdbcType="DECIMAL" property="price"/>
  69. <result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
  70. <result column="order_item_id" property="orderItemId"/>
  71. <result column="comm_sts" property="commSts"/>
  72. <result column="rec_time" property="recTime"/>
  73. </resultMap>
  74. <resultMap type="com.yami.shop.bean.model.Order" id="orderAndOrderItemMap">
  75. <id column="order_id" jdbcType="BIGINT" property="orderId"/>
  76. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  77. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  78. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  79. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  80. <result column="total" jdbcType="DECIMAL" property="total"/>
  81. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  82. <result column="pay_type" jdbcType="INTEGER" property="payType"/>
  83. <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
  84. <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
  85. <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
  86. <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
  87. <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
  88. <result column="platform_amount" jdbcType="DECIMAL" property="platformAmount"/>
  89. <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  90. <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
  91. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  92. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  93. <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
  94. <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
  95. <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
  96. <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
  97. <result column="is_payed" jdbcType="BIT" property="isPayed"/>
  98. <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
  99. <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
  100. <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
  101. <result column="order_type" jdbcType="INTEGER" property="orderType"/>
  102. <result column="close_type" jdbcType="INTEGER" property="closeType"/>
  103. <collection property="orderItems" ofType="com.yami.shop.bean.model.OrderItem">
  104. <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
  105. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  106. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  107. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  108. <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
  109. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  110. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  111. <result column="oi_prod_name" jdbcType="VARCHAR" property="prodName"/>
  112. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  113. <result column="price" jdbcType="DECIMAL" property="price"/>
  114. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  115. <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
  116. <!--<result column="platform_amount" jdbcType="DECIMAL" property="platformAmount"/>-->
  117. <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
  118. <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
  119. <result column="distribution_card_no" property="distributionCardNo"/>
  120. <result column="basket_date" property="basketDate"/>
  121. <result column="share_reduce" property="shareReduce"/>
  122. <result column="distribution_amount" property="distributionAmount"/>
  123. <result column="distribution_parent_amount" property="distributionParentAmount"/>
  124. <result column="return_money_sts" property="returnMoneySts"/>
  125. <result column="oi_actual_total" property="actualTotal"/>
  126. </collection>
  127. </resultMap>
  128. <resultMap type="com.yami.shop.bean.model.Order" id="orderAndOrderItemAndUserAddrMap">
  129. <id column="order_id" jdbcType="BIGINT" property="orderId"/>
  130. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  131. <result column="order_prod_name" jdbcType="VARCHAR" property="prodName"/>
  132. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  133. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  134. <result column="total" jdbcType="DECIMAL" property="total"/>
  135. <result column="actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  136. <result column="pay_type" jdbcType="INTEGER" property="payType"/>
  137. <result column="remarks" jdbcType="VARCHAR" property="remarks"/>
  138. <result column="hb_order_status" jdbcType="INTEGER" property="hbOrderStatus"/>
  139. <result column="dvy_type" jdbcType="VARCHAR" property="dvyType"/>
  140. <result column="dvy_id" jdbcType="BIGINT" property="dvyId"/>
  141. <result column="nick_name" jdbcType="BIGINT" property="nickName"/>
  142. <result column="dvy_flow_id" jdbcType="VARCHAR" property="dvyFlowId"/>
  143. <result column="freight_amount" jdbcType="DECIMAL" property="freightAmount"/>
  144. <result column="order_type" jdbcType="INTEGER" property="orderType"/>
  145. <result column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  146. <result column="product_nums" jdbcType="INTEGER" property="productNums"/>
  147. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  148. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  149. <result column="pay_time" jdbcType="TIMESTAMP" property="payTime"/>
  150. <result column="dvy_time" jdbcType="TIMESTAMP" property="dvyTime"/>
  151. <result column="finally_time" jdbcType="TIMESTAMP" property="finallyTime"/>
  152. <result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime"/>
  153. <result column="is_payed" jdbcType="BIT" property="isPayed"/>
  154. <result column="delete_status" jdbcType="INTEGER" property="deleteStatus"/>
  155. <result column="pay_score" jdbcType="INTEGER" property="score"/>
  156. <result column="refund_status" jdbcType="INTEGER" property="refundStatus"/>
  157. <result column="close_type" jdbcType="INTEGER" property="closeType"/>
  158. <result column="shop_name" jdbcType="VARCHAR" property="shopName"/>
  159. <result column="pay_score" jdbcType="INTEGER" property="payScore"/>
  160. <result column="user_mobile" jdbcType="VARCHAR" property="userMobile"/>
  161. <result column="qnh_order_id" jdbcType="VARCHAR" property="qnhOrderId"/>
  162. <result column="qnh_order_status" jdbcType="VARCHAR" property="qnhOrderStatus"/>
  163. <result column="dvy_status" jdbcType="INTEGER" property="dvyStatus"/>
  164. <association property="userAddrOrder" javaType="com.yami.shop.bean.model.UserAddrOrder">
  165. <id column="addr_order_id" jdbcType="BIGINT" property="addrOrderId"/>
  166. <result column="province" jdbcType="VARCHAR" property="province"/>
  167. <result column="city" jdbcType="VARCHAR" property="city"/>
  168. <result column="area" jdbcType="VARCHAR" property="area"/>
  169. <result column="addr" jdbcType="VARCHAR" property="addr"/>
  170. <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
  171. <result column="receiver" jdbcType="VARCHAR" property="receiver"/>
  172. <result column="address" jdbcType="VARCHAR" property="address"/>
  173. <result column="address_name" jdbcType="VARCHAR" property="addressName"/>
  174. <result column="address_detail" jdbcType="VARCHAR" property="addrDetail"/>
  175. </association>
  176. <collection property="orderItems" ofType="com.yami.shop.bean.model.OrderItem">
  177. <id column="order_item_id" jdbcType="BIGINT" property="orderItemId"/>
  178. <result column="shop_id" jdbcType="BIGINT" property="shopId"/>
  179. <result column="order_number" jdbcType="VARCHAR" property="orderNumber"/>
  180. <result column="prod_id" jdbcType="BIGINT" property="prodId"/>
  181. <!-- <result column="prod_name" jdbcType="BIGINT" property="prodName"/>-->
  182. <result column="sku_id" jdbcType="BIGINT" property="skuId"/>
  183. <result column="prod_count" jdbcType="INTEGER" property="prodCount"/>
  184. <result column="use_score" jdbcType="INTEGER" property="useScore"/>
  185. <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
  186. <result column="pic" jdbcType="VARCHAR" property="pic"/>
  187. <result column="price" jdbcType="DECIMAL" property="price"/>
  188. <result column="user_id" jdbcType="VARCHAR" property="userId"/>
  189. <result column="oi_actual_total" jdbcType="DECIMAL" property="actualTotal"/>
  190. <result column="product_total_amount" jdbcType="DECIMAL" property="productTotalAmount"/>
  191. <result column="rec_time" jdbcType="TIMESTAMP" property="recTime"/>
  192. <result column="comm_sts" jdbcType="INTEGER" property="commSts"/>
  193. <result column="item_status" jdbcType="INTEGER" property="status"/>
  194. <result column="distribution_card_no" property="distributionCardNo"/>
  195. <result column="basket_date" property="basketDate"/>
  196. <result column="share_reduce" property="shareReduce"/>
  197. <result column="platform_share_reduce" property="platformShareReduce"/>
  198. <result column="oi_return_money_sts" property="returnMoneySts"/>
  199. <result column="oi_status" property="status"/>
  200. </collection>
  201. </resultMap>
  202. <select id="getOrderByOrderNumber" resultType="com.yami.shop.bean.model.Order">
  203. select * from tz_order o where o.order_number = #{orderNumber}
  204. </select>
  205. <select id="listUnRefundOrderAndOrderItems" resultMap="orderAndOrderItemMap">
  206. select o.*,oi.*,tor.return_money_sts,oi.prod_name oi_prod_name,oi.actual_total as oi_actual_total from tz_order o
  207. join tz_order_item oi on o.order_number = oi.order_number
  208. left join tz_order_refund tor on tor.order_id = o.order_id
  209. where o.hb_order_status = #{orderStatus} and (refund_status IS NULL OR o.refund_status &lt;&gt; 1)
  210. and o.update_time &lt; #{lessThanUpdateTime}
  211. </select>
  212. <update id="cancelOrders">
  213. update tz_order set `hb_order_status`=60,cancel_time = NOW(),update_time=NOW() where order_id in
  214. <foreach collection="orders" item="order" open="(" close=")" separator=",">
  215. #{order.orderId}
  216. </foreach>
  217. </update>
  218. <update id="receiptOrder">
  219. update tz_order set `hb_order_status`=80,finally_time = NOW(),update_time=NOW() where order_id in
  220. <foreach collection="orders" item="order" open="(" close=")" separator=",">
  221. #{order.orderId}
  222. </foreach>
  223. </update>
  224. <update id="updateByToPaySuccess">
  225. update tz_order set `hb_order_status` = 20,is_payed =1,update_time=NOW(),pay_time=NOW(),pay_type =#{payType} where
  226. order_number in
  227. <foreach collection="orderNumbers" item="orderNumber" separator="," open="(" close=")">
  228. #{orderNumber}
  229. </foreach>
  230. </update>
  231. <select id="listOrdersDetialByOrder" resultMap="orderAndOrderItemAndUserAddrMap">
  232. select o.*,oi.*,oi.prod_name as item_prod_name,o.prod_name as order_prod_name,uao.* ,oi.hb_order_status as oi_status
  233. from tz_order o
  234. left join tz_order_item oi on o.order_number = oi.order_number
  235. left join tz_user_addr_order uao on o.addr_order_id = uao.addr_order_id
  236. where o.order_id in (
  237. select * from (
  238. select o.order_id from tz_order o
  239. left join tz_shop_detail sd on o.shop_id = sd.shop_id
  240. where 1=1
  241. <if test="order.orderNumber != null and order.orderNumber != ''">
  242. and o.order_number like concat('%',#{order.orderNumber},'%')
  243. </if>
  244. <if test="order.hb_order_status != null">
  245. and o.hb_order_status = #{order.orderStatus}
  246. </if>
  247. <if test="order.shopId != null">
  248. and o.shop_id = #{order.shopId}
  249. </if>
  250. <if test="order.isPayed != null">
  251. and o.is_payed = #{order.isPayed}
  252. and o.hb_order_status != 60
  253. </if>
  254. <if test="startTime != null">
  255. and o.create_time &gt; #{startTime}
  256. </if>
  257. <if test="endTime != null">
  258. and o.create_time &lt; #{endTime}
  259. </if>
  260. <if test="order.shopName != null">
  261. and sd.shop_name like concat("%",#{order.shopName},"%")
  262. </if>
  263. ORDER BY o.create_time DESC
  264. )
  265. AS limittable) ORDER BY o.create_time DESC
  266. </select>
  267. <select id="getOrderCountByShopId" resultType="com.yami.shop.bean.param.OrderPayParam">
  268. SELECT SUM(actual_total) as payActualTotal,COUNT(DISTINCT user_id) as payUserCount,
  269. COUNT(*) as payOrderCount
  270. FROM tz_order o
  271. <where>
  272. <if test="shopId != null">
  273. and o.shop_id = #{shopId}
  274. </if>
  275. <if test="startTime != null">
  276. and o.pay_time &gt;= #{startTime}
  277. </if>
  278. <if test="endTime != null">
  279. and o.pay_time &lt;= #{endTime}
  280. </if>
  281. AND o.is_payed =1
  282. </where>
  283. </select>
  284. <select id="getPayOrderByTime" resultType="com.yami.shop.bean.param.OrderPayParam">
  285. SELECT dates, MAX(orderCount) AS payOrderCount,MAX(payActualTotal) as payActualTotal FROM(
  286. SELECT @cdate := DATE_ADD(@cdate,INTERVAL - 1 DAY) dates ,0 AS 'orderCount',0 AS 'payActualTotal'
  287. FROM (SELECT @cdate :=DATE_ADD(CURDATE(),INTERVAL + 1 DAY) FROM tz_user) t1
  288. <where>
  289. <if test="startTime != null">
  290. and @cdate >= #{startTime}
  291. </if>
  292. </where>
  293. UNION ALL
  294. SELECT DATE_FORMAT(o.pay_time, '%Y-%m-%d') AS dates,COUNT(*) AS orderCount,SUM(actual_total) AS payActualTotal
  295. FROM tz_order o
  296. <where>
  297. <if test="shopId != null">
  298. and o.shop_id = #{shopId}
  299. </if>
  300. <if test="startTime != null">
  301. and o.pay_time &gt;= #{startTime}
  302. </if>
  303. <if test="endTime != null">
  304. and o.pay_time &lt;= #{endTime}
  305. </if>
  306. AND o.is_payed =1
  307. </where>
  308. GROUP BY dates) _tmpAllTable GROUP BY dates
  309. ORDER BY dates
  310. </select>
  311. <select id="getActualTotalByHour" resultType="com.yami.shop.bean.param.OrderPayParam">
  312. SELECT DATE_FORMAT(o.pay_time, '%k') AS dates,SUM(actual_total) as payActualTotal
  313. FROM tz_order o
  314. <where>
  315. <if test="shopId != null">
  316. and o.shop_id = #{shopId}
  317. </if>
  318. <if test="startTime != null">
  319. and o.pay_time &gt;= #{startTime}
  320. </if>
  321. <if test="endTime != null">
  322. and o.pay_time &lt;= #{endTime}
  323. </if>
  324. AND o.is_payed =1
  325. </where>
  326. GROUP BY dates
  327. </select>
  328. <select id="getActualTotalByDay" resultType="com.yami.shop.bean.param.OrderPayParam">
  329. SELECT DATE_FORMAT(o.pay_time, '%Y-%m-%d') AS payDay,SUM(actual_total) as payActualTotal
  330. FROM tz_order o
  331. <where>
  332. <if test="shopId != null">
  333. and o.shop_id = #{shopId}
  334. </if>
  335. <if test="startTime != null">
  336. and o.pay_time &gt;= #{startTime}
  337. </if>
  338. <if test="endTime != null">
  339. and o.pay_time &lt;= #{endTime}
  340. </if>
  341. AND o.is_payed =1
  342. </where>
  343. GROUP BY payDay
  344. </select>
  345. <select id="listOrdersDetialByOrderParam" resultMap="orderAndOrderItemAndUserAddrMap">
  346. SELECT *,oi.prod_name as item_prod_name,oi.actual_total as oi_actual_total,IF(r.refund_type = 2,r.return_money_sts,IF(ar.refund_type = 1,ar.return_money_sts,NULL)) AS oi_return_money_sts,
  347. temp.prod_name as order_prod_name,oi.hb_order_status as oi_status, IF(os.pay_score IS NULL,0,os.pay_score) as pay_score
  348. FROM
  349. (
  350. SELECT o.*,sd.shop_name,uao.receiver,uao.mobile,u.user_mobile,u.nick_name FROM tz_order o
  351. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  352. LEFT JOIN tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
  353. LEFT JOIN tz_user u on u.user_id=o.user_id
  354. <where>
  355. <!-- <if test="orderParam.type!=null and orderParam.type==1 and orderParam.content != null and orderParam.content != ''">-->
  356. <!-- and o.order_number = #{orderParam.content}-->
  357. <!-- </if>-->
  358. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  359. and o.order_number = #{orderParam.orderNumber}
  360. </if>
  361. <!-- <if test="orderParam.type!=null and orderParam.type==2 and orderParam.orderNumber != null and orderParam.orderNumber != ''">-->
  362. <!-- and o.order_number = #{orderParam.orderNumber}-->
  363. <!-- </if>-->
  364. <!-- <if test="orderParam.type!=null and orderParam.type==4 and orderParam.content != null and orderParam.content != ''">-->
  365. <!-- and u.nick_name LIKE concat("%",#{orderParam.content},"%")-->
  366. <!-- </if>-->
  367. <!-- <if test="orderParam.type!=null and orderParam.type==5 and orderParam.content != null and orderParam.content != ''">-->
  368. <!-- and u.user_mobile LIKE concat("%",#{orderParam.content},"%")-->
  369. <!-- </if>-->
  370. <!-- <if test="orderParam.type!=null and orderParam.type==6 and orderParam.content != null and orderParam.content != ''">-->
  371. <!-- and u.dvy_flow_id = #{orderParam.content}-->
  372. <!-- </if>-->
  373. <if test="orderParam.hb_order_status != null">
  374. and o.hb_order_status = #{orderParam.hbOrderStatus}
  375. </if>
  376. <!-- <if test="orderParam.payType != null">-->
  377. <!-- and o.pay_type = #{orderParam.payType}-->
  378. <!-- </if>-->
  379. <if test="orderParam.shopId != null">
  380. and o.shop_id = #{orderParam.shopId}
  381. </if>
  382. <if test="orderParam.isPayed != null">
  383. and o.is_payed = #{orderParam.isPayed}
  384. and o.hb_order_status != 60
  385. </if>
  386. <if test="orderParam.startTime != null">
  387. and o.create_time &gt; #{orderParam.startTime}
  388. </if>
  389. <if test="orderParam.endTime != null">
  390. and o.create_time &lt; #{orderParam.endTime}
  391. </if>
  392. <if test="orderParam.orderType != null">
  393. and o.order_type = #{orderParam.orderType}
  394. </if>
  395. <if test="orderParam.orderType == null">
  396. and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
  397. </if>
  398. <if test="orderParam.shopName != null">
  399. and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
  400. </if>
  401. <if test="orderParam.refundStatus == 0">
  402. and o.refund_status IS NULL
  403. </if>
  404. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  405. and o.refund_status = #{orderParam.refundStatus}
  406. </if>
  407. <if test="orderParam.prodName != null">
  408. and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
  409. </if>
  410. <!-- <if test="orderParam.type!=null and orderParam.type==2 and orderParam.content != null and orderParam.content != ''">-->
  411. <!-- and uao.receiver LIKE concat("%",#{orderParam.content},"%")-->
  412. <!-- </if>-->
  413. <!-- <if test="orderParam.type!=null and orderParam.type==3 and orderParam.content != null and orderParam.content != ''">-->
  414. <!-- and uao.mobile LIKE concat("%",#{orderParam.content},"%")-->
  415. <!-- </if>-->
  416. </where>
  417. ORDER BY o.create_time DESC
  418. LIMIT #{adapter.begin} , #{adapter.size}
  419. ) AS temp
  420. LEFT JOIN tz_order_item oi ON temp.order_number = oi.order_number
  421. <!--连接单个物品退款的退款信息-->
  422. 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 &gt; 0 AND r.return_money_sts &lt; 6
  423. <!--连接整单退款的退款信息-->
  424. LEFT JOIN tz_order_refund ar ON ar.order_id = temp.order_id AND ar.refund_type = 1 AND ar.return_money_sts &gt; 0 AND ar.return_money_sts &lt; 6
  425. LEFT JOIN tz_order_settlement os ON temp.order_number = os.order_number
  426. ORDER BY temp.create_time DESC
  427. </select>
  428. <select id="countOrderDetial" resultType="long">
  429. SELECT count(0)
  430. FROM tz_order o
  431. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  432. JOIN tz_user_addr_order uao
  433. ON o.addr_order_id = uao.addr_order_id
  434. <where>
  435. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  436. and o.order_number = #{orderParam.orderNumber}
  437. </if>
  438. <if test="orderParam.orderStatus != null">
  439. and o.hb_order_status = #{orderParam.orderStatus}
  440. </if>
  441. <if test="orderParam.shopId != null">
  442. and o.shop_id = #{orderParam.shopId}
  443. </if>
  444. <if test="orderParam.isPayed != null">
  445. and o.is_payed = #{orderParam.isPayed}
  446. and o.hb_order_status != 60
  447. </if>
  448. <if test="orderParam.startTime != null">
  449. and o.create_time &gt; #{orderParam.startTime}
  450. </if>
  451. <if test="orderParam.endTime != null">
  452. and o.create_time &lt; #{orderParam.endTime}
  453. </if>
  454. <if test="orderParam.orderType != null">
  455. and o.order_type = #{orderParam.orderType}
  456. </if>
  457. <if test="orderParam.orderType == null">
  458. and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
  459. </if>
  460. <if test="orderParam.shopName != null">
  461. and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
  462. </if>
  463. <if test="orderParam.refundStatus == 0">
  464. and o.refund_status IS NULL
  465. </if>
  466. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  467. and o.refund_status = #{orderParam.refundStatus}
  468. </if>
  469. <if test="orderParam.prodName != null">
  470. and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
  471. </if>
  472. <if test="orderParam.receiver != null">
  473. and uao.receiver LIKE concat("%",#{orderParam.receiver},"%")
  474. </if>
  475. <if test="orderParam.mobile != null">
  476. and uao.mobile LIKE concat("%",#{orderParam.mobile},"%")
  477. </if>
  478. </where>
  479. </select>
  480. <select id="calculateUserInShopData" resultType="com.yami.shop.bean.distribution.UserShoppingDataDto">
  481. select
  482. count(o.order_number) as expense_number,
  483. ifnull(SUM(o.actual_total),0) as expense_amount
  484. from tz_order o
  485. where o.user_id=#{userId} and o.shop_id = #{shopId} and (o.hb_order_status = 45 or o.hb_order_status = 80)
  486. </select>
  487. <select id="listMyOrderByUserIdAndStatus" resultMap="MyOrderMap">
  488. SELECT
  489. o.order_type,o.actual_total,o.order_number,o.freight_amount,o.create_time,o.order_id,
  490. o.hb_order_status,
  491. o.hb_logistic_status,
  492. o.offset_points,
  493. o.pay_time,
  494. (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) AS refund_type,
  495. (SELECT r.return_money_sts FROM tz_order_refund r WHERE r.order_id =o.order_id ORDER BY r.update_time DESC LIMIT 0,1) AS return_money_sts,
  496. oi.pic,oi.price,oi.prod_name,oi.pic,oi.sku_name,ifnull(oi.use_score,0) as use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
  497. sd.shop_id,sd.shop_name,oi.actual_total as oi_actual_total,ad.longitude,ad.latitude
  498. FROM (
  499. SELECT temp.order_type,
  500. temp.hb_order_status,
  501. temp.hb_logistic_status,
  502. temp.offset_points,
  503. temp.pay_time,
  504. temp.order_id, temp.create_time, temp.freight_amount,temp.order_number,temp.actual_total,temp.shop_id,temp.addr_order_id FROM tz_order temp
  505. WHERE temp.user_id = #{userId} and temp.delete_status = 0
  506. <if test="status != null and status != 0">
  507. AND temp.hb_order_status = #{status}
  508. </if>
  509. ORDER BY temp.create_time DESC
  510. LIMIT #{adapter.begin} , #{adapter.size}
  511. )AS o
  512. JOIN tz_order_item oi ON o.order_number = oi.order_number
  513. left join tz_shop_detail sd on o.shop_id = sd.shop_id
  514. left join tz_order_refund tor on o.order_id = tor.order_id
  515. left join tz_user_addr_order ad on o.addr_order_id = ad.addr_order_id
  516. ORDER BY o.create_time DESC
  517. </select>
  518. <select id="countMyOrderByUserIdAndStatus" resultType="Long">
  519. SELECT count(*)
  520. FROM (
  521. SELECT count(*) FROM tz_order temp
  522. JOIN tz_order_item oi ON temp.order_number = oi.order_number
  523. WHERE temp.user_id = #{userId} and temp.delete_status = 0
  524. <if test="status != null and status != 0">
  525. AND temp.hb_order_status = #{status}
  526. </if>
  527. <if test="isComm != null">
  528. AND temp.hb_order_status = 80
  529. </if>
  530. <if test="isComm != null">
  531. AND oi.comm_sts = #{isComm}
  532. </if>
  533. group by temp.order_id
  534. )AS o
  535. </select>
  536. <update id="deleteOrders">
  537. UPDATE tz_order SET `delete_status`=2,update_time=NOW()
  538. WHERE order_id IN
  539. <foreach collection="orders" item="order" open="(" close=")" separator=",">
  540. #{order.orderId}
  541. </foreach>
  542. </update>
  543. <select id="getOrderCount" resultType="com.yami.shop.bean.app.dto.OrderCountData">
  544. SELECT
  545. COUNT(o.order_id) all_count,
  546. COUNT( CASE WHEN o.hb_order_status = 0 THEN o.order_id ELSE NULL END ) AS unPay,
  547. COUNT( CASE WHEN o.hb_order_status = 20 THEN o.order_id ELSE NULL END ) AS payed,
  548. COUNT( CASE WHEN o.hb_order_status = 30 THEN o.order_id ELSE NULL END ) AS consignment,
  549. COUNT( CASE WHEN o.hb_order_status = 40 THEN o.order_id ELSE NULL END ) AS confirm,
  550. COUNT( CASE WHEN o.hb_order_status = 50 THEN o.order_id ELSE NULL END ) AS success,
  551. COUNT( CASE WHEN o.hb_order_status = 60 THEN o.order_id ELSE NULL END ) AS `close`
  552. FROM tz_order o
  553. WHERE o.user_id =#{userId} AND o.delete_status = 0
  554. </select>
  555. <update id="cancelSeckillOrderByTime">
  556. UPDATE tz_order o JOIN (
  557. SELECT so.order_number FROM tz_seckill_order so JOIN
  558. tz_seckill s ON s.seckill_id = so.seckill_id
  559. AND (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(so.`create_time`))/60 &gt; s.`max_cancel_time` and so.state = 0 ) t
  560. ON o.order_number = t.order_number
  561. SET o.`hb_order_status`=60,o.cancel_time = NOW(),o.update_time=NOW()
  562. </update>
  563. <update id="updateToWaitGroup">
  564. UPDATE tz_order SET hb_order_status = 7,update_time=NOW() WHERE order_number = #{orderNumber}
  565. </update>
  566. <update id="updateToWaitDelivery">
  567. UPDATE tz_order SET `hb_order_status` = 20, `update_time` = NOW()
  568. WHERE `order_number` IN
  569. (
  570. SELECT order_number FROM
  571. (SELECT o.`order_number` FROM tz_order o
  572. LEFT JOIN tz_group_order go ON go.`order_number` = o.`order_number`
  573. LEFT JOIN tz_group_team gt ON gt.`group_team_id` = go.`group_team_id`
  574. WHERE gt.`group_team_id` = #{groupTeamId}) temp
  575. )
  576. </update>
  577. <select id="getOrderByOrderNumberAndUserId" resultType="com.yami.shop.bean.model.Order">
  578. select o.* from tz_order o where o.order_number = #{orderNumber} and o.user_id = #{userId}
  579. </select>
  580. <select id="getOrderAndOrderItemByOrderNumber" resultMap="orderAndOrderItemMap">
  581. select o.*,oi.*,oi.prod_name oi_prod_name,oi.actual_total as oi_actual_total from tz_order o
  582. left join tz_order_item oi on o.order_number = oi.order_number
  583. where o.order_number = #{orderNumber}
  584. </select>
  585. <select id="hasBuySuccessProd" resultType="java.lang.Integer">
  586. select count(*) from tz_order_item oi
  587. join tz_order o on o.order_number = oi.order_number
  588. where o.user_id=#{userId} and o.hb_order_status = 50 and oi.prod_id = #{prodId}
  589. </select>
  590. <select id="listMyOrderByParams" resultMap="MyOrderMap">
  591. SELECT
  592. o.order_type,o.actual_total,
  593. oi.pic,oi.price,oi.prod_id,oi.prod_name,oi.sku_name,ifnull(oi.use_score,0) as use_score,oi.prod_count,oi.order_item_id,o.hb_order_status,o.order_number,oi.comm_sts,
  594. sd.shop_id,sd.shop_name
  595. FROM (
  596. SELECT temp.order_type, temp.create_time, temp.order_number,temp.actual_total,temp.hb_order_status,temp.shop_id,prod_name
  597. FROM tz_order temp
  598. WHERE temp.user_id = #{userId} and temp.delete_status = 0
  599. <if test="status != null and status != 0">
  600. AND temp.hb_order_status = #{status}
  601. </if>
  602. <if test="orderNumber != null and orderNumber != ''">
  603. AND temp.order_number LIKE CONCAT("%",#{orderNumber},"%")
  604. </if>
  605. <if test="orderType == 0">
  606. AND (temp.order_type = 0 or temp.order_type is null)
  607. </if>
  608. <if test="orderType != null and orderType !='' and orderType != 0">
  609. AND temp.order_type = #{orderType}
  610. </if>
  611. <if test="orderTimeStatus == 1 or orderTimeStatus == 2">
  612. AND temp.create_time &gt;= #{preTime}
  613. </if>
  614. <if test="orderTimeStatus == 3">
  615. AND temp.create_time &lt;= #{preTime}
  616. </if>
  617. <if test="orderName != null and orderName != ''">
  618. AND temp.prod_name LIKE concat('%',#{orderName},'%')
  619. </if>
  620. ORDER BY temp.create_time DESC
  621. LIMIT #{adapter.begin} , #{adapter.size}
  622. )AS o
  623. JOIN tz_order_item oi ON o.order_number = oi.order_number
  624. LEFT JOIN tz_shop_detail sd on o.shop_id = sd.shop_id
  625. ORDER BY o.create_time DESC
  626. </select>
  627. <select id="countMyOrderByParams" resultType="Long">
  628. SELECT COUNT(*) FROM(
  629. SELECT
  630. count(1)
  631. FROM tz_order o
  632. JOIN tz_order_item oi ON o.order_number = oi.order_number
  633. join tz_shop_detail sd on o.shop_id = sd.shop_id
  634. WHERE o.user_id = #{userId} and o.delete_status = 0
  635. <if test="status != null and status != 0">
  636. AND o.hb_order_status = #{status}
  637. </if>
  638. <if test="orderNumber != null and orderNumber != ''">
  639. AND o.order_number LIKE CONCAT("%",#{orderNumber},"%")
  640. </if>
  641. <if test="orderType == 0">
  642. AND (o.order_type = 0 or o.order_type is null)
  643. </if>
  644. <if test="orderType != null and orderType !='' and orderType != 0">
  645. AND o.order_type = #{orderType}
  646. </if>
  647. <if test="orderTimeStatus == 1 or orderTimeStatus == 2">
  648. AND o.create_time &gt;= #{preTime}
  649. </if>
  650. <if test="orderTimeStatus == 3">
  651. AND o.create_time &lt;= #{preTime}
  652. </if>
  653. <if test="orderName != null and orderName != ''">
  654. AND (o.prod_name LIKE concat('%',#{orderName},'%') OR oi.prod_name LIKE concat('%',#{orderName},'%'))
  655. </if>
  656. GROUP BY o.order_number
  657. ) AS temp
  658. </select>
  659. <select id="listOrdersDetialByOrderInfo" resultMap="orderAndOrderItemAndUserAddrMap">
  660. SELECT *,oi.prod_name,uao.address,uao.address_name,uao.addr_detail as item_prod_name,oi.actual_total as oi_actual_total,temp.prod_name as order_prod_name,oi.hb_order_status as oi_status
  661. FROM
  662. (
  663. SELECT o.*,sd.shop_name FROM tz_order o
  664. LEFT JOIN tz_shop_detail sd ON o.shop_id = sd.shop_id
  665. <where>
  666. <if test="orderParam.orderNumber != null and orderParam.orderNumber != ''">
  667. and o.order_number = #{orderParam.orderNumber}
  668. </if>
  669. <if test="orderParam.status != null">
  670. and o.hb_order_status = #{orderParam.status}
  671. </if>
  672. <if test="orderParam.shopId != null">
  673. and o.shop_id = #{orderParam.shopId}
  674. </if>
  675. <if test="orderParam.isPayed != null">
  676. and o.is_payed = #{orderParam.isPayed}
  677. and o.hb_order_status != 60
  678. </if>
  679. <if test="orderParam.startTime != null">
  680. and o.create_time &gt; #{orderParam.startTime}
  681. </if>
  682. <if test="orderParam.endTime != null">
  683. and o.create_time &lt; #{orderParam.endTime}
  684. </if>
  685. <if test="orderParam.orderType != null">
  686. and o.order_type = #{orderParam.orderType}
  687. </if>
  688. <if test="orderParam.orderType == null">
  689. and (o.order_type <![CDATA[ <> ]]> 3 OR o.order_type IS NULL)
  690. </if>
  691. <if test="orderParam.shopName != null">
  692. and sd.shop_name LIKE concat("%",#{orderParam.shopName},"%")
  693. </if>
  694. <if test="orderParam.refundStatus == 0">
  695. and o.refund_status IS NULL
  696. </if>
  697. <if test="orderParam.refundStatus != null and orderParam.refundStatus != 0">
  698. and o.refund_status = #{orderParam.refundStatus}
  699. </if>
  700. <if test="orderParam.prodName != null">
  701. and o.prod_name LIKE concat("%",#{orderParam.prodName},"%")
  702. </if>
  703. </where>
  704. ORDER BY o.create_time DESC
  705. ) AS temp
  706. LEFT JOIN tz_order_item oi
  707. ON temp.order_number = oi.order_number
  708. LEFT JOIN tz_user_addr_order uao
  709. ON temp.addr_order_id = uao.addr_order_id
  710. <where>
  711. <if test="orderParam.receiver != null">
  712. and uao.receiver LIKE concat("%",#{orderParam.receiver},"%")
  713. </if>
  714. <if test="orderParam.mobile != null">
  715. and uao.mobile LIKE concat("%",#{orderParam.mobile},"%")
  716. </if>
  717. </where>
  718. ORDER BY temp.create_time DESC
  719. </select>
  720. <select id="getOrderPayInfoByOrderNumber" resultMap="orderAndOrderItemMap">
  721. SELECT o.*,oi.prod_name as oi_prod_name,oi.actual_total as oi_actual_total,oi.use_score
  722. FROM tz_order o
  723. LEFT JOIN tz_order_item oi ON oi.order_number = o.order_number
  724. WHERE o.order_number IN
  725. <foreach collection="orderNumberList" item="orderNumber" separator="," open="(" close=")">
  726. #{orderNumber}
  727. </foreach>
  728. </select>
  729. <select id="getOrderDetailByOrderNumberAndShopId" resultMap="orderAndOrderItemAndUserAddrMap">
  730. SELECT o.*,oi.prod_name as item_prod_name,oi.*,uao.*,u.`nick_name`,u.user_mobile,oi.hb_order_status as oi_status, IF(o.refund_type = 1,
  731. o.rms,r.return_money_sts) AS oi_return_money_sts
  732. FROM (
  733. SELECT temp.*,tr.refund_type,tr.return_money_sts rms
  734. FROM tz_order temp
  735. LEFT JOIN tz_order_refund tr ON tr.order_id = temp.order_id AND tr.return_money_sts &gt; 0 AND
  736. tr.return_money_sts &lt; 6
  737. WHERE temp.order_number =#{orderNumber}
  738. <if test="shopId != null">
  739. and temp.shop_id =#{shopId}
  740. </if>
  741. ) as o
  742. LEFT JOIN tz_order_item oi ON oi.order_number = o.order_number
  743. LEFT JOIN tz_order_refund r ON r.order_item_id = oi.order_item_id AND r.return_money_sts &gt; 0 AND r.return_money_sts &lt; 6
  744. LEFT JOIN tz_user_addr_order uao ON o.addr_order_id = uao.addr_order_id
  745. LEFT JOIN tz_user u ON u.user_id = o.user_id
  746. </select>
  747. <select id="OrderCommentByUserIdAndStatus" resultMap="MyOrderMap">
  748. SELECT
  749. o.order_type,o.actual_total,o.hb_order_status,o.order_number,o.freight_amount,o.create_time,
  750. pc.rec_time,
  751. oi.pic,oi.price,oi.prod_name,oi.pic,oi.sku_name,oi.use_score,oi.prod_id,oi.rec_time,oi.prod_count,oi.order_item_id,oi.comm_sts,
  752. sd.shop_id,sd.shop_name,oi.actual_total as oi_actual_total
  753. FROM (
  754. SELECT DISTINCT temp.order_type, temp.create_time, temp.freight_amount,temp.order_number,temp.actual_total,temp.hb_order_status,temp.shop_id FROM tz_order temp
  755. JOIN tz_order_item toi ON temp.order_number = toi.order_number AND toi.comm_sts = #{isComm}
  756. WHERE temp.user_id = #{userId} and temp.delete_status = 0 AND temp.hb_order_status = 80
  757. ORDER BY temp.create_time DESC
  758. LIMIT #{adapter.begin} , #{adapter.size}
  759. )AS o
  760. JOIN tz_order_item oi ON o.order_number = oi.order_number AND oi.comm_sts = #{isComm}
  761. left JOIN tz_prod_comm pc ON pc.order_item_id = oi.order_item_id
  762. left join tz_shop_detail sd on o.shop_id = sd.shop_id
  763. ORDER BY o.create_time DESC
  764. </select>
  765. <select id="orderItemCommentByUserIdAndStatus" resultMap="MyOrderItemMap">
  766. SELECT
  767. 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,
  768. oi.actual_total as oi_actual_total
  769. FROM tz_order o
  770. left JOIN tz_order_item oi ON o.order_number = oi.order_number
  771. left JOIN tz_prod_comm pc ON pc.order_item_id = oi.order_item_id
  772. where oi.comm_sts = #{isComm} and o.user_id = #{userId}
  773. <if test="isComm == 1">
  774. AND o.hb_order_status = 80
  775. </if>
  776. ORDER BY pc.rec_time DESC
  777. LIMIT #{adapter.begin} , #{adapter.size}
  778. </select>
  779. <select id="countOrderItemComment" resultType="long">
  780. SELECT count(*)
  781. FROM tz_order o
  782. left JOIN tz_order_item oi ON o.order_number = oi.order_number
  783. where oi.comm_sts = #{isComm} and o.user_id = #{userId}
  784. <if test="isComm == 1">
  785. AND o.hb_order_status = 80
  786. </if>
  787. </select>
  788. </mapper>