OrderDao.xml 94 KB

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