1
0

ApiOrderMapper.xml 20 KB

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