OrderDao.xml 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456
  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="payMobile" column="pay_mobile"/>
  28. <result property="shippingFee" column="shipping_fee"/>
  29. <result property="actualPrice" column="actual_price"/>
  30. <result property="integral" column="integral"/>
  31. <result property="integralMoney" column="integral_money"/>
  32. <result property="orderPrice" column="order_price"/>
  33. <result property="goodsPrice" column="goods_price"/>
  34. <result property="addTime" column="add_time"/>
  35. <result property="confirmTime" column="confirm_time"/>
  36. <result property="payTime" column="pay_time"/>
  37. <result property="freightPrice" column="freight_price"/>
  38. <result property="couponId" column="coupon_id"/>
  39. <result property="couponPrice" column="coupon_price"/>
  40. <result property="callbackStatus" column="callback_status"/>
  41. <result property="orderType" column="order_type"/>
  42. <result property="storeId" column="store_id"/>
  43. <result property="userName" column="username"/>
  44. <result property="orderType" column="order_type"/>
  45. <result property="activityId" column="activity_id"/>
  46. <result property="deliveryDate" column="delivery_date"/>
  47. <result property="deliveryRemark" column="delivery_remark"/>
  48. <result property="predictTime" column="predict_time"/>
  49. <result property="orderBizType" column="order_biz_type"/>
  50. <result property="isPaymentSend" column="is_payment_send"/>
  51. <result property="isEleOrderSend" column="is_ele_order_send"/>
  52. <result property="isCustomsSend" column="is_customs_send"/>
  53. <result property="payFlag" column="pay_flag"/>
  54. <result column="buyer_pay_check" property="buyerPayCheck"/>
  55. <result property="merchSn" column="merch_sn"/>
  56. <result property="sku" column="sku"/>
  57. <result property="createTime" column="create_time"/>
  58. <result property="modTime" column="mod_time"/>
  59. <result property="isOnfflineOrder" column="is_onffline_order"/>
  60. <result property="orderSnWx" column="order_sn_wx"/>
  61. <result property="isMergePay" column="is_merge_pay"/>
  62. <result property="payTransactionId" column="pay_transaction_id"/>
  63. <result property="storeName" column="store_name"/>
  64. <result property="moderSn" column="moder_sn"/>
  65. <result property="unitCode" column="unit_code"/>
  66. <result property="ciqProdModel" column="ciq_prod_model"/>
  67. <result property="oriCntCode" column="ori_cnt_code"/>
  68. <result property="brand" column="brand"/>
  69. <result column="gross_weight" property="grossWeight" />
  70. <result column="net_weight" property="netWeight" />
  71. <result property="fullCutPrice" column="full_cut_price"/>
  72. <result property="campMinusId" column="camp_minus_id"/>
  73. <result property="campName" column="camp_name"/>
  74. <result property="pickUpCodeSn" column="pick_up_code_sn"/>
  75. <result property="pickUpCodeStatus" column="pick_up_code_status"/>
  76. <result property="pickUpCodeSn" column="pick_up_code_sn"/>
  77. </resultMap>
  78. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  79. select o.*,u.username as username
  80. from mall_order o
  81. left join mall_user u on o.user_id = u.id
  82. where o.id = #{value}
  83. </select>
  84. <select id="queryObjectBySysUser" resultType="com.kmall.admin.entity.OrderEntity">
  85. select o.*,u.username as username
  86. from mall_order o
  87. left join sys_user u on o.user_id = u.user_id
  88. where o.id = #{value}
  89. </select>
  90. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  91. select o.*,u.username as username
  92. from mall_order o
  93. left join mall_user u on o.user_id = u.id
  94. where o.activity_id = #{activityId}
  95. </select>
  96. <select id="getTotalActualPrice" resultType="java.lang.Double">
  97. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  98. </select>
  99. <select id="queryObjectByMerchOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  100. select * from mall_order a where merch_order_sn = #{merchOrderSn}
  101. </select>
  102. <select id="queryObjectByOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  103. select o.*,c.pick_up_code_sn
  104. from mall_order o
  105. left join mall_pick_up_code c
  106. on c.order_sn = o.order_sn where o.order_sn = #{orderSn}
  107. </select>
  108. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  109. SELECT DISTINCT
  110. o.order_sn,
  111. o.merch_order_sn,
  112. o.order_status,
  113. o.actual_price,
  114. o.order_biz_type,
  115. o.shipping_no,
  116. o.shipping_name,
  117. o.shipping_code,
  118. o.consignee,
  119. o.mobile,
  120. o.province,
  121. o.city,
  122. o.district,
  123. o.address,
  124. o.add_time,
  125. o.pay_id,
  126. o.pay_status,
  127. o.shipping_status,
  128. o.is_merge_pay,
  129. o.buyer_pay_check,
  130. o.order_price,
  131. o.moder_sn,
  132. o.id,
  133. u.username AS username,
  134. p.is_payment_send,
  135. p.is_ele_order_send,
  136. p.is_customs_send,
  137. s.store_name,
  138. o.full_cut_price,
  139. o.camp_minus_id,
  140. o.camp_name
  141. FROM
  142. mall_order o
  143. LEFT JOIN mall_user u ON o.user_id = u.id
  144. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  145. left join mall_store s on o.store_id = s.id
  146. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  147. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  148. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  149. AND r.goods_id = g.goods_id
  150. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  151. WHERE 1=1
  152. <if test="startTime != null and startTime != ''">
  153. AND o.add_time <![CDATA[ > ]]> #{startTime}
  154. </if>
  155. <if test="endTime != null and endTime != ''">
  156. AND o.add_time <![CDATA[ < ]]> #{endTime}
  157. </if>
  158. <if test="storeId != null and storeId != ''">
  159. AND o.store_id = #{storeId}
  160. </if>
  161. <if test="sku != null and sku.trim() != ''">
  162. AND gs.sku = #{sku}
  163. </if>
  164. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  165. AND gs.prod_barcode = #{prodBarcode}
  166. </if>
  167. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  168. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  169. </if>
  170. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  171. AND t.third_merch_sn = #{thirdMerchSn}
  172. </if>
  173. <if test="supplierThirdId != null and supplierThirdId != ''">
  174. AND r.supplier_third_id = #{supplierThirdId}
  175. </if>
  176. <if test="orderBizType != null and orderBizType != ''">
  177. AND o.order_biz_type = #{orderBizType}
  178. </if>
  179. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  180. AND o.merch_order_sn = #{merchOrderSn}
  181. </if>
  182. <if test="merchSn != null and merchSn.trim() != ''">
  183. AND o.merch_sn = #{merchSn}
  184. </if>
  185. <if test="orderSn != null and orderSn.trim() != ''">
  186. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  187. </if>
  188. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  189. AND o.shipping_status = #{shippingStatus}
  190. </if>
  191. <if test="payStatus != null and payStatus.trim() != ''">
  192. AND o.pay_status = #{payStatus}
  193. </if>
  194. <if test="orderStatus != null and orderStatus.trim() != ''">
  195. AND o.order_status = #{orderStatus}
  196. </if>
  197. <if test="shippingId != null and shippingId != 0">
  198. AND o.shipping_id = #{shippingId}
  199. </if>
  200. <if test="orderType != null and orderType.trim() != ''">
  201. AND o.order_type = #{orderType}
  202. </if>
  203. <if test="isOnfiilineOrder != null">
  204. AND o.is_onffline_order = #{isOnfiilineOrder}
  205. </if>
  206. <if test="ids != null and ids.trim() != ''">
  207. AND o.id in (${ids})
  208. </if>
  209. <choose>
  210. <when test="sidx != null and sidx.trim() != ''">
  211. order by ${sidx} ${order}
  212. </when>
  213. <otherwise>
  214. order by o.id desc
  215. </otherwise>
  216. </choose>
  217. <if test="offset != null and limit != null">
  218. limit #{offset}, #{limit}
  219. </if>
  220. </select>
  221. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  222. SELECT
  223. o.order_sn,
  224. o.merch_order_sn,
  225. o.order_status,
  226. o.actual_price,
  227. o.order_biz_type,
  228. o.shipping_no,
  229. o.shipping_name,
  230. o.shipping_code,
  231. o.consignee,
  232. o.mobile,
  233. o.province,
  234. o.city,
  235. o.district,
  236. o.address,
  237. o.add_time,
  238. o.pay_id,
  239. o.shipping_status,
  240. o.shipping_fee,
  241. o.moder_sn,
  242. o.pay_transaction_id,
  243. u.id_no 'idNo',
  244. u.username AS username,
  245. p.is_payment_send,
  246. p.is_ele_order_send,
  247. p.is_customs_send,
  248. g.sku,
  249. g.goods_name,
  250. g.number,
  251. g.retail_price,
  252. s.store_name,
  253. nc.NAME ori_cnt_code,
  254. good.ciq_prod_model,
  255. good.brand,
  256. uc.NAME unit_code,
  257. good.gross_weight * g.number gross_weight,
  258. good.net_weight * g.number net_weight,
  259. t2.third_party_merch_name 'supplierThirdPartyMerchName',
  260. t2.third_party_merch_code 'supplierThirdPartyMerchCode'
  261. FROM
  262. mall_order o
  263. LEFT JOIN mall_user u ON o.user_id = u.id
  264. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  265. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  266. LEFT JOIN mall_store s ON o.store_id = s.id
  267. LEFT JOIN mall_goods good ON good.id = g.goods_id
  268. LEFT JOIN sys_cus_nation_code nc ON nc.CODE = good.ori_cnt_code
  269. LEFT JOIN sys_cus_unit_code uc ON uc.CODE = good.unit_code
  270. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  271. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  272. AND r.goods_id = g.goods_id
  273. LEFT JOIN third_merchant_biz t2 ON t2.third_merch_sn = r.supplier_third_id
  274. WHERE
  275. 1 =1
  276. <if test="storeId != null and storeId != ''">
  277. AND o.store_id = #{storeId}
  278. </if>
  279. <if test="orderStatus != null and orderStatus.trim() != ''">
  280. AND o.order_status = #{orderStatus}
  281. </if>
  282. <if test="sku != null and sku.trim() != ''">
  283. AND g.sku = #{sku}
  284. </if>
  285. <if test="startTime != null and startTime != ''">
  286. AND o.add_time <![CDATA[ > ]]> #{startTime}
  287. </if>
  288. <if test="endTime != null and endTime != ''">
  289. AND o.add_time <![CDATA[ < ]]> #{endTime}
  290. </if>
  291. <if test="storeId != null and storeId != ''">
  292. AND o.store_id = #{storeId}
  293. </if>
  294. <if test="orderBizType != null and orderBizType != ''">
  295. AND o.order_biz_type = #{orderBizType}
  296. </if>
  297. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  298. AND o.merch_order_sn = #{merchOrderSn}
  299. </if>
  300. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  301. AND t.third_merch_sn = #{thirdMerchSn}
  302. </if>
  303. <if test="supplierThirdId != null and supplierThirdId != ''">
  304. AND r.supplier_third_id = #{supplierThirdId}
  305. </if>
  306. <if test="orderSn != null and orderSn.trim() != ''">
  307. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  308. </if>
  309. <if test="payStatus != null and payStatus.trim() != ''">
  310. AND o.pay_status = #{payStatus}
  311. </if>
  312. <if test="isOnfiilineOrder != null">
  313. AND o.is_onffline_order = #{isOnfiilineOrder}
  314. </if>
  315. </select>
  316. <select id="queryTotal" resultType="int">
  317. select count(DISTINCT o.id) FROM
  318. mall_order o
  319. LEFT JOIN mall_user u ON o.user_id = u.id
  320. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  321. left join mall_store s on o.store_id = s.id
  322. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  323. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  324. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  325. AND r.goods_id = g.goods_id
  326. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  327. WHERE 1=1
  328. <if test="startTime != null and startTime != ''">
  329. AND o.add_time <![CDATA[ > ]]> #{startTime}
  330. </if>
  331. <if test="endTime != null and endTime != ''">
  332. AND o.add_time <![CDATA[ < ]]> #{endTime}
  333. </if>
  334. <if test="storeId != null and storeId != ''">
  335. AND o.store_id = #{storeId}
  336. </if>
  337. <if test="sku != null and sku.trim() != ''">
  338. AND gs.sku = #{sku}
  339. </if>
  340. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  341. AND gs.prod_barcode = #{prodBarcode}
  342. </if>
  343. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  344. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  345. </if>
  346. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  347. AND t.third_merch_sn = #{thirdMerchSn}
  348. </if>
  349. <if test="supplierThirdId != null and supplierThirdId != ''">
  350. AND r.supplier_third_id = #{supplierThirdId}
  351. </if>
  352. <if test="orderBizType != null and orderBizType != ''">
  353. AND o.order_biz_type = #{orderBizType}
  354. </if>
  355. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  356. AND o.merch_order_sn = #{merchOrderSn}
  357. </if>
  358. <if test="merchSn != null and merchSn.trim() != ''">
  359. AND o.merch_sn = #{merchSn}
  360. </if>
  361. <if test="orderSn != null and orderSn.trim() != ''">
  362. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  363. </if>
  364. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  365. AND o.shipping_status = #{shippingStatus}
  366. </if>
  367. <if test="payStatus != null and payStatus.trim() != ''">
  368. AND o.pay_status = #{payStatus}
  369. </if>
  370. <if test="orderStatus != null and orderStatus.trim() != ''">
  371. AND o.order_status = #{orderStatus}
  372. </if>
  373. <if test="shippingId != null and shippingId != 0">
  374. AND o.shipping_id = #{shippingId}
  375. </if>
  376. <if test="orderType != null and orderType.trim() != ''">
  377. AND o.order_type = #{orderType}
  378. </if>
  379. <if test="isOnfiilineOrder != null">
  380. AND o.is_onffline_order = #{isOnfiilineOrder}
  381. </if>
  382. <if test="ids != null and ids.trim() != ''">
  383. AND o.id in (${ids})
  384. </if>
  385. </select>
  386. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  387. SELECT distinct
  388. o.id,
  389. o.order_sn,
  390. s.store_name storeName,
  391. o.pay_name,
  392. u.userName userName,
  393. o.mobile,
  394. o.is_onffline_order,
  395. o.order_biz_type,
  396. o.order_status,
  397. o.pay_status,
  398. o.coupon_name,
  399. o.coupon_price,
  400. o.actual_price,
  401. o.order_price,
  402. o.pay_time,
  403. o.pay_flag,
  404. c.pick_up_code_sn
  405. from mall_order o
  406. LEFT JOIN mall_store s on o.store_id = s.id
  407. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  408. LEFT JOIN mall_user u ON o.user_id = u.id
  409. LEFT JOIN mall_pick_up_code c on c.order_sn = o.order_sn
  410. WHERE 1=1
  411. <if test="storeId != null and storeId != ''">
  412. AND o.store_id = #{storeId}
  413. </if>
  414. <if test="storeName != null and storeName != ''">
  415. AND s.store_name LIKE concat('%',#{storeName},'%')
  416. </if>
  417. <if test="merchSn != null and merchSn.trim() != ''">
  418. AND o.merch_sn = #{merchSn}
  419. </if>
  420. <if test="goodsSn != null and goodsSn.trim() != ''">
  421. AND g.goods_sn = #{goodsSn}
  422. </if>
  423. <if test="sku != null and sku.trim() != ''">
  424. AND gs.sku = #{sku}
  425. </if>
  426. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  427. AND gs.prod_barcode = #{prodBarcode}
  428. </if>
  429. <if test="startTime != null and startTime != ''">
  430. AND o.add_time <![CDATA[ > ]]> #{startTime}
  431. </if>
  432. <if test="endTime != null and endTime != ''">
  433. AND o.add_time <![CDATA[ < ]]> #{endTime}
  434. </if>
  435. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  436. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  437. </if>
  438. <if test="orderSn != null and orderSn.trim() != ''">
  439. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  440. </if>
  441. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  442. AND o.shipping_status = #{shippingStatus}
  443. </if>
  444. <if test="payStatus != null and payStatus.trim() != ''">
  445. AND o.pay_status = #{payStatus}
  446. </if>
  447. <if test="orderStatus != null and orderStatus.trim() != ''">
  448. AND o.order_status = #{orderStatus}
  449. </if>
  450. <if test="shippingId != null and shippingId != 0">
  451. AND o.shipping_id = #{shippingId}
  452. </if>
  453. <if test="orderType != null and orderType.trim() != ''">
  454. AND o.order_type = #{orderType}
  455. </if>
  456. <if test="isOnfiilineOrder != null">
  457. AND o.is_onffline_order = #{isOnfiilineOrder}
  458. </if>
  459. <if test="ids != null and ids.trim() != ''">
  460. AND o.id in (${ids})
  461. </if>
  462. <choose>
  463. <when test="sidx != null and sidx.trim() != ''">
  464. order by ${sidx} ${order}
  465. </when>
  466. <otherwise>
  467. order by id desc
  468. </otherwise>
  469. </choose>
  470. <if test="offset != null and limit != null">
  471. limit #{offset}, #{limit}
  472. </if>
  473. </select>
  474. <select id="queryOffilineOrderTotal" resultType="int">
  475. select count(DISTINCT o.id) FROM
  476. mall_order o
  477. LEFT JOIN mall_store s on o.store_id = s.id
  478. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  479. WHERE 1=1
  480. <if test="storeId != null and storeId != ''">
  481. AND o.store_id = #{storeId}
  482. </if>
  483. <if test="storeName != null and storeName != ''">
  484. AND s.store_name LIKE concat('%',#{storeName},'%')
  485. </if>
  486. <if test="merchSn != null and merchSn.trim() != ''">
  487. AND o.merch_sn = #{merchSn}
  488. </if>
  489. <if test="goodsSn != null and goodsSn.trim() != ''">
  490. AND g.goods_sn = #{goodsSn}
  491. </if>
  492. <if test="sku != null and sku.trim() != ''">
  493. AND gs.sku = #{sku}
  494. </if>
  495. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  496. AND gs.prod_barcode = #{prodBarcode}
  497. </if>
  498. <if test="startTime != null and startTime != ''">
  499. AND o.add_time <![CDATA[ > ]]> #{startTime}
  500. </if>
  501. <if test="endTime != null and endTime != ''">
  502. AND o.add_time <![CDATA[ < ]]> #{endTime}
  503. </if>
  504. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  505. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  506. </if>
  507. <if test="orderSn != null and orderSn.trim() != ''">
  508. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  509. </if>
  510. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  511. AND o.shipping_status = #{shippingStatus}
  512. </if>
  513. <if test="payStatus != null and payStatus.trim() != ''">
  514. AND o.pay_status = #{payStatus}
  515. </if>
  516. <if test="orderStatus != null and orderStatus.trim() != ''">
  517. AND o.order_status = #{orderStatus}
  518. </if>
  519. <if test="shippingId != null and shippingId != 0">
  520. AND o.shipping_id = #{shippingId}
  521. </if>
  522. <if test="orderType != null and orderType.trim() != ''">
  523. AND o.order_type = #{orderType}
  524. </if>
  525. <if test="isOnfiilineOrder != null">
  526. AND o.is_onffline_order = #{isOnfiilineOrder}
  527. </if>
  528. <if test="ids != null and ids.trim() != ''">
  529. AND o.id in (${ids})
  530. </if>
  531. </select>
  532. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  533. insert into mall_order
  534. (
  535. `order_sn`,
  536. `user_id`,
  537. `order_status`,
  538. `shipping_status`,
  539. `pay_status`,
  540. `consignee`,
  541. `country`,
  542. `province`,
  543. `city`,
  544. `district`,
  545. `address`,
  546. `mobile`,
  547. `postscript`,
  548. `shipping_id`,
  549. `shipping_name`,
  550. `shipping_code`,
  551. `shipping_no`,
  552. `pay_id`,
  553. `pay_name`,
  554. `shipping_fee`,
  555. `actual_price`,
  556. `integral`,
  557. `integral_money`,
  558. `order_price`,
  559. `goods_price`,
  560. `add_time`,
  561. `confirm_time`,
  562. `pay_time`,
  563. `freight_price`,
  564. `coupon_id`,
  565. `coupon_price`,
  566. full_cut_price,
  567. camp_minus_id,
  568. camp_name,
  569. `callback_status`,
  570. `order_type`,
  571. `store_id`,
  572. `order_biz_type`,
  573. `is_onffline_order`,
  574. `order_sn_wx`,
  575. `pay_flag`,
  576. `merch_sn`,
  577. `create_time`,
  578. `mod_time`
  579. )
  580. values
  581. (
  582. #{orderSn},
  583. #{userId},
  584. #{orderStatus},
  585. #{shippingStatus},
  586. #{payStatus},
  587. #{consignee},
  588. #{country},
  589. #{province},
  590. #{city},
  591. #{district},
  592. #{address},
  593. #{mobile},
  594. #{postscript},
  595. #{shippingId},
  596. #{shippingName},
  597. #{shippingCode},
  598. #{shippingNo},
  599. #{payId},
  600. #{payName},
  601. #{shippingFee},
  602. #{actualPrice},
  603. #{integral},
  604. #{integralMoney},
  605. #{orderPrice},
  606. #{goodsPrice},
  607. #{addTime},
  608. #{confirmTime},
  609. #{payTime},
  610. #{freightPrice},
  611. #{couponId},
  612. #{couponPrice},
  613. #{fullCutPrice},
  614. #{campMinusId},
  615. #{campName},
  616. #{callbackStatus},
  617. #{orderType},
  618. #{storeId},
  619. #{orderBizType},
  620. #{isOnfflineOrder},
  621. #{orderSnWx},
  622. #{payFlag},
  623. #{merchSn},
  624. #{createTime},
  625. #{modTime}
  626. )
  627. </insert>
  628. <insert id="saveOrderVo" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  629. insert into mall_order
  630. (
  631. `order_sn`,
  632. `user_id`,
  633. `order_status`,
  634. `shipping_status`,
  635. `shipping_code`,
  636. `pay_status`,
  637. `consignee`,
  638. `country`,
  639. `province`,
  640. `city`,
  641. `district`,
  642. `address`,
  643. `address_id`,
  644. `mobile`,
  645. `postscript`,
  646. `pay_id`,
  647. `pay_name`,
  648. `shipping_fee`,
  649. `actual_price`,
  650. `cash_fee`,
  651. `cash_fee_type`,
  652. `total_fee`,
  653. `fee_type`,
  654. `rate`,
  655. `integral`,
  656. `integral_money`,
  657. `order_price`,
  658. `goods_price`,
  659. `add_time`,
  660. `confirm_time`,
  661. `pay_time`,
  662. `freight_price`,
  663. `coupon_id`,
  664. `coupon_price`,
  665. `full_cut_price`,
  666. camp_minus_id,
  667. camp_name,
  668. `order_type`,
  669. `activity_id`,
  670. `store_id`,
  671. `delivery_date`,
  672. `delivery_remark`,
  673. `predict_time`,
  674. `coupon_name`,
  675. `comment_count`,
  676. <if test="merchSn != null" >
  677. merch_sn,
  678. </if>
  679. <if test="merchOrderSn != null" >
  680. merch_order_sn,
  681. </if>
  682. <if test="isScan != null" >
  683. is_scan,
  684. </if>
  685. <if test="isMergePay != null" >
  686. is_merge_pay,
  687. </if>
  688. <if test="orderBizType != null" >
  689. order_biz_type,
  690. </if>
  691. <if test="payTransactionId != null" >
  692. pay_transaction_id,
  693. </if>
  694. <if test="payMobile != null" >
  695. pay_mobile,
  696. </if>
  697. <if test="buyerPayCheck != null" >
  698. buyer_pay_check,
  699. </if>
  700. <if test="isOnfflineOrder != null" >
  701. `is_onffline_order`,
  702. </if>
  703. <if test="payFlag != null" >
  704. pay_flag,
  705. </if>
  706. <if test="createrSn != null" >
  707. creater_sn,
  708. </if>
  709. <if test="createTime != null" >
  710. create_time,
  711. </if>
  712. <if test="moderSn != null" >
  713. moder_sn,
  714. </if>
  715. <if test="modTime != null" >
  716. mod_time
  717. </if>
  718. )
  719. values
  720. (
  721. #{order_sn},
  722. #{user_id},
  723. #{order_status},
  724. #{shipping_status},
  725. #{shipping_code},
  726. #{pay_status},
  727. #{consignee},
  728. #{country},
  729. #{province},
  730. #{city},
  731. #{district},
  732. #{address},
  733. #{address_id},
  734. #{mobile},
  735. #{postscript},
  736. #{pay_id},
  737. #{pay_name},
  738. #{shipping_fee},
  739. #{actual_price},
  740. #{cashFee},
  741. #{cashFeeType},
  742. #{totalFee},
  743. #{feeType},
  744. #{rate},
  745. #{integral},
  746. #{integral_money},
  747. #{order_price},
  748. #{goods_price},
  749. now(),
  750. #{confirm_time},
  751. #{pay_time},
  752. #{freight_price},
  753. #{coupon_id},
  754. #{coupon_price},
  755. #{full_cut_price},
  756. #{campMinusId},
  757. #{campName},
  758. #{order_type},
  759. #{activity_id},
  760. #{store_id},
  761. #{delivery_date},
  762. #{delivery_remark},
  763. #{predict_time},
  764. #{coupon_name},
  765. #{comment_count},
  766. <if test="merchSn != null" >
  767. #{merchSn},
  768. </if>
  769. <if test="merchOrderSn != null" >
  770. #{merchOrderSn},
  771. </if>
  772. <if test="isScan != null" >
  773. #{isScan},
  774. </if>
  775. <if test="isMergePay != null" >
  776. #{isMergePay},
  777. </if>
  778. <if test="orderBizType != null" >
  779. #{orderBizType,jdbcType=CHAR},
  780. </if>
  781. <if test="payTransactionId != null" >
  782. #{payTransactionId},
  783. </if>
  784. <if test="payMobile != null" >
  785. #{payMobile},
  786. </if>
  787. <if test="buyerPayCheck != null" >
  788. #{buyerPayCheck},
  789. </if>
  790. <if test="isOnfflineOrder != null" >
  791. #{isOnfflineOrder},
  792. </if>
  793. <if test="payFlag != null" >
  794. #{payFlag},
  795. </if>
  796. <if test="createrSn != null" >
  797. #{createrSn},
  798. </if>
  799. <if test="createTime != null" >
  800. #{createTime},
  801. </if>
  802. <if test="moderSn != null" >
  803. #{moderSn},
  804. </if>
  805. <if test="modTime != null" >
  806. #{modTime}
  807. </if>
  808. )
  809. </insert>
  810. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  811. update mall_order
  812. <set>
  813. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  814. <if test="userId != null">`user_id` = #{userId},</if>
  815. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  816. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  817. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  818. <if test="consignee != null">`consignee` = #{consignee},</if>
  819. <if test="country != null">`country` = #{country},</if>
  820. <if test="province != null">`province` = #{province},</if>
  821. <if test="city != null">`city` = #{city},</if>
  822. <if test="district != null">`district` = #{district},</if>
  823. <if test="address != null">`address` = #{address},</if>
  824. <if test="mobile != null">`mobile` = #{mobile},</if>
  825. <if test="postscript != null">`postscript` = #{postscript},</if>
  826. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  827. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  828. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  829. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  830. <if test="payId != null">`pay_id` = #{payId},</if>
  831. <if test="payName != null">`pay_name` = #{payName},</if>
  832. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  833. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  834. <if test="integral != null">`integral` = #{integral},</if>
  835. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  836. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  837. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  838. <if test="addTime != null">`add_time` = #{addTime},</if>
  839. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  840. <if test="payTime != null">`pay_time` = #{payTime},</if>
  841. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  842. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  843. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  844. <if test="fullCutPrice != null">`full_cut_price` = #{fullCutPrice},</if>
  845. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  846. <if test="campName != null">`camp_name` = #{campName},</if>
  847. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  848. <if test="AliTradeNo != null">`ali_trade_no` = #{AliTradeNo},</if>
  849. <if test="orderType != null">`order_type` = #{orderType},</if>
  850. <if test="storeId != null">`store_id` = #{storeId},</if>
  851. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  852. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  853. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  854. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  855. <if test="createTime != null">`create_time` = #{createTime},</if>
  856. <if test="modTime != null">`mod_time` = #{modTime},</if>
  857. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  858. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  859. </set>
  860. where id = #{id}
  861. </update>
  862. <delete id="delete">
  863. delete from mall_order where id = #{value}
  864. </delete>
  865. <delete id="deleteBatch">
  866. delete from mall_order where id in
  867. <foreach item="id" collection="array" open="(" separator="," close=")">
  868. #{id}
  869. </foreach>
  870. </delete>
  871. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  872. update mall_order
  873. <set>
  874. `order_status` = #{orderStatus},
  875. `shipping_status` = #{shippingStatus},
  876. `shipping_id` = #{shippingId},
  877. `shipping_name` = #{shippingName},
  878. `shipping_fee` = #{shippingFee},
  879. `shipping_no` = #{shippingNo},
  880. `shipping_mobile` = #{shippingMobile}
  881. </set>
  882. where id = #{id}
  883. </update>
  884. <select id="getYfkOrderUserSum" resultType="int">
  885. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  886. 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
  887. left join mall_store s on o.store_id = s.id
  888. where pay_status = 2
  889. <if test="storeId != null and storeId != ''">
  890. AND o.store_id = #{storeId}
  891. </if>
  892. <if test="merchSn != null and merchSn.trim() != ''">
  893. AND o.merch_sn = #{merchSn}
  894. </if>
  895. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  896. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  897. </if>
  898. group by o.user_id) u
  899. </select>
  900. <select id="getOderUserSum" resultType="int">
  901. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  902. 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
  903. left join mall_store s on o.store_id = s.id
  904. where 1=1
  905. <if test="storeId != null and storeId != ''">
  906. AND o.store_id = #{storeId}
  907. </if>
  908. <if test="merchSn != null and merchSn.trim() != ''">
  909. AND o.merch_sn = #{merchSn}
  910. </if>
  911. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  912. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  913. </if>
  914. group by o.user_id) u
  915. </select>
  916. <select id="getTodayUserOrder" resultType="int">
  917. select count(1) from mall_order o
  918. left join mall_store s on o.store_id = s.id
  919. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  920. <if test="storeId != null and storeId != ''">
  921. AND o.store_id = #{storeId}
  922. </if>
  923. <if test="merchSn != null and merchSn.trim() != ''">
  924. AND o.merch_sn = #{merchSn}
  925. </if>
  926. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  927. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  928. </if>
  929. </select>
  930. <select id="getTodayUserSales" resultType="int">
  931. select ifnull(sum(o.actual_price),0) from mall_order o
  932. 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')
  933. <if test="storeId != null and storeId != ''">
  934. AND o.store_id = #{storeId}
  935. </if>
  936. <if test="merchSn != null and merchSn.trim() != ''">
  937. AND o.merch_sn = #{merchSn}
  938. </if>
  939. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  940. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  941. </if>
  942. </select>
  943. <select id="getIncomeSum" resultType="int">
  944. select ifnull(sum(actual_price),0) from mall_order o
  945. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  946. <if test="storeId != null and storeId != ''">
  947. AND o.store_id = #{storeId}
  948. </if>
  949. <if test="merchSn != null and merchSn.trim() != ''">
  950. AND o.merch_sn = #{merchSn}
  951. </if>
  952. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  953. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  954. </if>
  955. </select>
  956. <select id="getPayedOrderCount" resultType="int">
  957. select count(1) from mall_order o
  958. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  959. <if test="storeId != null and storeId != ''">
  960. AND o.store_id = #{storeId}
  961. </if>
  962. <if test="merchSn != null and merchSn.trim() != ''">
  963. AND o.merch_sn = #{merchSn}
  964. </if>
  965. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  966. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  967. </if>
  968. </select>
  969. <select id="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  970. SELECT
  971. s.prom_id,
  972. o.id,
  973. o.order_sn,
  974. o.merch_order_sn,
  975. o.actual_price,
  976. o.freight_price,
  977. o.activity_id,
  978. o.order_status,
  979. o.pay_status,
  980. store.store_name storeName,
  981. u.userName userName,
  982. o.buyer_pay_check,
  983. o.order_price,
  984. o.coupon_name couponName,
  985. o.add_time,
  986. o.shipping_status,
  987. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  988. g.goods_id goodsId
  989. FROM
  990. mk_store_prom_stat s
  991. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  992. LEFT JOIN mall_order o ON r.order_id = o.id
  993. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  994. AND g.id = r.order_goods_id
  995. LEFT JOIN mall_store store ON o.store_id = store.id
  996. LEFT JOIN mall_user u ON o.user_id = u.id
  997. WHERE
  998. r.order_id IS NOT NULL
  999. <if test="promId != null and promId != ''">
  1000. AND s.prom_id = #{promId}
  1001. </if>
  1002. <if test="startTime != null and startTime != ''">
  1003. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1004. </if>
  1005. <if test="endTime != null and endTime != ''">
  1006. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1007. </if>
  1008. <if test="storeId != null and storeId != ''">
  1009. AND o.store_id = #{storeId}
  1010. </if>
  1011. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1012. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1013. </if>
  1014. <if test="orderBizType != null and orderBizType != ''">
  1015. AND o.order_biz_type = #{orderBizType}
  1016. </if>
  1017. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1018. AND o.merch_order_sn = #{merchOrderSn}
  1019. </if>
  1020. <if test="merchSn != null and merchSn.trim() != ''">
  1021. AND o.merch_sn = #{merchSn}
  1022. </if>
  1023. <if test="orderSn != null and orderSn.trim() != ''">
  1024. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1025. </if>
  1026. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1027. AND o.shipping_status = #{shippingStatus}
  1028. </if>
  1029. <if test="payStatus != null and payStatus.trim() != ''">
  1030. AND o.pay_status = #{payStatus}
  1031. </if>
  1032. <if test="orderStatus != null and orderStatus.trim() != ''">
  1033. AND o.order_status = #{orderStatus}
  1034. </if>
  1035. <if test="shippingId != null and shippingId != 0">
  1036. AND o.shipping_id = #{shippingId}
  1037. </if>
  1038. <if test="orderType != null and orderType.trim() != ''">
  1039. AND o.order_type = #{orderType}
  1040. </if>
  1041. <if test="isOnfiilineOrder != null">
  1042. AND o.is_onffline_order = #{isOnfiilineOrder}
  1043. </if>
  1044. <choose>
  1045. <when test="sidx != null and sidx.trim() != ''">
  1046. order by ${sidx} ${order}
  1047. </when>
  1048. <otherwise>
  1049. order by o.id desc
  1050. </otherwise>
  1051. </choose>
  1052. <if test="offset != null and limit != null">
  1053. limit #{offset}, #{limit}
  1054. </if>
  1055. </select>
  1056. <select id="queryPromOrderTotal" resultType="int">
  1057. SELECT
  1058. count(*)
  1059. FROM
  1060. mk_store_prom_stat s
  1061. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1062. LEFT JOIN mall_order o ON r.order_id = o.id
  1063. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1064. AND g.id = r.order_goods_id
  1065. LEFT JOIN mall_store store ON o.store_id = store.id
  1066. LEFT JOIN mall_user u ON o.user_id = u.id
  1067. WHERE
  1068. r.order_id IS NOT NULL
  1069. <if test="promId != null and promId != ''">
  1070. AND s.prom_id = #{promId}
  1071. </if>
  1072. <if test="startTime != null and startTime != ''">
  1073. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1074. </if>
  1075. <if test="endTime != null and endTime != ''">
  1076. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1077. </if>
  1078. <if test="storeId != null and storeId != ''">
  1079. AND o.store_id = #{storeId}
  1080. </if>
  1081. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1082. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1083. </if>
  1084. <if test="orderBizType != null and orderBizType != ''">
  1085. AND o.order_biz_type = #{orderBizType}
  1086. </if>
  1087. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1088. AND o.merch_order_sn = #{merchOrderSn}
  1089. </if>
  1090. <if test="merchSn != null and merchSn.trim() != ''">
  1091. AND o.merch_sn = #{merchSn}
  1092. </if>
  1093. <if test="orderSn != null and orderSn.trim() != ''">
  1094. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1095. </if>
  1096. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1097. AND o.shipping_status = #{shippingStatus}
  1098. </if>
  1099. <if test="payStatus != null and payStatus.trim() != ''">
  1100. AND o.pay_status = #{payStatus}
  1101. </if>
  1102. <if test="orderStatus != null and orderStatus.trim() != ''">
  1103. AND o.order_status = #{orderStatus}
  1104. </if>
  1105. <if test="shippingId != null and shippingId != 0">
  1106. AND o.shipping_id = #{shippingId}
  1107. </if>
  1108. <if test="orderType != null and orderType.trim() != ''">
  1109. AND o.order_type = #{orderType}
  1110. </if>
  1111. <if test="isOnfiilineOrder != null">
  1112. AND o.is_onffline_order = #{isOnfiilineOrder}
  1113. </if>
  1114. </select>
  1115. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  1116. SELECT
  1117. s.prom_id,
  1118. o.id,
  1119. o.order_sn,
  1120. o.merch_order_sn,
  1121. o.actual_price,
  1122. g.goods_name,
  1123. g.number,
  1124. g.retail_price,
  1125. o.freight_price,
  1126. o.activity_id,
  1127. o.order_status,
  1128. o.pay_status,
  1129. store.store_name storeName,
  1130. u.userName userName,
  1131. o.buyer_pay_check,
  1132. o.order_price,
  1133. o.add_time,
  1134. o.shipping_status,
  1135. g.goods_id goodsId
  1136. FROM
  1137. mk_store_prom_stat s
  1138. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1139. LEFT JOIN mall_order o ON r.order_id = o.id
  1140. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1141. AND g.id = r.order_goods_id
  1142. LEFT JOIN mall_store store ON o.store_id = store.id
  1143. LEFT JOIN mall_user u ON o.user_id = u.id
  1144. WHERE
  1145. r.order_id IS NOT NULL
  1146. <if test="promId != null and promId != ''">
  1147. AND s.prom_id = #{promId}
  1148. </if>
  1149. <if test="startTime != null and startTime != ''">
  1150. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1151. </if>
  1152. <if test="endTime != null and endTime != ''">
  1153. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1154. </if>
  1155. <if test="storeId != null and storeId != ''">
  1156. AND o.store_id = #{storeId}
  1157. </if>
  1158. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1159. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1160. </if>
  1161. <if test="orderBizType != null and orderBizType != ''">
  1162. AND o.order_biz_type = #{orderBizType}
  1163. </if>
  1164. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1165. AND o.merch_order_sn = #{merchOrderSn}
  1166. </if>
  1167. <if test="merchSn != null and merchSn.trim() != ''">
  1168. AND o.merch_sn = #{merchSn}
  1169. </if>
  1170. <if test="orderSn != null and orderSn.trim() != ''">
  1171. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1172. </if>
  1173. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1174. AND o.shipping_status = #{shippingStatus}
  1175. </if>
  1176. <if test="payStatus != null and payStatus.trim() != ''">
  1177. AND o.pay_status = #{payStatus}
  1178. </if>
  1179. <if test="orderStatus != null and orderStatus.trim() != ''">
  1180. AND o.order_status = #{orderStatus}
  1181. </if>
  1182. <if test="shippingId != null and shippingId != 0">
  1183. AND o.shipping_id = #{shippingId}
  1184. </if>
  1185. <if test="orderType != null and orderType.trim() != ''">
  1186. AND o.order_type = #{orderType}
  1187. </if>
  1188. <if test="isOnfiilineOrder != null">
  1189. AND o.is_onffline_order = #{isOnfiilineOrder}
  1190. </if>
  1191. </select>
  1192. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  1193. SELECT
  1194. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  1195. FROM
  1196. mk_store_prom_order_real r
  1197. LEFT JOIN mall_order o ON r.order_id = o.id
  1198. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1199. AND g.id = r.order_goods_id
  1200. WHERE 1=1
  1201. AND g.goods_id = #{goodsId}
  1202. AND r.order_id = #{orderId}
  1203. <if test="statusList != null">
  1204. AND o.order_status IN
  1205. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  1206. #{statusList}
  1207. </foreach>
  1208. </if>
  1209. </select>
  1210. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1211. SELECT
  1212. s.title 'storeTopicName',
  1213. pt.prom_type_name 'storeTopicType',
  1214. ss.store_name 'storeName',
  1215. s.id 'storeTopicId',
  1216. o.id,
  1217. o.order_sn,
  1218. o.merch_order_sn,
  1219. o.actual_price,
  1220. o.freight_price,
  1221. o.activity_id,
  1222. o.coupon_id,
  1223. o.coupon_name,
  1224. o.camp_minus_id,
  1225. o.camp_name,
  1226. o.order_status,
  1227. o.pay_status,
  1228. u.userName userName,
  1229. o.order_price,
  1230. o.add_time,
  1231. o.shipping_status
  1232. FROM
  1233. mall_order o
  1234. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1235. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1236. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1237. LEFT JOIN mall_user u ON o.user_id = u.id
  1238. WHERE
  1239. 1=1
  1240. <if test="storeTopicId != null and storeTopicId != ''">
  1241. AND s.id = #{storeTopicId}
  1242. </if>
  1243. <if test="startTime != null and startTime != ''">
  1244. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1245. </if>
  1246. <if test="endTime != null and endTime != ''">
  1247. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1248. </if>
  1249. <if test="storeId != null and storeId != ''">
  1250. AND o.store_id = #{storeId}
  1251. </if>
  1252. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1253. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1254. </if>
  1255. <if test="orderBizType != null and orderBizType != ''">
  1256. AND o.order_biz_type = #{orderBizType}
  1257. </if>
  1258. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1259. AND o.merch_order_sn = #{merchOrderSn}
  1260. </if>
  1261. <if test="merchSn != null and merchSn.trim() != ''">
  1262. AND o.merch_sn = #{merchSn}
  1263. </if>
  1264. <if test="orderSn != null and orderSn.trim() != ''">
  1265. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1266. </if>
  1267. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1268. AND o.shipping_status = #{shippingStatus}
  1269. </if>
  1270. <if test="payStatus != null and payStatus.trim() != ''">
  1271. AND o.pay_status = #{payStatus}
  1272. </if>
  1273. <if test="orderStatus != null and orderStatus.trim() != ''">
  1274. AND o.order_status = #{orderStatus}
  1275. </if>
  1276. <if test="shippingId != null and shippingId != 0">
  1277. AND o.shipping_id = #{shippingId}
  1278. </if>
  1279. <if test="orderType != null and orderType.trim() != ''">
  1280. AND o.order_type = #{orderType}
  1281. </if>
  1282. <if test="isOnfiilineOrder != null">
  1283. AND o.is_onffline_order = #{isOnfiilineOrder}
  1284. </if>
  1285. order by o.id DESC
  1286. <if test="offset != null and limit != null">
  1287. limit #{offset}, #{limit}
  1288. </if>
  1289. </select>
  1290. <select id="queryStoreTopicOrderTotal" resultType="int">
  1291. SELECT
  1292. count(*)
  1293. FROM
  1294. mall_order o
  1295. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1296. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1297. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1298. LEFT JOIN mall_user u ON o.user_id = u.id
  1299. WHERE 1=1
  1300. <if test="storeTopicId != null and storeTopicId != ''">
  1301. AND s.id = #{storeTopicId}
  1302. </if>
  1303. <if test="startTime != null and startTime != ''">
  1304. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1305. </if>
  1306. <if test="endTime != null and endTime != ''">
  1307. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1308. </if>
  1309. <if test="storeId != null and storeId != ''">
  1310. AND o.store_id = #{storeId}
  1311. </if>
  1312. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1313. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1314. </if>
  1315. <if test="orderBizType != null and orderBizType != ''">
  1316. AND o.order_biz_type = #{orderBizType}
  1317. </if>
  1318. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1319. AND o.merch_order_sn = #{merchOrderSn}
  1320. </if>
  1321. <if test="merchSn != null and merchSn.trim() != ''">
  1322. AND o.merch_sn = #{merchSn}
  1323. </if>
  1324. <if test="orderSn != null and orderSn.trim() != ''">
  1325. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1326. </if>
  1327. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1328. AND o.shipping_status = #{shippingStatus}
  1329. </if>
  1330. <if test="payStatus != null and payStatus.trim() != ''">
  1331. AND o.pay_status = #{payStatus}
  1332. </if>
  1333. <if test="orderStatus != null and orderStatus.trim() != ''">
  1334. AND o.order_status = #{orderStatus}
  1335. </if>
  1336. <if test="shippingId != null and shippingId != 0">
  1337. AND o.shipping_id = #{shippingId}
  1338. </if>
  1339. <if test="orderType != null and orderType.trim() != ''">
  1340. AND o.order_type = #{orderType}
  1341. </if>
  1342. <if test="isOnfiilineOrder != null">
  1343. AND o.is_onffline_order = #{isOnfiilineOrder}
  1344. </if>
  1345. </select>
  1346. <!-- 可根据自己的需求,是否要使用 -->
  1347. <resultMap type="com.kmall.admin.dto.OrderRecognitionDto" id="orderRecognitionMap">
  1348. <result property="id" column="id"/>
  1349. <result property="merchOrderSn" column="merch_order_sn"/>
  1350. <result property="orderSn" column="order_sn"/>
  1351. <result property="userId" column="user_id"/>
  1352. <result property="orderStatus" column="order_status"/>
  1353. <result property="shippingStatus" column="shipping_status"/>
  1354. <result property="payStatus" column="pay_status"/>
  1355. <result property="consignee" column="consignee"/>
  1356. <result property="country" column="country"/>
  1357. <result property="province" column="province"/>
  1358. <result property="city" column="city"/>
  1359. <result property="district" column="district"/>
  1360. <result property="address" column="address"/>
  1361. <result property="mobile" column="mobile"/>
  1362. <result property="postscript" column="postscript"/>
  1363. <result property="shippingId" column="shipping_id"/>
  1364. <result property="shippingName" column="shipping_name"/>
  1365. <result property="shippingCode" column="shipping_code"/>
  1366. <result property="shippingNo" column="shipping_no"/>
  1367. <result property="payId" column="pay_id"/>
  1368. <result property="payName" column="pay_name"/>
  1369. <result property="shippingFee" column="shipping_fee"/>
  1370. <result property="actualPrice" column="actual_price"/>
  1371. <result property="integral" column="integral"/>
  1372. <result property="integralMoney" column="integral_money"/>
  1373. <result property="orderPrice" column="order_price"/>
  1374. <result property="goodsPrice" column="goods_price"/>
  1375. <result property="addTime" column="add_time"/>
  1376. <result property="confirmTime" column="confirm_time"/>
  1377. <result property="payTime" column="pay_time"/>
  1378. <result property="freightPrice" column="freight_price"/>
  1379. <result property="couponId" column="coupon_id"/>
  1380. <result property="couponPrice" column="coupon_price"/>
  1381. <result property="callbackStatus" column="callback_status"/>
  1382. <result property="orderType" column="order_type"/>
  1383. <result property="storeId" column="store_id"/>
  1384. <result property="userName" column="username"/>
  1385. <result property="orderType" column="order_type"/>
  1386. <result property="activityId" column="activity_id"/>
  1387. <result property="deliveryDate" column="delivery_date"/>
  1388. <result property="deliveryRemark" column="delivery_remark"/>
  1389. <result property="predictTime" column="predict_time"/>
  1390. <result property="orderBizType" column="order_biz_type"/>
  1391. <result property="isPaymentSend" column="is_payment_send"/>
  1392. <result property="isEleOrderSend" column="is_ele_order_send"/>
  1393. <result property="isCustomsSend" column="is_customs_send"/>
  1394. <result property="payFlag" column="pay_flag"/>
  1395. <result column="buyer_pay_check" property="buyerPayCheck"/>
  1396. <result property="merchSn" column="merch_sn"/>
  1397. <result property="sku" column="sku"/>
  1398. <result property="createTime" column="create_time"/>
  1399. <result property="modTime" column="mod_time"/>
  1400. <result property="isOnfflineOrder" column="is_onffline_order"/>
  1401. <result property="orderSnWx" column="order_sn_wx"/>
  1402. <result property="isMergePay" column="is_merge_pay"/>
  1403. <result property="payTransactionId" column="pay_transaction_id"/>
  1404. <result property="storeName" column="store_name"/>
  1405. <result property="moderSn" column="moder_sn"/>
  1406. <result property="unitCode" column="unit_code"/>
  1407. <result property="ciqProdModel" column="ciq_prod_model"/>
  1408. <result property="oriCntCode" column="ori_cnt_code"/>
  1409. <result property="brand" column="brand"/>
  1410. <result column="gross_weight" property="grossWeight" />
  1411. <result column="net_weight" property="netWeight" />
  1412. <result property="fullCutPrice" column="full_cut_price"/>
  1413. <result property="campMinusId" column="camp_minus_id"/>
  1414. <result property="campName" column="camp_name"/>
  1415. <result property="isTempNoti" column="is_temp_noti"/>
  1416. <result property="isFaceCheck" column="is_face_check"/>
  1417. <result property="tempNotiMsg" column="temp_noti_msg"/>
  1418. <result property="recognitionReturnMsg" column="recognition_return_msg"/>
  1419. <result property="lastFaceTime" column="last_face_time"/>
  1420. <result property="failCount" column="fail_count"/>
  1421. <result property="checkOperatorType" column="check_operator_type"/>
  1422. <result property="faceLivenessId" column="faceLivenessId"/>
  1423. </resultMap>
  1424. <select id="queryOrderListByRecognition" resultMap="orderRecognitionMap">
  1425. SELECT DISTINCT
  1426. o.order_sn,
  1427. o.merch_order_sn,
  1428. o.order_status,
  1429. o.actual_price,
  1430. o.order_biz_type,
  1431. o.shipping_no,
  1432. o.shipping_name,
  1433. o.shipping_code,
  1434. o.consignee,
  1435. o.mobile,
  1436. o.province,
  1437. o.city,
  1438. o.district,
  1439. o.address,
  1440. o.add_time,
  1441. o.pay_id,
  1442. o.pay_status,
  1443. o.shipping_status,
  1444. o.is_merge_pay,
  1445. o.buyer_pay_check,
  1446. o.order_price,
  1447. o.moder_sn,
  1448. o.id,
  1449. u.username AS username,
  1450. o.user_id,
  1451. p.is_payment_send,
  1452. p.is_ele_order_send,
  1453. p.is_customs_send,
  1454. s.store_name,
  1455. o.full_cut_price,
  1456. o.camp_minus_id,
  1457. o.camp_name,
  1458. fd.is_temp_noti,
  1459. fd.is_face_check,
  1460. fd.temp_noti_msg,
  1461. fd.recognition_return_msg,
  1462. fd.fail_count,
  1463. fd.id 'faceLivenessId',
  1464. fd.check_operator_type,
  1465. u.last_face_time,
  1466. t.is_face_check 'thirdIsFaceCheck'
  1467. FROM
  1468. mall_order o
  1469. LEFT JOIN mall_user u ON o.user_id = u.id
  1470. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1471. left join mall_store s on o.store_id = s.id
  1472. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1473. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1474. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1475. AND r.goods_id = g.goods_id
  1476. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1477. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1478. WHERE 1=1
  1479. <if test="startTime != null and startTime != ''">
  1480. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1481. </if>
  1482. <if test="endTime != null and endTime != ''">
  1483. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1484. </if>
  1485. <if test="storeId != null and storeId != ''">
  1486. AND o.store_id = #{storeId}
  1487. </if>
  1488. <if test="sku != null and sku.trim() != ''">
  1489. AND gs.sku = #{sku}
  1490. </if>
  1491. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1492. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1493. </if>
  1494. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1495. AND t.third_merch_sn = #{thirdMerchSn}
  1496. </if>
  1497. <if test="supplierThirdId != null and supplierThirdId != ''">
  1498. AND r.supplier_third_id = #{supplierThirdId}
  1499. </if>
  1500. <if test="orderBizType != null and orderBizType != ''">
  1501. AND o.order_biz_type = #{orderBizType}
  1502. </if>
  1503. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1504. AND o.merch_order_sn = #{merchOrderSn}
  1505. </if>
  1506. <if test="merchSn != null and merchSn.trim() != ''">
  1507. AND o.merch_sn = #{merchSn}
  1508. </if>
  1509. <if test="orderSn != null and orderSn.trim() != ''">
  1510. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1511. </if>
  1512. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1513. AND o.shipping_status = #{shippingStatus}
  1514. </if>
  1515. <if test="payStatus != null and payStatus.trim() != ''">
  1516. AND o.pay_status = #{payStatus}
  1517. </if>
  1518. <if test="orderStatus != null and orderStatus.trim() != ''">
  1519. AND o.order_status = #{orderStatus}
  1520. </if>
  1521. <if test="shippingId != null and shippingId != 0">
  1522. AND o.shipping_id = #{shippingId}
  1523. </if>
  1524. <if test="orderType != null and orderType.trim() != ''">
  1525. AND o.order_type = #{orderType}
  1526. </if>
  1527. <if test="isOnfiilineOrder != null">
  1528. AND o.is_onffline_order = #{isOnfiilineOrder}
  1529. </if>
  1530. <if test="ids != null and ids.trim() != ''">
  1531. AND o.id in (${ids})
  1532. </if>
  1533. <choose>
  1534. <when test="sidx != null and sidx.trim() != ''">
  1535. order by ${sidx} ${order}
  1536. </when>
  1537. <otherwise>
  1538. order by o.id desc
  1539. </otherwise>
  1540. </choose>
  1541. <if test="offset != null and limit != null">
  1542. limit #{offset}, #{limit}
  1543. </if>
  1544. </select>
  1545. <select id="queryOrderListByRecognitionTotal" resultType="int">
  1546. SELECT count(1)
  1547. FROM
  1548. mall_order o
  1549. LEFT JOIN mall_user u ON o.user_id = u.id
  1550. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1551. left join mall_store s on o.store_id = s.id
  1552. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1553. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1554. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1555. AND r.goods_id = g.goods_id
  1556. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1557. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1558. WHERE 1=1
  1559. <if test="startTime != null and startTime != ''">
  1560. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1561. </if>
  1562. <if test="endTime != null and endTime != ''">
  1563. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1564. </if>
  1565. <if test="storeId != null and storeId != ''">
  1566. AND o.store_id = #{storeId}
  1567. </if>
  1568. <if test="sku != null and sku.trim() != ''">
  1569. AND gs.sku = #{sku}
  1570. </if>
  1571. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1572. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1573. </if>
  1574. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1575. AND t.third_merch_sn = #{thirdMerchSn}
  1576. </if>
  1577. <if test="supplierThirdId != null and supplierThirdId != ''">
  1578. AND r.supplier_third_id = #{supplierThirdId}
  1579. </if>
  1580. <if test="orderBizType != null and orderBizType != ''">
  1581. AND o.order_biz_type = #{orderBizType}
  1582. </if>
  1583. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1584. AND o.merch_order_sn = #{merchOrderSn}
  1585. </if>
  1586. <if test="merchSn != null and merchSn.trim() != ''">
  1587. AND o.merch_sn = #{merchSn}
  1588. </if>
  1589. <if test="orderSn != null and orderSn.trim() != ''">
  1590. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1591. </if>
  1592. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1593. AND o.shipping_status = #{shippingStatus}
  1594. </if>
  1595. <if test="payStatus != null and payStatus.trim() != ''">
  1596. AND o.pay_status = #{payStatus}
  1597. </if>
  1598. <if test="orderStatus != null and orderStatus.trim() != ''">
  1599. AND o.order_status = #{orderStatus}
  1600. </if>
  1601. <if test="shippingId != null and shippingId != 0">
  1602. AND o.shipping_id = #{shippingId}
  1603. </if>
  1604. <if test="orderType != null and orderType.trim() != ''">
  1605. AND o.order_type = #{orderType}
  1606. </if>
  1607. <if test="isOnfiilineOrder != null">
  1608. AND o.is_onffline_order = #{isOnfiilineOrder}
  1609. </if>
  1610. <if test="ids != null and ids.trim() != ''">
  1611. AND o.id in (${ids})
  1612. </if>
  1613. </select>
  1614. <select id="queryOrderByRecogTemp" resultType="com.kmall.admin.dto.SendTempDto">
  1615. SELECT
  1616. o.add_time 'addTime',
  1617. u.weixin_openid 'openId',
  1618. o.merch_order_sn 'merchOrderSn',
  1619. o.id 'orderId',
  1620. o.order_sn 'orderSn'
  1621. FROM
  1622. mall_order o
  1623. INNER JOIN mall_user u ON o.user_id = u.id
  1624. where o.id = #{value}
  1625. </select>
  1626. <select id="queryRealtimeSales" resultType="com.kmall.admin.entity.RealtimeSalesDetection">
  1627. SELECT
  1628. s.id AS storeId,
  1629. o.merch_sn AS merchSn,
  1630. m.merch_name AS merchName,
  1631. count( distinct o.order_sn ) AS guestNumber,
  1632. sum( og.actual_payment_amount) + sum(og.discounted_price)AS totalSales,
  1633. sum( og.actual_payment_amount) - sum(og.tax_price) + sum(og.discounted_price) AS actualSales,
  1634. s.store_name AS storeName,
  1635. max( o.add_time ) AS lastSalesTime ,
  1636. sum( sr.bottom_line_price) AS totalCost
  1637. FROM
  1638. mall_order o
  1639. LEFT JOIN mall_store s ON o.store_id = s.id
  1640. LEFT JOIN mall_merch m ON o.merch_sn = m.merch_sn
  1641. LEFT JOIN mall_order_goods og ON o.id = og.order_id
  1642. LEFT JOIN mall_goods g ON og.goods_id = g.id
  1643. LEFT JOIN mall_product_store_rela sr ON sr.goods_id = g.id and sr.store_id = o.store_id
  1644. LEFT JOIN mall_category c ON sr.category_id = c.id
  1645. WHERE
  1646. 1 = 1
  1647. and (o.order_status = '300' or o.order_status = '201')
  1648. <if test="storeId != null and storeId.trim() != ''">
  1649. and o.store_id=#{storeId}
  1650. </if>
  1651. <if test="merchSn != null and merchSn.trim() != ''">
  1652. and o.merch_sn=#{merchSn}
  1653. </if>
  1654. <choose>
  1655. <when test="compareDate != null and compareDate != ''">
  1656. and ( datediff ( o.add_time , #{compareDate} ) = 0 )
  1657. </when>
  1658. <when test="salesDate != null and salesDate != ''">
  1659. and ( datediff ( o.add_time , #{salesDate} ) = 0 )
  1660. </when >
  1661. <otherwise></otherwise>
  1662. </choose>
  1663. <if test="categoryId != null and categoryId != ''">
  1664. AND (c.parent_id = #{categoryId} or c.id = #{categoryId})
  1665. </if>
  1666. </select>
  1667. <select id="purchaseSalesInStockDetailList" resultType="com.kmall.admin.entity.PurchaseSalesInStockDetail">
  1668. select
  1669. substr(msmc.create_time,1,10) as time,
  1670. if(msmc.change_type = 1 ,'销售','期初') as type,
  1671. sum(if((msmc.change_type = 2 or msmc.change_type = 3 ),msmc.store_change_num,0)) as addNum,
  1672. sum(if(msmc.change_type = 1 ,msmc.store_change_num,0)) as lessNum,
  1673. rela.stock_num as endingInventory,
  1674. rela.stock_num as inventory,
  1675. 0 as costPrice,
  1676. rela.retail_price as retailPrice,
  1677. 0 as addAmount,
  1678. sum(if(msmc.change_type = 1 ,msmc.store_change_num,0)*rela.retail_price) as lessAmount,
  1679. 0 as price
  1680. from mall_product_store_rela rela
  1681. left join mall_store_mng_change msmc on msmc.goods_id = rela.goods_id
  1682. left join mall_goods g on g.id = msmc.goods_id
  1683. WHERE 1=1 and msmc.creater_sn <![CDATA[ <> ]]> '定时任务'
  1684. <if test="storeId != null and storeId != ''">
  1685. AND rela.store_id = #{storeId}
  1686. </if>
  1687. <if test="goodsSn != null and goodsSn.trim() != ''">
  1688. AND g.goods_sn = #{goodsSn}
  1689. </if>
  1690. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1691. AND g.prod_barcode = #{prodBarcode}
  1692. </if>
  1693. <if test="startTime != null and startTime.trim() != ''">
  1694. AND substr(msmc.create_time,1,10) <![CDATA[ >= ]]> #{startTime}
  1695. </if>
  1696. <if test="endTime != null and endTime.trim() != ''">
  1697. AND substr(msmc.create_time,1,10) <![CDATA[ <= ]]> #{endTime}
  1698. </if>
  1699. group by substr(msmc.create_time,1,10)
  1700. <if test="offset != null and limit != null">
  1701. limit #{offset}, #{limit}
  1702. </if>
  1703. </select>
  1704. <select id="purchaseSalesInStockDetailTotal" resultType="int">
  1705. select count(1) from ( select count(DISTINCT rela.id)
  1706. from mall_product_store_rela rela
  1707. left join mall_store_mng_change msmc on msmc.goods_id = rela.goods_id
  1708. left join mall_goods g on g.id = msmc.goods_id
  1709. WHERE 1=1 and msmc.creater_sn <![CDATA[ <> ]]> '定时任务'
  1710. <if test="storeId != null and storeId != ''">
  1711. AND rela.store_id = #{storeId}
  1712. </if>
  1713. <if test="goodsSn != null and goodsSn.trim() != ''">
  1714. AND g.goods_sn = #{goodsSn}
  1715. </if>
  1716. <if test="sku != null and sku.trim() != ''">
  1717. AND g.sku = #{sku}
  1718. </if>
  1719. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1720. AND g.prod_barcode = #{prodBarcode}
  1721. </if>
  1722. <if test="startTime != null and startTime.trim() != ''">
  1723. AND substr(msmc.create_time,1,10) <![CDATA[ >= ]]> #{startTime}
  1724. </if>
  1725. <if test="endTime != null and endTime.trim() != ''">
  1726. AND substr(msmc.create_time,1,10) <![CDATA[ <= ]]> #{endTime}
  1727. </if>
  1728. group by substr(msmc.create_time,1,10)
  1729. ) b
  1730. </select>
  1731. <select id="queryTopicPriceByOrderSnAndSku" resultType="java.math.BigDecimal">
  1732. SELECT mst.topic_price FROM mall_order mo
  1733. inner JOIN mall_order_goods mog ON mo.id = mog.order_id
  1734. inner JOIN mall_store_topic mst ON mog.store_topic_id=mst.id
  1735. WHERE mo.order_sn=#{orderSn} AND mog.sku=#{sku};
  1736. </select>
  1737. <select id="queryExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1738. SELECT distinct
  1739. o.id,
  1740. o.order_sn,
  1741. u.username as userName,
  1742. o.pay_name,
  1743. o.mobile,
  1744. o.is_onffline_order,
  1745. o.order_biz_type,
  1746. o.order_status,
  1747. o.pay_status,
  1748. o.coupon_name,
  1749. o.coupon_price,
  1750. g.actual_payment_amount as actualPrice,
  1751. o.order_price,
  1752. o.pay_time,
  1753. o.pay_flag,
  1754. u.username AS userName,
  1755. g.discounted_price as couponPrice ,
  1756. s.store_name storeName,
  1757. g.sku,
  1758. g.goods_name as goodsName,
  1759. g.retail_price,
  1760. g.number
  1761. FROM
  1762. mall_order o
  1763. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1764. left join mall_store s on o.store_id = s.id
  1765. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1766. left join mall_sale_record record on record.order_sn = o.order_sn
  1767. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  1768. WHERE 1=1
  1769. <if test="orderSn != null and orderSn.trim() != ''">
  1770. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1771. </if>
  1772. <if test="orderStatus != null and orderStatus.trim() != ''">
  1773. AND o.order_status = #{orderStatus}
  1774. </if>
  1775. <if test="isOnfiilineOrder != null">
  1776. AND o.is_onffline_order = #{isOnfiilineOrder}
  1777. </if>
  1778. <if test="startTime != null and startTime != ''">
  1779. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1780. </if>
  1781. <if test="endTime != null and endTime != ''">
  1782. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1783. </if>
  1784. <if test="storeName != null and storeName != ''">
  1785. AND s.store_name LIKE concat('%',#{storeName},'%')
  1786. </if>
  1787. </select>
  1788. <select id="queryMasterExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1789. SELECT distinct
  1790. o.id,
  1791. o.order_sn,
  1792. u.username as userName,
  1793. o.pay_name,
  1794. o.mobile,
  1795. o.is_onffline_order,
  1796. o.order_biz_type,
  1797. o.order_status,
  1798. o.pay_status,
  1799. o.coupon_name,
  1800. o.coupon_price,
  1801. o.actual_price,
  1802. o.order_price,
  1803. o.pay_time,
  1804. o.pay_flag,
  1805. u.username AS userName,
  1806. s.store_name storeName
  1807. FROM
  1808. mall_order o
  1809. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1810. left join mall_store s on o.store_id = s.id
  1811. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1812. left join mall_sale_record record on record.order_sn = o.order_sn
  1813. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  1814. WHERE 1=1
  1815. <if test="storeId != null and storeId != ''">
  1816. AND o.store_id = #{storeId}
  1817. </if>
  1818. <if test="merchSn != null and merchSn.trim() != ''">
  1819. AND o.merch_sn = #{merchSn}
  1820. </if>
  1821. <if test="goodsSn != null and goodsSn.trim() != ''">
  1822. AND gs.goods_sn = #{goodsSn}
  1823. </if>
  1824. <if test="sku != null and sku.trim() != ''">
  1825. AND gs.sku = #{sku}
  1826. </if>
  1827. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1828. AND gs.prod_barcode = #{prodBarcode}
  1829. </if>
  1830. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1831. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1832. </if>
  1833. <if test="orderSn != null and orderSn.trim() != ''">
  1834. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1835. </if>
  1836. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1837. AND o.shipping_status = #{shippingStatus}
  1838. </if>
  1839. <if test="payStatus != null and payStatus.trim() != ''">
  1840. AND o.pay_status = #{payStatus}
  1841. </if>
  1842. <if test="orderStatus != null and orderStatus.trim() != ''">
  1843. AND o.order_status = #{orderStatus}
  1844. </if>
  1845. <if test="shippingId != null and shippingId != 0">
  1846. AND o.shipping_id = #{shippingId}
  1847. </if>
  1848. <if test="orderType != null and orderType.trim() != ''">
  1849. AND o.order_type = #{orderType}
  1850. </if>
  1851. <if test="isOnfiilineOrder != null">
  1852. AND o.is_onffline_order = #{isOnfiilineOrder}
  1853. </if>
  1854. <if test="ids != null and ids.trim() != ''">
  1855. AND o.id in (${ids})
  1856. </if>
  1857. <if test="startTime != null and startTime != ''">
  1858. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1859. </if>
  1860. <if test="endTime != null and endTime != ''">
  1861. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1862. </if>
  1863. <if test="billDate != null and billDate != ''">
  1864. AND DATE_FORMAT(o.add_time,'%Y-%m-%d') = #{billDate}
  1865. </if>
  1866. <if test="storeId != null and storeId != ''">
  1867. AND o.store_id = #{storeId}
  1868. </if>
  1869. <if test="storeName != null and storeName != ''">
  1870. AND s.store_name LIKE concat('%',#{storeName},'%')
  1871. </if>
  1872. order by o.order_status
  1873. </select>
  1874. <select id="queryMasterExportList" resultType="com.kmall.admin.entity.OrderEntity">
  1875. SELECT DISTINCT
  1876. o.order_sn,
  1877. o.merch_order_sn,
  1878. o.order_status,
  1879. o.actual_price,
  1880. o.order_biz_type,
  1881. o.shipping_no,
  1882. o.shipping_name,
  1883. o.shipping_code,
  1884. o.consignee,
  1885. o.mobile,
  1886. o.province,
  1887. o.city,
  1888. o.district,
  1889. o.address,
  1890. o.add_time,
  1891. o.pay_id,
  1892. o.pay_status,
  1893. o.shipping_status,
  1894. o.is_merge_pay,
  1895. o.buyer_pay_check,
  1896. o.order_price,
  1897. o.moder_sn,
  1898. o.id,
  1899. u.username AS username,
  1900. p.is_payment_send,
  1901. p.is_ele_order_send,
  1902. p.is_customs_send,
  1903. s.store_name,
  1904. o.full_cut_price,
  1905. o.camp_minus_id,
  1906. o.camp_name
  1907. FROM
  1908. mall_order o
  1909. LEFT JOIN mall_user u ON o.user_id = u.id
  1910. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1911. left join mall_store s on o.store_id = s.id
  1912. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1913. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1914. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1915. AND r.goods_id = g.goods_id
  1916. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1917. WHERE 1=1
  1918. <if test="startTime != null and startTime != ''">
  1919. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1920. </if>
  1921. <if test="endTime != null and endTime != ''">
  1922. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1923. </if>
  1924. <if test="storeId != null and storeId != ''">
  1925. AND o.store_id = #{storeId}
  1926. </if>
  1927. <if test="sku != null and sku.trim() != ''">
  1928. AND gs.sku = #{sku}
  1929. </if>
  1930. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1931. AND gs.prod_barcode = #{prodBarcode}
  1932. </if>
  1933. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1934. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1935. </if>
  1936. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1937. AND t.third_merch_sn = #{thirdMerchSn}
  1938. </if>
  1939. <if test="supplierThirdId != null and supplierThirdId != ''">
  1940. AND r.supplier_third_id = #{supplierThirdId}
  1941. </if>
  1942. <if test="orderBizType != null and orderBizType != ''">
  1943. AND o.order_biz_type = #{orderBizType}
  1944. </if>
  1945. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1946. AND o.merch_order_sn = #{merchOrderSn}
  1947. </if>
  1948. <if test="merchSn != null and merchSn.trim() != ''">
  1949. AND o.merch_sn = #{merchSn}
  1950. </if>
  1951. <if test="orderSn != null and orderSn.trim() != ''">
  1952. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1953. </if>
  1954. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1955. AND o.shipping_status = #{shippingStatus}
  1956. </if>
  1957. <if test="payStatus != null and payStatus.trim() != ''">
  1958. AND o.pay_status = #{payStatus}
  1959. </if>
  1960. <if test="orderStatus != null and orderStatus.trim() != ''">
  1961. AND o.order_status = #{orderStatus}
  1962. </if>
  1963. <if test="shippingId != null and shippingId != 0">
  1964. AND o.shipping_id = #{shippingId}
  1965. </if>
  1966. <if test="orderType != null and orderType.trim() != ''">
  1967. AND o.order_type = #{orderType}
  1968. </if>
  1969. <if test="isOnfiilineOrder != null">
  1970. AND o.is_onffline_order = #{isOnfiilineOrder}
  1971. </if>
  1972. <if test="ids != null and ids.trim() != ''">
  1973. AND o.id in (${ids})
  1974. </if>
  1975. </select>
  1976. <select id="queryPickUpCodeList" resultType="com.kmall.admin.entity.OrderEntity">
  1977. SELECT distinct
  1978. o.*,
  1979. c.pick_up_code_sn,
  1980. c.pick_up_code_status
  1981. FROM mall_order o
  1982. LEFT JOIN mall_pick_up_code c ON c.order_sn = o.order_sn
  1983. WHERE 1=1
  1984. <if test="storeId != null and storeId != ''">
  1985. AND o.store_id = #{storeId}
  1986. </if>
  1987. <if test="isOnfiilineOrder != null">
  1988. AND o.is_onffline_order = #{isOnfiilineOrder}
  1989. </if>
  1990. <if test="orderSn != null and orderSn.trim() != ''">
  1991. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1992. </if>
  1993. <if test="payName != null and payName.trim() != ''">
  1994. AND o.pay_name LIKE concat('%',#{payName},'%')
  1995. </if>
  1996. <if test="payMobile != null and payMobile.trim() != ''">
  1997. AND o.pay_mobile LIKE concat('%',#{payMobile},'%')
  1998. </if>
  1999. <if test="startTime != null and startTime.trim() != ''">
  2000. AND c.pick_up_code_createtime &gt;= #{startTime}
  2001. </if>
  2002. <if test="endTime != null and endTime.trim() != ''">
  2003. AND c.pick_up_code_createtime &lt;= #{endTime}
  2004. </if>
  2005. order by o.id desc
  2006. </select>
  2007. <select id="queryExportSystemFormatList" resultType="com.kmall.admin.dto.SystemFormatDto">
  2008. SELECT distinct
  2009. o.id,
  2010. g.goods_id,
  2011. o.order_sn as receiptNo,
  2012. u.username as cashRegisterNo,
  2013. o.create_time as timeStampDetails,
  2014. u.username as staffID,
  2015. u.username as staffName,
  2016. gs.hs_code as hsCode,
  2017. gs.hs_code_name as hsCodeName,
  2018. gs.goods_sn as ematouCode,
  2019. gs.plu as plu,
  2020. gs.mychem_id as mychemID,
  2021. gs.english_name as productNameEN,
  2022. gs.name as productNameCN,
  2023. gs.prod_barcode as barcode,
  2024. gs.ciq_prod_model as packSize,
  2025. gs.goods_number as goodsNumber,
  2026. uc.name as productSpecification,
  2027. b.name as brand,
  2028. gs.daily_price as edlp,
  2029. sr.bottom_line_price as costPrice,
  2030. sr.bottom_line_price*gs.goods_number as primeCost,
  2031. g.number as unitSold,
  2032. g.actual_payment_amount as totalSalesInclTax,
  2033. gs.goods_rate as taxRate,
  2034. '专柜单品' as productCategory,
  2035. sup.child_supplier_name as supplierName,
  2036. '300' as orderStatus,
  2037. g.tax_price as taxPrice,
  2038. s.store_name as storeName,
  2039. o.pay_flag as payFlag,
  2040. o.pay_transaction_id as orderSnWx,
  2041. o.ali_trade_no as orderSnAli
  2042. FROM
  2043. mall_order o
  2044. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2045. left join mall_store s on o.store_id = s.id
  2046. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2047. left join mall_sale_record record on record.order_sn = o.order_sn
  2048. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2049. left join sys_cus_unit_code uc on uc.code = gs.unit_code
  2050. left join mall_product_store_rela sr on sr.goods_id=gs.id and sr.store_id = o.store_id
  2051. left join mall_brand b on b.id=sr.brand_id
  2052. left join mall_supplier sup on gs.supplier_id = sup.id
  2053. WHERE 1=1
  2054. <if test="orderSn != null and orderSn.trim() != ''">
  2055. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  2056. </if>
  2057. <choose>
  2058. <when test="orderStatus != null and orderStatus.trim() != ''">
  2059. AND o.order_status = #{orderStatus}
  2060. </when>
  2061. <otherwise>
  2062. AND o.order_status in ('401','300')
  2063. </otherwise>
  2064. </choose>
  2065. <if test="isOnfiilineOrder != null">
  2066. AND o.is_onffline_order = #{isOnfiilineOrder}
  2067. </if>
  2068. <if test="startTime != null and startTime != ''">
  2069. AND o.add_time <![CDATA[ > ]]> #{startTime}
  2070. </if>
  2071. <if test="endTime != null and endTime != ''">
  2072. AND o.add_time <![CDATA[ < ]]> #{endTime}
  2073. </if>
  2074. <if test="storeName != null and storeName != ''">
  2075. AND s.store_name LIKE concat('%',#{storeName},'%')
  2076. </if>
  2077. union
  2078. SELECT distinct
  2079. o.id,
  2080. g.goods_id,
  2081. o.order_sn as receiptNo,
  2082. u.username as cashRegisterNo,
  2083. mor.create_time as timeStampDetails,
  2084. u.username as staffID,
  2085. u.username as staffName,
  2086. gs.hs_code as hsCode,
  2087. gs.hs_code_name as hsCodeName,
  2088. gs.goods_sn as ematouCode,
  2089. gs.plu as plu,
  2090. gs.mychem_id as mychemID,
  2091. gs.english_name as productNameEN,
  2092. gs.name as productNameCN,
  2093. gs.prod_barcode as barcode,
  2094. gs.ciq_prod_model as packSize,
  2095. gs.goods_number as goodsNumber,
  2096. uc.name as productSpecification,
  2097. b.name as brand,
  2098. gs.daily_price as edlp,
  2099. sr.bottom_line_price as costPrice,
  2100. sr.bottom_line_price*gs.goods_number as primeCost,
  2101. g.number as unitSold,
  2102. g.actual_payment_amount as totalSalesInclTax,
  2103. gs.goods_rate as taxRate,
  2104. '专柜单品' as productCategory,
  2105. sup.child_supplier_name as supplierName,
  2106. o.order_status as orderStatus,
  2107. g.tax_price as taxPrice,
  2108. s.store_name as storeName,
  2109. o.pay_flag as payFlag,
  2110. o.pay_transaction_id as orderSnWx,
  2111. o.ali_trade_no as orderSnAli
  2112. FROM
  2113. mall_order o
  2114. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2115. left join mall_store s on o.store_id = s.id
  2116. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2117. left join mall_sale_record record on record.order_sn = o.order_sn
  2118. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2119. left join sys_cus_unit_code uc on uc.code = gs.unit_code
  2120. left join mall_product_store_rela sr on sr.goods_id=gs.id and sr.store_id = o.store_id
  2121. left join mall_brand b on b.id=sr.brand_id
  2122. left join mall_supplier sup on gs.supplier_id = sup.id
  2123. left join mall_order_refund mor on mor.out_refund_no = o.order_sn
  2124. WHERE 1=1
  2125. <if test="orderSn != null and orderSn.trim() != ''">
  2126. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  2127. </if>
  2128. <choose>
  2129. <when test="orderStatus != null and orderStatus.trim() != ''">
  2130. AND o.order_status = #{orderStatus}
  2131. </when>
  2132. <otherwise>
  2133. AND o.order_status = '401'
  2134. </otherwise>
  2135. </choose>
  2136. <if test="isOnfiilineOrder != null">
  2137. AND o.is_onffline_order = #{isOnfiilineOrder}
  2138. </if>
  2139. <if test="startTime != null and startTime != ''">
  2140. AND mor.create_time <![CDATA[ > ]]> #{startTime}
  2141. </if>
  2142. <if test="endTime != null and endTime != ''">
  2143. AND mor.create_time <![CDATA[ < ]]> #{endTime}
  2144. </if>
  2145. <if test="storeName != null and storeName != ''">
  2146. AND s.store_name LIKE concat('%',#{storeName},'%')
  2147. </if>
  2148. </select>
  2149. <update id="updateOrderInfo" parameterType="map">
  2150. UPDATE mall_order a
  2151. <set>
  2152. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  2153. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  2154. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  2155. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  2156. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  2157. <if test="payTime != null">a.pay_time = #{payTime},</if>
  2158. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  2159. <if test="feeType != null">a.fee_type = #{feeType},</if>
  2160. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  2161. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  2162. <if test="rate != null">a.rate = #{rate},</if>
  2163. </set>
  2164. WHERE 1 = 1
  2165. AND a.id = #{orderId}
  2166. </update>
  2167. <update id="updateOrderProcessRecord" parameterType="map">
  2168. UPDATE mall_order_process_record a
  2169. <set>
  2170. <if test="payTime != null">a.pay_succ_time = #{payTime}</if>
  2171. </set>
  2172. WHERE 1 = 1
  2173. AND a.order_sn = #{orderSn}
  2174. </update>
  2175. <select id="totalAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
  2176. select
  2177. ifnull(sum(actual_price),0) as totalAmount
  2178. ,ifnull(count(1),0) as totalCount
  2179. from
  2180. mall_order
  2181. where
  2182. order_status = 300
  2183. and DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
  2184. <if test="storeId != ''">
  2185. and store_id = #{storeId}
  2186. </if>
  2187. </select>
  2188. <select id="refundCurrentAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
  2189. select
  2190. ifnull(sum(actual_price),0) as refundCurrentAmount,
  2191. ifnull(count(1),0) as refundCurrentCount
  2192. from
  2193. mall_order
  2194. where
  2195. DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
  2196. and id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
  2197. <if test="storeId != ''">
  2198. and store_id = #{storeId}
  2199. </if>
  2200. </select>
  2201. <select id="refundPreviousAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
  2202. select
  2203. ifnull(sum(actual_price),0) as refundPreviousAmount
  2204. ,ifnull(count(1),0) as refundPreviousCount
  2205. from
  2206. mall_order
  2207. where
  2208. DATE_FORMAT(pay_time,'%Y-%m-%d') != #{billDate}
  2209. and id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
  2210. <if test="storeId != ''">
  2211. and store_id = #{storeId}
  2212. </if>
  2213. </select>
  2214. <select id="currentTax" resultType="com.kmall.admin.dto.ExportExcelDto">
  2215. select
  2216. ifnull(sum(tax_price),0) as currentTax
  2217. from
  2218. mall_order_goods t1
  2219. where
  2220. DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate}
  2221. and order_id in (
  2222. select id from mall_order where order_status = 300 and DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
  2223. <if test="storeId != ''">
  2224. and store_id = #{storeId}
  2225. </if>
  2226. )
  2227. </select>
  2228. <select id="refundPreviousTax" resultType="com.kmall.admin.dto.ExportExcelDto">
  2229. select
  2230. ifnull(sum(tax_price),0) as previousTax
  2231. from
  2232. mall_order_goods t1
  2233. where
  2234. DATE_FORMAT(create_time,'%Y-%m-%d') != #{billDate}
  2235. and order_id in (
  2236. select distinct mor.order_id from mall_order_refund mor , mall_order o where mor.out_refund_no = o.order_sn and DATE_FORMAT(mor.create_time,'%Y-%m-%d') = #{billDate}
  2237. <if test="storeId != ''">
  2238. and o.store_id = #{storeId}
  2239. </if>
  2240. )
  2241. </select>
  2242. <select id="queryCurrentPreviousOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  2243. SELECT distinct
  2244. o.id,
  2245. o.order_sn,
  2246. u.username as userName,
  2247. o.pay_name,
  2248. o.mobile,
  2249. o.is_onffline_order,
  2250. o.order_biz_type,
  2251. o.order_status,
  2252. o.pay_status,
  2253. o.coupon_name,
  2254. o.coupon_price,
  2255. if(o.order_status=401,concat("-",o.actual_price),o.actual_price) as actualPrice
  2256. , if(o.order_status=401,concat("-",o.order_price),o.order_price) as orderPrice,
  2257. o.pay_time,
  2258. o.pay_flag,
  2259. u.username AS userName,
  2260. s.store_name storeName
  2261. FROM
  2262. mall_order o
  2263. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2264. left join mall_store s on o.store_id = s.id
  2265. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2266. left join mall_sale_record record on record.order_sn = o.order_sn
  2267. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2268. WHERE
  2269. (DATE_FORMAT(o.create_time,'%Y-%m-%d') = #{billDate})
  2270. <if test="storeId != ''">
  2271. and o.store_id = #{storeId}
  2272. </if>
  2273. order by o.order_status
  2274. </select>
  2275. <select id="queryRefundPreviousOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  2276. SELECT distinct
  2277. o.id,
  2278. o.order_sn,
  2279. u.username as userName,
  2280. o.pay_name,
  2281. o.mobile,
  2282. o.is_onffline_order,
  2283. o.order_biz_type,
  2284. o.order_status,
  2285. o.pay_status,
  2286. o.coupon_name,
  2287. o.coupon_price,
  2288. if(o.order_status=401,concat("-",o.actual_price),o.actual_price) as actualPrice
  2289. , if(o.order_status=401,concat("-",o.order_price),o.order_price) as orderPrice,
  2290. o.pay_time,
  2291. o.pay_flag,
  2292. u.username AS userName,
  2293. s.store_name storeName
  2294. FROM
  2295. mall_order o
  2296. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2297. left join mall_store s on o.store_id = s.id
  2298. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2299. left join mall_sale_record record on record.order_sn = o.order_sn
  2300. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2301. WHERE
  2302. (DATE_FORMAT(o.create_time,'%Y-%m-%d') != #{billDate})
  2303. and o.id in (select r.order_id from mall_order_refund r where (DATE_FORMAT(r.create_time,'%Y-%m-%d') = #{billDate}))
  2304. <if test="storeId != ''">
  2305. and o.store_id = #{storeId}
  2306. </if>
  2307. order by o.order_status
  2308. </select>
  2309. <select id="queryCurrentTaxDetailList" resultType="com.kmall.admin.dto.TaxDetailDto">
  2310. select o.order_sn as orderSn,s.id as storeId, s.store_name as storeName,g.goods_sn as sku,
  2311. imp_consum_tax_rate as saleTaxRate , value_added_tax_rate as vatRate,
  2312. og.tax_price as tax , o.mod_time as receiveTaxTime,og.actual_payment_amount as postTaxPrice
  2313. from mall_order o ,mall_order_goods og , mall_goods g , mall_store s where o.id = og.order_id and og.sku = g.goods_sn and o.store_id = s.id and o.order_status = 300
  2314. and DATE_FORMAT(o.pay_time,'%Y-%m-%d') = #{billDate}
  2315. <if test="storeId != ''">
  2316. and o.store_id = #{storeId}
  2317. </if>
  2318. </select>
  2319. <select id="queryRefundPreviousTaxDetailList" resultType="com.kmall.admin.dto.TaxDetailDto">
  2320. select o.order_sn as orderSn,s.id as storeId, s.store_name as storeName,g.goods_sn as sku,
  2321. imp_consum_tax_rate as preSaleTax , value_added_tax_rate as preVat,
  2322. og.tax_price as preTax , o.mod_time as preTaxTime,og.actual_payment_amount as postTaxPrice
  2323. from mall_order o ,mall_order_goods og , mall_goods g , mall_store s where o.id = og.order_id and og.sku = g.goods_sn and o.store_id = s.id
  2324. and DATE_FORMAT(o.pay_time,'%Y-%m-%d') != #{billDate} and o.id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
  2325. <if test="storeId != ''">
  2326. and o.store_id = #{storeId}
  2327. </if>
  2328. </select>
  2329. <select id="queryAll201Order" resultType="com.kmall.admin.entity.OrderEntity">
  2330. SELECT
  2331. *
  2332. FROM
  2333. mall_order
  2334. WHERE
  2335. DATE_FORMAT( create_time, '%Y-%m-%d' ) = #{date}
  2336. AND order_status = 201
  2337. AND now( ) - INTERVAL 5 MINUTE >= pay_time
  2338. ORDER BY
  2339. create_time DESC
  2340. </select>
  2341. <update id="updateOrderRefunding">
  2342. update mall_order set pay_status = 3 where id = #{id}
  2343. </update>
  2344. <update id="updateOrderStatusByOrderSnList" parameterType="java.util.List">
  2345. update mall_order
  2346. set order_status = 300
  2347. where order_sn in
  2348. <foreach collection="list" item="item" open="(" separator="," close=")">
  2349. #{item}
  2350. </foreach>
  2351. </update>
  2352. <select id="queryObjectByMerchOrderSnHkMall" parameterType="java.lang.String" resultType="java.lang.Integer">
  2353. select count(*) from mall_order a where merch_order_sn = #{merchOrderSn}
  2354. </select>
  2355. <update id="updateBuyerPayCheck" parameterType="hashMap">
  2356. update mall_order
  2357. <set >
  2358. <if test="buyerPayCheck != null">
  2359. buyer_pay_check = #{buyerPayCheck},
  2360. </if>
  2361. <if test="orderStatus != null">
  2362. order_status = #{orderStatus},
  2363. </if>
  2364. <if test="shippingNo != null">
  2365. shipping_no = #{shippingNo},
  2366. </if>
  2367. <if test="shippingCode != null">
  2368. shipping_code = #{shippingCode},
  2369. </if>
  2370. <if test="shippingName != null">
  2371. shipping_name = #{shippingName},
  2372. </if>
  2373. <if test="shippingStatus != null">
  2374. shipping_status = #{shippingStatus},
  2375. </if>
  2376. </set>
  2377. where order_sn = #{orderSn,jdbcType=VARCHAR}
  2378. </update>
  2379. </mapper>