1
0

OrderDao.xml 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583
  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. <result property="fullCutPrice" column="full_cut_price"/>
  71. <result property="campMinusId" column="camp_minus_id"/>
  72. <result property="campName" column="camp_name"/>
  73. </resultMap>
  74. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  75. select o.*,u.username as username
  76. from mall_order o
  77. left join mall_user u on o.user_id = u.id
  78. where o.id = #{value}
  79. </select>
  80. <select id="queryObjectBySysUser" resultType="com.kmall.admin.entity.OrderEntity">
  81. select o.*,u.username as username
  82. from mall_order o
  83. left join sys_user u on o.user_id = u.user_id
  84. where o.id = #{value}
  85. </select>
  86. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  87. select o.*,u.username as username
  88. from mall_order o
  89. left join mall_user u on o.user_id = u.id
  90. where o.activity_id = #{activityId}
  91. </select>
  92. <select id="getTotalActualPrice" resultType="java.lang.Double">
  93. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  94. </select>
  95. <select id="queryObjectByMerchOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  96. select * from mall_order a where merch_order_sn = #{merchOrderSn}
  97. </select>
  98. <select id="queryObjectByOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  99. select * from mall_order a where order_sn = #{orderSn}
  100. </select>
  101. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  102. SELECT DISTINCT
  103. o.order_sn,
  104. o.merch_order_sn,
  105. o.order_status,
  106. o.actual_price,
  107. o.order_biz_type,
  108. o.shipping_no,
  109. o.shipping_name,
  110. o.shipping_code,
  111. o.consignee,
  112. o.mobile,
  113. o.province,
  114. o.city,
  115. o.district,
  116. o.address,
  117. o.add_time,
  118. o.pay_id,
  119. o.pay_status,
  120. o.shipping_status,
  121. o.is_merge_pay,
  122. o.buyer_pay_check,
  123. o.order_price,
  124. o.moder_sn,
  125. o.id,
  126. u.username AS username,
  127. p.is_payment_send,
  128. p.is_ele_order_send,
  129. p.is_customs_send,
  130. s.store_name,
  131. o.full_cut_price,
  132. o.camp_minus_id,
  133. o.camp_name
  134. FROM
  135. mall_order o
  136. LEFT JOIN mall_user u ON o.user_id = u.id
  137. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  138. left join mall_store s on o.store_id = s.id
  139. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  140. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  141. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  142. AND r.goods_id = g.goods_id
  143. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  144. WHERE 1=1
  145. <if test="startTime != null and startTime != ''">
  146. AND o.add_time <![CDATA[ > ]]> #{startTime}
  147. </if>
  148. <if test="endTime != null and endTime != ''">
  149. AND o.add_time <![CDATA[ < ]]> #{endTime}
  150. </if>
  151. <if test="storeId != null and storeId != ''">
  152. AND o.store_id = #{storeId}
  153. </if>
  154. <if test="sku != null and sku.trim() != ''">
  155. AND gs.sku = #{sku}
  156. </if>
  157. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  158. AND gs.prod_barcode = #{prodBarcode}
  159. </if>
  160. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  161. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  162. </if>
  163. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  164. AND t.third_merch_sn = #{thirdMerchSn}
  165. </if>
  166. <if test="supplierThirdId != null and supplierThirdId != ''">
  167. AND r.supplier_third_id = #{supplierThirdId}
  168. </if>
  169. <if test="orderBizType != null and orderBizType != ''">
  170. AND o.order_biz_type = #{orderBizType}
  171. </if>
  172. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  173. AND o.merch_order_sn = #{merchOrderSn}
  174. </if>
  175. <if test="merchSn != null and merchSn.trim() != ''">
  176. AND o.merch_sn = #{merchSn}
  177. </if>
  178. <if test="orderSn != null and orderSn.trim() != ''">
  179. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  180. </if>
  181. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  182. AND o.shipping_status = #{shippingStatus}
  183. </if>
  184. <if test="payStatus != null and payStatus.trim() != ''">
  185. AND o.pay_status = #{payStatus}
  186. </if>
  187. <if test="orderStatus != null and orderStatus.trim() != ''">
  188. AND o.order_status = #{orderStatus}
  189. </if>
  190. <if test="shippingId != null and shippingId != 0">
  191. AND o.shipping_id = #{shippingId}
  192. </if>
  193. <if test="orderType != null and orderType.trim() != ''">
  194. AND o.order_type = #{orderType}
  195. </if>
  196. <if test="isOnfiilineOrder != null">
  197. AND o.is_onffline_order = #{isOnfiilineOrder}
  198. </if>
  199. <if test="ids != null and ids.trim() != ''">
  200. AND o.id in (${ids})
  201. </if>
  202. <choose>
  203. <when test="sidx != null and sidx.trim() != ''">
  204. order by ${sidx} ${order}
  205. </when>
  206. <otherwise>
  207. order by o.id desc
  208. </otherwise>
  209. </choose>
  210. <if test="offset != null and limit != null">
  211. limit #{offset}, #{limit}
  212. </if>
  213. </select>
  214. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  215. SELECT
  216. o.order_sn,
  217. o.merch_order_sn,
  218. o.order_status,
  219. o.actual_price,
  220. o.order_biz_type,
  221. o.shipping_no,
  222. o.shipping_name,
  223. o.shipping_code,
  224. o.consignee,
  225. o.mobile,
  226. o.province,
  227. o.city,
  228. o.district,
  229. o.address,
  230. o.add_time,
  231. o.pay_id,
  232. o.pay_transaction_id,
  233. u.id_no 'idNo',
  234. u.username AS username,
  235. p.is_payment_send,
  236. p.is_ele_order_send,
  237. p.is_customs_send,
  238. g.sku,
  239. g.goods_name,
  240. g.number,
  241. g.retail_price,
  242. s.store_name,
  243. nc.NAME ori_cnt_code,
  244. good.ciq_prod_model,
  245. good.brand,
  246. uc.NAME unit_code,
  247. good.gross_weight * g.number gross_weight,
  248. good.net_weight * g.number net_weight,
  249. t2.third_party_merch_name 'supplierThirdPartyMerchName',
  250. t2.third_party_merch_code 'supplierThirdPartyMerchCode'
  251. FROM
  252. mall_order o
  253. LEFT JOIN mall_user u ON o.user_id = u.id
  254. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  255. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  256. LEFT JOIN mall_store s ON o.store_id = s.id
  257. LEFT JOIN mall_goods good ON good.id = g.goods_id
  258. LEFT JOIN sys_cus_nation_code nc ON nc.CODE = good.ori_cnt_code
  259. LEFT JOIN sys_cus_unit_code uc ON uc.CODE = good.unit_code
  260. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  261. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  262. AND r.goods_id = g.goods_id
  263. LEFT JOIN third_merchant_biz t2 ON t2.third_merch_sn = r.supplier_third_id
  264. WHERE
  265. 1 =1
  266. <if test="startTime != null and startTime != ''">
  267. AND o.add_time <![CDATA[ > ]]> #{startTime}
  268. </if>
  269. <if test="endTime != null and endTime != ''">
  270. AND o.add_time <![CDATA[ < ]]> #{endTime}
  271. </if>
  272. <if test="storeId != null and storeId != ''">
  273. AND o.store_id = #{storeId}
  274. </if>
  275. <if test="orderBizType != null and orderBizType != ''">
  276. AND o.order_biz_type = #{orderBizType}
  277. </if>
  278. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  279. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  280. </if>
  281. <if test="sku != null and sku.trim() != ''">
  282. AND good.sku = #{sku}
  283. </if>
  284. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  285. AND o.merch_order_sn = #{merchOrderSn}
  286. </if>
  287. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  288. AND t.third_merch_sn = #{thirdMerchSn}
  289. </if>
  290. <if test="supplierThirdId != null and supplierThirdId != ''">
  291. AND r.supplier_third_id = #{supplierThirdId}
  292. </if>
  293. <if test="merchSn != null and merchSn.trim() != ''">
  294. AND o.merch_sn = #{merchSn}
  295. </if>
  296. <if test="orderSn != null and orderSn.trim() != ''">
  297. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  298. </if>
  299. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  300. AND o.shipping_status = #{shippingStatus}
  301. </if>
  302. <if test="payStatus != null and payStatus.trim() != ''">
  303. AND o.pay_status = #{payStatus}
  304. </if>
  305. <if test="orderStatus != null and orderStatus.trim() != ''">
  306. AND o.order_status = #{orderStatus}
  307. </if>
  308. <if test="shippingId != null and shippingId != 0">
  309. AND o.shipping_id = #{shippingId}
  310. </if>
  311. <if test="orderType != null and orderType.trim() != ''">
  312. AND o.order_type = #{orderType}
  313. </if>
  314. <if test="isOnfiilineOrder != null">
  315. AND o.is_onffline_order = #{isOnfiilineOrder}
  316. </if>
  317. <if test="ids != null and ids.trim() != ''">
  318. AND o.id in (${ids})
  319. </if>
  320. <choose>
  321. <when test="sidx != null and sidx.trim() != ''">
  322. order by ${sidx} ${order}
  323. </when>
  324. <otherwise>
  325. order by o.id desc
  326. </otherwise>
  327. </choose>
  328. <if test="offset != null and limit != null">
  329. limit #{offset}, #{limit}
  330. </if>
  331. </select>
  332. <select id="queryTotal" resultType="int">
  333. select count(DISTINCT o.id) FROM
  334. mall_order o
  335. LEFT JOIN mall_user u ON o.user_id = u.id
  336. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  337. left join mall_store s on o.store_id = s.id
  338. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  339. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  340. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  341. AND r.goods_id = g.goods_id
  342. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  343. WHERE 1=1
  344. <if test="startTime != null and startTime != ''">
  345. AND o.add_time <![CDATA[ > ]]> #{startTime}
  346. </if>
  347. <if test="endTime != null and endTime != ''">
  348. AND o.add_time <![CDATA[ < ]]> #{endTime}
  349. </if>
  350. <if test="storeId != null and storeId != ''">
  351. AND o.store_id = #{storeId}
  352. </if>
  353. <if test="sku != null and sku.trim() != ''">
  354. AND gs.sku = #{sku}
  355. </if>
  356. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  357. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  358. </if>
  359. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  360. AND t.third_merch_sn = #{thirdMerchSn}
  361. </if>
  362. <if test="supplierThirdId != null and supplierThirdId != ''">
  363. AND r.supplier_third_id = #{supplierThirdId}
  364. </if>
  365. <if test="orderBizType != null and orderBizType != ''">
  366. AND o.order_biz_type = #{orderBizType}
  367. </if>
  368. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  369. AND o.merch_order_sn = #{merchOrderSn}
  370. </if>
  371. <if test="merchSn != null and merchSn.trim() != ''">
  372. AND o.merch_sn = #{merchSn}
  373. </if>
  374. <if test="orderSn != null and orderSn.trim() != ''">
  375. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  376. </if>
  377. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  378. AND o.shipping_status = #{shippingStatus}
  379. </if>
  380. <if test="payStatus != null and payStatus.trim() != ''">
  381. AND o.pay_status = #{payStatus}
  382. </if>
  383. <if test="orderStatus != null and orderStatus.trim() != ''">
  384. AND o.order_status = #{orderStatus}
  385. </if>
  386. <if test="shippingId != null and shippingId != 0">
  387. AND o.shipping_id = #{shippingId}
  388. </if>
  389. <if test="orderType != null and orderType.trim() != ''">
  390. AND o.order_type = #{orderType}
  391. </if>
  392. <if test="isOnfiilineOrder != null">
  393. AND o.is_onffline_order = #{isOnfiilineOrder}
  394. </if>
  395. <if test="ids != null and ids.trim() != ''">
  396. AND o.id in (${ids})
  397. </if>
  398. </select>
  399. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  400. SELECT
  401. o.*,
  402. u.username AS username,
  403. p.is_payment_send,
  404. p.is_ele_order_send,
  405. p.is_customs_send
  406. FROM
  407. mall_order o
  408. LEFT JOIN sys_user u ON o.user_id = u.user_id
  409. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  410. left join mall_store s on o.store_id = s.id
  411. WHERE 1=1
  412. <if test="storeId != null and storeId != ''">
  413. AND o.store_id = #{storeId}
  414. </if>
  415. <if test="merchSn != null and merchSn.trim() != ''">
  416. AND o.merch_sn = #{merchSn}
  417. </if>
  418. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  419. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  420. </if>
  421. <if test="orderSn != null and orderSn.trim() != ''">
  422. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  423. </if>
  424. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  425. AND o.shipping_status = #{shippingStatus}
  426. </if>
  427. <if test="payStatus != null and payStatus.trim() != ''">
  428. AND o.pay_status = #{payStatus}
  429. </if>
  430. <if test="orderStatus != null and orderStatus.trim() != ''">
  431. AND o.order_status = #{orderStatus}
  432. </if>
  433. <if test="shippingId != null and shippingId != 0">
  434. AND o.shipping_id = #{shippingId}
  435. </if>
  436. <if test="orderType != null and orderType.trim() != ''">
  437. AND o.order_type = #{orderType}
  438. </if>
  439. <if test="isOnfiilineOrder != null">
  440. AND o.is_onffline_order = #{isOnfiilineOrder}
  441. </if>
  442. <if test="ids != null and ids.trim() != ''">
  443. AND o.id in (${ids})
  444. </if>
  445. <choose>
  446. <when test="sidx != null and sidx.trim() != ''">
  447. order by ${sidx} ${order}
  448. </when>
  449. <otherwise>
  450. order by id desc
  451. </otherwise>
  452. </choose>
  453. <if test="offset != null and limit != null">
  454. limit #{offset}, #{limit}
  455. </if>
  456. </select>
  457. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  458. insert into mall_order
  459. (
  460. `order_sn`,
  461. `user_id`,
  462. `order_status`,
  463. `shipping_status`,
  464. `pay_status`,
  465. `consignee`,
  466. `country`,
  467. `province`,
  468. `city`,
  469. `district`,
  470. `address`,
  471. `mobile`,
  472. `postscript`,
  473. `shipping_id`,
  474. `shipping_name`,
  475. `shipping_code`,
  476. `shipping_no`,
  477. `pay_id`,
  478. `pay_name`,
  479. `shipping_fee`,
  480. `actual_price`,
  481. `integral`,
  482. `integral_money`,
  483. `order_price`,
  484. `goods_price`,
  485. `add_time`,
  486. `confirm_time`,
  487. `pay_time`,
  488. `freight_price`,
  489. `coupon_id`,
  490. `coupon_price`,
  491. full_cut_price,
  492. camp_minus_id,
  493. camp_name,
  494. `callback_status`,
  495. `order_type`,
  496. `store_id`,
  497. `order_biz_type`,
  498. `is_onffline_order`,
  499. `order_sn_wx`,
  500. `pay_flag`,
  501. `merch_sn`,
  502. `create_time`,
  503. `mod_time`
  504. )
  505. values
  506. (
  507. #{orderSn},
  508. #{userId},
  509. #{orderStatus},
  510. #{shippingStatus},
  511. #{payStatus},
  512. #{consignee},
  513. #{country},
  514. #{province},
  515. #{city},
  516. #{district},
  517. #{address},
  518. #{mobile},
  519. #{postscript},
  520. #{shippingId},
  521. #{shippingName},
  522. #{shippingCode},
  523. #{shippingNo},
  524. #{payId},
  525. #{payName},
  526. #{shippingFee},
  527. #{actualPrice},
  528. #{integral},
  529. #{integralMoney},
  530. #{orderPrice},
  531. #{goodsPrice},
  532. #{addTime},
  533. #{confirmTime},
  534. #{payTime},
  535. #{freightPrice},
  536. #{couponId},
  537. #{couponPrice},
  538. #{fullCutPrice},
  539. #{campMinusId},
  540. #{campName},
  541. #{callbackStatus},
  542. #{orderType},
  543. #{storeId},
  544. #{orderBizType},
  545. #{isOnfflineOrder},
  546. #{orderSnWx},
  547. #{payFlag},
  548. #{merchSn},
  549. #{createTime},
  550. #{modTime}
  551. )
  552. </insert>
  553. <insert id="saveOrderVo" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  554. insert into mall_order
  555. (
  556. `order_sn`,
  557. `user_id`,
  558. `order_status`,
  559. `shipping_status`,
  560. `shipping_code`,
  561. `pay_status`,
  562. `consignee`,
  563. `country`,
  564. `province`,
  565. `city`,
  566. `district`,
  567. `address`,
  568. `address_id`,
  569. `mobile`,
  570. `postscript`,
  571. `pay_id`,
  572. `pay_name`,
  573. `shipping_fee`,
  574. `actual_price`,
  575. `cash_fee`,
  576. `cash_fee_type`,
  577. `total_fee`,
  578. `fee_type`,
  579. `rate`,
  580. `integral`,
  581. `integral_money`,
  582. `order_price`,
  583. `goods_price`,
  584. `add_time`,
  585. `confirm_time`,
  586. `pay_time`,
  587. `freight_price`,
  588. `coupon_id`,
  589. `coupon_price`,
  590. `full_cut_price`,
  591. camp_minus_id,
  592. camp_name,
  593. `order_type`,
  594. `activity_id`,
  595. `store_id`,
  596. `delivery_date`,
  597. `delivery_remark`,
  598. `predict_time`,
  599. `coupon_name`,
  600. `comment_count`,
  601. <if test="merchSn != null" >
  602. merch_sn,
  603. </if>
  604. <if test="merchOrderSn != null" >
  605. merch_order_sn,
  606. </if>
  607. <if test="isScan != null" >
  608. is_scan,
  609. </if>
  610. <if test="isMergePay != null" >
  611. is_merge_pay,
  612. </if>
  613. <if test="orderBizType != null" >
  614. order_biz_type,
  615. </if>
  616. <if test="payTransactionId != null" >
  617. pay_transaction_id,
  618. </if>
  619. <if test="payMobile != null" >
  620. pay_mobile,
  621. </if>
  622. <if test="buyerPayCheck != null" >
  623. buyer_pay_check,
  624. </if>
  625. <if test="isOnfflineOrder != null" >
  626. `is_onffline_order`,
  627. </if>
  628. <if test="payFlag != null" >
  629. pay_flag,
  630. </if>
  631. <if test="createrSn != null" >
  632. creater_sn,
  633. </if>
  634. <if test="createTime != null" >
  635. create_time,
  636. </if>
  637. <if test="moderSn != null" >
  638. moder_sn,
  639. </if>
  640. <if test="modTime != null" >
  641. mod_time
  642. </if>
  643. )
  644. values
  645. (
  646. #{order_sn},
  647. #{user_id},
  648. #{order_status},
  649. #{shipping_status},
  650. #{shipping_code},
  651. #{pay_status},
  652. #{consignee},
  653. #{country},
  654. #{province},
  655. #{city},
  656. #{district},
  657. #{address},
  658. #{address_id},
  659. #{mobile},
  660. #{postscript},
  661. #{pay_id},
  662. #{pay_name},
  663. #{shipping_fee},
  664. #{actual_price},
  665. #{cashFee},
  666. #{cashFeeType},
  667. #{totalFee},
  668. #{feeType},
  669. #{rate},
  670. #{integral},
  671. #{integral_money},
  672. #{order_price},
  673. #{goods_price},
  674. now(),
  675. #{confirm_time},
  676. #{pay_time},
  677. #{freight_price},
  678. #{coupon_id},
  679. #{coupon_price},
  680. #{full_cut_price},
  681. #{campMinusId},
  682. #{campName},
  683. #{order_type},
  684. #{activity_id},
  685. #{store_id},
  686. #{delivery_date},
  687. #{delivery_remark},
  688. #{predict_time},
  689. #{coupon_name},
  690. #{comment_count},
  691. <if test="merchSn != null" >
  692. #{merchSn},
  693. </if>
  694. <if test="merchOrderSn != null" >
  695. #{merchOrderSn},
  696. </if>
  697. <if test="isScan != null" >
  698. #{isScan},
  699. </if>
  700. <if test="isMergePay != null" >
  701. #{isMergePay},
  702. </if>
  703. <if test="orderBizType != null" >
  704. #{orderBizType,jdbcType=CHAR},
  705. </if>
  706. <if test="payTransactionId != null" >
  707. #{payTransactionId},
  708. </if>
  709. <if test="payMobile != null" >
  710. #{payMobile},
  711. </if>
  712. <if test="buyerPayCheck != null" >
  713. #{buyerPayCheck},
  714. </if>
  715. <if test="isOnfflineOrder != null" >
  716. #{isOnfflineOrder},
  717. </if>
  718. <if test="payFlag != null" >
  719. #{payFlag},
  720. </if>
  721. <if test="createrSn != null" >
  722. #{createrSn},
  723. </if>
  724. <if test="createTime != null" >
  725. #{createTime},
  726. </if>
  727. <if test="moderSn != null" >
  728. #{moderSn},
  729. </if>
  730. <if test="modTime != null" >
  731. #{modTime}
  732. </if>
  733. )
  734. </insert>
  735. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  736. update mall_order
  737. <set>
  738. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  739. <if test="userId != null">`user_id` = #{userId},</if>
  740. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  741. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  742. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  743. <if test="consignee != null">`consignee` = #{consignee},</if>
  744. <if test="country != null">`country` = #{country},</if>
  745. <if test="province != null">`province` = #{province},</if>
  746. <if test="city != null">`city` = #{city},</if>
  747. <if test="district != null">`district` = #{district},</if>
  748. <if test="address != null">`address` = #{address},</if>
  749. <if test="mobile != null">`mobile` = #{mobile},</if>
  750. <if test="postscript != null">`postscript` = #{postscript},</if>
  751. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  752. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  753. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  754. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  755. <if test="payId != null">`pay_id` = #{payId},</if>
  756. <if test="payName != null">`pay_name` = #{payName},</if>
  757. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  758. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  759. <if test="integral != null">`integral` = #{integral},</if>
  760. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  761. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  762. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  763. <if test="addTime != null">`add_time` = #{addTime},</if>
  764. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  765. <if test="payTime != null">`pay_time` = #{payTime},</if>
  766. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  767. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  768. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  769. <if test="fullCutPrice != null">`full_cut_price` = #{fullCutPrice},</if>
  770. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  771. <if test="campName != null">`camp_name` = #{campName},</if>
  772. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  773. <if test="AliTradeNo != null">`ali_trade_no` = #{AliTradeNo},</if>
  774. <if test="orderType != null">`order_type` = #{orderType},</if>
  775. <if test="storeId != null">`store_id` = #{storeId},</if>
  776. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  777. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  778. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  779. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  780. <if test="createTime != null">`create_time` = #{createTime},</if>
  781. <if test="modTime != null">`mod_time` = #{modTime},</if>
  782. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  783. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  784. </set>
  785. where id = #{id}
  786. </update>
  787. <delete id="delete">
  788. delete from mall_order where id = #{value}
  789. </delete>
  790. <delete id="deleteBatch">
  791. delete from mall_order where id in
  792. <foreach item="id" collection="array" open="(" separator="," close=")">
  793. #{id}
  794. </foreach>
  795. </delete>
  796. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  797. update mall_order
  798. <set>
  799. `order_status` = #{orderStatus},
  800. `shipping_status` = #{shippingStatus},
  801. `shipping_id` = #{shippingId},
  802. `shipping_name` = #{shippingName},
  803. `shipping_fee` = #{shippingFee},
  804. `shipping_no` = #{shippingNo},
  805. `shipping_mobile` = #{shippingMobile}
  806. </set>
  807. where id = #{id}
  808. </update>
  809. <select id="getYfkOrderUserSum" resultType="int">
  810. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  811. 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
  812. left join mall_store s on o.store_id = s.id
  813. where pay_status = 2
  814. <if test="storeId != null and storeId != ''">
  815. AND o.store_id = #{storeId}
  816. </if>
  817. <if test="merchSn != null and merchSn.trim() != ''">
  818. AND o.merch_sn = #{merchSn}
  819. </if>
  820. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  821. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  822. </if>
  823. group by o.user_id) u
  824. </select>
  825. <select id="getOderUserSum" resultType="int">
  826. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  827. 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
  828. left join mall_store s on o.store_id = s.id
  829. where 1=1
  830. <if test="storeId != null and storeId != ''">
  831. AND o.store_id = #{storeId}
  832. </if>
  833. <if test="merchSn != null and merchSn.trim() != ''">
  834. AND o.merch_sn = #{merchSn}
  835. </if>
  836. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  837. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  838. </if>
  839. group by o.user_id) u
  840. </select>
  841. <select id="getTodayUserOrder" resultType="int">
  842. select count(1) from mall_order o
  843. left join mall_store s on o.store_id = s.id
  844. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  845. <if test="storeId != null and storeId != ''">
  846. AND o.store_id = #{storeId}
  847. </if>
  848. <if test="merchSn != null and merchSn.trim() != ''">
  849. AND o.merch_sn = #{merchSn}
  850. </if>
  851. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  852. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  853. </if>
  854. </select>
  855. <select id="getTodayUserSales" resultType="int">
  856. select ifnull(sum(o.actual_price),0) from mall_order o
  857. 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')
  858. <if test="storeId != null and storeId != ''">
  859. AND o.store_id = #{storeId}
  860. </if>
  861. <if test="merchSn != null and merchSn.trim() != ''">
  862. AND o.merch_sn = #{merchSn}
  863. </if>
  864. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  865. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  866. </if>
  867. </select>
  868. <select id="getIncomeSum" resultType="int">
  869. select ifnull(sum(actual_price),0) from mall_order o
  870. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  871. <if test="storeId != null and storeId != ''">
  872. AND o.store_id = #{storeId}
  873. </if>
  874. <if test="merchSn != null and merchSn.trim() != ''">
  875. AND o.merch_sn = #{merchSn}
  876. </if>
  877. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  878. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  879. </if>
  880. </select>
  881. <select id="getPayedOrderCount" resultType="int">
  882. select count(1) from mall_order o
  883. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  884. <if test="storeId != null and storeId != ''">
  885. AND o.store_id = #{storeId}
  886. </if>
  887. <if test="merchSn != null and merchSn.trim() != ''">
  888. AND o.merch_sn = #{merchSn}
  889. </if>
  890. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  891. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  892. </if>
  893. </select>
  894. <select id="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  895. SELECT
  896. s.prom_id,
  897. o.id,
  898. o.order_sn,
  899. o.merch_order_sn,
  900. o.actual_price,
  901. o.freight_price,
  902. o.activity_id,
  903. o.order_status,
  904. o.pay_status,
  905. store.store_name storeName,
  906. u.userName userName,
  907. o.buyer_pay_check,
  908. o.order_price,
  909. o.coupon_name couponName,
  910. o.add_time,
  911. o.shipping_status,
  912. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  913. g.goods_id goodsId
  914. FROM
  915. mk_store_prom_stat s
  916. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  917. LEFT JOIN mall_order o ON r.order_id = o.id
  918. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  919. AND g.id = r.order_goods_id
  920. LEFT JOIN mall_store store ON o.store_id = store.id
  921. LEFT JOIN mall_user u ON o.user_id = u.id
  922. WHERE
  923. r.order_id IS NOT NULL
  924. <if test="promId != null and promId != ''">
  925. AND s.prom_id = #{promId}
  926. </if>
  927. <if test="startTime != null and startTime != ''">
  928. AND o.add_time <![CDATA[ > ]]> #{startTime}
  929. </if>
  930. <if test="endTime != null and endTime != ''">
  931. AND o.add_time <![CDATA[ < ]]> #{endTime}
  932. </if>
  933. <if test="storeId != null and storeId != ''">
  934. AND o.store_id = #{storeId}
  935. </if>
  936. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  937. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  938. </if>
  939. <if test="orderBizType != null and orderBizType != ''">
  940. AND o.order_biz_type = #{orderBizType}
  941. </if>
  942. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  943. AND o.merch_order_sn = #{merchOrderSn}
  944. </if>
  945. <if test="merchSn != null and merchSn.trim() != ''">
  946. AND o.merch_sn = #{merchSn}
  947. </if>
  948. <if test="orderSn != null and orderSn.trim() != ''">
  949. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  950. </if>
  951. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  952. AND o.shipping_status = #{shippingStatus}
  953. </if>
  954. <if test="payStatus != null and payStatus.trim() != ''">
  955. AND o.pay_status = #{payStatus}
  956. </if>
  957. <if test="orderStatus != null and orderStatus.trim() != ''">
  958. AND o.order_status = #{orderStatus}
  959. </if>
  960. <if test="shippingId != null and shippingId != 0">
  961. AND o.shipping_id = #{shippingId}
  962. </if>
  963. <if test="orderType != null and orderType.trim() != ''">
  964. AND o.order_type = #{orderType}
  965. </if>
  966. <if test="isOnfiilineOrder != null">
  967. AND o.is_onffline_order = #{isOnfiilineOrder}
  968. </if>
  969. <choose>
  970. <when test="sidx != null and sidx.trim() != ''">
  971. order by ${sidx} ${order}
  972. </when>
  973. <otherwise>
  974. order by o.id desc
  975. </otherwise>
  976. </choose>
  977. <if test="offset != null and limit != null">
  978. limit #{offset}, #{limit}
  979. </if>
  980. </select>
  981. <select id="queryPromOrderTotal" resultType="int">
  982. SELECT
  983. count(*)
  984. FROM
  985. mk_store_prom_stat s
  986. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  987. LEFT JOIN mall_order o ON r.order_id = o.id
  988. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  989. AND g.id = r.order_goods_id
  990. LEFT JOIN mall_store store ON o.store_id = store.id
  991. LEFT JOIN mall_user u ON o.user_id = u.id
  992. WHERE
  993. r.order_id IS NOT NULL
  994. <if test="promId != null and promId != ''">
  995. AND s.prom_id = #{promId}
  996. </if>
  997. <if test="startTime != null and startTime != ''">
  998. AND o.add_time <![CDATA[ > ]]> #{startTime}
  999. </if>
  1000. <if test="endTime != null and endTime != ''">
  1001. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1002. </if>
  1003. <if test="storeId != null and storeId != ''">
  1004. AND o.store_id = #{storeId}
  1005. </if>
  1006. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1007. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1008. </if>
  1009. <if test="orderBizType != null and orderBizType != ''">
  1010. AND o.order_biz_type = #{orderBizType}
  1011. </if>
  1012. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1013. AND o.merch_order_sn = #{merchOrderSn}
  1014. </if>
  1015. <if test="merchSn != null and merchSn.trim() != ''">
  1016. AND o.merch_sn = #{merchSn}
  1017. </if>
  1018. <if test="orderSn != null and orderSn.trim() != ''">
  1019. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1020. </if>
  1021. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1022. AND o.shipping_status = #{shippingStatus}
  1023. </if>
  1024. <if test="payStatus != null and payStatus.trim() != ''">
  1025. AND o.pay_status = #{payStatus}
  1026. </if>
  1027. <if test="orderStatus != null and orderStatus.trim() != ''">
  1028. AND o.order_status = #{orderStatus}
  1029. </if>
  1030. <if test="shippingId != null and shippingId != 0">
  1031. AND o.shipping_id = #{shippingId}
  1032. </if>
  1033. <if test="orderType != null and orderType.trim() != ''">
  1034. AND o.order_type = #{orderType}
  1035. </if>
  1036. <if test="isOnfiilineOrder != null">
  1037. AND o.is_onffline_order = #{isOnfiilineOrder}
  1038. </if>
  1039. </select>
  1040. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  1041. SELECT
  1042. s.prom_id,
  1043. o.id,
  1044. o.order_sn,
  1045. o.merch_order_sn,
  1046. o.actual_price,
  1047. g.goods_name,
  1048. g.number,
  1049. g.retail_price,
  1050. o.freight_price,
  1051. o.activity_id,
  1052. o.order_status,
  1053. o.pay_status,
  1054. store.store_name storeName,
  1055. u.userName userName,
  1056. o.buyer_pay_check,
  1057. o.order_price,
  1058. o.add_time,
  1059. o.shipping_status,
  1060. g.goods_id goodsId
  1061. FROM
  1062. mk_store_prom_stat s
  1063. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1064. LEFT JOIN mall_order o ON r.order_id = o.id
  1065. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1066. AND g.id = r.order_goods_id
  1067. LEFT JOIN mall_store store ON o.store_id = store.id
  1068. LEFT JOIN mall_user u ON o.user_id = u.id
  1069. WHERE
  1070. r.order_id IS NOT NULL
  1071. <if test="promId != null and promId != ''">
  1072. AND s.prom_id = #{promId}
  1073. </if>
  1074. <if test="startTime != null and startTime != ''">
  1075. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1076. </if>
  1077. <if test="endTime != null and endTime != ''">
  1078. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1079. </if>
  1080. <if test="storeId != null and storeId != ''">
  1081. AND o.store_id = #{storeId}
  1082. </if>
  1083. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1084. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1085. </if>
  1086. <if test="orderBizType != null and orderBizType != ''">
  1087. AND o.order_biz_type = #{orderBizType}
  1088. </if>
  1089. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1090. AND o.merch_order_sn = #{merchOrderSn}
  1091. </if>
  1092. <if test="merchSn != null and merchSn.trim() != ''">
  1093. AND o.merch_sn = #{merchSn}
  1094. </if>
  1095. <if test="orderSn != null and orderSn.trim() != ''">
  1096. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1097. </if>
  1098. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1099. AND o.shipping_status = #{shippingStatus}
  1100. </if>
  1101. <if test="payStatus != null and payStatus.trim() != ''">
  1102. AND o.pay_status = #{payStatus}
  1103. </if>
  1104. <if test="orderStatus != null and orderStatus.trim() != ''">
  1105. AND o.order_status = #{orderStatus}
  1106. </if>
  1107. <if test="shippingId != null and shippingId != 0">
  1108. AND o.shipping_id = #{shippingId}
  1109. </if>
  1110. <if test="orderType != null and orderType.trim() != ''">
  1111. AND o.order_type = #{orderType}
  1112. </if>
  1113. <if test="isOnfiilineOrder != null">
  1114. AND o.is_onffline_order = #{isOnfiilineOrder}
  1115. </if>
  1116. </select>
  1117. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  1118. SELECT
  1119. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  1120. FROM
  1121. mk_store_prom_order_real r
  1122. LEFT JOIN mall_order o ON r.order_id = o.id
  1123. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1124. AND g.id = r.order_goods_id
  1125. WHERE 1=1
  1126. AND g.goods_id = #{goodsId}
  1127. AND r.order_id = #{orderId}
  1128. <if test="statusList != null">
  1129. AND o.order_status IN
  1130. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  1131. #{statusList}
  1132. </foreach>
  1133. </if>
  1134. </select>
  1135. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1136. SELECT
  1137. s.title 'storeTopicName',
  1138. pt.prom_type_name 'storeTopicType',
  1139. ss.store_name 'storeName',
  1140. s.id 'storeTopicId',
  1141. o.id,
  1142. o.order_sn,
  1143. o.merch_order_sn,
  1144. o.actual_price,
  1145. o.freight_price,
  1146. o.activity_id,
  1147. o.coupon_id,
  1148. o.coupon_name,
  1149. o.camp_minus_id,
  1150. o.camp_name,
  1151. o.order_status,
  1152. o.pay_status,
  1153. u.userName userName,
  1154. o.order_price,
  1155. o.add_time,
  1156. o.shipping_status
  1157. FROM
  1158. mall_order o
  1159. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1160. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1161. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1162. LEFT JOIN mall_user u ON o.user_id = u.id
  1163. WHERE
  1164. 1=1
  1165. <if test="storeTopicId != null and storeTopicId != ''">
  1166. AND s.id = #{storeTopicId}
  1167. </if>
  1168. <if test="startTime != null and startTime != ''">
  1169. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1170. </if>
  1171. <if test="endTime != null and endTime != ''">
  1172. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1173. </if>
  1174. <if test="storeId != null and storeId != ''">
  1175. AND o.store_id = #{storeId}
  1176. </if>
  1177. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1178. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1179. </if>
  1180. <if test="orderBizType != null and orderBizType != ''">
  1181. AND o.order_biz_type = #{orderBizType}
  1182. </if>
  1183. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1184. AND o.merch_order_sn = #{merchOrderSn}
  1185. </if>
  1186. <if test="merchSn != null and merchSn.trim() != ''">
  1187. AND o.merch_sn = #{merchSn}
  1188. </if>
  1189. <if test="orderSn != null and orderSn.trim() != ''">
  1190. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1191. </if>
  1192. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1193. AND o.shipping_status = #{shippingStatus}
  1194. </if>
  1195. <if test="payStatus != null and payStatus.trim() != ''">
  1196. AND o.pay_status = #{payStatus}
  1197. </if>
  1198. <if test="orderStatus != null and orderStatus.trim() != ''">
  1199. AND o.order_status = #{orderStatus}
  1200. </if>
  1201. <if test="shippingId != null and shippingId != 0">
  1202. AND o.shipping_id = #{shippingId}
  1203. </if>
  1204. <if test="orderType != null and orderType.trim() != ''">
  1205. AND o.order_type = #{orderType}
  1206. </if>
  1207. <if test="isOnfiilineOrder != null">
  1208. AND o.is_onffline_order = #{isOnfiilineOrder}
  1209. </if>
  1210. order by o.id DESC
  1211. <if test="offset != null and limit != null">
  1212. limit #{offset}, #{limit}
  1213. </if>
  1214. </select>
  1215. <select id="queryStoreTopicOrderTotal" resultType="int">
  1216. SELECT
  1217. count(*)
  1218. FROM
  1219. mall_order o
  1220. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1221. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1222. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1223. LEFT JOIN mall_user u ON o.user_id = u.id
  1224. WHERE 1=1
  1225. <if test="storeTopicId != null and storeTopicId != ''">
  1226. AND s.id = #{storeTopicId}
  1227. </if>
  1228. <if test="startTime != null and startTime != ''">
  1229. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1230. </if>
  1231. <if test="endTime != null and endTime != ''">
  1232. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1233. </if>
  1234. <if test="storeId != null and storeId != ''">
  1235. AND o.store_id = #{storeId}
  1236. </if>
  1237. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1238. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1239. </if>
  1240. <if test="orderBizType != null and orderBizType != ''">
  1241. AND o.order_biz_type = #{orderBizType}
  1242. </if>
  1243. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1244. AND o.merch_order_sn = #{merchOrderSn}
  1245. </if>
  1246. <if test="merchSn != null and merchSn.trim() != ''">
  1247. AND o.merch_sn = #{merchSn}
  1248. </if>
  1249. <if test="orderSn != null and orderSn.trim() != ''">
  1250. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1251. </if>
  1252. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1253. AND o.shipping_status = #{shippingStatus}
  1254. </if>
  1255. <if test="payStatus != null and payStatus.trim() != ''">
  1256. AND o.pay_status = #{payStatus}
  1257. </if>
  1258. <if test="orderStatus != null and orderStatus.trim() != ''">
  1259. AND o.order_status = #{orderStatus}
  1260. </if>
  1261. <if test="shippingId != null and shippingId != 0">
  1262. AND o.shipping_id = #{shippingId}
  1263. </if>
  1264. <if test="orderType != null and orderType.trim() != ''">
  1265. AND o.order_type = #{orderType}
  1266. </if>
  1267. <if test="isOnfiilineOrder != null">
  1268. AND o.is_onffline_order = #{isOnfiilineOrder}
  1269. </if>
  1270. </select>
  1271. <!-- 可根据自己的需求,是否要使用 -->
  1272. <resultMap type="com.kmall.admin.dto.OrderRecognitionDto" id="orderRecognitionMap">
  1273. <result property="id" column="id"/>
  1274. <result property="merchOrderSn" column="merch_order_sn"/>
  1275. <result property="orderSn" column="order_sn"/>
  1276. <result property="userId" column="user_id"/>
  1277. <result property="orderStatus" column="order_status"/>
  1278. <result property="shippingStatus" column="shipping_status"/>
  1279. <result property="payStatus" column="pay_status"/>
  1280. <result property="consignee" column="consignee"/>
  1281. <result property="country" column="country"/>
  1282. <result property="province" column="province"/>
  1283. <result property="city" column="city"/>
  1284. <result property="district" column="district"/>
  1285. <result property="address" column="address"/>
  1286. <result property="mobile" column="mobile"/>
  1287. <result property="postscript" column="postscript"/>
  1288. <result property="shippingId" column="shipping_id"/>
  1289. <result property="shippingName" column="shipping_name"/>
  1290. <result property="shippingCode" column="shipping_code"/>
  1291. <result property="shippingNo" column="shipping_no"/>
  1292. <result property="payId" column="pay_id"/>
  1293. <result property="payName" column="pay_name"/>
  1294. <result property="shippingFee" column="shipping_fee"/>
  1295. <result property="actualPrice" column="actual_price"/>
  1296. <result property="integral" column="integral"/>
  1297. <result property="integralMoney" column="integral_money"/>
  1298. <result property="orderPrice" column="order_price"/>
  1299. <result property="goodsPrice" column="goods_price"/>
  1300. <result property="addTime" column="add_time"/>
  1301. <result property="confirmTime" column="confirm_time"/>
  1302. <result property="payTime" column="pay_time"/>
  1303. <result property="freightPrice" column="freight_price"/>
  1304. <result property="couponId" column="coupon_id"/>
  1305. <result property="couponPrice" column="coupon_price"/>
  1306. <result property="callbackStatus" column="callback_status"/>
  1307. <result property="orderType" column="order_type"/>
  1308. <result property="storeId" column="store_id"/>
  1309. <result property="userName" column="username"/>
  1310. <result property="orderType" column="order_type"/>
  1311. <result property="activityId" column="activity_id"/>
  1312. <result property="deliveryDate" column="delivery_date"/>
  1313. <result property="deliveryRemark" column="delivery_remark"/>
  1314. <result property="predictTime" column="predict_time"/>
  1315. <result property="orderBizType" column="order_biz_type"/>
  1316. <result property="isPaymentSend" column="is_payment_send"/>
  1317. <result property="isEleOrderSend" column="is_ele_order_send"/>
  1318. <result property="isCustomsSend" column="is_customs_send"/>
  1319. <result property="payFlag" column="pay_flag"/>
  1320. <result column="buyer_pay_check" property="buyerPayCheck"/>
  1321. <result property="merchSn" column="merch_sn"/>
  1322. <result property="sku" column="sku"/>
  1323. <result property="createTime" column="create_time"/>
  1324. <result property="modTime" column="mod_time"/>
  1325. <result property="isOnfflineOrder" column="is_onffline_order"/>
  1326. <result property="orderSnWx" column="order_sn_wx"/>
  1327. <result property="isMergePay" column="is_merge_pay"/>
  1328. <result property="payTransactionId" column="pay_transaction_id"/>
  1329. <result property="storeName" column="store_name"/>
  1330. <result property="moderSn" column="moder_sn"/>
  1331. <result property="unitCode" column="unit_code"/>
  1332. <result property="ciqProdModel" column="ciq_prod_model"/>
  1333. <result property="oriCntCode" column="ori_cnt_code"/>
  1334. <result property="brand" column="brand"/>
  1335. <result column="gross_weight" property="grossWeight" />
  1336. <result column="net_weight" property="netWeight" />
  1337. <result property="fullCutPrice" column="full_cut_price"/>
  1338. <result property="campMinusId" column="camp_minus_id"/>
  1339. <result property="campName" column="camp_name"/>
  1340. <result property="isTempNoti" column="is_temp_noti"/>
  1341. <result property="isFaceCheck" column="is_face_check"/>
  1342. <result property="tempNotiMsg" column="temp_noti_msg"/>
  1343. <result property="recognitionReturnMsg" column="recognition_return_msg"/>
  1344. <result property="lastFaceTime" column="last_face_time"/>
  1345. <result property="failCount" column="fail_count"/>
  1346. <result property="checkOperatorType" column="check_operator_type"/>
  1347. <result property="faceLivenessId" column="faceLivenessId"/>
  1348. </resultMap>
  1349. <select id="queryOrderListByRecognition" resultMap="orderRecognitionMap">
  1350. SELECT DISTINCT
  1351. o.order_sn,
  1352. o.merch_order_sn,
  1353. o.order_status,
  1354. o.actual_price,
  1355. o.order_biz_type,
  1356. o.shipping_no,
  1357. o.shipping_name,
  1358. o.shipping_code,
  1359. o.consignee,
  1360. o.mobile,
  1361. o.province,
  1362. o.city,
  1363. o.district,
  1364. o.address,
  1365. o.add_time,
  1366. o.pay_id,
  1367. o.pay_status,
  1368. o.shipping_status,
  1369. o.is_merge_pay,
  1370. o.buyer_pay_check,
  1371. o.order_price,
  1372. o.moder_sn,
  1373. o.id,
  1374. u.username AS username,
  1375. o.user_id,
  1376. p.is_payment_send,
  1377. p.is_ele_order_send,
  1378. p.is_customs_send,
  1379. s.store_name,
  1380. o.full_cut_price,
  1381. o.camp_minus_id,
  1382. o.camp_name,
  1383. fd.is_temp_noti,
  1384. fd.is_face_check,
  1385. fd.temp_noti_msg,
  1386. fd.recognition_return_msg,
  1387. fd.fail_count,
  1388. fd.id 'faceLivenessId',
  1389. fd.check_operator_type,
  1390. u.last_face_time,
  1391. t.is_face_check 'thirdIsFaceCheck'
  1392. FROM
  1393. mall_order o
  1394. LEFT JOIN mall_user u ON o.user_id = u.id
  1395. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1396. left join mall_store s on o.store_id = s.id
  1397. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1398. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1399. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1400. AND r.goods_id = g.goods_id
  1401. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1402. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1403. WHERE 1=1
  1404. <if test="startTime != null and startTime != ''">
  1405. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1406. </if>
  1407. <if test="endTime != null and endTime != ''">
  1408. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1409. </if>
  1410. <if test="storeId != null and storeId != ''">
  1411. AND o.store_id = #{storeId}
  1412. </if>
  1413. <if test="sku != null and sku.trim() != ''">
  1414. AND gs.sku = #{sku}
  1415. </if>
  1416. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1417. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1418. </if>
  1419. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1420. AND t.third_merch_sn = #{thirdMerchSn}
  1421. </if>
  1422. <if test="supplierThirdId != null and supplierThirdId != ''">
  1423. AND r.supplier_third_id = #{supplierThirdId}
  1424. </if>
  1425. <if test="orderBizType != null and orderBizType != ''">
  1426. AND o.order_biz_type = #{orderBizType}
  1427. </if>
  1428. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1429. AND o.merch_order_sn = #{merchOrderSn}
  1430. </if>
  1431. <if test="merchSn != null and merchSn.trim() != ''">
  1432. AND o.merch_sn = #{merchSn}
  1433. </if>
  1434. <if test="orderSn != null and orderSn.trim() != ''">
  1435. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1436. </if>
  1437. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1438. AND o.shipping_status = #{shippingStatus}
  1439. </if>
  1440. <if test="payStatus != null and payStatus.trim() != ''">
  1441. AND o.pay_status = #{payStatus}
  1442. </if>
  1443. <if test="orderStatus != null and orderStatus.trim() != ''">
  1444. AND o.order_status = #{orderStatus}
  1445. </if>
  1446. <if test="shippingId != null and shippingId != 0">
  1447. AND o.shipping_id = #{shippingId}
  1448. </if>
  1449. <if test="orderType != null and orderType.trim() != ''">
  1450. AND o.order_type = #{orderType}
  1451. </if>
  1452. <if test="isOnfiilineOrder != null">
  1453. AND o.is_onffline_order = #{isOnfiilineOrder}
  1454. </if>
  1455. <if test="ids != null and ids.trim() != ''">
  1456. AND o.id in (${ids})
  1457. </if>
  1458. <choose>
  1459. <when test="sidx != null and sidx.trim() != ''">
  1460. order by ${sidx} ${order}
  1461. </when>
  1462. <otherwise>
  1463. order by o.id desc
  1464. </otherwise>
  1465. </choose>
  1466. <if test="offset != null and limit != null">
  1467. limit #{offset}, #{limit}
  1468. </if>
  1469. </select>
  1470. <select id="queryOrderListByRecognitionTotal" resultType="int">
  1471. SELECT count(1)
  1472. FROM
  1473. mall_order o
  1474. LEFT JOIN mall_user u ON o.user_id = u.id
  1475. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1476. left join mall_store s on o.store_id = s.id
  1477. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1478. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1479. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1480. AND r.goods_id = g.goods_id
  1481. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1482. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1483. WHERE 1=1
  1484. <if test="startTime != null and startTime != ''">
  1485. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1486. </if>
  1487. <if test="endTime != null and endTime != ''">
  1488. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1489. </if>
  1490. <if test="storeId != null and storeId != ''">
  1491. AND o.store_id = #{storeId}
  1492. </if>
  1493. <if test="sku != null and sku.trim() != ''">
  1494. AND gs.sku = #{sku}
  1495. </if>
  1496. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1497. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1498. </if>
  1499. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1500. AND t.third_merch_sn = #{thirdMerchSn}
  1501. </if>
  1502. <if test="supplierThirdId != null and supplierThirdId != ''">
  1503. AND r.supplier_third_id = #{supplierThirdId}
  1504. </if>
  1505. <if test="orderBizType != null and orderBizType != ''">
  1506. AND o.order_biz_type = #{orderBizType}
  1507. </if>
  1508. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1509. AND o.merch_order_sn = #{merchOrderSn}
  1510. </if>
  1511. <if test="merchSn != null and merchSn.trim() != ''">
  1512. AND o.merch_sn = #{merchSn}
  1513. </if>
  1514. <if test="orderSn != null and orderSn.trim() != ''">
  1515. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1516. </if>
  1517. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1518. AND o.shipping_status = #{shippingStatus}
  1519. </if>
  1520. <if test="payStatus != null and payStatus.trim() != ''">
  1521. AND o.pay_status = #{payStatus}
  1522. </if>
  1523. <if test="orderStatus != null and orderStatus.trim() != ''">
  1524. AND o.order_status = #{orderStatus}
  1525. </if>
  1526. <if test="shippingId != null and shippingId != 0">
  1527. AND o.shipping_id = #{shippingId}
  1528. </if>
  1529. <if test="orderType != null and orderType.trim() != ''">
  1530. AND o.order_type = #{orderType}
  1531. </if>
  1532. <if test="isOnfiilineOrder != null">
  1533. AND o.is_onffline_order = #{isOnfiilineOrder}
  1534. </if>
  1535. <if test="ids != null and ids.trim() != ''">
  1536. AND o.id in (${ids})
  1537. </if>
  1538. </select>
  1539. <select id="queryOrderByRecogTemp" resultType="com.kmall.admin.dto.SendTempDto">
  1540. SELECT
  1541. o.add_time 'addTime',
  1542. u.weixin_openid 'openId',
  1543. o.merch_order_sn 'merchOrderSn',
  1544. o.id 'orderId',
  1545. o.order_sn 'orderSn'
  1546. FROM
  1547. mall_order o
  1548. INNER JOIN mall_user u ON o.user_id = u.id
  1549. where o.id = #{value}
  1550. </select>
  1551. </mapper>