ApiOrderMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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.api.dao.ApiOrderMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.OrderVo" id="orderMap">
  6. <result property="id" column="id"/>
  7. <result property="order_sn" column="order_sn"/>
  8. <result property="user_id" column="user_id"/>
  9. <result property="order_status" column="order_status"/>
  10. <result property="shipping_status" column="shipping_status"/>
  11. <result property="pay_status" column="pay_status"/>
  12. <result property="consignee" column="consignee"/>
  13. <result property="country" column="country"/>
  14. <result property="province" column="province"/>
  15. <result property="city" column="city"/>
  16. <result property="district" column="district"/>
  17. <result property="address" column="address"/>
  18. <result property="address_id" column="address_id"/>
  19. <result property="mobile" column="mobile"/>
  20. <result property="postscript" column="postscript"/>
  21. <result property="shipping_id" column="shipping_id"/>
  22. <result property="shipping_name" column="shipping_name"/>
  23. <result property="shipping_mobile" column="shipping_mobile"/>
  24. <result property="shipping_fee" column="shipping_fee"/>
  25. <result property="shipping_no" column="shipping_no"/>
  26. <result property="shipping_code" column="shipping_code"/>
  27. <result property="pay_id" column="pay_id"/>
  28. <result property="pay_name" column="pay_name"/>
  29. <result property="actual_price" column="actual_price"/>
  30. <result property="integral" column="integral"/>
  31. <result property="integral_money" column="integral_money"/>
  32. <result property="order_price" column="order_price"/>
  33. <result property="goods_price" column="goods_price"/>
  34. <result property="add_time" column="add_time"/>
  35. <result property="confirm_time" column="confirm_time"/>
  36. <result property="pay_time" column="pay_time"/>
  37. <result property="freight_price" column="freight_price"/>
  38. <result property="coupon_id" column="coupon_id"/>
  39. <result property="coupon_name" column="coupon_name"/>
  40. <result property="coupon_price" column="coupon_price"/>
  41. <result property="full_cut_price" column="full_cut_price"/>
  42. <result property="order_type" column="order_type"/>
  43. <result property="activity_id" column="activity_id"/>
  44. <result property="store_id" column="store_id"/>
  45. <result property="delivery_date" column="delivery_date"/>
  46. <result property="delivery_remark" column="delivery_remark"/>
  47. <result property="predict_time" column="predict_time"/>
  48. <result property="latitude" column="latitude"/>
  49. <result property="longitude" column="longitude"/>
  50. <result property="comment_count" column="comment_count"/>
  51. <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
  52. <result column="order_biz_type" property="orderBizType" jdbcType="CHAR" />
  53. <result column="pay_transaction_id" property="payTransactionId" jdbcType="VARCHAR" />
  54. <result column="pay_mobile" property="payMobile" jdbcType="VARCHAR" />
  55. <result column="buyer_pay_check" property="buyerPayCheck" jdbcType="VARCHAR" />
  56. <result column="pay_flag" property="payFlag" jdbcType="VARCHAR" />
  57. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  58. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  59. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  60. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  61. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  62. <result column="merch_order_sn" property="merchOrderSn" jdbcType="VARCHAR" />
  63. <result column="is_scan" property="isScan" jdbcType="VARCHAR" />
  64. <result column="store_name" property="storeName" jdbcType="VARCHAR" />
  65. <result property="isRefundStatus" column="isRefundStatus"/>
  66. <result property="refundStatus" column="refund_status"/>
  67. <result property="approvalRemark" column="approval_remark"/>
  68. </resultMap>
  69. <select id="queryObject" resultMap="orderMap">
  70. select a.*,b.latitude,b.longitude
  71. from mall_order a
  72. left join mall_address b on a.address_id = b.id
  73. where a.id = #{value}
  74. </select>
  75. <select id="queryObjectByOrderSn" resultMap="orderMap">
  76. select a.*,b.latitude,b.longitude
  77. from mall_order a
  78. left join mall_address b on a.address_id = b.id
  79. where a.order_sn = #{order_sn}
  80. </select>
  81. <select id="queryList" resultMap="orderMap">
  82. select a.*,b.latitude,b.longitude,s.store_name,f.refund_status,f.approval_remark
  83. from mall_order a
  84. left join mall_address b on a.address_id = b.id
  85. left join mall_store s on a.store_id = s.id
  86. left join mall_order_refund f on a.id = f.order_id
  87. <where>
  88. <if test="user_id != null">
  89. and a.user_id = #{user_id}
  90. </if>
  91. <if test="pay_status != null">
  92. and a.pay_status = #{pay_status}
  93. </if>
  94. <if test="shipping_status != null">
  95. and a.shipping_status = #{shipping_status}
  96. </if>
  97. <if test="order_status != null">
  98. and a.order_status = #{order_status}
  99. </if>
  100. <if test="evaluate_status != null and evaluate_status != 0 ">
  101. and a.comment_count <![CDATA[ >= ]]> 1
  102. </if>
  103. <if test="evaluate_status != null and evaluate_status == 0 ">
  104. and a.comment_count <![CDATA[ < ]]> 1
  105. </if>
  106. <if test="startDate!=null and startDate!=''">
  107. AND a.add_time >= #{startDate}
  108. </if>
  109. <if test="endDate!=null and endDate!=''">
  110. AND a.add_time <![CDATA[ < ]]> #{endDate}
  111. </if>
  112. <if test="shippingId!=null and shippingId!=''">
  113. AND a.shipping_id = #{shippingId}
  114. </if>
  115. </where>
  116. <if test="order_status != 401">
  117. <choose>
  118. <when test="sidx != null and sidx.trim() != ''">
  119. order by ${sidx} ${order}
  120. </when>
  121. <otherwise>
  122. order by a.id desc
  123. </otherwise>
  124. </choose>
  125. </if>
  126. <if test="order_status == 401">
  127. order by f.refund_time desc
  128. </if>
  129. <if test="offset != null and limit != null">
  130. limit #{offset}, #{limit}
  131. </if>
  132. </select>
  133. <select id="queryTotal" resultType="int">
  134. select count(id) from mall_order a
  135. <where>
  136. <if test="user_id != null">
  137. and a.user_id = #{user_id}
  138. </if>
  139. <if test="pay_status != null">
  140. and a.pay_status = #{pay_status}
  141. </if>
  142. <if test="shipping_status != null">
  143. and a.shipping_status = #{shipping_status}
  144. </if>
  145. <if test="evaluate_status != null and evaluate_status != 0 ">
  146. and a.comment_count <![CDATA[ >= ]]> 1
  147. </if>
  148. <if test="evaluate_status != null and evaluate_status == 0 ">
  149. and a.comment_count <![CDATA[ < ]]> 1
  150. </if>
  151. <if test="startDate!=null and startDate!=''">
  152. AND a.add_time >= #{startDate}
  153. </if>
  154. <if test="endDate!=null and endDate!=''">
  155. AND a.add_time <![CDATA[ < ]]> #{endDate}
  156. </if>
  157. <if test="shippingId!=null and shippingId!=''">
  158. AND a.shipping_id = #{shippingId}
  159. </if>
  160. <if test="order_status != null">
  161. and a.order_status = #{order_status}
  162. </if>
  163. </where>
  164. </select>
  165. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  166. insert into mall_order
  167. (
  168. `order_sn`,
  169. `user_id`,
  170. `order_status`,
  171. `shipping_status`,
  172. `shipping_code`,
  173. `pay_status`,
  174. `consignee`,
  175. `country`,
  176. `province`,
  177. `city`,
  178. `district`,
  179. `address`,
  180. `address_id`,
  181. `mobile`,
  182. `postscript`,
  183. `pay_id`,
  184. `pay_name`,
  185. `shipping_fee`,
  186. `actual_price`,
  187. `integral`,
  188. `integral_money`,
  189. `order_price`,
  190. `goods_price`,
  191. `add_time`,
  192. `confirm_time`,
  193. `pay_time`,
  194. `freight_price`,
  195. `coupon_id`,
  196. `coupon_price`,
  197. `full_cut_price`,
  198. `order_type`,
  199. `activity_id`,
  200. `store_id`,
  201. `delivery_date`,
  202. `delivery_remark`,
  203. `predict_time`,
  204. `coupon_name`,
  205. `comment_count`,
  206. <if test="merchSn != null" >
  207. merch_sn,
  208. </if>
  209. <if test="merchOrderSn != null" >
  210. merch_order_sn,
  211. </if>
  212. <if test="isScan != null" >
  213. is_scan,
  214. </if>
  215. <if test="orderBizType != null" >
  216. order_biz_type,
  217. </if>
  218. <if test="payTransactionId != null" >
  219. pay_transaction_id,
  220. </if>
  221. <if test="payMobile != null" >
  222. pay_mobile,
  223. </if>
  224. <if test="buyerPayCheck != null" >
  225. buyer_pay_check,
  226. </if>
  227. <if test="payFlag != null" >
  228. pay_flag,
  229. </if>
  230. <if test="createrSn != null" >
  231. creater_sn,
  232. </if>
  233. <if test="createTime != null" >
  234. create_time,
  235. </if>
  236. <if test="moderSn != null" >
  237. moder_sn,
  238. </if>
  239. <if test="modTime != null" >
  240. mod_time
  241. </if>
  242. )
  243. values
  244. (
  245. #{order_sn},
  246. #{user_id},
  247. #{order_status},
  248. #{shipping_status},
  249. #{shipping_code},
  250. #{pay_status},
  251. #{consignee},
  252. #{country},
  253. #{province},
  254. #{city},
  255. #{district},
  256. #{address},
  257. #{address_id},
  258. #{mobile},
  259. #{postscript},
  260. #{pay_id},
  261. #{pay_name},
  262. #{shipping_fee},
  263. #{actual_price},
  264. #{integral},
  265. #{integral_money},
  266. #{order_price},
  267. #{goods_price},
  268. now(),
  269. #{confirm_time},
  270. #{pay_time},
  271. #{freight_price},
  272. #{coupon_id},
  273. #{coupon_price},
  274. #{full_cut_price},
  275. #{order_type},
  276. #{activity_id},
  277. #{store_id},
  278. #{delivery_date},
  279. #{delivery_remark},
  280. #{predict_time},
  281. #{coupon_name},
  282. #{comment_count},
  283. <if test="merchSn != null" >
  284. #{merchSn,jdbcType=VARCHAR},
  285. </if>
  286. <if test="merchOrderSn != null" >
  287. #{merchOrderSn,jdbcType=VARCHAR},
  288. </if>
  289. <if test="isScan != null" >
  290. #{isScan,jdbcType=VARCHAR},
  291. </if>
  292. <if test="orderBizType != null" >
  293. #{orderBizType,jdbcType=CHAR},
  294. </if>
  295. <if test="payTransactionId != null" >
  296. #{payTransactionId,jdbcType=VARCHAR},
  297. </if>
  298. <if test="payMobile != null" >
  299. #{payMobile,jdbcType=VARCHAR},
  300. </if>
  301. <if test="buyerPayCheck != null" >
  302. #{buyerPayCheck,jdbcType=VARCHAR},
  303. </if>
  304. <if test="payFlag != null" >
  305. #{payFlag,jdbcType=VARCHAR},
  306. </if>
  307. <if test="createrSn != null" >
  308. #{createrSn,jdbcType=VARCHAR},
  309. </if>
  310. <if test="createTime != null" >
  311. #{createTime,jdbcType=TIMESTAMP},
  312. </if>
  313. <if test="moderSn != null" >
  314. #{moderSn,jdbcType=VARCHAR},
  315. </if>
  316. <if test="modTime != null" >
  317. #{modTime,jdbcType=TIMESTAMP}
  318. </if>
  319. )
  320. </insert>
  321. <select id="queryObjectByIdList" resultMap="orderMap">
  322. select a.*
  323. from mall_order a
  324. where a.id in
  325. <foreach collection="orderIdList" item="orderId" open="(" close=")" separator=",">
  326. #{orderId}
  327. </foreach>
  328. </select>
  329. <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  330. insert into mall_order
  331. (
  332. `order_sn`,
  333. `user_id`,
  334. `order_status`,
  335. `shipping_status`,
  336. `shipping_code`,
  337. `pay_status`,
  338. `consignee`,
  339. `country`,
  340. `province`,
  341. `city`,
  342. `district`,
  343. `address`,
  344. `address_id`,
  345. `mobile`,
  346. `postscript`,
  347. `pay_id`,
  348. `pay_name`,
  349. `shipping_fee`,
  350. `actual_price`,
  351. `integral`,
  352. `integral_money`,
  353. `order_price`,
  354. `goods_price`,
  355. `add_time`,
  356. `confirm_time`,
  357. `pay_time`,
  358. `freight_price`,
  359. `coupon_id`,
  360. `coupon_price`,
  361. `full_cut_price`,
  362. `order_type`,
  363. `activity_id`,
  364. `store_id`,
  365. `delivery_date`,
  366. `delivery_remark`,
  367. `predict_time`,
  368. `coupon_name`,
  369. `comment_count`,
  370. merch_sn,
  371. merch_order_sn,
  372. is_scan,
  373. order_biz_type,
  374. pay_transaction_id,
  375. pay_mobile,
  376. create_time,
  377. mod_time
  378. )
  379. values
  380. <foreach collection="list" index="index" item="orderInfo" separator=",">
  381. (
  382. #{orderInfo.order_sn},
  383. #{orderInfo.user_id},
  384. #{orderInfo.order_status},
  385. #{orderInfo.shipping_status},
  386. #{orderInfo.shipping_code},
  387. #{orderInfo.pay_status},
  388. #{orderInfo.consignee},
  389. #{orderInfo.country},
  390. #{orderInfo.province},
  391. #{orderInfo.city},
  392. #{orderInfo.district},
  393. #{orderInfo.address},
  394. #{orderInfo.address_id},
  395. #{orderInfo.mobile},
  396. #{orderInfo.postscript},
  397. #{orderInfo.pay_id},
  398. #{orderInfo.pay_name},
  399. #{orderInfo.shipping_fee},
  400. #{orderInfo.actual_price},
  401. #{orderInfo.integral},
  402. #{orderInfo.integral_money},
  403. #{orderInfo.order_price},
  404. #{orderInfo.goods_price},
  405. now(),
  406. #{orderInfo.confirm_time},
  407. #{orderInfo.pay_time},
  408. #{orderInfo.freight_price},
  409. #{orderInfo.coupon_id},
  410. #{orderInfo.coupon_price},
  411. #{orderInfo.full_cut_price},
  412. #{orderInfo.order_type},
  413. #{orderInfo.activity_id},
  414. #{orderInfo.store_id},
  415. #{orderInfo.delivery_date},
  416. #{orderInfo.delivery_remark},
  417. #{orderInfo.predict_time},
  418. #{orderInfo.coupon_name},
  419. #{orderInfo.comment_count},
  420. #{orderInfo.merchSn,jdbcType=VARCHAR},
  421. #{orderInfo.merchOrderSn,jdbcType=VARCHAR},
  422. #{orderInfo.isScan,jdbcType=VARCHAR},
  423. #{orderInfo.orderBizType,jdbcType=CHAR},
  424. #{orderInfo.payTransactionId,jdbcType=VARCHAR},
  425. #{orderInfo.payMobile,jdbcType=VARCHAR},
  426. #{orderInfo.createTime,jdbcType=TIMESTAMP},
  427. #{orderInfo.modTime,jdbcType=TIMESTAMP}
  428. )
  429. </foreach>
  430. </insert>
  431. <update id="update" parameterType="com.kmall.api.entity.OrderVo">
  432. update mall_order
  433. <set>
  434. <if test="order_sn != null">`order_sn` = #{order_sn},</if>
  435. <if test="user_id != null">`user_id` = #{user_id},</if>
  436. <if test="order_status != null">`order_status` = #{order_status},</if>
  437. <if test="shipping_status != null">`shipping_status` = #{shipping_status},</if>
  438. <if test="shipping_code != null">`shipping_code` = #{shipping_code},</if>
  439. <if test="pay_status != null">`pay_status` = #{pay_status},</if>
  440. <if test="consignee != null">`consignee` = #{consignee},</if>
  441. <if test="country != null">`country` = #{country},</if>
  442. <if test="province != null">`province` = #{province},</if>
  443. <if test="city != null">`city` = #{city},</if>
  444. <if test="district != null">`district` = #{district},</if>
  445. <if test="address != null">`address` = #{address},</if>
  446. <if test="address_id != null">`address_id` = #{address_id},</if>
  447. <if test="mobile != null">`mobile` = #{mobile},</if>
  448. <if test="postscript != null">`postscript` = #{postscript},</if>
  449. <if test="shipping_id != null">`shipping_id` = #{shipping_id},</if>
  450. <if test="shipping_name != null">`shipping_name` = #{shipping_name},</if>
  451. <if test="shipping_fee != null">`shipping_fee` = #{shipping_fee},</if>
  452. <if test="shipping_no != null">`shipping_no` = #{shipping_no},</if>
  453. <if test="pay_id != null">`pay_id` = #{pay_id},</if>
  454. <if test="pay_name != null">`pay_name` = #{pay_name},</if>
  455. <if test="pay_time != null">`pay_time` = #{pay_time},</if>
  456. <if test="actual_price != null">`actual_price` = #{actual_price},</if>
  457. <if test="integral != null">`integral` = #{integral},</if>
  458. <if test="integral_money != null">`integral_money` = #{integral_money},</if>
  459. <if test="order_price != null">`order_price` = #{order_price},</if>
  460. <if test="goods_price != null">`goods_price` = #{goods_price},</if>
  461. <if test="confirm_time != null">`confirm_time` = #{confirm_time},</if>
  462. <if test="freight_price != null">`freight_price` = #{freight_price},</if>
  463. <if test="coupon_id != null">`coupon_id` = #{coupon_id},</if>
  464. <if test="coupon_price != null">`coupon_price` = #{coupon_price},</if>
  465. <if test="full_cut_price != null">`full_cut_price` = #{full_cut_price},</if>
  466. <if test="order_type != null">`order_type` = #{order_type},</if>
  467. <if test="activity_id != null">`activity_id` = #{activity_id},</if>
  468. <if test="store_id != null">`store_id` = #{store_id},</if>
  469. <if test="shipping_mobile != null">`shipping_mobile` = #{shipping_mobile},</if>
  470. <if test="delivery_date != null">`delivery_date` = #{delivery_date},</if>
  471. <if test="delivery_remark != null">`delivery_remark` = #{delivery_remark},</if>
  472. <if test="predict_time != null">`predict_time` = #{predict_time},</if>
  473. <if test="coupon_name != null">`coupon_name` = #{coupon_name},</if>
  474. <if test="comment_count != null">`comment_count` = #{comment_count},</if>
  475. <if test="merchSn != null" >
  476. merch_sn = #{merchSn,jdbcType=VARCHAR},
  477. </if>
  478. <if test="merchOrderSn != null" >
  479. merch_order_sn = #{merchOrderSn,jdbcType=VARCHAR},
  480. </if>
  481. <if test="isScan != null" >
  482. is_scan = #{isScan,jdbcType=VARCHAR},
  483. </if>
  484. <if test="orderBizType != null" >
  485. order_biz_type = #{orderBizType,jdbcType=CHAR},
  486. </if>
  487. <if test="payTransactionId != null" >
  488. pay_transaction_id = #{payTransactionId,jdbcType=VARCHAR},
  489. </if>
  490. <if test="payMobile != null" >
  491. pay_mobile = #{payMobile,jdbcType=VARCHAR},
  492. </if>
  493. <if test="buyerPayCheck != null" >
  494. buyer_pay_check = #{buyerPayCheck,jdbcType=VARCHAR},
  495. </if>
  496. <if test="payFlag != null" >
  497. pay_flag = #{payFlag,jdbcType=VARCHAR},
  498. </if>
  499. <if test="createrSn != null" >
  500. creater_sn = #{createrSn,jdbcType=VARCHAR},
  501. </if>
  502. <if test="createTime != null" >
  503. create_time = #{createTime,jdbcType=TIMESTAMP},
  504. </if>
  505. <if test="moderSn != null" >
  506. moder_sn = #{moderSn,jdbcType=VARCHAR},
  507. </if>
  508. <if test="modTime != null" >
  509. mod_time = #{modTime,jdbcType=TIMESTAMP},
  510. </if>
  511. </set>
  512. where id = #{id}
  513. </update>
  514. <update id="riderOrderUpdate" parameterType="com.kmall.api.entity.OrderVo">
  515. update mall_order
  516. <set>
  517. `order_status` = #{order_status},
  518. `shipping_status` = #{shipping_status},
  519. `shipping_code` = #{shipping_code},
  520. `shipping_id` = #{shipping_id},
  521. `shipping_name` = #{shipping_name},
  522. `shipping_fee` = #{shipping_fee},
  523. `shipping_no` = #{shipping_no},
  524. `shipping_mobile` = #{shipping_mobile}
  525. </set>
  526. where id = #{id}
  527. </update>
  528. <select id="queryUcenterMap" resultType="map">
  529. select count(a.id) as orders, sum(case a.order_status when 0 then 1 else 0 end ) as unPayNum, sum(case a.order_status when 300 then 1 else 0 end ) as unTakeNum
  530. ,sum(case a.order_status when 201 then 1 else 0 end ) as unPaymentNum, sum(case a.order_status when 301 then 1 else 0 end ) as unEvalNum
  531. from mall_order a
  532. left join mall_comment b on a.id = b.order_id
  533. where 1 = 1
  534. <if test="user_id != null">
  535. and a.user_id = #{user_id}
  536. </if>
  537. <if test="pay_status != null">
  538. and a.pay_status = #{pay_status}
  539. </if>
  540. <if test="shipping_status != null">
  541. and a.shipping_status = #{shipping_status}
  542. </if>
  543. <if test="evaluate_status != null and evaluate_status == 0 ">
  544. and not exists (select 1 from mall_comment m where a.id = m.order_id )
  545. </if>
  546. <if test="startDate!=null and startDate!=''">
  547. AND a.add_time >= #{startDate}
  548. </if>
  549. <if test="endDate!=null and endDate!=''">
  550. AND a.add_time <![CDATA[ < ]]> #{endDate}
  551. </if>
  552. <if test="shippingId!=null and shippingId!=''">
  553. AND a.shipping_id <![CDATA[ < ]]> #{shippingId}
  554. </if>
  555. </select>
  556. <select id="queryObjectByMerchOrderSn" resultMap="orderMap">
  557. select a.*
  558. from mall_order a
  559. where a.merch_order_sn = #{merchOrderSn}
  560. </select>
  561. </mapper>