1
0

OrderDao.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  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.admin.dao.OrderDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.OrderEntity" id="orderMap">
  6. <result property="id" column="id"/>
  7. <result property="merchOrderSn" column="merch_order_sn"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="orderStatus" column="order_status"/>
  11. <result property="shippingStatus" column="shipping_status"/>
  12. <result property="payStatus" column="pay_status"/>
  13. <result property="consignee" column="consignee"/>
  14. <result property="country" column="country"/>
  15. <result property="province" column="province"/>
  16. <result property="city" column="city"/>
  17. <result property="district" column="district"/>
  18. <result property="address" column="address"/>
  19. <result property="mobile" column="mobile"/>
  20. <result property="postscript" column="postscript"/>
  21. <result property="shippingId" column="shipping_id"/>
  22. <result property="shippingName" column="shipping_name"/>
  23. <result property="shippingCode" column="shipping_code"/>
  24. <result property="shippingNo" column="shipping_no"/>
  25. <result property="payId" column="pay_id"/>
  26. <result property="payName" column="pay_name"/>
  27. <result property="shippingFee" column="shipping_fee"/>
  28. <result property="actualPrice" column="actual_price"/>
  29. <result property="integral" column="integral"/>
  30. <result property="integralMoney" column="integral_money"/>
  31. <result property="orderPrice" column="order_price"/>
  32. <result property="goodsPrice" column="goods_price"/>
  33. <result property="addTime" column="add_time"/>
  34. <result property="confirmTime" column="confirm_time"/>
  35. <result property="payTime" column="pay_time"/>
  36. <result property="freightPrice" column="freight_price"/>
  37. <result property="couponId" column="coupon_id"/>
  38. <result property="couponPrice" column="coupon_price"/>
  39. <result property="callbackStatus" column="callback_status"/>
  40. <result property="orderType" column="order_type"/>
  41. <result property="storeId" column="store_id"/>
  42. <result property="userName" column="username"/>
  43. <result property="orderType" column="order_type"/>
  44. <result property="activityId" column="activity_id"/>
  45. <result property="deliveryDate" column="delivery_date"/>
  46. <result property="deliveryRemark" column="delivery_remark"/>
  47. <result property="predictTime" column="predict_time"/>
  48. <result property="orderBizType" column="order_biz_type"/>
  49. <result property="isPaymentSend" column="is_payment_send"/>
  50. <result property="isEleOrderSend" column="is_ele_order_send"/>
  51. <result property="isCustomsSend" column="is_customs_send"/>
  52. <result property="payFlag" column="pay_flag"/>
  53. <result column="buyer_pay_check" property="buyerPayCheck"/>
  54. <result property="merchSn" column="merch_sn"/>
  55. <result property="sku" column="sku"/>
  56. <result property="createTime" column="create_time"/>
  57. <result property="modTime" column="mod_time"/>
  58. <result property="isOnfflineOrder" column="is_onffline_order"/>
  59. <result property="orderSnWx" column="order_sn_wx"/>
  60. <result property="isMergePay" column="is_merge_pay"/>
  61. <result property="payTransactionId" column="pay_transaction_id"/>
  62. </resultMap>
  63. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  64. select o.*,u.username as username
  65. from mall_order o
  66. left join mall_user u on o.user_id = u.id
  67. where o.id = #{value}
  68. </select>
  69. <select id="queryObjectBySysUser" resultType="com.kmall.admin.entity.OrderEntity">
  70. select o.*,u.username as username
  71. from mall_order o
  72. left join sys_user u on o.user_id = u.user_id
  73. where o.id = #{value}
  74. </select>
  75. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  76. select o.*,u.username as username
  77. from mall_order o
  78. left join mall_user u on o.user_id = u.id
  79. where o.activity_id = #{activityId} and o.order_type = #{orderType}
  80. </select>
  81. <select id="getTotalActualPrice" resultType="java.lang.Double">
  82. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  83. </select>
  84. <select id="queryObjectByMerchOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  85. select * from mall_order a where merch_order_sn = #{merchOrderSn}
  86. </select>
  87. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  88. SELECT
  89. o.*,
  90. u.username AS username,
  91. p.is_payment_send,
  92. p.is_ele_order_send,
  93. p.is_customs_send
  94. FROM
  95. mall_order o
  96. LEFT JOIN mall_user u ON o.user_id = u.id
  97. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  98. left join mall_store s on o.store_id = s.id
  99. WHERE 1=1
  100. <if test="startTime != null and startTime != ''">
  101. AND o.add_time <![CDATA[ > ]]> #{startTime}
  102. </if>
  103. <if test="endTime != null and endTime != ''">
  104. AND o.add_time <![CDATA[ < ]]> #{endTime}
  105. </if>
  106. <if test="storeId != null and storeId != ''">
  107. AND o.store_id = #{storeId}
  108. </if>
  109. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  110. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  111. </if>
  112. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  113. AND o.merch_order_sn = #{merchOrderSn}
  114. </if>
  115. <if test="merchSn != null and merchSn.trim() != ''">
  116. AND o.merch_sn = #{merchSn}
  117. </if>
  118. <if test="orderSn != null and orderSn.trim() != ''">
  119. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  120. </if>
  121. <if test="shippingStatus != null">
  122. AND o.shipping_status = #{shippingStatus}
  123. </if>
  124. <if test="payStatus != null">
  125. AND o.pay_status = #{payStatus}
  126. </if>
  127. <if test="orderStatus != null and orderStatus.trim() != ''">
  128. AND o.order_status = #{orderStatus}
  129. </if>
  130. <if test="shippingId != null and shippingId != 0">
  131. AND o.shipping_id = #{shippingId}
  132. </if>
  133. <if test="orderType != null and orderType.trim() != ''">
  134. AND o.order_type = #{orderType}
  135. </if>
  136. <if test="isOnfiilineOrder != null">
  137. AND o.is_onffline_order = #{isOnfiilineOrder}
  138. </if>
  139. <if test="ids != null and ids.trim() != ''">
  140. AND o.id in (${ids})
  141. </if>
  142. <choose>
  143. <when test="sidx != null and sidx.trim() != ''">
  144. order by ${sidx} ${order}
  145. </when>
  146. <otherwise>
  147. order by id desc
  148. </otherwise>
  149. </choose>
  150. <if test="offset != null and limit != null">
  151. limit #{offset}, #{limit}
  152. </if>
  153. </select>
  154. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  155. SELECT
  156. o.*,
  157. u.username AS username,
  158. p.is_payment_send,
  159. p.is_ele_order_send,
  160. p.is_customs_send,
  161. g.sku,
  162. g.goods_name,
  163. g.number,
  164. g.retail_price
  165. FROM
  166. mall_order o
  167. LEFT JOIN mall_user u ON o.user_id = u.id
  168. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  169. Left join mall_order_goods g on o.id = g.order_id
  170. left join mall_store s on o.store_id = s.id
  171. WHERE 1=1
  172. <if test="startTime != null and startTime != ''">
  173. AND o.add_time <![CDATA[ > ]]> #{startTime}
  174. </if>
  175. <if test="endTime != null and endTime != ''">
  176. AND o.add_time <![CDATA[ < ]]> #{endTime}
  177. </if>
  178. <if test="storeId != null and storeId != ''">
  179. AND o.store_id = #{storeId}
  180. </if>
  181. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  182. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  183. </if>
  184. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  185. AND o.merch_order_sn = #{merchOrderSn}
  186. </if>
  187. <if test="merchSn != null and merchSn.trim() != ''">
  188. AND o.merch_sn = #{merchSn}
  189. </if>
  190. <if test="orderSn != null and orderSn.trim() != ''">
  191. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  192. </if>
  193. <if test="shippingStatus != null">
  194. AND o.shipping_status = #{shippingStatus}
  195. </if>
  196. <if test="payStatus != null">
  197. AND o.pay_status = #{payStatus}
  198. </if>
  199. <if test="orderStatus != null and orderStatus.trim() != ''">
  200. AND o.order_status = #{orderStatus}
  201. </if>
  202. <if test="shippingId != null and shippingId != 0">
  203. AND o.shipping_id = #{shippingId}
  204. </if>
  205. <if test="orderType != null and orderType.trim() != ''">
  206. AND o.order_type = #{orderType}
  207. </if>
  208. <if test="isOnfiilineOrder != null">
  209. AND o.is_onffline_order = #{isOnfiilineOrder}
  210. </if>
  211. <if test="ids != null and ids.trim() != ''">
  212. AND o.id in (${ids})
  213. </if>
  214. <choose>
  215. <when test="sidx != null and sidx.trim() != ''">
  216. order by ${sidx} ${order}
  217. </when>
  218. <otherwise>
  219. order by id desc
  220. </otherwise>
  221. </choose>
  222. <if test="offset != null and limit != null">
  223. limit #{offset}, #{limit}
  224. </if>
  225. </select>
  226. <select id="queryTotal" resultType="int">
  227. select count(*) from mall_order o
  228. left join mall_store s on o.store_id = s.id WHERE 1=1
  229. <if test="startTime != null and startTime != ''">
  230. AND o.add_time <![CDATA[ > ]]> #{startTime}
  231. </if>
  232. <if test="endTime != null and endTime != ''">
  233. AND o.add_time <![CDATA[ < ]]> #{endTime}
  234. </if>
  235. <if test="storeId != null and storeId != ''">
  236. AND o.store_id = #{storeId}
  237. </if>
  238. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  239. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  240. </if>
  241. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  242. AND o.merch_order_sn = #{merchOrderSn}
  243. </if>
  244. <if test="merchSn != null and merchSn.trim() != ''">
  245. AND o.merch_sn = #{merchSn}
  246. </if>
  247. <if test="orderSn != null and orderSn.trim() != ''">
  248. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  249. </if>
  250. <if test="shippingStatus != null">
  251. AND o.shipping_status = #{shippingStatus}
  252. </if>
  253. <if test="payStatus != null">
  254. AND o.pay_status = #{payStatus}
  255. </if>
  256. <if test="orderStatus != null and orderStatus.trim() != ''">
  257. AND o.order_status = #{orderStatus}
  258. </if>
  259. <if test="shippingId != null and shippingId != 0">
  260. AND o.shipping_id = #{shippingId}
  261. </if>
  262. <if test="orderType != null and orderType.trim() != ''">
  263. AND o.order_type = #{orderType}
  264. </if>
  265. <if test="isOnfiilineOrder != null">
  266. AND o.is_onffline_order = #{isOnfiilineOrder}
  267. </if>
  268. <if test="ids != null and ids.trim() != ''">
  269. AND o.id in (${ids})
  270. </if>
  271. </select>
  272. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  273. SELECT
  274. o.*,
  275. u.username AS username,
  276. p.is_payment_send,
  277. p.is_ele_order_send,
  278. p.is_customs_send
  279. FROM
  280. mall_order o
  281. LEFT JOIN sys_user u ON o.user_id = u.user_id
  282. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  283. left join mall_store s on o.store_id = s.id
  284. WHERE 1=1
  285. <if test="storeId != null and storeId != ''">
  286. AND o.store_id = #{storeId}
  287. </if>
  288. <if test="merchSn != null and merchSn.trim() != ''">
  289. AND o.merch_sn = #{merchSn}
  290. </if>
  291. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  292. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  293. </if>
  294. <if test="orderSn != null and orderSn.trim() != ''">
  295. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  296. </if>
  297. <if test="shippingStatus != null">
  298. AND o.shipping_status = #{shippingStatus}
  299. </if>
  300. <if test="payStatus != null">
  301. AND o.pay_status = #{payStatus}
  302. </if>
  303. <if test="orderStatus != null and orderStatus.trim() != ''">
  304. AND o.order_status = #{orderStatus}
  305. </if>
  306. <if test="shippingId != null and shippingId != 0">
  307. AND o.shipping_id = #{shippingId}
  308. </if>
  309. <if test="orderType != null and orderType.trim() != ''">
  310. AND o.order_type = #{orderType}
  311. </if>
  312. <if test="isOnfiilineOrder != null">
  313. AND o.is_onffline_order = #{isOnfiilineOrder}
  314. </if>
  315. <if test="ids != null and ids.trim() != ''">
  316. AND o.id in (${ids})
  317. </if>
  318. <choose>
  319. <when test="sidx != null and sidx.trim() != ''">
  320. order by ${sidx} ${order}
  321. </when>
  322. <otherwise>
  323. order by id desc
  324. </otherwise>
  325. </choose>
  326. <if test="offset != null and limit != null">
  327. limit #{offset}, #{limit}
  328. </if>
  329. </select>
  330. <insert id="save" parameterType="com.kmall.admin.entity.OrderEntity" useGeneratedKeys="true" keyProperty="id">
  331. insert into mall_order
  332. (
  333. `order_sn`,
  334. `user_id`,
  335. `order_status`,
  336. `shipping_status`,
  337. `pay_status`,
  338. `consignee`,
  339. `country`,
  340. `province`,
  341. `city`,
  342. `district`,
  343. `address`,
  344. `mobile`,
  345. `postscript`,
  346. `shipping_id`,
  347. `shipping_name`,
  348. `shipping_code`,
  349. `shipping_no`,
  350. `pay_id`,
  351. `pay_name`,
  352. `shipping_fee`,
  353. `actual_price`,
  354. `integral`,
  355. `integral_money`,
  356. `order_price`,
  357. `goods_price`,
  358. `add_time`,
  359. `confirm_time`,
  360. `pay_time`,
  361. `freight_price`,
  362. `coupon_id`,
  363. `coupon_price`,
  364. `callback_status`,
  365. `order_type`,
  366. `store_id`,
  367. `order_biz_type`,
  368. `is_onffline_order`,
  369. `order_sn_wx`,
  370. `pay_flag`,
  371. `merch_sn`,
  372. `create_time`,
  373. `mod_time`
  374. )
  375. values
  376. (
  377. #{orderSn},
  378. #{userId},
  379. #{orderStatus},
  380. #{shippingStatus},
  381. #{payStatus},
  382. #{consignee},
  383. #{country},
  384. #{province},
  385. #{city},
  386. #{district},
  387. #{address},
  388. #{mobile},
  389. #{postscript},
  390. #{shippingId},
  391. #{shippingName},
  392. #{shippingCode},
  393. #{shippingNo},
  394. #{payId},
  395. #{payName},
  396. #{shippingFee},
  397. #{actualPrice},
  398. #{integral},
  399. #{integralMoney},
  400. #{orderPrice},
  401. #{goodsPrice},
  402. #{addTime},
  403. #{confirmTime},
  404. #{payTime},
  405. #{freightPrice},
  406. #{couponId},
  407. #{couponPrice},
  408. #{callbackStatus},
  409. #{orderType},
  410. #{storeId},
  411. #{orderBizType},
  412. #{isOnfflineOrder},
  413. #{orderSnWx},
  414. #{payFlag},
  415. #{merchSn},
  416. #{createTime},
  417. #{modTime}
  418. )
  419. </insert>
  420. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  421. update mall_order
  422. <set>
  423. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  424. <if test="userId != null">`user_id` = #{userId},</if>
  425. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  426. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  427. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  428. <if test="consignee != null">`consignee` = #{consignee},</if>
  429. <if test="country != null">`country` = #{country},</if>
  430. <if test="province != null">`province` = #{province},</if>
  431. <if test="city != null">`city` = #{city},</if>
  432. <if test="district != null">`district` = #{district},</if>
  433. <if test="address != null">`address` = #{address},</if>
  434. <if test="mobile != null">`mobile` = #{mobile},</if>
  435. <if test="postscript != null">`postscript` = #{postscript},</if>
  436. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  437. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  438. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  439. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  440. <if test="payId != null">`pay_id` = #{payId},</if>
  441. <if test="payName != null">`pay_name` = #{payName},</if>
  442. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  443. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  444. <if test="integral != null">`integral` = #{integral},</if>
  445. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  446. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  447. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  448. <if test="addTime != null">`add_time` = #{addTime},</if>
  449. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  450. <if test="payTime != null">`pay_time` = #{payTime},</if>
  451. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  452. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  453. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  454. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  455. <if test="orderType != null">`order_type` = #{orderType},</if>
  456. <if test="storeId != null">`store_id` = #{storeId},</if>
  457. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  458. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  459. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  460. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  461. <if test="createTime != null">`create_time` = #{createTime},</if>
  462. <if test="modTime != null">`mod_time` = #{modTime},</if>
  463. </set>
  464. where id = #{id}
  465. </update>
  466. <delete id="delete">
  467. delete from mall_order where id = #{value}
  468. </delete>
  469. <delete id="deleteBatch">
  470. delete from mall_order where id in
  471. <foreach item="id" collection="array" open="(" separator="," close=")">
  472. #{id}
  473. </foreach>
  474. </delete>
  475. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  476. update mall_order
  477. <set>
  478. `order_status` = #{orderStatus},
  479. `shipping_status` = #{shippingStatus},
  480. `shipping_id` = #{shippingId},
  481. `shipping_name` = #{shippingName},
  482. `shipping_fee` = #{shippingFee},
  483. `shipping_no` = #{shippingNo},
  484. `shipping_mobile` = #{shippingMobile}
  485. </set>
  486. where id = #{id}
  487. </update>
  488. <select id="getYfkOrderUserSum" resultType="int">
  489. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  490. inner join mall_merch_user mu on o.user_id=mu.user_id and o.merch_sn=mu.merch_sn and o.store_id=mu.store_id
  491. left join mall_store s on o.store_id = s.id
  492. where pay_status = 2
  493. <if test="storeId != null and storeId != ''">
  494. AND o.store_id = #{storeId}
  495. </if>
  496. <if test="merchSn != null and merchSn.trim() != ''">
  497. AND o.merch_sn = #{merchSn}
  498. </if>
  499. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  500. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  501. </if>
  502. group by o.user_id) u
  503. </select>
  504. <select id="getOderUserSum" resultType="int">
  505. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  506. inner join mall_merch_user mu on o.user_id=mu.user_id and o.merch_sn=mu.merch_sn and o.store_id=mu.store_id
  507. left join mall_store s on o.store_id = s.id
  508. where 1=1
  509. <if test="storeId != null and storeId != ''">
  510. AND o.store_id = #{storeId}
  511. </if>
  512. <if test="merchSn != null and merchSn.trim() != ''">
  513. AND o.merch_sn = #{merchSn}
  514. </if>
  515. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  516. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  517. </if>
  518. group by o.user_id) u
  519. </select>
  520. <select id="getTodayUserOrder" resultType="int">
  521. select count(1) from mall_order o
  522. left join mall_store s on o.store_id = s.id
  523. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  524. <if test="storeId != null and storeId != ''">
  525. AND o.store_id = #{storeId}
  526. </if>
  527. <if test="merchSn != null and merchSn.trim() != ''">
  528. AND o.merch_sn = #{merchSn}
  529. </if>
  530. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  531. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  532. </if>
  533. </select>
  534. <select id="getTodayUserSales" resultType="int">
  535. select ifnull(sum(o.actual_price),0) from mall_order o
  536. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.pay_time > date_format(sysdate(), '%Y-%m-%d')
  537. <if test="storeId != null and storeId != ''">
  538. AND o.store_id = #{storeId}
  539. </if>
  540. <if test="merchSn != null and merchSn.trim() != ''">
  541. AND o.merch_sn = #{merchSn}
  542. </if>
  543. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  544. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  545. </if>
  546. </select>
  547. <select id="getIncomeSum" resultType="int">
  548. select ifnull(sum(actual_price),0) from mall_order o
  549. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  550. <if test="storeId != null and storeId != ''">
  551. AND o.store_id = #{storeId}
  552. </if>
  553. <if test="merchSn != null and merchSn.trim() != ''">
  554. AND o.merch_sn = #{merchSn}
  555. </if>
  556. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  557. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  558. </if>
  559. </select>
  560. <select id="getPayedOrderCount" resultType="int">
  561. select count(1) from mall_order o
  562. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  563. <if test="storeId != null and storeId != ''">
  564. AND o.store_id = #{storeId}
  565. </if>
  566. <if test="merchSn != null and merchSn.trim() != ''">
  567. AND o.merch_sn = #{merchSn}
  568. </if>
  569. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  570. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  571. </if>
  572. </select>
  573. </mapper>