ApiOrderMapper.xml 19 KB

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