OrderMapper.xml 23 KB

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