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