1
0

OrderDao.xml 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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. <result property="unitCode" column="unit_code"/>
  65. <result property="ciqProdModel" column="ciq_prod_model"/>
  66. <result property="oriCntCode" column="ori_cnt_code"/>
  67. <result property="brand" column="brand"/>
  68. <result column="gross_weight" property="grossWeight" />
  69. <result column="net_weight" property="netWeight" />
  70. </resultMap>
  71. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  72. select o.*,u.username as username
  73. from mall_order o
  74. left join mall_user u on o.user_id = u.id
  75. where o.id = #{value}
  76. </select>
  77. <select id="queryObjectBySysUser" resultType="com.kmall.admin.entity.OrderEntity">
  78. select o.*,u.username as username
  79. from mall_order o
  80. left join sys_user u on o.user_id = u.user_id
  81. where o.id = #{value}
  82. </select>
  83. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  84. select o.*,u.username as username
  85. from mall_order o
  86. left join mall_user u on o.user_id = u.id
  87. where o.activity_id = #{activityId} and o.order_type = #{orderType}
  88. </select>
  89. <select id="getTotalActualPrice" resultType="java.lang.Double">
  90. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  91. </select>
  92. <select id="queryObjectByMerchOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  93. select * from mall_order a where merch_order_sn = #{merchOrderSn}
  94. </select>
  95. <select id="queryObjectByOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  96. select * from mall_order a where order_sn = #{orderSn}
  97. </select>
  98. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  99. SELECT
  100. o.order_sn,
  101. o.merch_order_sn,
  102. o.order_status,
  103. o.actual_price,
  104. o.order_biz_type,
  105. o.shipping_no,
  106. o.shipping_name,
  107. o.shipping_code,
  108. o.consignee,
  109. o.mobile,
  110. o.province,
  111. o.city,
  112. o.district,
  113. o.address,
  114. o.add_time,
  115. o.pay_id,
  116. o.pay_status,
  117. o.shipping_status,
  118. o.is_merge_pay,
  119. o.buyer_pay_check,
  120. o.order_price,
  121. o.moder_sn,
  122. o.id,
  123. u.username AS username,
  124. p.is_payment_send,
  125. p.is_ele_order_send,
  126. p.is_customs_send,
  127. s.store_name
  128. FROM
  129. mall_order o
  130. LEFT JOIN mall_user u ON o.user_id = u.id
  131. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  132. left join mall_store s on o.store_id = s.id
  133. WHERE 1=1
  134. <if test="startTime != null and startTime != ''">
  135. AND o.add_time <![CDATA[ > ]]> #{startTime}
  136. </if>
  137. <if test="endTime != null and endTime != ''">
  138. AND o.add_time <![CDATA[ < ]]> #{endTime}
  139. </if>
  140. <if test="storeId != null and storeId != ''">
  141. AND o.store_id = #{storeId}
  142. </if>
  143. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  144. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  145. </if>
  146. <if test="orderBizType != null and orderBizType != ''">
  147. AND o.order_biz_type = #{orderBizType}
  148. </if>
  149. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  150. AND o.merch_order_sn = #{merchOrderSn}
  151. </if>
  152. <if test="merchSn != null and merchSn.trim() != ''">
  153. AND o.merch_sn = #{merchSn}
  154. </if>
  155. <if test="orderSn != null and orderSn.trim() != ''">
  156. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  157. </if>
  158. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  159. AND o.shipping_status = #{shippingStatus}
  160. </if>
  161. <if test="payStatus != null and payStatus.trim() != ''">
  162. AND o.pay_status = #{payStatus}
  163. </if>
  164. <if test="orderStatus != null and orderStatus.trim() != ''">
  165. AND o.order_status = #{orderStatus}
  166. </if>
  167. <if test="shippingId != null and shippingId != 0">
  168. AND o.shipping_id = #{shippingId}
  169. </if>
  170. <if test="orderType != null and orderType.trim() != ''">
  171. AND o.order_type = #{orderType}
  172. </if>
  173. <if test="isOnfiilineOrder != null">
  174. AND o.is_onffline_order = #{isOnfiilineOrder}
  175. </if>
  176. <if test="ids != null and ids.trim() != ''">
  177. AND o.id in (${ids})
  178. </if>
  179. <choose>
  180. <when test="sidx != null and sidx.trim() != ''">
  181. order by ${sidx} ${order}
  182. </when>
  183. <otherwise>
  184. order by o.id desc
  185. </otherwise>
  186. </choose>
  187. <if test="offset != null and limit != null">
  188. limit #{offset}, #{limit}
  189. </if>
  190. </select>
  191. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  192. SELECT
  193. o.order_sn,
  194. o.merch_order_sn,
  195. o.order_status,
  196. o.actual_price,
  197. o.order_biz_type,
  198. o.shipping_no,
  199. o.shipping_name,
  200. o.shipping_code,
  201. o.consignee,
  202. o.mobile,
  203. o.province,
  204. o.city,
  205. o.district,
  206. o.address,
  207. o.add_time,
  208. o.pay_id,
  209. o.pay_transaction_id,
  210. u.id_no 'idNo',
  211. u.username AS username,
  212. p.is_payment_send,
  213. p.is_ele_order_send,
  214. p.is_customs_send,
  215. g.sku,
  216. g.goods_name,
  217. g.number,
  218. g.retail_price,
  219. s.store_name,
  220. nc.NAME ori_cnt_code,
  221. good.ciq_prod_model,
  222. good.brand,
  223. uc.NAME unit_code,
  224. good.gross_weight * g.number gross_weight,
  225. good.net_weight * g.number net_weight
  226. FROM
  227. mall_order o
  228. LEFT JOIN mall_user u ON o.user_id = u.id
  229. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  230. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  231. LEFT JOIN mall_store s ON o.store_id = s.id
  232. LEFT JOIN mall_goods good ON good.id = g.goods_id
  233. LEFT JOIN sys_cus_nation_code nc ON nc.CODE = good.ori_cnt_code
  234. LEFT JOIN sys_cus_unit_code uc ON uc.CODE = good.unit_code
  235. WHERE
  236. 1 =1
  237. <if test="startTime != null and startTime != ''">
  238. AND o.add_time <![CDATA[ > ]]> #{startTime}
  239. </if>
  240. <if test="endTime != null and endTime != ''">
  241. AND o.add_time <![CDATA[ < ]]> #{endTime}
  242. </if>
  243. <if test="storeId != null and storeId != ''">
  244. AND o.store_id = #{storeId}
  245. </if>
  246. <if test="orderBizType != null and orderBizType != ''">
  247. AND o.order_biz_type = #{orderBizType}
  248. </if>
  249. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  250. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  251. </if>
  252. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  253. AND o.merch_order_sn = #{merchOrderSn}
  254. </if>
  255. <if test="merchSn != null and merchSn.trim() != ''">
  256. AND o.merch_sn = #{merchSn}
  257. </if>
  258. <if test="orderSn != null and orderSn.trim() != ''">
  259. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  260. </if>
  261. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  262. AND o.shipping_status = #{shippingStatus}
  263. </if>
  264. <if test="payStatus != null and payStatus.trim() != ''">
  265. AND o.pay_status = #{payStatus}
  266. </if>
  267. <if test="orderStatus != null and orderStatus.trim() != ''">
  268. AND o.order_status = #{orderStatus}
  269. </if>
  270. <if test="shippingId != null and shippingId != 0">
  271. AND o.shipping_id = #{shippingId}
  272. </if>
  273. <if test="orderType != null and orderType.trim() != ''">
  274. AND o.order_type = #{orderType}
  275. </if>
  276. <if test="isOnfiilineOrder != null">
  277. AND o.is_onffline_order = #{isOnfiilineOrder}
  278. </if>
  279. <if test="ids != null and ids.trim() != ''">
  280. AND o.id in (${ids})
  281. </if>
  282. <choose>
  283. <when test="sidx != null and sidx.trim() != ''">
  284. order by ${sidx} ${order}
  285. </when>
  286. <otherwise>
  287. order by o.id desc
  288. </otherwise>
  289. </choose>
  290. <if test="offset != null and limit != null">
  291. limit #{offset}, #{limit}
  292. </if>
  293. </select>
  294. <select id="queryTotal" resultType="int">
  295. select count(*) from mall_order o
  296. left join mall_store s on o.store_id = s.id WHERE 1=1
  297. <if test="startTime != null and startTime != ''">
  298. AND o.add_time <![CDATA[ > ]]> #{startTime}
  299. </if>
  300. <if test="endTime != null and endTime != ''">
  301. AND o.add_time <![CDATA[ < ]]> #{endTime}
  302. </if>
  303. <if test="storeId != null and storeId != ''">
  304. AND o.store_id = #{storeId}
  305. </if>
  306. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  307. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  308. </if>
  309. <if test="orderBizType != null and orderBizType != ''">
  310. AND o.order_biz_type = #{orderBizType}
  311. </if>
  312. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  313. AND o.merch_order_sn = #{merchOrderSn}
  314. </if>
  315. <if test="merchSn != null and merchSn.trim() != ''">
  316. AND o.merch_sn = #{merchSn}
  317. </if>
  318. <if test="orderSn != null and orderSn.trim() != ''">
  319. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  320. </if>
  321. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  322. AND o.shipping_status = #{shippingStatus}
  323. </if>
  324. <if test="payStatus != null and payStatus.trim() != ''">
  325. AND o.pay_status = #{payStatus}
  326. </if>
  327. <if test="orderStatus != null and orderStatus.trim() != ''">
  328. AND o.order_status = #{orderStatus}
  329. </if>
  330. <if test="shippingId != null and shippingId != 0">
  331. AND o.shipping_id = #{shippingId}
  332. </if>
  333. <if test="orderType != null and orderType.trim() != ''">
  334. AND o.order_type = #{orderType}
  335. </if>
  336. <if test="isOnfiilineOrder != null">
  337. AND o.is_onffline_order = #{isOnfiilineOrder}
  338. </if>
  339. <if test="ids != null and ids.trim() != ''">
  340. AND o.id in (${ids})
  341. </if>
  342. </select>
  343. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  344. SELECT
  345. o.*,
  346. u.username AS username,
  347. p.is_payment_send,
  348. p.is_ele_order_send,
  349. p.is_customs_send
  350. FROM
  351. mall_order o
  352. LEFT JOIN sys_user u ON o.user_id = u.user_id
  353. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  354. left join mall_store s on o.store_id = s.id
  355. WHERE 1=1
  356. <if test="storeId != null and storeId != ''">
  357. AND o.store_id = #{storeId}
  358. </if>
  359. <if test="merchSn != null and merchSn.trim() != ''">
  360. AND o.merch_sn = #{merchSn}
  361. </if>
  362. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  363. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  364. </if>
  365. <if test="orderSn != null and orderSn.trim() != ''">
  366. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  367. </if>
  368. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  369. AND o.shipping_status = #{shippingStatus}
  370. </if>
  371. <if test="payStatus != null and payStatus.trim() != ''">
  372. AND o.pay_status = #{payStatus}
  373. </if>
  374. <if test="orderStatus != null and orderStatus.trim() != ''">
  375. AND o.order_status = #{orderStatus}
  376. </if>
  377. <if test="shippingId != null and shippingId != 0">
  378. AND o.shipping_id = #{shippingId}
  379. </if>
  380. <if test="orderType != null and orderType.trim() != ''">
  381. AND o.order_type = #{orderType}
  382. </if>
  383. <if test="isOnfiilineOrder != null">
  384. AND o.is_onffline_order = #{isOnfiilineOrder}
  385. </if>
  386. <if test="ids != null and ids.trim() != ''">
  387. AND o.id in (${ids})
  388. </if>
  389. <choose>
  390. <when test="sidx != null and sidx.trim() != ''">
  391. order by ${sidx} ${order}
  392. </when>
  393. <otherwise>
  394. order by id desc
  395. </otherwise>
  396. </choose>
  397. <if test="offset != null and limit != null">
  398. limit #{offset}, #{limit}
  399. </if>
  400. </select>
  401. <insert id="save" parameterType="com.kmall.admin.entity.OrderEntity" useGeneratedKeys="true" keyProperty="id">
  402. insert into mall_order
  403. (
  404. `order_sn`,
  405. `user_id`,
  406. `order_status`,
  407. `shipping_status`,
  408. `pay_status`,
  409. `consignee`,
  410. `country`,
  411. `province`,
  412. `city`,
  413. `district`,
  414. `address`,
  415. `mobile`,
  416. `postscript`,
  417. `shipping_id`,
  418. `shipping_name`,
  419. `shipping_code`,
  420. `shipping_no`,
  421. `pay_id`,
  422. `pay_name`,
  423. `shipping_fee`,
  424. `actual_price`,
  425. `integral`,
  426. `integral_money`,
  427. `order_price`,
  428. `goods_price`,
  429. `add_time`,
  430. `confirm_time`,
  431. `pay_time`,
  432. `freight_price`,
  433. `coupon_id`,
  434. `coupon_price`,
  435. `callback_status`,
  436. `order_type`,
  437. `store_id`,
  438. `order_biz_type`,
  439. `is_onffline_order`,
  440. `order_sn_wx`,
  441. `pay_flag`,
  442. `merch_sn`,
  443. `create_time`,
  444. `mod_time`
  445. )
  446. values
  447. (
  448. #{orderSn},
  449. #{userId},
  450. #{orderStatus},
  451. #{shippingStatus},
  452. #{payStatus},
  453. #{consignee},
  454. #{country},
  455. #{province},
  456. #{city},
  457. #{district},
  458. #{address},
  459. #{mobile},
  460. #{postscript},
  461. #{shippingId},
  462. #{shippingName},
  463. #{shippingCode},
  464. #{shippingNo},
  465. #{payId},
  466. #{payName},
  467. #{shippingFee},
  468. #{actualPrice},
  469. #{integral},
  470. #{integralMoney},
  471. #{orderPrice},
  472. #{goodsPrice},
  473. #{addTime},
  474. #{confirmTime},
  475. #{payTime},
  476. #{freightPrice},
  477. #{couponId},
  478. #{couponPrice},
  479. #{callbackStatus},
  480. #{orderType},
  481. #{storeId},
  482. #{orderBizType},
  483. #{isOnfflineOrder},
  484. #{orderSnWx},
  485. #{payFlag},
  486. #{merchSn},
  487. #{createTime},
  488. #{modTime}
  489. )
  490. </insert>
  491. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  492. update mall_order
  493. <set>
  494. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  495. <if test="userId != null">`user_id` = #{userId},</if>
  496. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  497. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  498. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  499. <if test="consignee != null">`consignee` = #{consignee},</if>
  500. <if test="country != null">`country` = #{country},</if>
  501. <if test="province != null">`province` = #{province},</if>
  502. <if test="city != null">`city` = #{city},</if>
  503. <if test="district != null">`district` = #{district},</if>
  504. <if test="address != null">`address` = #{address},</if>
  505. <if test="mobile != null">`mobile` = #{mobile},</if>
  506. <if test="postscript != null">`postscript` = #{postscript},</if>
  507. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  508. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  509. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  510. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  511. <if test="payId != null">`pay_id` = #{payId},</if>
  512. <if test="payName != null">`pay_name` = #{payName},</if>
  513. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  514. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  515. <if test="integral != null">`integral` = #{integral},</if>
  516. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  517. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  518. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  519. <if test="addTime != null">`add_time` = #{addTime},</if>
  520. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  521. <if test="payTime != null">`pay_time` = #{payTime},</if>
  522. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  523. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  524. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  525. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  526. <if test="orderType != null">`order_type` = #{orderType},</if>
  527. <if test="storeId != null">`store_id` = #{storeId},</if>
  528. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  529. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  530. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  531. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  532. <if test="createTime != null">`create_time` = #{createTime},</if>
  533. <if test="modTime != null">`mod_time` = #{modTime},</if>
  534. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  535. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  536. </set>
  537. where id = #{id}
  538. </update>
  539. <delete id="delete">
  540. delete from mall_order where id = #{value}
  541. </delete>
  542. <delete id="deleteBatch">
  543. delete from mall_order where id in
  544. <foreach item="id" collection="array" open="(" separator="," close=")">
  545. #{id}
  546. </foreach>
  547. </delete>
  548. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  549. update mall_order
  550. <set>
  551. `order_status` = #{orderStatus},
  552. `shipping_status` = #{shippingStatus},
  553. `shipping_id` = #{shippingId},
  554. `shipping_name` = #{shippingName},
  555. `shipping_fee` = #{shippingFee},
  556. `shipping_no` = #{shippingNo},
  557. `shipping_mobile` = #{shippingMobile}
  558. </set>
  559. where id = #{id}
  560. </update>
  561. <select id="getYfkOrderUserSum" resultType="int">
  562. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  563. 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
  564. left join mall_store s on o.store_id = s.id
  565. where pay_status = 2
  566. <if test="storeId != null and storeId != ''">
  567. AND o.store_id = #{storeId}
  568. </if>
  569. <if test="merchSn != null and merchSn.trim() != ''">
  570. AND o.merch_sn = #{merchSn}
  571. </if>
  572. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  573. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  574. </if>
  575. group by o.user_id) u
  576. </select>
  577. <select id="getOderUserSum" resultType="int">
  578. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  579. 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
  580. left join mall_store s on o.store_id = s.id
  581. where 1=1
  582. <if test="storeId != null and storeId != ''">
  583. AND o.store_id = #{storeId}
  584. </if>
  585. <if test="merchSn != null and merchSn.trim() != ''">
  586. AND o.merch_sn = #{merchSn}
  587. </if>
  588. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  589. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  590. </if>
  591. group by o.user_id) u
  592. </select>
  593. <select id="getTodayUserOrder" resultType="int">
  594. select count(1) from mall_order o
  595. left join mall_store s on o.store_id = s.id
  596. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  597. <if test="storeId != null and storeId != ''">
  598. AND o.store_id = #{storeId}
  599. </if>
  600. <if test="merchSn != null and merchSn.trim() != ''">
  601. AND o.merch_sn = #{merchSn}
  602. </if>
  603. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  604. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  605. </if>
  606. </select>
  607. <select id="getTodayUserSales" resultType="int">
  608. select ifnull(sum(o.actual_price),0) from mall_order o
  609. 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')
  610. <if test="storeId != null and storeId != ''">
  611. AND o.store_id = #{storeId}
  612. </if>
  613. <if test="merchSn != null and merchSn.trim() != ''">
  614. AND o.merch_sn = #{merchSn}
  615. </if>
  616. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  617. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  618. </if>
  619. </select>
  620. <select id="getIncomeSum" resultType="int">
  621. select ifnull(sum(actual_price),0) from mall_order o
  622. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  623. <if test="storeId != null and storeId != ''">
  624. AND o.store_id = #{storeId}
  625. </if>
  626. <if test="merchSn != null and merchSn.trim() != ''">
  627. AND o.merch_sn = #{merchSn}
  628. </if>
  629. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  630. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  631. </if>
  632. </select>
  633. <select id="getPayedOrderCount" resultType="int">
  634. select count(1) from mall_order o
  635. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  636. <if test="storeId != null and storeId != ''">
  637. AND o.store_id = #{storeId}
  638. </if>
  639. <if test="merchSn != null and merchSn.trim() != ''">
  640. AND o.merch_sn = #{merchSn}
  641. </if>
  642. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  643. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  644. </if>
  645. </select>
  646. <select id="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  647. SELECT
  648. s.prom_id,
  649. o.id,
  650. o.order_sn,
  651. o.merch_order_sn,
  652. o.actual_price,
  653. o.freight_price,
  654. o.activity_id,
  655. o.order_status,
  656. o.pay_status,
  657. store.store_name storeName,
  658. u.userName userName,
  659. o.buyer_pay_check,
  660. o.order_price,
  661. o.coupon_name couponName,
  662. o.add_time,
  663. o.shipping_status,
  664. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  665. g.goods_id goodsId
  666. FROM
  667. mk_store_prom_stat s
  668. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  669. LEFT JOIN mall_order o ON r.order_id = o.id
  670. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  671. AND g.id = r.order_goods_id
  672. LEFT JOIN mall_store store ON o.store_id = store.id
  673. LEFT JOIN mall_user u ON o.user_id = u.id
  674. WHERE
  675. r.order_id IS NOT NULL
  676. <if test="promId != null and promId != ''">
  677. AND s.prom_id = #{promId}
  678. </if>
  679. <if test="startTime != null and startTime != ''">
  680. AND o.add_time <![CDATA[ > ]]> #{startTime}
  681. </if>
  682. <if test="endTime != null and endTime != ''">
  683. AND o.add_time <![CDATA[ < ]]> #{endTime}
  684. </if>
  685. <if test="storeId != null and storeId != ''">
  686. AND o.store_id = #{storeId}
  687. </if>
  688. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  689. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  690. </if>
  691. <if test="orderBizType != null and orderBizType != ''">
  692. AND o.order_biz_type = #{orderBizType}
  693. </if>
  694. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  695. AND o.merch_order_sn = #{merchOrderSn}
  696. </if>
  697. <if test="merchSn != null and merchSn.trim() != ''">
  698. AND o.merch_sn = #{merchSn}
  699. </if>
  700. <if test="orderSn != null and orderSn.trim() != ''">
  701. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  702. </if>
  703. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  704. AND o.shipping_status = #{shippingStatus}
  705. </if>
  706. <if test="payStatus != null and payStatus.trim() != ''">
  707. AND o.pay_status = #{payStatus}
  708. </if>
  709. <if test="orderStatus != null and orderStatus.trim() != ''">
  710. AND o.order_status = #{orderStatus}
  711. </if>
  712. <if test="shippingId != null and shippingId != 0">
  713. AND o.shipping_id = #{shippingId}
  714. </if>
  715. <if test="orderType != null and orderType.trim() != ''">
  716. AND o.order_type = #{orderType}
  717. </if>
  718. <if test="isOnfiilineOrder != null">
  719. AND o.is_onffline_order = #{isOnfiilineOrder}
  720. </if>
  721. <choose>
  722. <when test="sidx != null and sidx.trim() != ''">
  723. order by ${sidx} ${order}
  724. </when>
  725. <otherwise>
  726. order by o.id desc
  727. </otherwise>
  728. </choose>
  729. <if test="offset != null and limit != null">
  730. limit #{offset}, #{limit}
  731. </if>
  732. </select>
  733. <select id="queryPromOrderTotal" resultType="int">
  734. SELECT
  735. count(*)
  736. FROM
  737. mk_store_prom_stat s
  738. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  739. LEFT JOIN mall_order o ON r.order_id = o.id
  740. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  741. AND g.id = r.order_goods_id
  742. LEFT JOIN mall_store store ON o.store_id = store.id
  743. LEFT JOIN mall_user u ON o.user_id = u.id
  744. WHERE
  745. r.order_id IS NOT NULL
  746. <if test="promId != null and promId != ''">
  747. AND s.prom_id = #{promId}
  748. </if>
  749. <if test="startTime != null and startTime != ''">
  750. AND o.add_time <![CDATA[ > ]]> #{startTime}
  751. </if>
  752. <if test="endTime != null and endTime != ''">
  753. AND o.add_time <![CDATA[ < ]]> #{endTime}
  754. </if>
  755. <if test="storeId != null and storeId != ''">
  756. AND o.store_id = #{storeId}
  757. </if>
  758. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  759. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  760. </if>
  761. <if test="orderBizType != null and orderBizType != ''">
  762. AND o.order_biz_type = #{orderBizType}
  763. </if>
  764. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  765. AND o.merch_order_sn = #{merchOrderSn}
  766. </if>
  767. <if test="merchSn != null and merchSn.trim() != ''">
  768. AND o.merch_sn = #{merchSn}
  769. </if>
  770. <if test="orderSn != null and orderSn.trim() != ''">
  771. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  772. </if>
  773. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  774. AND o.shipping_status = #{shippingStatus}
  775. </if>
  776. <if test="payStatus != null and payStatus.trim() != ''">
  777. AND o.pay_status = #{payStatus}
  778. </if>
  779. <if test="orderStatus != null and orderStatus.trim() != ''">
  780. AND o.order_status = #{orderStatus}
  781. </if>
  782. <if test="shippingId != null and shippingId != 0">
  783. AND o.shipping_id = #{shippingId}
  784. </if>
  785. <if test="orderType != null and orderType.trim() != ''">
  786. AND o.order_type = #{orderType}
  787. </if>
  788. <if test="isOnfiilineOrder != null">
  789. AND o.is_onffline_order = #{isOnfiilineOrder}
  790. </if>
  791. </select>
  792. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  793. SELECT
  794. s.prom_id,
  795. o.id,
  796. o.order_sn,
  797. o.merch_order_sn,
  798. o.actual_price,
  799. g.goods_name,
  800. g.number,
  801. g.retail_price,
  802. o.freight_price,
  803. o.activity_id,
  804. o.order_status,
  805. o.pay_status,
  806. store.store_name storeName,
  807. u.userName userName,
  808. o.buyer_pay_check,
  809. o.order_price,
  810. o.add_time,
  811. o.shipping_status,
  812. g.goods_id goodsId
  813. FROM
  814. mk_store_prom_stat s
  815. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  816. LEFT JOIN mall_order o ON r.order_id = o.id
  817. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  818. AND g.id = r.order_goods_id
  819. LEFT JOIN mall_store store ON o.store_id = store.id
  820. LEFT JOIN mall_user u ON o.user_id = u.id
  821. WHERE
  822. r.order_id IS NOT NULL
  823. <if test="promId != null and promId != ''">
  824. AND s.prom_id = #{promId}
  825. </if>
  826. <if test="startTime != null and startTime != ''">
  827. AND o.add_time <![CDATA[ > ]]> #{startTime}
  828. </if>
  829. <if test="endTime != null and endTime != ''">
  830. AND o.add_time <![CDATA[ < ]]> #{endTime}
  831. </if>
  832. <if test="storeId != null and storeId != ''">
  833. AND o.store_id = #{storeId}
  834. </if>
  835. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  836. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  837. </if>
  838. <if test="orderBizType != null and orderBizType != ''">
  839. AND o.order_biz_type = #{orderBizType}
  840. </if>
  841. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  842. AND o.merch_order_sn = #{merchOrderSn}
  843. </if>
  844. <if test="merchSn != null and merchSn.trim() != ''">
  845. AND o.merch_sn = #{merchSn}
  846. </if>
  847. <if test="orderSn != null and orderSn.trim() != ''">
  848. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  849. </if>
  850. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  851. AND o.shipping_status = #{shippingStatus}
  852. </if>
  853. <if test="payStatus != null and payStatus.trim() != ''">
  854. AND o.pay_status = #{payStatus}
  855. </if>
  856. <if test="orderStatus != null and orderStatus.trim() != ''">
  857. AND o.order_status = #{orderStatus}
  858. </if>
  859. <if test="shippingId != null and shippingId != 0">
  860. AND o.shipping_id = #{shippingId}
  861. </if>
  862. <if test="orderType != null and orderType.trim() != ''">
  863. AND o.order_type = #{orderType}
  864. </if>
  865. <if test="isOnfiilineOrder != null">
  866. AND o.is_onffline_order = #{isOnfiilineOrder}
  867. </if>
  868. </select>
  869. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  870. SELECT
  871. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  872. FROM
  873. mk_store_prom_order_real r
  874. LEFT JOIN mall_order o ON r.order_id = o.id
  875. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  876. AND g.id = r.order_goods_id
  877. WHERE 1=1
  878. AND g.goods_id = #{goodsId}
  879. AND r.order_id = #{orderId}
  880. <if test="statusList != null">
  881. AND o.order_status IN
  882. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  883. #{statusList}
  884. </foreach>
  885. </if>
  886. </select>
  887. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  888. SELECT
  889. s.title 'storeTopicName',
  890. pt.prom_type_name 'storeTopicType',
  891. ss.store_name 'storeName',
  892. s.id 'storeTopicId',
  893. o.id,
  894. o.order_sn,
  895. o.merch_order_sn,
  896. o.actual_price,
  897. o.freight_price,
  898. o.activity_id,
  899. o.order_status,
  900. o.pay_status,
  901. o.coupon_name,
  902. u.userName userName,
  903. o.order_price,
  904. o.add_time,
  905. o.shipping_status
  906. FROM
  907. mall_order o
  908. INNER JOIN mall_user_coupon cc ON o.coupon_id = cc.id
  909. AND cc.user_id = o.user_id
  910. INNER JOIN mall_store_topic s ON cc.store_topic_id = s.id
  911. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  912. LEFT JOIN mall_store ss ON o.store_id = ss.id
  913. LEFT JOIN mall_user u ON o.user_id = u.id
  914. WHERE
  915. 1=1
  916. <if test="storeTopicId != null and storeTopicId != ''">
  917. AND s.id = #{storeTopicId}
  918. </if>
  919. <if test="startTime != null and startTime != ''">
  920. AND o.add_time <![CDATA[ > ]]> #{startTime}
  921. </if>
  922. <if test="endTime != null and endTime != ''">
  923. AND o.add_time <![CDATA[ < ]]> #{endTime}
  924. </if>
  925. <if test="storeId != null and storeId != ''">
  926. AND o.store_id = #{storeId}
  927. </if>
  928. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  929. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  930. </if>
  931. <if test="orderBizType != null and orderBizType != ''">
  932. AND o.order_biz_type = #{orderBizType}
  933. </if>
  934. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  935. AND o.merch_order_sn = #{merchOrderSn}
  936. </if>
  937. <if test="merchSn != null and merchSn.trim() != ''">
  938. AND o.merch_sn = #{merchSn}
  939. </if>
  940. <if test="orderSn != null and orderSn.trim() != ''">
  941. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  942. </if>
  943. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  944. AND o.shipping_status = #{shippingStatus}
  945. </if>
  946. <if test="payStatus != null and payStatus.trim() != ''">
  947. AND o.pay_status = #{payStatus}
  948. </if>
  949. <if test="orderStatus != null and orderStatus.trim() != ''">
  950. AND o.order_status = #{orderStatus}
  951. </if>
  952. <if test="shippingId != null and shippingId != 0">
  953. AND o.shipping_id = #{shippingId}
  954. </if>
  955. <if test="orderType != null and orderType.trim() != ''">
  956. AND o.order_type = #{orderType}
  957. </if>
  958. <if test="isOnfiilineOrder != null">
  959. AND o.is_onffline_order = #{isOnfiilineOrder}
  960. </if>
  961. <choose>
  962. <when test="sidx != null and sidx.trim() != ''">
  963. order by ${sidx} ${order}
  964. </when>
  965. <otherwise>
  966. order by o.id desc
  967. </otherwise>
  968. </choose>
  969. <if test="offset != null and limit != null">
  970. limit #{offset}, #{limit}
  971. </if>
  972. </select>
  973. <select id="queryStoreTopicOrderTotal" resultType="int">
  974. SELECT
  975. count(*)
  976. FROM
  977. mall_order o
  978. INNER JOIN mall_user_coupon cc ON o.coupon_id = cc.id
  979. AND cc.user_id = o.user_id
  980. INNER JOIN mall_store_topic s ON cc.store_topic_id = s.id
  981. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  982. LEFT JOIN mall_store ss ON o.store_id = ss.id
  983. LEFT JOIN mall_user u ON o.user_id = u.id
  984. WHERE 1=1
  985. <if test="storeTopicId != null and storeTopicId != ''">
  986. AND s.id = #{storeTopicId}
  987. </if>
  988. <if test="startTime != null and startTime != ''">
  989. AND o.add_time <![CDATA[ > ]]> #{startTime}
  990. </if>
  991. <if test="endTime != null and endTime != ''">
  992. AND o.add_time <![CDATA[ < ]]> #{endTime}
  993. </if>
  994. <if test="storeId != null and storeId != ''">
  995. AND o.store_id = #{storeId}
  996. </if>
  997. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  998. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  999. </if>
  1000. <if test="orderBizType != null and orderBizType != ''">
  1001. AND o.order_biz_type = #{orderBizType}
  1002. </if>
  1003. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1004. AND o.merch_order_sn = #{merchOrderSn}
  1005. </if>
  1006. <if test="merchSn != null and merchSn.trim() != ''">
  1007. AND o.merch_sn = #{merchSn}
  1008. </if>
  1009. <if test="orderSn != null and orderSn.trim() != ''">
  1010. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1011. </if>
  1012. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1013. AND o.shipping_status = #{shippingStatus}
  1014. </if>
  1015. <if test="payStatus != null and payStatus.trim() != ''">
  1016. AND o.pay_status = #{payStatus}
  1017. </if>
  1018. <if test="orderStatus != null and orderStatus.trim() != ''">
  1019. AND o.order_status = #{orderStatus}
  1020. </if>
  1021. <if test="shippingId != null and shippingId != 0">
  1022. AND o.shipping_id = #{shippingId}
  1023. </if>
  1024. <if test="orderType != null and orderType.trim() != ''">
  1025. AND o.order_type = #{orderType}
  1026. </if>
  1027. <if test="isOnfiilineOrder != null">
  1028. AND o.is_onffline_order = #{isOnfiilineOrder}
  1029. </if>
  1030. </select>
  1031. </mapper>