1
0

ApiOrderMapper.xml 21 KB

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