OrderDao.xml 24 KB

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