1
0

ApiOrderMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.api.dao.ApiOrderMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.OrderVo" id="orderMap">
  6. <result property="id" column="id"/>
  7. <result property="order_sn" column="order_sn"/>
  8. <result property="user_id" column="user_id"/>
  9. <result property="order_status" column="order_status"/>
  10. <result property="shipping_status" column="shipping_status"/>
  11. <result property="pay_status" column="pay_status"/>
  12. <result property="consignee" column="consignee"/>
  13. <result property="country" column="country"/>
  14. <result property="province" column="province"/>
  15. <result property="city" column="city"/>
  16. <result property="district" column="district"/>
  17. <result property="address" column="address"/>
  18. <result property="address_id" column="address_id"/>
  19. <result property="mobile" column="mobile"/>
  20. <result property="postscript" column="postscript"/>
  21. <result property="shipping_id" column="shipping_id"/>
  22. <result property="shipping_name" column="shipping_name"/>
  23. <result property="shipping_mobile" column="shipping_mobile"/>
  24. <result property="shipping_fee" column="shipping_fee"/>
  25. <result property="shipping_no" column="shipping_no"/>
  26. <result property="shipping_code" column="shipping_code"/>
  27. <result property="pay_id" column="pay_id"/>
  28. <result property="pay_name" column="pay_name"/>
  29. <result property="actual_price" column="actual_price"/>
  30. <result property="integral" column="integral"/>
  31. <result property="integral_money" column="integral_money"/>
  32. <result property="order_price" column="order_price"/>
  33. <result property="goods_price" column="goods_price"/>
  34. <result property="add_time" column="add_time"/>
  35. <result property="confirm_time" column="confirm_time"/>
  36. <result property="pay_time" column="pay_time"/>
  37. <result property="freight_price" column="freight_price"/>
  38. <result property="coupon_id" column="coupon_id"/>
  39. <result property="coupon_name" column="coupon_name"/>
  40. <result property="coupon_price" column="coupon_price"/>
  41. <result property="full_cut_price" column="full_cut_price"/>
  42. <result property="order_type" column="order_type"/>
  43. <result property="activity_id" column="activity_id"/>
  44. <result property="store_id" column="store_id"/>
  45. <result property="delivery_date" column="delivery_date"/>
  46. <result property="delivery_remark" column="delivery_remark"/>
  47. <result property="predict_time" column="predict_time"/>
  48. <result property="latitude" column="latitude"/>
  49. <result property="longitude" column="longitude"/>
  50. <result property="comment_count" column="comment_count"/>
  51. <result column="merch_sn" property="merchSn" jdbcType="VARCHAR" />
  52. <result column="order_biz_type" property="orderBizType" jdbcType="CHAR" />
  53. <result column="pay_transaction_id" property="payTransactionId" jdbcType="VARCHAR" />
  54. <result column="pay_mobile" property="payMobile" jdbcType="VARCHAR" />
  55. <result column="buyer_pay_check" property="buyerPayCheck" jdbcType="VARCHAR" />
  56. <result column="pay_flag" property="payFlag" jdbcType="VARCHAR" />
  57. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  58. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  59. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  60. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  61. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  62. <result column="merch_order_sn" property="merchOrderSn" jdbcType="VARCHAR" />
  63. <result column="is_scan" property="isScan" jdbcType="VARCHAR" />
  64. <result column="store_name" property="storeName" jdbcType="VARCHAR" />
  65. <result property="isRefundStatus" column="isRefundStatus"/>
  66. <result property="refundStatus" column="refund_status"/>
  67. <result property="approvalRemark" column="approval_remark"/>
  68. <result property="isMergePay" column="is_merge_pay"/>
  69. <result property="isOnfflineOrder" column="is_onffline_order"/>
  70. <result column="merch_name" property="merchName" jdbcType="VARCHAR" />
  71. </resultMap>
  72. <select id="queryObject" resultMap="orderMap">
  73. select a.*,b.latitude,b.longitude
  74. from mall_order a
  75. left join mall_address b on a.address_id = b.id
  76. where a.id = #{value}
  77. </select>
  78. <select id="queryObjectByOrderSn" resultMap="orderMap">
  79. select a.*,b.latitude,b.longitude
  80. from mall_order a
  81. left join mall_address b on a.address_id = b.id
  82. where a.order_sn = #{order_sn}
  83. </select>
  84. <select id="queryList" resultMap="orderMap">
  85. select a.*,b.latitude,b.longitude,s.store_name,f.refund_status,f.approval_remark,m.merch_name
  86. from mall_order a
  87. left join mall_merch m on a.merch_sn = m.merch_sn
  88. left join mall_address b on a.address_id = b.id
  89. left join mall_store s on a.store_id = s.id
  90. left join mall_order_refund f on a.id = f.order_id
  91. <where>
  92. <if test="user_id != null">
  93. and a.user_id = #{user_id}
  94. </if>
  95. <if test="pay_status != null">
  96. and a.pay_status = #{pay_status}
  97. </if>
  98. <if test="shipping_status != null">
  99. and a.shipping_status = #{shipping_status}
  100. </if>
  101. <if test="order_status != null and order_status != 0">
  102. and a.order_status = #{order_status}
  103. </if>
  104. <if test="order_status == 0 ">
  105. and a.order_status in (0,100)
  106. </if>
  107. <if test="evaluate_status != null and evaluate_status != 0 ">
  108. and a.comment_count <![CDATA[ >= ]]> 1
  109. </if>
  110. <if test="evaluate_status != null and evaluate_status == 0 ">
  111. and a.comment_count <![CDATA[ < ]]> 1
  112. </if>
  113. <if test="startDate!=null and startDate!=''">
  114. AND a.add_time >= #{startDate}
  115. </if>
  116. <if test="endDate!=null and endDate!=''">
  117. AND a.add_time <![CDATA[ < ]]> #{endDate}
  118. </if>
  119. <if test="shippingId!=null and shippingId!=''">
  120. AND a.shipping_id = #{shippingId}
  121. </if>
  122. </where>
  123. <if test="order_status != 401">
  124. <choose>
  125. <when test="sidx != null and sidx.trim() != ''">
  126. order by ${sidx} ${order}
  127. </when>
  128. <otherwise>
  129. order by a.id desc
  130. </otherwise>
  131. </choose>
  132. </if>
  133. <if test="order_status == 401">
  134. order by f.refund_time desc
  135. </if>
  136. <if test="offset != null and limit != null">
  137. limit #{offset}, #{limit}
  138. </if>
  139. </select>
  140. <select id="queryTotal" resultType="int">
  141. select count(id) from mall_order a
  142. <where>
  143. <if test="user_id != null">
  144. and a.user_id = #{user_id}
  145. </if>
  146. <if test="pay_status != null">
  147. and a.pay_status = #{pay_status}
  148. </if>
  149. <if test="shipping_status != null">
  150. and a.shipping_status = #{shipping_status}
  151. </if>
  152. <if test="evaluate_status != null and evaluate_status != 0 ">
  153. and a.comment_count <![CDATA[ >= ]]> 1
  154. </if>
  155. <if test="evaluate_status != null and evaluate_status == 0 ">
  156. and a.comment_count <![CDATA[ < ]]> 1
  157. </if>
  158. <if test="startDate!=null and startDate!=''">
  159. AND a.add_time >= #{startDate}
  160. </if>
  161. <if test="endDate!=null and endDate!=''">
  162. AND a.add_time <![CDATA[ < ]]> #{endDate}
  163. </if>
  164. <if test="shippingId!=null and shippingId!=''">
  165. AND a.shipping_id = #{shippingId}
  166. </if>
  167. <if test="order_status != null">
  168. and a.order_status = #{order_status}
  169. </if>
  170. </where>
  171. </select>
  172. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  173. insert into mall_order
  174. (
  175. `order_sn`,
  176. `user_id`,
  177. `order_status`,
  178. `shipping_status`,
  179. `shipping_code`,
  180. `pay_status`,
  181. `consignee`,
  182. `country`,
  183. `province`,
  184. `city`,
  185. `district`,
  186. `address`,
  187. `address_id`,
  188. `mobile`,
  189. `postscript`,
  190. `pay_id`,
  191. `pay_name`,
  192. `shipping_fee`,
  193. `actual_price`,
  194. `integral`,
  195. `integral_money`,
  196. `order_price`,
  197. `goods_price`,
  198. `add_time`,
  199. `confirm_time`,
  200. `pay_time`,
  201. `freight_price`,
  202. `coupon_id`,
  203. `coupon_price`,
  204. `full_cut_price`,
  205. `order_type`,
  206. `activity_id`,
  207. `store_id`,
  208. `delivery_date`,
  209. `delivery_remark`,
  210. `predict_time`,
  211. `coupon_name`,
  212. `comment_count`,
  213. <if test="merchSn != null" >
  214. merch_sn,
  215. </if>
  216. <if test="merchOrderSn != null" >
  217. merch_order_sn,
  218. </if>
  219. <if test="isScan != null" >
  220. is_scan,
  221. </if>
  222. <if test="isMergePay != null" >
  223. is_merge_pay,
  224. </if>
  225. <if test="orderBizType != null" >
  226. order_biz_type,
  227. </if>
  228. <if test="payTransactionId != null" >
  229. pay_transaction_id,
  230. </if>
  231. <if test="payMobile != null" >
  232. pay_mobile,
  233. </if>
  234. <if test="buyerPayCheck != null" >
  235. buyer_pay_check,
  236. </if>
  237. <if test="isOnfflineOrder != null" >
  238. `is_onffline_order`,
  239. </if>
  240. <if test="payFlag != null" >
  241. pay_flag,
  242. </if>
  243. <if test="createrSn != null" >
  244. creater_sn,
  245. </if>
  246. <if test="createTime != null" >
  247. create_time,
  248. </if>
  249. <if test="moderSn != null" >
  250. moder_sn,
  251. </if>
  252. <if test="modTime != null" >
  253. mod_time
  254. </if>
  255. )
  256. values
  257. (
  258. #{order_sn},
  259. #{user_id},
  260. #{order_status},
  261. #{shipping_status},
  262. #{shipping_code},
  263. #{pay_status},
  264. #{consignee},
  265. #{country},
  266. #{province},
  267. #{city},
  268. #{district},
  269. #{address},
  270. #{address_id},
  271. #{mobile},
  272. #{postscript},
  273. #{pay_id},
  274. #{pay_name},
  275. #{shipping_fee},
  276. #{actual_price},
  277. #{integral},
  278. #{integral_money},
  279. #{order_price},
  280. #{goods_price},
  281. now(),
  282. #{confirm_time},
  283. #{pay_time},
  284. #{freight_price},
  285. #{coupon_id},
  286. #{coupon_price},
  287. #{full_cut_price},
  288. #{order_type},
  289. #{activity_id},
  290. #{store_id},
  291. #{delivery_date},
  292. #{delivery_remark},
  293. #{predict_time},
  294. #{coupon_name},
  295. #{comment_count},
  296. <if test="merchSn != null" >
  297. #{merchSn,jdbcType=VARCHAR},
  298. </if>
  299. <if test="merchOrderSn != null" >
  300. #{merchOrderSn,jdbcType=VARCHAR},
  301. </if>
  302. <if test="isScan != null" >
  303. #{isScan,jdbcType=VARCHAR},
  304. </if>
  305. <if test="isMergePay != null" >
  306. #{isMergePay},
  307. </if>
  308. <if test="orderBizType != null" >
  309. #{orderBizType,jdbcType=CHAR},
  310. </if>
  311. <if test="payTransactionId != null" >
  312. #{payTransactionId,jdbcType=VARCHAR},
  313. </if>
  314. <if test="payMobile != null" >
  315. #{payMobile,jdbcType=VARCHAR},
  316. </if>
  317. <if test="buyerPayCheck != null" >
  318. #{buyerPayCheck,jdbcType=VARCHAR},
  319. </if>
  320. <if test="isOnfflineOrder != null" >
  321. #{isOnfflineOrder,jdbcType=VARCHAR},
  322. </if>
  323. <if test="payFlag != null" >
  324. #{payFlag,jdbcType=VARCHAR},
  325. </if>
  326. <if test="createrSn != null" >
  327. #{createrSn,jdbcType=VARCHAR},
  328. </if>
  329. <if test="createTime != null" >
  330. #{createTime,jdbcType=TIMESTAMP},
  331. </if>
  332. <if test="moderSn != null" >
  333. #{moderSn,jdbcType=VARCHAR},
  334. </if>
  335. <if test="modTime != null" >
  336. #{modTime,jdbcType=TIMESTAMP}
  337. </if>
  338. )
  339. </insert>
  340. <select id="queryObjectByIdList" resultMap="orderMap">
  341. select a.*
  342. from mall_order a
  343. where a.id in
  344. <foreach collection="orderIdList" item="orderId" open="(" close=")" separator=",">
  345. #{orderId}
  346. </foreach>
  347. </select>
  348. <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  349. insert into mall_order
  350. (
  351. `order_sn`,
  352. `user_id`,
  353. `order_status`,
  354. `shipping_status`,
  355. `shipping_code`,
  356. `pay_status`,
  357. `consignee`,
  358. `country`,
  359. `province`,
  360. `city`,
  361. `district`,
  362. `address`,
  363. `address_id`,
  364. `mobile`,
  365. `postscript`,
  366. `pay_id`,
  367. `pay_name`,
  368. `shipping_fee`,
  369. `actual_price`,
  370. `integral`,
  371. `integral_money`,
  372. `order_price`,
  373. `goods_price`,
  374. `add_time`,
  375. `confirm_time`,
  376. `pay_time`,
  377. `freight_price`,
  378. `coupon_id`,
  379. `coupon_price`,
  380. `full_cut_price`,
  381. `order_type`,
  382. `activity_id`,
  383. `store_id`,
  384. `delivery_date`,
  385. `delivery_remark`,
  386. `predict_time`,
  387. `coupon_name`,
  388. `comment_count`,
  389. merch_sn,
  390. merch_order_sn,
  391. is_scan,
  392. is_merge_pay,
  393. order_biz_type,
  394. `is_onffline_order`,
  395. pay_transaction_id,
  396. pay_mobile,
  397. create_time,
  398. mod_time
  399. )
  400. values
  401. <foreach collection="list" index="index" item="orderInfo" separator=",">
  402. (
  403. #{orderInfo.order_sn},
  404. #{orderInfo.user_id},
  405. #{orderInfo.order_status},
  406. #{orderInfo.shipping_status},
  407. #{orderInfo.shipping_code},
  408. #{orderInfo.pay_status},
  409. #{orderInfo.consignee},
  410. #{orderInfo.country},
  411. #{orderInfo.province},
  412. #{orderInfo.city},
  413. #{orderInfo.district},
  414. #{orderInfo.address},
  415. #{orderInfo.address_id},
  416. #{orderInfo.mobile},
  417. #{orderInfo.postscript},
  418. #{orderInfo.pay_id},
  419. #{orderInfo.pay_name},
  420. #{orderInfo.shipping_fee},
  421. #{orderInfo.actual_price},
  422. #{orderInfo.integral},
  423. #{orderInfo.integral_money},
  424. #{orderInfo.order_price},
  425. #{orderInfo.goods_price},
  426. now(),
  427. #{orderInfo.confirm_time},
  428. #{orderInfo.pay_time},
  429. #{orderInfo.freight_price},
  430. #{orderInfo.coupon_id},
  431. #{orderInfo.coupon_price},
  432. #{orderInfo.full_cut_price},
  433. #{orderInfo.order_type},
  434. #{orderInfo.activity_id},
  435. #{orderInfo.store_id},
  436. #{orderInfo.delivery_date},
  437. #{orderInfo.delivery_remark},
  438. #{orderInfo.predict_time},
  439. #{orderInfo.coupon_name},
  440. #{orderInfo.comment_count},
  441. #{orderInfo.merchSn,jdbcType=VARCHAR},
  442. #{orderInfo.merchOrderSn,jdbcType=VARCHAR},
  443. #{orderInfo.isScan,jdbcType=VARCHAR},
  444. #{orderInfo.isMergePay},
  445. #{orderInfo.orderBizType,jdbcType=CHAR},
  446. #{orderInfo.isOnfflineOrder},
  447. #{orderInfo.payTransactionId,jdbcType=VARCHAR},
  448. #{orderInfo.payMobile,jdbcType=VARCHAR},
  449. #{orderInfo.createTime,jdbcType=TIMESTAMP},
  450. #{orderInfo.modTime,jdbcType=TIMESTAMP}
  451. )
  452. </foreach>
  453. </insert>
  454. <update id="update" parameterType="com.kmall.api.entity.OrderVo">
  455. update mall_order
  456. <set>
  457. <if test="order_sn != null">`order_sn` = #{order_sn},</if>
  458. <if test="user_id != null">`user_id` = #{user_id},</if>
  459. <if test="order_status != null">`order_status` = #{order_status},</if>
  460. <if test="shipping_status != null">`shipping_status` = #{shipping_status},</if>
  461. <if test="shipping_code != null">`shipping_code` = #{shipping_code},</if>
  462. <if test="pay_status != null">`pay_status` = #{pay_status},</if>
  463. <if test="consignee != null">`consignee` = #{consignee},</if>
  464. <if test="country != null">`country` = #{country},</if>
  465. <if test="province != null">`province` = #{province},</if>
  466. <if test="city != null">`city` = #{city},</if>
  467. <if test="district != null">`district` = #{district},</if>
  468. <if test="address != null">`address` = #{address},</if>
  469. <if test="address_id != null">`address_id` = #{address_id},</if>
  470. <if test="mobile != null">`mobile` = #{mobile},</if>
  471. <if test="postscript != null">`postscript` = #{postscript},</if>
  472. <if test="shipping_id != null">`shipping_id` = #{shipping_id},</if>
  473. <if test="shipping_name != null">`shipping_name` = #{shipping_name},</if>
  474. <if test="shipping_fee != null">`shipping_fee` = #{shipping_fee},</if>
  475. <if test="shipping_no != null">`shipping_no` = #{shipping_no},</if>
  476. <if test="pay_id != null">`pay_id` = #{pay_id},</if>
  477. <if test="pay_name != null">`pay_name` = #{pay_name},</if>
  478. <if test="pay_time != null">`pay_time` = #{pay_time},</if>
  479. <if test="actual_price != null">`actual_price` = #{actual_price},</if>
  480. <if test="integral != null">`integral` = #{integral},</if>
  481. <if test="integral_money != null">`integral_money` = #{integral_money},</if>
  482. <if test="order_price != null">`order_price` = #{order_price},</if>
  483. <if test="goods_price != null">`goods_price` = #{goods_price},</if>
  484. <if test="confirm_time != null">`confirm_time` = #{confirm_time},</if>
  485. <if test="freight_price != null">`freight_price` = #{freight_price},</if>
  486. <if test="coupon_id != null">`coupon_id` = #{coupon_id},</if>
  487. <if test="coupon_price != null">`coupon_price` = #{coupon_price},</if>
  488. <if test="full_cut_price != null">`full_cut_price` = #{full_cut_price},</if>
  489. <if test="order_type != null">`order_type` = #{order_type},</if>
  490. <if test="activity_id != null">`activity_id` = #{activity_id},</if>
  491. <if test="store_id != null">`store_id` = #{store_id},</if>
  492. <if test="shipping_mobile != null">`shipping_mobile` = #{shipping_mobile},</if>
  493. <if test="delivery_date != null">`delivery_date` = #{delivery_date},</if>
  494. <if test="delivery_remark != null">`delivery_remark` = #{delivery_remark},</if>
  495. <if test="predict_time != null">`predict_time` = #{predict_time},</if>
  496. <if test="coupon_name != null">`coupon_name` = #{coupon_name},</if>
  497. <if test="comment_count != null">`comment_count` = #{comment_count},</if>
  498. <if test="merchSn != null" >
  499. merch_sn = #{merchSn,jdbcType=VARCHAR},
  500. </if>
  501. <if test="merchOrderSn != null" >
  502. merch_order_sn = #{merchOrderSn,jdbcType=VARCHAR},
  503. </if>
  504. <if test="isScan != null" >
  505. is_scan = #{isScan,jdbcType=VARCHAR},
  506. </if>
  507. <if test="isMergePay != null" >
  508. is_merge_pay = #{isMergePay},
  509. </if>
  510. <if test="orderBizType != null" >
  511. order_biz_type = #{orderBizType,jdbcType=CHAR},
  512. </if>
  513. <if test="payTransactionId != null" >
  514. pay_transaction_id = #{payTransactionId,jdbcType=VARCHAR},
  515. </if>
  516. <if test="payMobile != null" >
  517. pay_mobile = #{payMobile,jdbcType=VARCHAR},
  518. </if>
  519. <if test="buyerPayCheck != null" >
  520. buyer_pay_check = #{buyerPayCheck,jdbcType=VARCHAR},
  521. </if>
  522. <if test="payFlag != null" >
  523. pay_flag = #{payFlag,jdbcType=VARCHAR},
  524. </if>
  525. <if test="createrSn != null" >
  526. creater_sn = #{createrSn,jdbcType=VARCHAR},
  527. </if>
  528. <if test="createTime != null" >
  529. create_time = #{createTime,jdbcType=TIMESTAMP},
  530. </if>
  531. <if test="moderSn != null" >
  532. moder_sn = #{moderSn,jdbcType=VARCHAR},
  533. </if>
  534. <if test="modTime != null" >
  535. mod_time = #{modTime,jdbcType=TIMESTAMP},
  536. </if>
  537. </set>
  538. where id = #{id}
  539. </update>
  540. <update id="riderOrderUpdate" parameterType="com.kmall.api.entity.OrderVo">
  541. update mall_order
  542. <set>
  543. `order_status` = #{order_status},
  544. `shipping_status` = #{shipping_status},
  545. `shipping_code` = #{shipping_code},
  546. `shipping_id` = #{shipping_id},
  547. `shipping_name` = #{shipping_name},
  548. `shipping_fee` = #{shipping_fee},
  549. `shipping_no` = #{shipping_no},
  550. `shipping_mobile` = #{shipping_mobile}
  551. </set>
  552. where id = #{id}
  553. </update>
  554. <update id="updateOrderByMerchOrderSn" parameterType="com.kmall.api.entity.OrderVo">
  555. update mall_order
  556. <set>
  557. `is_merge_pay` = #{isMergePay}
  558. </set>
  559. where merch_order_sn = #{merchOrderSn}
  560. </update>
  561. <select id="queryUcenterMap" resultType="map">
  562. 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
  563. ,sum(case a.order_status when 201 then 1 else 0 end ) as unPaymentNum,
  564. 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
  565. from mall_order a
  566. left join mall_comment b on a.id = b.order_id
  567. where 1 = 1
  568. <if test="user_id != null">
  569. and a.user_id = #{user_id}
  570. </if>
  571. <if test="pay_status != null">
  572. and a.pay_status = #{pay_status}
  573. </if>
  574. <if test="shipping_status != null">
  575. and a.shipping_status = #{shipping_status}
  576. </if>
  577. <if test="evaluate_status != null and evaluate_status == 0 ">
  578. and not exists (select 1 from mall_comment m where a.id = m.order_id )
  579. </if>
  580. <if test="startDate!=null and startDate!=''">
  581. AND a.add_time >= #{startDate}
  582. </if>
  583. <if test="endDate!=null and endDate!=''">
  584. AND a.add_time <![CDATA[ < ]]> #{endDate}
  585. </if>
  586. <if test="shippingId!=null and shippingId!=''">
  587. AND a.shipping_id <![CDATA[ < ]]> #{shippingId}
  588. </if>
  589. </select>
  590. <select id="queryObjectByMerchOrderSn" resultMap="orderMap">
  591. select a.*
  592. from mall_order a
  593. where a.merch_order_sn = #{merchOrderSn}
  594. </select>
  595. <select id="queryCountByMerchOrderSn" resultType="java.lang.Integer">
  596. select count(*)
  597. from mall_order a
  598. where a.merch_order_sn = #{merchOrderSn}
  599. </select>
  600. <select id="queryOrderByMerchOrderSnAndRefundStatus" resultMap="orderMap">
  601. select * from mall_order o inner join mall_order_refund r on r.order_id = o.id where o.merch_order_sn = #{merchOrderSn}
  602. and r.refund_status = 2
  603. </select>
  604. </mapper>