OrderDao.xml 60 KB

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