OrderMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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.sqx.modules.order.dao.AppOrderDao">
  4. <select id="selectOrderList" resultType="com.sqx.modules.order.entity.TbOrder">
  5. select tor.*, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.shop_lng as shopLng,
  6. gs.shop_lat as shopLat, gs.phone as shopPhone,
  7. gs.errand_money as errandMoney, gs.exempt_min_money as exemptMinMoney, gs.minimum_delivery as minimumDelivery,
  8. gs.distribution_distance as distributionDistance
  9. from tb_order tor left join goods_shop gs on tor.shop_id = gs.shop_id
  10. where tor.user_id = #{userId}
  11. <if test="orderType!=null">
  12. and tor.order_type = #{orderType}
  13. </if>
  14. <if test="shopId!=null">
  15. and tor.shop_id = #{shopId}
  16. </if>
  17. <if test="status!=null">
  18. <if test="status == 0">
  19. and tor.status = 0
  20. </if>
  21. <if test="status == 1">
  22. and tor.status = 1
  23. </if>
  24. <if test="status == 2">
  25. and tor.status = 2
  26. </if>
  27. <if test="status == 3">
  28. and tor.status in (7, 6, 3, 4, 5, 8)
  29. </if>
  30. </if>
  31. </select>
  32. <insert id="insertOrder" parameterType="com.sqx.modules.order.entity.TbOrder" useGeneratedKeys="true"
  33. keyProperty="orderId">
  34. insert into tb_order (coupon_id, user_id, user_name, phone, address, order_number, is_pay, pay_time,
  35. order_code, order_type, pack_money, errand_money, status, delete_flag, parent_user_id,
  36. shop_id, parent_id, create_time)
  37. values (#{couponId}, #{userId}, #{userName}, #{phone}, #{address}, #{orderNumber}, #{isPay}, #{payTime},
  38. #{orderCode}, #{orderType}, #{packMoney}, #{errandMoney}, #{status}, #{deleteFlag}, #{parentUserId},
  39. #{shopId}, #{parentId}, #{createTime})
  40. </insert>
  41. <select id="selectOrder" resultType="com.sqx.modules.order.entity.TbOrder">
  42. select tor.*, tu.avatar as avatar, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.phone as
  43. shopPhone,
  44. ti.rider_user_id as riderUserId, tcu.money as couponMoney,
  45. pd.trade_no as transactionId
  46. from tb_order tor
  47. left join tb_user tu on tor.user_id = tu.user_id
  48. left join goods_shop gs on tor.shop_id = gs.shop_id
  49. left join tb_indent ti on tor.order_id = ti.order_id
  50. left join tb_coupon_user tcu on tor.coupon_id = tcu.id
  51. left join pay_details pd on pd.order_id = tor.order_number
  52. where 1 = 1 and tor.is_pay = 1
  53. <if test="shopName!=null and shopName!=''">
  54. and gs.shop_name like concat('%',#{shopName},'%')
  55. </if>
  56. <if test="userName!=null and userName!=''">
  57. and tor.user_name like concat('%',#{userName},'%')
  58. </if>
  59. <if test="phone!=null and phone!=''">
  60. and tor.phone like concat('%',#{phone},'%')
  61. </if>
  62. <if test="orderNumber!=null and orderNumber!=''">
  63. and tor.order_number = #{orderNumber}
  64. </if>
  65. <if test="status!=null and status!=5">
  66. and tor.status = #{status}
  67. </if>
  68. <if test="status!=null and status==5">
  69. and tor.status in (5, 8)
  70. </if>
  71. <if test="status==null">
  72. and tor.status in (7, 6, 3, 4, 5, 8)
  73. </if>
  74. <if test="shopId!=null">
  75. and tor.shop_id = #{shopId}
  76. </if>
  77. <if test="orderType!=null">
  78. and tor.order_type = #{orderType}
  79. </if>
  80. <if test="transactionId != null and transactionId != ''">
  81. and pd.trade_no = #{transactionId}
  82. </if>
  83. order by tor.pay_time desc, tor.create_time desc
  84. </select>
  85. <select id="selectAllOrderAdmin" resultType="com.sqx.modules.order.entity.TbOrder">
  86. select tor.*, tu.avatar as avatar, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.phone as
  87. shopPhone,
  88. tiu.user_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
  89. ti.rider_user_id as riderUserId, tcu.money as couponMoney,
  90. apr.discount_amount as activityDiscountAmount, ai.title activityTitle,tiu.rider_station_id as riderStationId,
  91. (select rs.station_name from rider_station rs where rs.id =tiu.rider_station_id ) as stationName,
  92. (select st.shop_type_name from shop_type st where st.id =gs.shop_type_id ) as shopTypeName,
  93. pd.trade_no as transactionId
  94. from tb_order tor
  95. left join tb_user tu on tor.user_id = tu.user_id
  96. left join goods_shop gs on tor.shop_id = gs.shop_id
  97. left join tb_indent ti on tor.order_id = ti.order_id
  98. left join tb_user tiu on tiu.user_id = ti.rider_user_id
  99. left join tb_coupon_user tcu on tor.coupon_id = tcu.id
  100. left join activity_part_record apr on apr.order_id = tor.order_id
  101. left join activity ai on ai.id = apr.activity_id
  102. left join pay_details pd on pd.order_id = tor.order_number
  103. where 1 = 1
  104. <if test="query.riderPhone!=null and query.riderPhone!=''">
  105. and tiu.phone =#{query.riderPhone}
  106. </if>
  107. <if test="query.shopName!=null and query.shopName!=''">
  108. and gs.shop_name like concat('%',#{query.shopName},'%')
  109. </if>
  110. <if test="query.userName!=null and query.userName!=''">
  111. and tor.user_name like concat('%',#{query.userName},'%')
  112. </if>
  113. <if test="query.phone!=null and query.phone!=''">
  114. and tor.phone like concat('%',#{query.phone},'%')
  115. </if>
  116. <if test="query.orderNumber!=null and query.orderNumber!=''">
  117. and tor.order_number = #{query.orderNumber}
  118. </if>
  119. <if test="query.status!=null and query.status!=-1 and query.status!=1">
  120. and tor.status = #{query.status}
  121. </if>
  122. <if test="query.status!=null and query.status==1">
  123. and tor.status in (1,2)
  124. </if>
  125. <if test="query.shopId!=null">
  126. and tor.shop_id = #{query.shopId}
  127. </if>
  128. <if test="query.orderType!=null">
  129. and tor.order_type_extra = #{query.orderType}
  130. </if>
  131. <if test="query.indentStatus != null and query.indentStatus != ''">
  132. and ti.indent_state = #{query.indentStatus}
  133. </if>
  134. <if test="query.reservationFlag != null and query.reservationFlag !=''">
  135. and tor.reservation_flag = #{query.reservationFlag}
  136. </if>
  137. <if test="query.startTime!=null and query.startTime!=''">
  138. and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{query.startTime},'%Y-%m-%d')
  139. </if>
  140. <if test="query.endTime!=null and query.endTime!='' ">
  141. and date_format(tor.create_time,'%Y-%m-%d') &lt;= date_format(#{query.endTime},'%Y-%m-%d')
  142. </if>
  143. <if test="query.payStartTime != null and query.payStartTime != ''">
  144. and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{query.payStartTime},'%Y-%m-%d')
  145. </if>
  146. <if test="query.payEndTime != null and query.payEndTime != '' ">
  147. and date_format(tor.pay_time,'%Y-%m-%d') &lt;= date_format(#{query.payEndTime},'%Y-%m-%d')
  148. </if>
  149. <if test="query.riderStationId!=null and query.riderStationId!=''">
  150. and tiu.rider_station_id=#{query.riderStationId}
  151. </if>
  152. <if test="query.shopTypeId!=null and query.shopTypeId!=''">
  153. and gs.shop_type_id=#{query.shopTypeId}
  154. </if>
  155. <if test="query.transactionId != null and query.transactionId != ''">
  156. and pd.trade_no = #{query.transactionId}
  157. </if>
  158. order by tor.pay_time desc, tor.create_time desc
  159. </select>
  160. <select id="excelAllOrderAdmin" resultType="com.sqx.modules.order.entity.TbOrder">
  161. select tor.*, tu.avatar as avatar, gs.shop_name as shopName, gs.detailed_address as detailedAddress, gs.phone as
  162. shopPhone,
  163. tiu.nick_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
  164. ti.rider_user_id as riderUserId, tcu.money as couponMoney,
  165. apr.discount_amount as activityDiscountAmount, ai.title activityTitle,ogg.detail,ogg.sumPrice,
  166. (select rs.station_name from rider_station rs where rs.id =tiu.rider_station_id ) as stationName
  167. from tb_order tor
  168. left join tb_user tu on tor.user_id = tu.user_id
  169. left join goods_shop gs on tor.shop_id = gs.shop_id
  170. left join tb_indent ti on tor.order_id = ti.order_id
  171. left join tb_user tiu on tiu.user_id = ti.rider_user_id
  172. left join tb_coupon_user tcu on tor.coupon_id = tcu.id
  173. left join activity_part_record apr on apr.order_id = tor.order_id
  174. left join activity ai on ai.id = apr.activity_id
  175. left join ( select @a:=0,order_id ,group_concat(@a:=@a+1,".商品名:",goods_name,",数量:",goods_num,",规格:",sku_message) detail,sum(goods_num*goods_price) sumPrice from order_goods og group by order_id
  176. ) ogg on ogg.order_id =tor.order_id
  177. where 1 = 1
  178. <if test="riderPhone!=null and riderPhone!=''">
  179. and tiu.phone =#{riderPhone}
  180. </if>
  181. <if test="shopName!=null and shopName!=''">
  182. and gs.shop_name like concat('%',#{shopName},'%')
  183. </if>
  184. <if test="userName!=null and userName!=''">
  185. and tor.user_name like concat('%',#{userName},'%')
  186. </if>
  187. <if test="phone!=null and phone!=''">
  188. and tor.phone like concat('%',#{phone},'%')
  189. </if>
  190. <if test="orderNumber!=null and orderNumber!=''">
  191. and tor.order_number = #{orderNumber}
  192. </if>
  193. <if test="status!=null and status!=-1 and status!=1">
  194. and tor.status = #{status}
  195. </if>
  196. <if test="status!=null and status==1">
  197. and tor.status in (1,2)
  198. </if>
  199. <if test="shopId!=null">
  200. and tor.shop_id = #{shopId}
  201. </if>
  202. <if test="orderType!=null">
  203. and tor.order_type_extra = #{orderType}
  204. </if>
  205. <if test="startTime!=null and startTime!=''">
  206. and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
  207. </if>
  208. <if test="endTime!=null and endTime!='' ">
  209. and date_format(tor.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
  210. </if>
  211. <if test="payStartTime != null and payStartTime != ''">
  212. and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{payStartTime},'%Y-%m-%d')
  213. </if>
  214. <if test="payEndTime != null and payEndTime != '' ">
  215. and date_format(tor.pay_time,'%Y-%m-%d') &lt;= date_format(#{payEndTime},'%Y-%m-%d')
  216. </if>
  217. <if test="riderStationId!=null and riderStationId!=''">
  218. and tiu.rider_station_id=#{riderStationId}
  219. </if>
  220. order by tor.pay_time desc, tor.create_time desc
  221. </select>
  222. <select id="excelAllOrderAdminCount" resultType="java.lang.Integer">
  223. select count(1) from tb_order tor
  224. left join tb_user tu on tor.user_id = tu.user_id
  225. left join goods_shop gs on tor.shop_id = gs.shop_id
  226. left join tb_indent ti on tor.order_id = ti.order_id
  227. left join tb_user tiu on tiu.user_id = ti.rider_user_id
  228. where 1 = 1
  229. <if test="riderPhone!=null and riderPhone!=''">
  230. and tiu.phone =#{riderPhone}
  231. </if>
  232. <if test="shopName!=null and shopName!=''">
  233. and gs.shop_name like concat('%',#{shopName},'%')
  234. </if>
  235. <if test="userName!=null and userName!=''">
  236. and tor.user_name like concat('%',#{userName},'%')
  237. </if>
  238. <if test="phone!=null and phone!=''">
  239. and tor.phone like concat('%',#{phone},'%')
  240. </if>
  241. <if test="orderNumber!=null and orderNumber!=''">
  242. and tor.order_number = #{orderNumber}
  243. </if>
  244. <if test="status!=null and status!=-1 and status!=1">
  245. and tor.status = #{status}
  246. </if>
  247. <if test="status!=null and status==1">
  248. and tor.status in (1,2)
  249. </if>
  250. <if test="shopId!=null">
  251. and tor.shop_id = #{shopId}
  252. </if>
  253. <if test="orderType!=null">
  254. and tor.order_type_extra = #{orderType}
  255. </if>
  256. <if test="startTime!=null and startTime!=''">
  257. and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
  258. </if>
  259. <if test="endTime!=null and endTime!='' ">
  260. and date_format(tor.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
  261. </if>
  262. <if test="payStartTime != null and payStartTime != ''">
  263. and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{payStartTime},'%Y-%m-%d')
  264. </if>
  265. <if test="payEndTime != null and payEndTime != '' ">
  266. and date_format(tor.pay_time,'%Y-%m-%d') &lt;= date_format(#{payEndTime},'%Y-%m-%d')
  267. </if>
  268. <if test="riderStationId!=null and riderStationId!=''">
  269. and tiu.rider_station_id=#{riderStationId}
  270. </if>
  271. order by tor.pay_time desc, tor.create_time desc
  272. </select>
  273. <select id="selectOrderByAdmin" resultType="com.sqx.modules.order.entity.TbOrder">
  274. select tor.*, tu.avatar as avatar, gs.shop_name as shopName from sys_user_shop sus
  275. left join tb_order tor on sus.shop_id = tor.shop_id
  276. left join tb_user tu on tor.user_id = tu.user_id
  277. left join goods_shop gs on tor.shop_id = gs.shop_id
  278. where 1 = 1 and sus.user_id = #{userId}
  279. and tor.is_pay = 1
  280. <if test="userName!=null and userName!=''">
  281. and tor.user_name like concat('%',#{userName},'%')
  282. </if>
  283. <if test="phone!=null and phone!=''">
  284. and tor.phone like concat('%',#{phone},'%')
  285. </if>
  286. <if test="orderNumber!=null and orderNumber!=''">
  287. and tor.order_number = #{orderNumber}
  288. </if>
  289. <if test="status!=null">
  290. and tor.status = #{status}
  291. </if>
  292. <if test="shopId!=null">
  293. and tor.shop_id = #{shopId}
  294. </if>
  295. <if test="orderType!=null">
  296. and tor.order_type = #{orderType}
  297. </if>
  298. order by tor.pay_time desc, tor.create_time desc
  299. </select>
  300. <select id="selectCountOrderByUserId" resultType="int">
  301. select count(*) from tb_order where user_id = #{userId}
  302. <if test="dateType=='day'">
  303. and date_format(pay_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  304. </if>
  305. <if test="dateType=='month'">
  306. and date_format(pay_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  307. </if>
  308. <if test="dateType=='year'">
  309. and date_format(pay_time,'%Y')=date_format(#{date},'%Y')
  310. </if>
  311. </select>
  312. <select id="selectSunMoneyByUserId" resultType="java.math.BigDecimal">
  313. select ifnull(sum(pay_money), 0) from tb_order where user_id = #{userId}
  314. <if test="dateType=='day'">
  315. and date_format(pay_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
  316. </if>
  317. <if test="dateType=='month'">
  318. and date_format(pay_time,'%Y-%m')=date_format(#{date},'%Y-%m')
  319. </if>
  320. <if test="dateType=='year'">
  321. and date_format(pay_time,'%Y')=date_format(#{date},'%Y')
  322. </if>
  323. </select>
  324. <select id="selectOrderDetails" resultType="com.sqx.modules.order.entity.TbOrder">
  325. select tor.*,
  326. gs.shop_name as shopName,
  327. gs.detailed_address as detailedAddress,
  328. gs.phone as shopPhone,
  329. tu.nick_name as riderNickName,
  330. tu.phone as riderPhone
  331. from tb_order tor
  332. left join goods_shop gs on tor.shop_id = gs.shop_id
  333. left join tb_indent ti on tor.order_id = ti.order_id
  334. left join tb_user tu on ti.rider_user_id = tu.user_id
  335. where tor.user_id = #{userId}
  336. and tor.status in (7, 6, 3, 4, 5, 8)
  337. order by pay_time desc
  338. </select>
  339. <select id="waitTakeFood" resultType="com.sqx.modules.order.entity.TbOrder">
  340. select tor.*, tu.avatar as avatar, ti.rider_user_id as riderUserId, gs.shop_name as shopName, gs.shop_cover as
  341. shopCover, gs.detailed_address as detailedAddress,tu1.phone as riderPhone,gs.phone as shopPhone,ti.indent_state as indentState,
  342. (select count(*) from tb_order where order_type = 1 and status in (6, 3) and pay_time &lt; tor.pay_time
  343. and shop_id = tor.shop_id) as countOrder
  344. from tb_order tor
  345. left join tb_user tu on tor.user_id = tu.user_id
  346. left join tb_indent ti on tor.order_id = ti.order_id
  347. left join goods_shop gs on tor.shop_id = gs.shop_id
  348. left join tb_user tu1 on ti.rider_user_id = tu1.user_id
  349. where tor.user_id = #{userId}
  350. and order_type = #{orderType}
  351. <if test="status!=null and status!=5">
  352. and tor.status = #{status}
  353. </if>
  354. <if test="status!=null and status==5">
  355. and tor.status in (5, 8)
  356. </if>
  357. <if test="status==null">
  358. and tor.status in (0, 7, 6, 3, 4, 5, 8)
  359. </if>
  360. order by tor.pay_time desc, tor.create_time desc
  361. </select>
  362. <select id="selectCountOrderByTime" resultType="int">
  363. select count(*)
  364. from tb_order
  365. where order_type = 1
  366. and status = 3
  367. and pay_time &lt; #{payTime}
  368. and shop_id = #{shopId}
  369. </select>
  370. <update id="deleteCouponByOrderId">
  371. update tb_order
  372. set coupon_id = null
  373. where order_id = #{orderId}
  374. </update>
  375. <select id="selectSumMoney" resultType="java.math.BigDecimal">
  376. select ifnull(sum(pay_money), 0) from tb_order where is_pay=1 and status in (0,3,4,7,6)
  377. <if test="query.shopId!=null">
  378. and shop_id=#{query.shopId}
  379. </if>
  380. <if test="query.dateType=='day'">
  381. and date_format(pay_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
  382. </if>
  383. <if test="query.dateType=='month'">
  384. and date_format(pay_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
  385. </if>
  386. <if test="query.dateType=='year'">
  387. and date_format(pay_time,'%Y')=date_format(#{query.date},'%Y')
  388. </if>
  389. <if test="query.startTime!=null and query.startTime!=''">
  390. and pay_time>=#{query.startTime}
  391. </if>
  392. <if test="query.endTime!=null and query.endTime!=''">
  393. and pay_time <![CDATA[<=]]> #{query.endTime}
  394. </if>
  395. </select>
  396. <select id="selectCountOrder" resultType="int">
  397. select count(*) from tb_order where is_pay=1 and status in (0,3,4,7,6)
  398. <if test="query.shopId!=null">
  399. and shop_id=#{query.shopId}
  400. </if>
  401. <if test="query.dateType=='day'">
  402. and date_format(pay_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
  403. </if>
  404. <if test="query.dateType=='month'">
  405. and date_format(pay_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
  406. </if>
  407. <if test="query.dateType=='year'">
  408. and date_format(pay_time,'%Y')=date_format(#{query.date},'%Y')
  409. </if>
  410. <if test="query.startTime!=null and query.startTime!=''">
  411. and pay_time>=#{query.startTime}
  412. </if>
  413. <if test="query.endTime!=null and query.endTime!=''">
  414. and pay_time <![CDATA[<=]]> #{query.endTime}
  415. </if>
  416. </select>
  417. <update id="updateorderStatus">
  418. update tb_order
  419. set status = 4
  420. where update_time &lt; #{date}
  421. and status = 3
  422. </update>
  423. <select id="selectOrderByTimeList" resultType="com.sqx.modules.order.entity.TbOrder">
  424. select *
  425. from tb_order
  426. where update_time &lt; #{date}
  427. and status = 3
  428. </select>
  429. <select id="selectShoppingTrolley" resultType="com.sqx.modules.order.entity.TbOrder">
  430. select t.*, gs.shop_name as shopName
  431. from tb_order t
  432. left join goods_shop gs on t.shop_id = gs.shop_id
  433. where t.status = 1
  434. and t.user_id = #{userId}
  435. order by t.add_goods_time desc
  436. </select>
  437. <select id="selectShoppingTrolleyByShopId" resultType="com.sqx.modules.order.entity.TbOrder">
  438. select t.*, gs.shop_name as shopName
  439. from tb_order t
  440. left join goods_shop gs on t.shop_id = gs.shop_id
  441. where t.status = 1
  442. and t.user_id = #{userId}
  443. and t.shop_id = #{shopId}
  444. order by t.add_goods_time desc
  445. </select>
  446. <select id="selectByOrderId" resultType="com.sqx.modules.order.entity.TbOrder">
  447. select tor.*,
  448. ti.indent_id as indentId,
  449. ti.indent_number as indentNumber,
  450. ti.rider_user_id as riderUserId,
  451. ti.indent_state as indentState,
  452. tu.nick_name as riderNickName,
  453. tu.avatar as riderAvatar,
  454. tu.phone as riderPhone,
  455. e.evaluate_message as evaluateMessage,
  456. e.shop_reply_message as shopReplyMessage,
  457. e.score as score,
  458. e.create_time as eCreateTime,
  459. tus.avatar as avatar,
  460. tus.nick_name as userNickName
  461. from tb_order tor
  462. left join tb_indent ti on tor.order_id = ti.order_id
  463. left join tb_user tu on ti.rider_user_id = tu.user_id
  464. left join tb_user tus on ti.user_id = tus.user_id
  465. left join evaluate e on tor.order_number = e.order_number
  466. where tor.order_id = #{orderId}
  467. </select>
  468. <select id="selectBuyGoods" resultType="com.sqx.modules.order.entity.TbOrder">
  469. select tor.*,
  470. gs.shop_name as shopName,
  471. gs.detailed_address as detailedAddress,
  472. gs.shop_lng as shopLng,
  473. gs.shop_lat as shopLat,
  474. gs.phone as shopPhone,
  475. gs.errand_money as errandMoney,
  476. gs.exempt_min_money as exemptMinMoney,
  477. gs.minimum_delivery as minimumDelivery,
  478. gs.distribution_distance as distributionDistance
  479. from tb_order tor
  480. left join goods_shop gs on tor.shop_id = gs.shop_id
  481. where tor.order_id = #{orderId}
  482. and tor.user_id = #{userId}
  483. </select>
  484. <select id="selectOverTimeOrder" resultType="com.sqx.modules.order.entity.TbOrder">
  485. select *
  486. from tb_order
  487. where status = 7
  488. and pay_time &lt; #{overTime}
  489. </select>
  490. <select id="selectMakeOrdersList" resultType="com.sqx.modules.order.entity.TbOrder">
  491. select * from tb_order where status=6 and shop_receiving_time <![CDATA[ <= #{minusMinutes}]]></select>
  492. <select id="selectCurrentOrderSequenceByShopId" resultType="java.lang.Long">
  493. select
  494. order_id
  495. from
  496. tb_order
  497. where
  498. is_pay = 1
  499. and shop_id = #{shopId}
  500. and date(pay_time) = date(#{payTime})
  501. order by pay_time asc
  502. </select>
  503. <select id="countByShopIdAndActivityIdAndUserIdAndCurDate" resultType="java.lang.Integer">
  504. select
  505. count(1)
  506. from
  507. tb_order o
  508. left join activity_part_record apr on apr.order_id = o.order_id
  509. where
  510. o.shop_id = #{shopId}
  511. and o.user_id = #{userId}
  512. and date(o.create_time) = curdate()
  513. and apr.activity_id = #{activityId}
  514. and o.is_pay = 1
  515. <if test="orderId != null">
  516. and o.order_id != #{orderId}
  517. </if>
  518. </select>
  519. <select id="selectCurWaitReceivingOrderIds" resultType="java.lang.Long">
  520. select
  521. order_id
  522. from
  523. tb_order
  524. where
  525. reservation_flag = '1'
  526. and `status` = '7'
  527. and expect_delivery_time <![CDATA[ <= ]]> adddate(now(),interval 30 minute)
  528. </select>
  529. <select id="countUnFinishByShopId" resultType="java.lang.Integer">
  530. select count(order_id)
  531. from tb_order
  532. where shop_id = #{shopId} and status in (6, 3)
  533. </select>
  534. <select id="countCurDayPayByShopId" resultType="java.lang.Integer">
  535. select
  536. count(order_id)
  537. from
  538. tb_order
  539. where
  540. is_pay = 1
  541. and shop_id = #{shopId}
  542. and date(pay_time) = date(#{payTime})
  543. </select>
  544. <select id="changeTimeOutOrder" resultType="com.sqx.modules.order.entity.TbOrder">
  545. SELECT o.*,
  546. pd.state as state
  547. FROM `tb_order` o
  548. LEFT JOIN pay_details pd ON o.order_number = pd.order_id
  549. WHERE o.`status` = 0
  550. AND o.time_out IS NOT NULL
  551. AND #{time} >= o.time_out
  552. AND pd.state in (0, 2)
  553. </select>
  554. </mapper>