OrderDao.xml 91 KB

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