1
0

OrderDao.xml 92 KB

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