OrderDao.xml 93 KB

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