OrderDao.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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.kmall.admin.dao.OrderDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.OrderEntity" id="orderMap">
  6. <result property="id" column="id"/>
  7. <result property="merchOrderSn" column="merch_order_sn"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="orderStatus" column="order_status"/>
  11. <result property="shippingStatus" column="shipping_status"/>
  12. <result property="payStatus" column="pay_status"/>
  13. <result property="consignee" column="consignee"/>
  14. <result property="country" column="country"/>
  15. <result property="province" column="province"/>
  16. <result property="city" column="city"/>
  17. <result property="district" column="district"/>
  18. <result property="address" column="address"/>
  19. <result property="mobile" column="mobile"/>
  20. <result property="postscript" column="postscript"/>
  21. <result property="shippingId" column="shipping_id"/>
  22. <result property="shippingName" column="shipping_name"/>
  23. <result property="shippingCode" column="shipping_code"/>
  24. <result property="shippingNo" column="shipping_no"/>
  25. <result property="payId" column="pay_id"/>
  26. <result property="payName" column="pay_name"/>
  27. <result property="shippingFee" column="shipping_fee"/>
  28. <result property="actualPrice" column="actual_price"/>
  29. <result property="integral" column="integral"/>
  30. <result property="integralMoney" column="integral_money"/>
  31. <result property="orderPrice" column="order_price"/>
  32. <result property="goodsPrice" column="goods_price"/>
  33. <result property="addTime" column="add_time"/>
  34. <result property="confirmTime" column="confirm_time"/>
  35. <result property="payTime" column="pay_time"/>
  36. <result property="freightPrice" column="freight_price"/>
  37. <result property="couponId" column="coupon_id"/>
  38. <result property="couponPrice" column="coupon_price"/>
  39. <result property="callbackStatus" column="callback_status"/>
  40. <result property="orderType" column="order_type"/>
  41. <result property="storeId" column="store_id"/>
  42. <result property="userName" column="username"/>
  43. <result property="orderType" column="order_type"/>
  44. <result property="activityId" column="activity_id"/>
  45. <result property="deliveryDate" column="delivery_date"/>
  46. <result property="deliveryRemark" column="delivery_remark"/>
  47. <result property="predictTime" column="predict_time"/>
  48. <result property="orderBizType" column="order_biz_type"/>
  49. <result property="isPaymentSend" column="is_payment_send"/>
  50. <result property="isEleOrderSend" column="is_ele_order_send"/>
  51. <result property="isCustomsSend" column="is_customs_send"/>
  52. <result property="payFlag" column="pay_flag"/>
  53. <result column="buyer_pay_check" property="buyerPayCheck"/>
  54. <result property="merchSn" column="merch_sn"/>
  55. <result property="sku" column="sku"/>
  56. <result property="createTime" column="create_time"/>
  57. <result property="modTime" column="mod_time"/>
  58. <result property="isOnfflineOrder" column="is_onffline_order"/>
  59. <result property="orderSnWx" column="order_sn_wx"/>
  60. <result property="isMergePay" column="is_merge_pay"/>
  61. <result property="payTransactionId" column="pay_transaction_id"/>
  62. </resultMap>
  63. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  64. select o.*,u.username as username
  65. from mall_order o
  66. left join mall_user u on o.user_id = u.id
  67. where o.id = #{value}
  68. </select>
  69. <select id="queryObjectBySysUser" resultType="com.kmall.admin.entity.OrderEntity">
  70. select o.*,u.username as username
  71. from mall_order o
  72. left join sys_user u on o.user_id = u.user_id
  73. where o.id = #{value}
  74. </select>
  75. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  76. select o.*,u.username as username
  77. from mall_order o
  78. left join mall_user u on o.user_id = u.id
  79. where o.activity_id = #{activityId} and o.order_type = #{orderType}
  80. </select>
  81. <select id="getTotalActualPrice" resultType="java.lang.Double">
  82. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  83. </select>
  84. <select id="queryObjectByMerchOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  85. select * from mall_order a where merch_order_sn = #{merchOrderSn}
  86. </select>
  87. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  88. SELECT
  89. o.*,
  90. u.username AS username,
  91. p.is_payment_send,
  92. p.is_ele_order_send,
  93. p.is_customs_send
  94. FROM
  95. mall_order o
  96. LEFT JOIN mall_user u ON o.user_id = u.id
  97. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  98. WHERE 1=1
  99. <if test="startTime != null and startTime != ''">
  100. AND o.add_time <![CDATA[ > ]]> #{startTime}
  101. </if>
  102. <if test="endTime != null and endTime != ''">
  103. AND o.add_time <![CDATA[ < ]]> #{endTime}
  104. </if>
  105. <if test="storeId != null and storeId != ''">
  106. AND o.store_id = #{storeId}
  107. </if>
  108. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  109. AND o.merch_order_sn = #{merchOrderSn}
  110. </if>
  111. <if test="merchSn != null and merchSn.trim() != ''">
  112. AND o.merch_sn = #{merchSn}
  113. </if>
  114. <if test="orderSn != null and orderSn.trim() != ''">
  115. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  116. </if>
  117. <if test="shippingStatus != null">
  118. AND o.shipping_status = #{shippingStatus}
  119. </if>
  120. <if test="payStatus != null">
  121. AND o.pay_status = #{payStatus}
  122. </if>
  123. <if test="orderStatus != null and orderStatus.trim() != ''">
  124. AND o.order_status = #{orderStatus}
  125. </if>
  126. <if test="shippingId != null and shippingId != 0">
  127. AND o.shipping_id = #{shippingId}
  128. </if>
  129. <if test="orderType != null and orderType.trim() != ''">
  130. AND o.order_type = #{orderType}
  131. </if>
  132. <if test="isOnfiilineOrder != null">
  133. AND o.is_onffline_order = #{isOnfiilineOrder}
  134. </if>
  135. <if test="ids != null and ids.trim() != ''">
  136. AND o.id in (${ids})
  137. </if>
  138. <choose>
  139. <when test="sidx != null and sidx.trim() != ''">
  140. order by ${sidx} ${order}
  141. </when>
  142. <otherwise>
  143. order by id desc
  144. </otherwise>
  145. </choose>
  146. <if test="offset != null and limit != null">
  147. limit #{offset}, #{limit}
  148. </if>
  149. </select>
  150. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  151. SELECT
  152. o.*,
  153. u.username AS username,
  154. p.is_payment_send,
  155. p.is_ele_order_send,
  156. p.is_customs_send,
  157. g.sku,
  158. g.goods_name,
  159. g.number,
  160. g.retail_price
  161. FROM
  162. mall_order o
  163. LEFT JOIN mall_user u ON o.user_id = u.id
  164. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  165. Left join mall_order_goods g on o.id = g.order_id
  166. WHERE 1=1
  167. <if test="startTime != null and startTime != ''">
  168. AND o.add_time <![CDATA[ > ]]> #{startTime}
  169. </if>
  170. <if test="endTime != null and endTime != ''">
  171. AND o.add_time <![CDATA[ < ]]> #{endTime}
  172. </if>
  173. <if test="storeId != null and storeId != ''">
  174. AND o.store_id = #{storeId}
  175. </if>
  176. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  177. AND o.merch_order_sn = #{merchOrderSn}
  178. </if>
  179. <if test="merchSn != null and merchSn.trim() != ''">
  180. AND o.merch_sn = #{merchSn}
  181. </if>
  182. <if test="orderSn != null and orderSn.trim() != ''">
  183. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  184. </if>
  185. <if test="shippingStatus != null">
  186. AND o.shipping_status = #{shippingStatus}
  187. </if>
  188. <if test="payStatus != null">
  189. AND o.pay_status = #{payStatus}
  190. </if>
  191. <if test="orderStatus != null and orderStatus.trim() != ''">
  192. AND o.order_status = #{orderStatus}
  193. </if>
  194. <if test="shippingId != null and shippingId != 0">
  195. AND o.shipping_id = #{shippingId}
  196. </if>
  197. <if test="orderType != null and orderType.trim() != ''">
  198. AND o.order_type = #{orderType}
  199. </if>
  200. <if test="isOnfiilineOrder != null">
  201. AND o.is_onffline_order = #{isOnfiilineOrder}
  202. </if>
  203. <if test="ids != null and ids.trim() != ''">
  204. AND o.id in (${ids})
  205. </if>
  206. <choose>
  207. <when test="sidx != null and sidx.trim() != ''">
  208. order by ${sidx} ${order}
  209. </when>
  210. <otherwise>
  211. order by id desc
  212. </otherwise>
  213. </choose>
  214. <if test="offset != null and limit != null">
  215. limit #{offset}, #{limit}
  216. </if>
  217. </select>
  218. <select id="queryTotal" resultType="int">
  219. select count(*) from mall_order o WHERE 1=1
  220. <if test="startTime != null and startTime != ''">
  221. AND o.add_time <![CDATA[ > ]]> #{startTime}
  222. </if>
  223. <if test="endTime != null and endTime != ''">
  224. AND o.add_time <![CDATA[ < ]]> #{endTime}
  225. </if>
  226. <if test="storeId != null and storeId != ''">
  227. AND o.store_id = #{storeId}
  228. </if>
  229. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  230. AND o.merch_order_sn = #{merchOrderSn}
  231. </if>
  232. <if test="merchSn != null and merchSn.trim() != ''">
  233. AND o.merch_sn = #{merchSn}
  234. </if>
  235. <if test="orderSn != null and orderSn.trim() != ''">
  236. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  237. </if>
  238. <if test="shippingStatus != null">
  239. AND o.shipping_status = #{shippingStatus}
  240. </if>
  241. <if test="payStatus != null">
  242. AND o.pay_status = #{payStatus}
  243. </if>
  244. <if test="orderStatus != null and orderStatus.trim() != ''">
  245. AND o.order_status = #{orderStatus}
  246. </if>
  247. <if test="shippingId != null and shippingId != 0">
  248. AND o.shipping_id = #{shippingId}
  249. </if>
  250. <if test="orderType != null and orderType.trim() != ''">
  251. AND o.order_type = #{orderType}
  252. </if>
  253. <if test="isOnfiilineOrder != null">
  254. AND o.is_onffline_order = #{isOnfiilineOrder}
  255. </if>
  256. <if test="ids != null and ids.trim() != ''">
  257. AND o.id in (${ids})
  258. </if>
  259. </select>
  260. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  261. SELECT
  262. o.*,
  263. u.username AS username,
  264. p.is_payment_send,
  265. p.is_ele_order_send,
  266. p.is_customs_send
  267. FROM
  268. mall_order o
  269. LEFT JOIN sys_user u ON o.user_id = u.user_id
  270. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  271. WHERE 1=1
  272. <if test="storeId != null and storeId != ''">
  273. AND o.store_id = #{storeId}
  274. </if>
  275. <if test="merchSn != null and merchSn.trim() != ''">
  276. AND o.merch_sn = #{merchSn}
  277. </if>
  278. <if test="orderSn != null and orderSn.trim() != ''">
  279. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  280. </if>
  281. <if test="shippingStatus != null">
  282. AND o.shipping_status = #{shippingStatus}
  283. </if>
  284. <if test="payStatus != null">
  285. AND o.pay_status = #{payStatus}
  286. </if>
  287. <if test="orderStatus != null and orderStatus.trim() != ''">
  288. AND o.order_status = #{orderStatus}
  289. </if>
  290. <if test="shippingId != null and shippingId != 0">
  291. AND o.shipping_id = #{shippingId}
  292. </if>
  293. <if test="orderType != null and orderType.trim() != ''">
  294. AND o.order_type = #{orderType}
  295. </if>
  296. <if test="isOnfiilineOrder != null">
  297. AND o.is_onffline_order = #{isOnfiilineOrder}
  298. </if>
  299. <if test="ids != null and ids.trim() != ''">
  300. AND o.id in (${ids})
  301. </if>
  302. <choose>
  303. <when test="sidx != null and sidx.trim() != ''">
  304. order by ${sidx} ${order}
  305. </when>
  306. <otherwise>
  307. order by id desc
  308. </otherwise>
  309. </choose>
  310. <if test="offset != null and limit != null">
  311. limit #{offset}, #{limit}
  312. </if>
  313. </select>
  314. <insert id="save" parameterType="com.kmall.admin.entity.OrderEntity" useGeneratedKeys="true" keyProperty="id">
  315. insert into mall_order
  316. (
  317. `order_sn`,
  318. `user_id`,
  319. `order_status`,
  320. `shipping_status`,
  321. `pay_status`,
  322. `consignee`,
  323. `country`,
  324. `province`,
  325. `city`,
  326. `district`,
  327. `address`,
  328. `mobile`,
  329. `postscript`,
  330. `shipping_id`,
  331. `shipping_name`,
  332. `shipping_code`,
  333. `shipping_no`,
  334. `pay_id`,
  335. `pay_name`,
  336. `shipping_fee`,
  337. `actual_price`,
  338. `integral`,
  339. `integral_money`,
  340. `order_price`,
  341. `goods_price`,
  342. `add_time`,
  343. `confirm_time`,
  344. `pay_time`,
  345. `freight_price`,
  346. `coupon_id`,
  347. `coupon_price`,
  348. `callback_status`,
  349. `order_type`,
  350. `store_id`,
  351. `order_biz_type`,
  352. `is_onffline_order`,
  353. `order_sn_wx`,
  354. `pay_flag`,
  355. `merch_sn`,
  356. `create_time`,
  357. `mod_time`
  358. )
  359. values
  360. (
  361. #{orderSn},
  362. #{userId},
  363. #{orderStatus},
  364. #{shippingStatus},
  365. #{payStatus},
  366. #{consignee},
  367. #{country},
  368. #{province},
  369. #{city},
  370. #{district},
  371. #{address},
  372. #{mobile},
  373. #{postscript},
  374. #{shippingId},
  375. #{shippingName},
  376. #{shippingCode},
  377. #{shippingNo},
  378. #{payId},
  379. #{payName},
  380. #{shippingFee},
  381. #{actualPrice},
  382. #{integral},
  383. #{integralMoney},
  384. #{orderPrice},
  385. #{goodsPrice},
  386. #{addTime},
  387. #{confirmTime},
  388. #{payTime},
  389. #{freightPrice},
  390. #{couponId},
  391. #{couponPrice},
  392. #{callbackStatus},
  393. #{orderType},
  394. #{storeId},
  395. #{orderBizType},
  396. #{isOnfflineOrder},
  397. #{orderSnWx},
  398. #{payFlag},
  399. #{merchSn},
  400. #{createTime},
  401. #{modTime}
  402. )
  403. </insert>
  404. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  405. update mall_order
  406. <set>
  407. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  408. <if test="userId != null">`user_id` = #{userId},</if>
  409. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  410. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  411. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  412. <if test="consignee != null">`consignee` = #{consignee},</if>
  413. <if test="country != null">`country` = #{country},</if>
  414. <if test="province != null">`province` = #{province},</if>
  415. <if test="city != null">`city` = #{city},</if>
  416. <if test="district != null">`district` = #{district},</if>
  417. <if test="address != null">`address` = #{address},</if>
  418. <if test="mobile != null">`mobile` = #{mobile},</if>
  419. <if test="postscript != null">`postscript` = #{postscript},</if>
  420. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  421. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  422. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  423. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  424. <if test="payId != null">`pay_id` = #{payId},</if>
  425. <if test="payName != null">`pay_name` = #{payName},</if>
  426. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  427. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  428. <if test="integral != null">`integral` = #{integral},</if>
  429. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  430. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  431. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  432. <if test="addTime != null">`add_time` = #{addTime},</if>
  433. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  434. <if test="payTime != null">`pay_time` = #{payTime},</if>
  435. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  436. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  437. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  438. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  439. <if test="orderType != null">`order_type` = #{orderType},</if>
  440. <if test="storeId != null">`store_id` = #{storeId},</if>
  441. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  442. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  443. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  444. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  445. <if test="createTime != null">`create_time` = #{createTime},</if>
  446. <if test="modTime != null">`mod_time` = #{modTime},</if>
  447. </set>
  448. where id = #{id}
  449. </update>
  450. <delete id="delete">
  451. delete from mall_order where id = #{value}
  452. </delete>
  453. <delete id="deleteBatch">
  454. delete from mall_order where id in
  455. <foreach item="id" collection="array" open="(" separator="," close=")">
  456. #{id}
  457. </foreach>
  458. </delete>
  459. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  460. update mall_order
  461. <set>
  462. `order_status` = #{orderStatus},
  463. `shipping_status` = #{shippingStatus},
  464. `shipping_id` = #{shippingId},
  465. `shipping_name` = #{shippingName},
  466. `shipping_fee` = #{shippingFee},
  467. `shipping_no` = #{shippingNo},
  468. `shipping_mobile` = #{shippingMobile}
  469. </set>
  470. where id = #{id}
  471. </update>
  472. <select id="getYfkOrderUserSum" resultType="int">
  473. select count(1) from (select user_id,count(user_id) as counts from mall_order where pay_status = 2 group by user_id) u
  474. </select>
  475. <select id="getOderUserSum" resultType="int">
  476. select count(1) from (select user_id,count(user_id) as counts from mall_order group by user_id) u
  477. </select>
  478. <select id="getTodayUserOrder" resultType="int">
  479. select count(1) from mall_order where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  480. </select>
  481. <select id="getTodayUserSales" resultType="int">
  482. select ifnull(sum(actual_price),0) from mall_order where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  483. </select>
  484. <select id="getIncomeSum" resultType="int">
  485. select ifnull(sum(actual_price),0) from mall_order where pay_status = 2
  486. </select>
  487. <select id="getPayedOrderCount" resultType="int">
  488. select count(1) from mall_order where pay_status = 2
  489. </select>
  490. </mapper>