OrderMapper.xml 24 KB

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