ApiOrderMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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="order_type" column="order_type"/>
  42. <result property="activity_id" column="activity_id"/>
  43. <result property="store_id" column="store_id"/>
  44. <result property="delivery_date" column="delivery_date"/>
  45. <result property="delivery_remark" column="delivery_remark"/>
  46. <result property="predict_time" column="predict_time"/>
  47. <result property="latitude" column="latitude"/>
  48. <result property="longitude" column="longitude"/>
  49. <result property="comment_count" column="comment_count"/>
  50. <result property="full_cut_price" column="full_cut_price"/>
  51. <result property="campMinusId" column="camp_minus_id"/>
  52. <result property="campName" column="camp_name"/>
  53. <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
  54. <result column="order_biz_type" property="orderBizType" jdbcType="CHAR" />
  55. <result column="pay_transaction_id" property="payTransactionId" jdbcType="VARCHAR" />
  56. <result column="pay_mobile" property="payMobile" jdbcType="VARCHAR" />
  57. <result column="buyer_pay_check" property="buyerPayCheck" jdbcType="VARCHAR" />
  58. <result column="pay_flag" property="payFlag" jdbcType="VARCHAR" />
  59. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  60. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  61. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  62. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  63. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  64. <result column="merch_order_sn" property="merchOrderSn" jdbcType="VARCHAR" />
  65. <result column="is_scan" property="isScan" jdbcType="VARCHAR" />
  66. <result column="store_name" property="storeName" jdbcType="VARCHAR" />
  67. <result property="isRefundStatus" column="isRefundStatus"/>
  68. <result property="refundStatus" column="refund_status"/>
  69. <result property="approvalRemark" column="approval_remark"/>
  70. <result property="isMergePay" column="is_merge_pay"/>
  71. <result property="isOnfflineOrder" column="is_onffline_order"/>
  72. <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
  73. <result property="cashFee" column="cash_fee"/>
  74. <result property="cashFeeType" column="cash_fee_type"/>
  75. <result property="totalFee" column="total_fee"/>
  76. <result property="feeType" column="fee_type"/>
  77. <result property="rate" column="rate"/>
  78. </resultMap>
  79. <select id="queryObject" resultMap="orderMap">
  80. select a.*,b.latitude,b.longitude,m.apply_type 'applyType',t.apply_type 'discountApplyType'
  81. from mall_order a
  82. left join mall_address b on a.address_id = b.id
  83. left join mk_store_camp_minus m on a.activity_id = m.store_topic_id
  84. left join mk_store_ticket_discount t on a.activity_id = t.store_topic_id
  85. where a.id = #{value}
  86. </select>
  87. <select id="queryObjectByOrderSn" resultMap="orderMap">
  88. select a.*,b.latitude,b.longitude
  89. from mall_order a
  90. left join mall_address b on a.address_id = b.id
  91. where a.order_sn = #{order_sn}
  92. </select>
  93. <select id="queryList" resultMap="orderMap">
  94. select a.*,b.latitude,b.longitude,s.store_name,f.refund_status,f.approval_remark,m.merch_name
  95. from mall_order a
  96. left join mall_merch m on a.merch_sn = m.merch_sn
  97. left join mall_address b on a.address_id = b.id
  98. left join mall_store s on a.store_id = s.id
  99. left join mall_order_refund f on a.id = f.order_id
  100. <where>
  101. <if test="user_id != null">
  102. and a.user_id = #{user_id}
  103. </if>
  104. <if test="pay_status != null">
  105. and a.pay_status = #{pay_status}
  106. </if>
  107. <if test="shipping_status != null">
  108. and a.shipping_status = #{shipping_status}
  109. </if>
  110. <if test="order_status != null and order_status != 0">
  111. and a.order_status = #{order_status}
  112. </if>
  113. <if test="order_status == 0 ">
  114. and a.order_status in (0,100)
  115. </if>
  116. <if test="evaluate_status != null and evaluate_status != 0 ">
  117. and a.comment_count <![CDATA[ >= ]]> 1
  118. </if>
  119. <if test="evaluate_status != null and evaluate_status == 0 ">
  120. and a.comment_count <![CDATA[ < ]]> 1
  121. </if>
  122. <if test="startDate!=null and startDate!=''">
  123. AND a.add_time >= #{startDate}
  124. </if>
  125. <if test="endDate!=null and endDate!=''">
  126. AND a.add_time <![CDATA[ < ]]> #{endDate}
  127. </if>
  128. <if test="shippingId!=null and shippingId!=''">
  129. AND a.shipping_id = #{shippingId}
  130. </if>
  131. </where>
  132. <if test="order_status != 401">
  133. <choose>
  134. <when test="sidx != null and sidx.trim() != ''">
  135. order by ${sidx} ${order}
  136. </when>
  137. <otherwise>
  138. order by a.id desc
  139. </otherwise>
  140. </choose>
  141. </if>
  142. <if test="order_status == 401">
  143. order by f.refund_time desc
  144. </if>
  145. <if test="offset != null and limit != null">
  146. limit #{offset}, #{limit}
  147. </if>
  148. </select>
  149. <select id="queryTotal" resultType="int">
  150. select count(id) from mall_order a
  151. <where>
  152. <if test="user_id != null">
  153. and a.user_id = #{user_id}
  154. </if>
  155. <if test="pay_status != null">
  156. and a.pay_status = #{pay_status}
  157. </if>
  158. <if test="shipping_status != null">
  159. and a.shipping_status = #{shipping_status}
  160. </if>
  161. <if test="evaluate_status != null and evaluate_status != 0 ">
  162. and a.comment_count <![CDATA[ >= ]]> 1
  163. </if>
  164. <if test="evaluate_status != null and evaluate_status == 0 ">
  165. and a.comment_count <![CDATA[ < ]]> 1
  166. </if>
  167. <if test="startDate!=null and startDate!=''">
  168. AND a.add_time >= #{startDate}
  169. </if>
  170. <if test="endDate!=null and endDate!=''">
  171. AND a.add_time <![CDATA[ < ]]> #{endDate}
  172. </if>
  173. <if test="shippingId!=null and shippingId!=''">
  174. AND a.shipping_id = #{shippingId}
  175. </if>
  176. <if test="order_status != null">
  177. and a.order_status = #{order_status}
  178. </if>
  179. </where>
  180. </select>
  181. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  182. insert into mall_order
  183. (
  184. `order_sn`,
  185. `user_id`,
  186. `order_status`,
  187. `shipping_status`,
  188. `shipping_code`,
  189. `pay_status`,
  190. `consignee`,
  191. `country`,
  192. `province`,
  193. `city`,
  194. `district`,
  195. `address`,
  196. `address_id`,
  197. `mobile`,
  198. `postscript`,
  199. `pay_id`,
  200. `pay_name`,
  201. `shipping_fee`,
  202. `actual_price`,
  203. `cash_fee`,
  204. `cash_fee_type`,
  205. `total_fee`,
  206. `fee_type`,
  207. `rate`,
  208. `integral`,
  209. `integral_money`,
  210. `order_price`,
  211. `goods_price`,
  212. `add_time`,
  213. `confirm_time`,
  214. `pay_time`,
  215. `freight_price`,
  216. `coupon_id`,
  217. `coupon_price`,
  218. `full_cut_price`,
  219. camp_minus_id,
  220. camp_name,
  221. `order_type`,
  222. `activity_id`,
  223. `store_id`,
  224. `delivery_date`,
  225. `delivery_remark`,
  226. `predict_time`,
  227. `coupon_name`,
  228. `comment_count`,
  229. <if test="merchSn != null" >
  230. merch_sn,
  231. </if>
  232. <if test="merchOrderSn != null" >
  233. merch_order_sn,
  234. </if>
  235. <if test="isScan != null" >
  236. is_scan,
  237. </if>
  238. <if test="isMergePay != null" >
  239. is_merge_pay,
  240. </if>
  241. <if test="orderBizType != null" >
  242. order_biz_type,
  243. </if>
  244. <if test="payTransactionId != null" >
  245. pay_transaction_id,
  246. </if>
  247. <if test="payMobile != null" >
  248. pay_mobile,
  249. </if>
  250. <if test="buyerPayCheck != null" >
  251. buyer_pay_check,
  252. </if>
  253. <if test="isOnfflineOrder != null" >
  254. `is_onffline_order`,
  255. </if>
  256. <if test="payFlag != null" >
  257. pay_flag,
  258. </if>
  259. <if test="createrSn != null" >
  260. creater_sn,
  261. </if>
  262. <if test="createTime != null" >
  263. create_time,
  264. </if>
  265. <if test="moderSn != null" >
  266. moder_sn,
  267. </if>
  268. <if test="modTime != null" >
  269. mod_time
  270. </if>
  271. )
  272. values
  273. (
  274. #{order_sn},
  275. #{user_id},
  276. #{order_status},
  277. #{shipping_status},
  278. #{shipping_code},
  279. #{pay_status},
  280. #{consignee},
  281. #{country},
  282. #{province},
  283. #{city},
  284. #{district},
  285. #{address},
  286. #{address_id},
  287. #{mobile},
  288. #{postscript},
  289. #{pay_id},
  290. #{pay_name},
  291. #{shipping_fee},
  292. #{actual_price},
  293. #{cashFee},
  294. #{cashFeeType},
  295. #{totalFee},
  296. #{feeType},
  297. #{rate},
  298. #{integral},
  299. #{integral_money},
  300. #{order_price},
  301. #{goods_price},
  302. now(),
  303. #{confirm_time},
  304. #{pay_time},
  305. #{freight_price},
  306. #{coupon_id},
  307. #{coupon_price},
  308. #{full_cut_price},
  309. #{campMinusId},
  310. #{campName},
  311. #{order_type},
  312. #{activity_id},
  313. #{store_id},
  314. #{delivery_date},
  315. #{delivery_remark},
  316. #{predict_time},
  317. #{coupon_name},
  318. #{comment_count},
  319. <if test="merchSn != null" >
  320. #{merchSn},
  321. </if>
  322. <if test="merchOrderSn != null" >
  323. #{merchOrderSn},
  324. </if>
  325. <if test="isScan != null" >
  326. #{isScan},
  327. </if>
  328. <if test="isMergePay != null" >
  329. #{isMergePay},
  330. </if>
  331. <if test="orderBizType != null" >
  332. #{orderBizType,jdbcType=CHAR},
  333. </if>
  334. <if test="payTransactionId != null" >
  335. #{payTransactionId},
  336. </if>
  337. <if test="payMobile != null" >
  338. #{payMobile},
  339. </if>
  340. <if test="buyerPayCheck != null" >
  341. #{buyerPayCheck},
  342. </if>
  343. <if test="isOnfflineOrder != null" >
  344. #{isOnfflineOrder},
  345. </if>
  346. <if test="payFlag != null" >
  347. #{payFlag},
  348. </if>
  349. <if test="createrSn != null" >
  350. #{createrSn},
  351. </if>
  352. <if test="createTime != null" >
  353. #{createTime},
  354. </if>
  355. <if test="moderSn != null" >
  356. #{moderSn},
  357. </if>
  358. <if test="modTime != null" >
  359. #{modTime}
  360. </if>
  361. )
  362. </insert>
  363. <select id="queryObjectByIdList" resultMap="orderMap">
  364. select a.*
  365. from mall_order a
  366. where a.id in
  367. <foreach collection="orderIdList" item="orderId" open="(" close=")" separator=",">
  368. #{orderId}
  369. </foreach>
  370. </select>
  371. <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  372. insert into mall_order
  373. (
  374. `order_sn`,
  375. `user_id`,
  376. `order_status`,
  377. `shipping_status`,
  378. `shipping_code`,
  379. `pay_status`,
  380. `consignee`,
  381. `country`,
  382. `province`,
  383. `city`,
  384. `district`,
  385. `address`,
  386. `address_id`,
  387. `mobile`,
  388. `postscript`,
  389. `pay_id`,
  390. `pay_name`,
  391. `shipping_fee`,
  392. `actual_price`,
  393. `cash_fee`,
  394. `cash_fee_type`,
  395. `total_fee`,
  396. `fee_type`,
  397. `rate`,
  398. `integral`,
  399. `integral_money`,
  400. `order_price`,
  401. `goods_price`,
  402. `add_time`,
  403. `confirm_time`,
  404. `pay_time`,
  405. `freight_price`,
  406. `coupon_id`,
  407. `coupon_price`,
  408. `full_cut_price`,
  409. `camp_minus_id`,
  410. `camp_name`,
  411. `order_type`,
  412. `activity_id`,
  413. `store_id`,
  414. `delivery_date`,
  415. `delivery_remark`,
  416. `predict_time`,
  417. `coupon_name`,
  418. `comment_count`,
  419. merch_sn,
  420. merch_order_sn,
  421. is_scan,
  422. is_merge_pay,
  423. order_biz_type,
  424. `is_onffline_order`,
  425. pay_transaction_id,
  426. pay_mobile,
  427. create_time,
  428. mod_time
  429. )
  430. values
  431. <foreach collection="list" index="index" item="orderInfo" separator=",">
  432. (
  433. #{orderInfo.order_sn},
  434. #{orderInfo.user_id},
  435. #{orderInfo.order_status},
  436. #{orderInfo.shipping_status},
  437. #{orderInfo.shipping_code},
  438. #{orderInfo.pay_status},
  439. #{orderInfo.consignee},
  440. #{orderInfo.country},
  441. #{orderInfo.province},
  442. #{orderInfo.city},
  443. #{orderInfo.district},
  444. #{orderInfo.address},
  445. #{orderInfo.address_id},
  446. #{orderInfo.mobile},
  447. #{orderInfo.postscript},
  448. #{orderInfo.pay_id},
  449. #{orderInfo.pay_name},
  450. #{orderInfo.shipping_fee},
  451. #{orderInfo.actual_price},
  452. #{orderInfo.cashFee},
  453. #{orderInfo.cashFeeType},
  454. #{orderInfo.totalFee},
  455. #{orderInfo.feeType},
  456. #{orderInfo.rate},
  457. #{orderInfo.integral},
  458. #{orderInfo.integral_money},
  459. #{orderInfo.order_price},
  460. #{orderInfo.goods_price},
  461. now(),
  462. #{orderInfo.confirm_time},
  463. #{orderInfo.pay_time},
  464. #{orderInfo.freight_price},
  465. #{orderInfo.coupon_id},
  466. #{orderInfo.coupon_price},
  467. #{orderInfo.full_cut_price},
  468. #{orderInfo.campMinusId},
  469. #{orderInfo.campName},
  470. #{orderInfo.order_type},
  471. #{orderInfo.activity_id},
  472. #{orderInfo.store_id},
  473. #{orderInfo.delivery_date},
  474. #{orderInfo.delivery_remark},
  475. #{orderInfo.predict_time},
  476. #{orderInfo.coupon_name},
  477. #{orderInfo.comment_count},
  478. #{orderInfo.merchSn},
  479. #{orderInfo.merchOrderSn},
  480. #{orderInfo.isScan},
  481. #{orderInfo.isMergePay},
  482. #{orderInfo.orderBizType,jdbcType=CHAR},
  483. #{orderInfo.isOnfflineOrder},
  484. #{orderInfo.payTransactionId},
  485. #{orderInfo.payMobile},
  486. #{orderInfo.createTime},
  487. #{orderInfo.modTime}
  488. )
  489. </foreach>
  490. </insert>
  491. <update id="update" parameterType="com.kmall.api.entity.OrderVo">
  492. update mall_order
  493. <set>
  494. <if test="order_sn != null">`order_sn` = #{order_sn},</if>
  495. <if test="user_id != null">`user_id` = #{user_id},</if>
  496. <if test="order_status != null">`order_status` = #{order_status},</if>
  497. <if test="shipping_status != null">`shipping_status` = #{shipping_status},</if>
  498. <if test="shipping_code != null">`shipping_code` = #{shipping_code},</if>
  499. <if test="pay_status != null">`pay_status` = #{pay_status},</if>
  500. <if test="consignee != null">`consignee` = #{consignee},</if>
  501. <if test="country != null">`country` = #{country},</if>
  502. <if test="province != null">`province` = #{province},</if>
  503. <if test="city != null">`city` = #{city},</if>
  504. <if test="district != null">`district` = #{district},</if>
  505. <if test="address != null">`address` = #{address},</if>
  506. <if test="address_id != null">`address_id` = #{address_id},</if>
  507. <if test="mobile != null">`mobile` = #{mobile},</if>
  508. <if test="postscript != null">`postscript` = #{postscript},</if>
  509. <if test="shipping_id != null">`shipping_id` = #{shipping_id},</if>
  510. <if test="shipping_name != null">`shipping_name` = #{shipping_name},</if>
  511. <if test="shipping_fee != null">`shipping_fee` = #{shipping_fee},</if>
  512. <if test="shipping_no != null">`shipping_no` = #{shipping_no},</if>
  513. <if test="pay_id != null">`pay_id` = #{pay_id},</if>
  514. <if test="pay_name != null">`pay_name` = #{pay_name},</if>
  515. <if test="pay_time != null">`pay_time` = #{pay_time},</if>
  516. <if test="actual_price != null">`actual_price` = #{actual_price},</if>
  517. <if test="cashFee != null">`cash_fee` = #{cashFee}, </if>
  518. <if test="cashFeeType != null">`cash_fee_type` = #{cashFeeType}, </if>
  519. <if test="totalFee != null">`total_fee` = #{totalFee}, </if>
  520. <if test="feeType != null">`fee_type` = #{feeType}, </if>
  521. <if test="rate != null">`rate` = #{rate}, </if>
  522. <if test="integral != null">`integral` = #{integral},</if>
  523. <if test="integral_money != null">`integral_money` = #{integral_money},</if>
  524. <if test="order_price != null">`order_price` = #{order_price},</if>
  525. <if test="goods_price != null">`goods_price` = #{goods_price},</if>
  526. <if test="confirm_time != null">`confirm_time` = #{confirm_time},</if>
  527. <if test="freight_price != null">`freight_price` = #{freight_price},</if>
  528. <if test="coupon_id != null">`coupon_id` = #{coupon_id},</if>
  529. <if test="coupon_price != null">`coupon_price` = #{coupon_price},</if>
  530. <if test="full_cut_price != null">`full_cut_price` = #{full_cut_price},</if>
  531. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  532. <if test="campName != null">`camp_name` = #{campName},</if>
  533. <if test="order_type != null">`order_type` = #{order_type},</if>
  534. <if test="activity_id != null">`activity_id` = #{activity_id},</if>
  535. <if test="store_id != null">`store_id` = #{store_id},</if>
  536. <if test="shipping_mobile != null">`shipping_mobile` = #{shipping_mobile},</if>
  537. <if test="delivery_date != null">`delivery_date` = #{delivery_date},</if>
  538. <if test="delivery_remark != null">`delivery_remark` = #{delivery_remark},</if>
  539. <if test="predict_time != null">`predict_time` = #{predict_time},</if>
  540. <if test="coupon_name != null">`coupon_name` = #{coupon_name},</if>
  541. <if test="comment_count != null">`comment_count` = #{comment_count},</if>
  542. <if test="merchSn != null" >merch_sn = #{merchSn},</if>
  543. <if test="merchOrderSn != null" >merch_order_sn = #{merchOrderSn},</if>
  544. <if test="isScan != null" >is_scan = #{isScan},</if>
  545. <if test="isMergePay != null" >is_merge_pay = #{isMergePay},</if>
  546. <if test="orderBizType != null" >order_biz_type = #{orderBizType,jdbcType=CHAR},</if>
  547. <if test="payTransactionId != null" >pay_transaction_id = #{payTransactionId},</if>
  548. <if test="payMobile != null" >pay_mobile = #{payMobile},</if>
  549. <if test="buyerPayCheck != null" >buyer_pay_check = #{buyerPayCheck},</if>
  550. <if test="payFlag != null" >pay_flag = #{payFlag},</if>
  551. <if test="createrSn != null" >creater_sn = #{createrSn},</if>
  552. <if test="createTime != null" >create_time = #{createTime},</if>
  553. <if test="moderSn != null" >moder_sn = #{moderSn},</if>
  554. <if test="modTime != null" >mod_time = #{modTime},</if>
  555. </set>
  556. where id = #{id}
  557. </update>
  558. <update id="updateBatch" parameterType="java.util.List">
  559. <foreach collection="list" item="oderInfo" index="index" open="" close="" separator=";">
  560. update mall_order
  561. <set>
  562. <if test="oderInfo.order_sn != null">`order_sn` = #{oderInfo.order_sn},</if>
  563. <if test="oderInfo.user_id != null">`user_id` = #{oderInfo.user_id},</if>
  564. <if test="oderInfo.order_status != null">`order_status` = #{oderInfo.order_status},</if>
  565. <if test="oderInfo.shipping_status != null">`shipping_status` = #{oderInfo.shipping_status},</if>
  566. <if test="oderInfo.shipping_code != null">`shipping_code` = #{oderInfo.shipping_code},</if>
  567. <if test="oderInfo.pay_status != null">`pay_status` = #{oderInfo.pay_status},</if>
  568. <if test="oderInfo.consignee != null">`consignee` = #{oderInfo.consignee},</if>
  569. <if test="oderInfo.country != null">`country` = #{oderInfo.country},</if>
  570. <if test="oderInfo.province != null">`province` = #{oderInfo.province},</if>
  571. <if test="oderInfo.city != null">`city` = #{oderInfo.city},</if>
  572. <if test="oderInfo.district != null">`district` = #{oderInfo.district},</if>
  573. <if test="oderInfo.address != null">`address` = #{oderInfo.address},</if>
  574. <if test="oderInfo.address_id != null">`address_id` = #{oderInfo.address_id},</if>
  575. <if test="oderInfo.mobile != null">`mobile` = #{oderInfo.mobile},</if>
  576. <if test="oderInfo.postscript != null">`postscript` = #{oderInfo.postscript},</if>
  577. <if test="oderInfo.shipping_id != null">`shipping_id` = #{oderInfo.shipping_id},</if>
  578. <if test="oderInfo.shipping_name != null">`shipping_name` = #{oderInfo.shipping_name},</if>
  579. <if test="oderInfo.shipping_fee != null">`shipping_fee` = #{oderInfo.shipping_fee},</if>
  580. <if test="oderInfo.shipping_no != null">`shipping_no` = #{oderInfo.shipping_no},</if>
  581. <if test="oderInfo.pay_id != null">`pay_id` = #{oderInfo.pay_id},</if>
  582. <if test="oderInfo.pay_name != null">`pay_name` = #{oderInfo.pay_name},</if>
  583. <if test="oderInfo.pay_time != null">`pay_time` = #{oderInfo.pay_time},</if>
  584. <if test="oderInfo.actual_price != null">`actual_price` = #{oderInfo.actual_price},</if>
  585. <if test="oderInfo.integral != null">`integral` = #{oderInfo.integral},</if>
  586. <if test="oderInfo.integral_money != null">`integral_money` = #{oderInfo.integral_money},</if>
  587. <if test="oderInfo.order_price != null">`order_price` = #{oderInfo.order_price},</if>
  588. <if test="oderInfo.goods_price != null">`goods_price` = #{oderInfo.goods_price},</if>
  589. <if test="oderInfo.confirm_time != null">`confirm_time` = #{oderInfo.confirm_time},</if>
  590. <if test="oderInfo.freight_price != null">`freight_price` = #{oderInfo.freight_price},</if>
  591. <if test="oderInfo.coupon_id != null">`coupon_id` = #{oderInfo.coupon_id},</if>
  592. <if test="oderInfo.coupon_price != null">`coupon_price` = #{oderInfo.coupon_price},</if>
  593. <if test="oderInfo.full_cut_price != null">`full_cut_price` = #{oderInfo.full_cut_price},</if>
  594. <if test="oderInfo.campMinusId != null">`camp_minus_id` = #{oderInfo.campMinusId},</if>
  595. <if test="oderInfo.campName != null">`camp_name` = #{oderInfo.campName},</if>
  596. <if test="oderInfo.order_type != null">`order_type` = #{oderInfo.order_type},</if>
  597. <if test="oderInfo.activity_id != null">`activity_id` = #{oderInfo.activity_id},</if>
  598. <if test="oderInfo.store_id != null">`store_id` = #{oderInfo.store_id},</if>
  599. <if test="oderInfo.shipping_mobile != null">`shipping_mobile` = #{oderInfo.shipping_mobile},</if>
  600. <if test="oderInfo.delivery_date != null">`delivery_date` = #{oderInfo.delivery_date},</if>
  601. <if test="oderInfo.delivery_remark != null">`delivery_remark` = #{oderInfo.delivery_remark},</if>
  602. <if test="oderInfo.predict_time != null">`predict_time` = #{oderInfo.predict_time},</if>
  603. <if test="oderInfo.coupon_name != null">`coupon_name` = #{oderInfo.coupon_name},</if>
  604. <if test="oderInfo.comment_count != null">`comment_count` = #{oderInfo.comment_count},</if>
  605. <if test="oderInfo.merchSn != null" >merch_sn = #{oderInfo.merchSn},</if>
  606. <if test="oderInfo.merchOrderSn != null" >merch_order_sn = #{oderInfo.merchOrderSn},</if>
  607. <if test="oderInfo.isScan != null" >is_scan = #{oderInfo.isScan},</if>
  608. <if test="oderInfo.isMergePay != null" >is_merge_pay = #{oderInfo.isMergePay},</if>
  609. <if test="oderInfo.orderBizType != null" >order_biz_type = #{oderInfo.orderBizType},</if>
  610. <if test="oderInfo.payTransactionId != null" >pay_transaction_id = #{oderInfo.payTransactionId},</if>
  611. <if test="oderInfo.payMobile != null" >pay_mobile = #{oderInfo.payMobile},</if>
  612. <if test="oderInfo.buyerPayCheck != null" >buyer_pay_check = #{oderInfo.buyerPayCheck},</if>
  613. <if test="oderInfo.payFlag != null" >pay_flag = #{oderInfo.payFlag},</if>
  614. <if test="oderInfo.createrSn != null" >creater_sn = #{oderInfo.createrSn},</if>
  615. <if test="oderInfo.createTime != null" >create_time = #{oderInfo.createTime},</if>
  616. <if test="oderInfo.moderSn != null" >moder_sn = #{oderInfo.moderSn},</if>
  617. <if test="oderInfo.modTime != null" >mod_time = #{oderInfo.modTime},</if>
  618. </set>
  619. where id = #{oderInfo.id}
  620. </foreach>
  621. </update>
  622. <update id="riderOrderUpdate" parameterType="com.kmall.api.entity.OrderVo">
  623. update mall_order
  624. <set>
  625. `order_status` = #{order_status},
  626. `shipping_status` = #{shipping_status},
  627. `shipping_code` = #{shipping_code},
  628. `shipping_id` = #{shipping_id},
  629. `shipping_name` = #{shipping_name},
  630. `shipping_fee` = #{shipping_fee},
  631. `shipping_no` = #{shipping_no},
  632. `shipping_mobile` = #{shipping_mobile}
  633. </set>
  634. where id = #{id}
  635. </update>
  636. <update id="updateOrderByMerchOrderSn" parameterType="com.kmall.api.entity.OrderVo">
  637. update mall_order
  638. <set>
  639. <if test="order_sn != null">`order_sn` = #{order_sn},</if>
  640. <if test="user_id != null">`user_id` = #{user_id},</if>
  641. <if test="order_status != null">`order_status` = #{order_status},</if>
  642. <if test="shipping_status != null">`shipping_status` = #{shipping_status},</if>
  643. <if test="shipping_code != null">`shipping_code` = #{shipping_code},</if>
  644. <if test="pay_status != null">`pay_status` = #{pay_status},</if>
  645. <if test="consignee != null">`consignee` = #{consignee},</if>
  646. <if test="country != null">`country` = #{country},</if>
  647. <if test="province != null">`province` = #{province},</if>
  648. <if test="city != null">`city` = #{city},</if>
  649. <if test="district != null">`district` = #{district},</if>
  650. <if test="address != null">`address` = #{address},</if>
  651. <if test="address_id != null">`address_id` = #{address_id},</if>
  652. <if test="mobile != null">`mobile` = #{mobile},</if>
  653. <if test="postscript != null">`postscript` = #{postscript},</if>
  654. <if test="shipping_id != null">`shipping_id` = #{shipping_id},</if>
  655. <if test="shipping_name != null">`shipping_name` = #{shipping_name},</if>
  656. <if test="shipping_fee != null">`shipping_fee` = #{shipping_fee},</if>
  657. <if test="shipping_no != null">`shipping_no` = #{shipping_no},</if>
  658. <if test="pay_id != null">`pay_id` = #{pay_id},</if>
  659. <if test="pay_name != null">`pay_name` = #{pay_name},</if>
  660. <if test="pay_time != null">`pay_time` = #{pay_time},</if>
  661. <if test="actual_price != null">`actual_price` = #{actual_price},</if>
  662. <if test="integral != null">`integral` = #{integral},</if>
  663. <if test="integral_money != null">`integral_money` = #{integral_money},</if>
  664. <if test="order_price != null">`order_price` = #{order_price},</if>
  665. <if test="goods_price != null">`goods_price` = #{goods_price},</if>
  666. <if test="confirm_time != null">`confirm_time` = #{confirm_time},</if>
  667. <if test="freight_price != null">`freight_price` = #{freight_price},</if>
  668. <if test="coupon_id != null">`coupon_id` = #{coupon_id},</if>
  669. <if test="coupon_price != null">`coupon_price` = #{coupon_price},</if>
  670. <if test="full_cut_price != null">`full_cut_price` = #{full_cut_price},</if>
  671. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  672. <if test="campName != null">`camp_name` = #{campName},</if>
  673. <if test="order_type != null">`order_type` = #{order_type},</if>
  674. <if test="activity_id != null">`activity_id` = #{activity_id},</if>
  675. <if test="store_id != null">`store_id` = #{store_id},</if>
  676. <if test="shipping_mobile != null">`shipping_mobile` = #{shipping_mobile},</if>
  677. <if test="delivery_date != null">`delivery_date` = #{delivery_date},</if>
  678. <if test="delivery_remark != null">`delivery_remark` = #{delivery_remark},</if>
  679. <if test="predict_time != null">`predict_time` = #{predict_time},</if>
  680. <if test="coupon_name != null">`coupon_name` = #{coupon_name},</if>
  681. <if test="comment_count != null">`comment_count` = #{comment_count},</if>
  682. <if test="merchSn != null" >merch_sn = #{merchSn},</if>
  683. <if test="isScan != null" >is_scan = #{isScan},</if>
  684. <if test="isMergePay != null" >is_merge_pay = #{isMergePay},</if>
  685. <if test="orderBizType != null" >order_biz_type = #{orderBizType,jdbcType=CHAR},</if>
  686. <if test="payTransactionId != null" >pay_transaction_id = #{payTransactionId},</if>
  687. <if test="payMobile != null" >pay_mobile = #{payMobile},</if>
  688. <if test="buyerPayCheck != null" >buyer_pay_check = #{buyerPayCheck},</if>
  689. <if test="payFlag != null" >pay_flag = #{payFlag},</if>
  690. <if test="createrSn != null" >creater_sn = #{createrSn},</if>
  691. <if test="createTime != null" >create_time = #{createTime},</if>
  692. <if test="moderSn != null" >moder_sn = #{moderSn},</if>
  693. <if test="modTime != null" >mod_time = #{modTime},</if>
  694. </set>
  695. where merch_order_sn = #{merchOrderSn}
  696. </update>
  697. <select id="queryUcenterMap" resultType="map">
  698. 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
  699. ,sum(case a.order_status when 201 then 1 else 0 end ) as unPaymentNum,
  700. sum(case a.order_status when 301 then 1 else 0 end and case a.comment_count when 0 then 1 else 0 end ) as unEvalNum
  701. from mall_order a
  702. left join mall_comment b on a.id = b.order_id
  703. where 1 = 1
  704. <if test="user_id != null">
  705. and a.user_id = #{user_id}
  706. </if>
  707. <if test="pay_status != null">
  708. and a.pay_status = #{pay_status}
  709. </if>
  710. <if test="shipping_status != null">
  711. and a.shipping_status = #{shipping_status}
  712. </if>
  713. <if test="evaluate_status != null and evaluate_status == 0 ">
  714. and not exists (select 1 from mall_comment m where a.id = m.order_id )
  715. </if>
  716. <if test="startDate!=null and startDate!=''">
  717. AND a.add_time >= #{startDate}
  718. </if>
  719. <if test="endDate!=null and endDate!=''">
  720. AND a.add_time <![CDATA[ < ]]> #{endDate}
  721. </if>
  722. <if test="shippingId!=null and shippingId!=''">
  723. AND a.shipping_id <![CDATA[ < ]]> #{shippingId}
  724. </if>
  725. </select>
  726. <select id="queryObjectByMerchOrderSn" resultMap="orderMap">
  727. select a.*
  728. from mall_order a
  729. where a.merch_order_sn = #{merchOrderSn}
  730. </select>
  731. <select id="queryCountByMerchOrderSn" resultType="java.lang.Integer">
  732. select count(*)
  733. from mall_order a
  734. where a.merch_order_sn = #{merchOrderSn}
  735. </select>
  736. <select id="queryOrderByMerchOrderSnAndRefundStatus" resultMap="orderMap">
  737. select * from mall_order o inner join mall_order_refund r on r.order_id = o.id where o.merch_order_sn = #{merchOrderSn}
  738. and r.refund_status = 2
  739. </select>
  740. <select id="querySubmitNumByStoreTopicId" resultType="com.kmall.api.entity.OrderVo">
  741. SELECT
  742. cc.user_id
  743. FROM
  744. mall_user_coupon cc
  745. LEFT JOIN mall_store_topic s ON cc.store_topic_id = s.id
  746. LEFT JOIN mall_order a ON a.coupon_id = cc.id
  747. where s.id = #{storeTopicId}
  748. GROUP BY cc.user_id
  749. </select>
  750. <select id="querySubmitOrderNumByStoreTopicId" resultType="java.lang.Integer">
  751. SELECT COUNT(*)
  752. FROM
  753. mall_order
  754. WHERE
  755. activity_id = #{storeTopicId}
  756. </select>
  757. <select id="queryTopicNumByTopicIdAndUserId" resultType="java.lang.Integer">
  758. SELECT COUNT(*)
  759. FROM
  760. mall_order
  761. WHERE
  762. activity_id = #{storeTopicId} and user_id = #{userId}
  763. AND order_status != '101'
  764. </select>
  765. </mapper>