OrderDao.xml 76 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999
  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 * from mall_order a where order_sn = #{orderSn}
  104. </select>
  105. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  106. SELECT DISTINCT
  107. o.order_sn,
  108. o.merch_order_sn,
  109. o.order_status,
  110. o.actual_price,
  111. o.order_biz_type,
  112. o.shipping_no,
  113. o.shipping_name,
  114. o.shipping_code,
  115. o.consignee,
  116. o.mobile,
  117. o.province,
  118. o.city,
  119. o.district,
  120. o.address,
  121. o.add_time,
  122. o.pay_id,
  123. o.pay_status,
  124. o.shipping_status,
  125. o.is_merge_pay,
  126. o.buyer_pay_check,
  127. o.order_price,
  128. o.moder_sn,
  129. o.id,
  130. u.username AS username,
  131. p.is_payment_send,
  132. p.is_ele_order_send,
  133. p.is_customs_send,
  134. s.store_name,
  135. o.full_cut_price,
  136. o.camp_minus_id,
  137. o.camp_name
  138. FROM
  139. mall_order o
  140. LEFT JOIN mall_user u ON o.user_id = u.id
  141. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  142. left join mall_store s on o.store_id = s.id
  143. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  144. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  145. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  146. AND r.goods_id = g.goods_id
  147. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  148. WHERE 1=1
  149. <if test="startTime != null and startTime != ''">
  150. AND o.add_time <![CDATA[ > ]]> #{startTime}
  151. </if>
  152. <if test="endTime != null and endTime != ''">
  153. AND o.add_time <![CDATA[ < ]]> #{endTime}
  154. </if>
  155. <if test="storeId != null and storeId != ''">
  156. AND o.store_id = #{storeId}
  157. </if>
  158. <if test="sku != null and sku.trim() != ''">
  159. AND gs.sku = #{sku}
  160. </if>
  161. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  162. AND gs.prod_barcode = #{prodBarcode}
  163. </if>
  164. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  165. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  166. </if>
  167. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  168. AND t.third_merch_sn = #{thirdMerchSn}
  169. </if>
  170. <if test="supplierThirdId != null and supplierThirdId != ''">
  171. AND r.supplier_third_id = #{supplierThirdId}
  172. </if>
  173. <if test="orderBizType != null and orderBizType != ''">
  174. AND o.order_biz_type = #{orderBizType}
  175. </if>
  176. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  177. AND o.merch_order_sn = #{merchOrderSn}
  178. </if>
  179. <if test="merchSn != null and merchSn.trim() != ''">
  180. AND o.merch_sn = #{merchSn}
  181. </if>
  182. <if test="orderSn != null and orderSn.trim() != ''">
  183. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  184. </if>
  185. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  186. AND o.shipping_status = #{shippingStatus}
  187. </if>
  188. <if test="payStatus != null and payStatus.trim() != ''">
  189. AND o.pay_status = #{payStatus}
  190. </if>
  191. <if test="orderStatus != null and orderStatus.trim() != ''">
  192. AND o.order_status = #{orderStatus}
  193. </if>
  194. <if test="shippingId != null and shippingId != 0">
  195. AND o.shipping_id = #{shippingId}
  196. </if>
  197. <if test="orderType != null and orderType.trim() != ''">
  198. AND o.order_type = #{orderType}
  199. </if>
  200. <if test="isOnfiilineOrder != null">
  201. AND o.is_onffline_order = #{isOnfiilineOrder}
  202. </if>
  203. <if test="ids != null and ids.trim() != ''">
  204. AND o.id in (${ids})
  205. </if>
  206. <choose>
  207. <when test="sidx != null and sidx.trim() != ''">
  208. order by ${sidx} ${order}
  209. </when>
  210. <otherwise>
  211. order by o.id desc
  212. </otherwise>
  213. </choose>
  214. <if test="offset != null and limit != null">
  215. limit #{offset}, #{limit}
  216. </if>
  217. </select>
  218. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  219. SELECT
  220. o.order_sn,
  221. o.merch_order_sn,
  222. o.order_status,
  223. o.actual_price,
  224. o.order_biz_type,
  225. o.shipping_no,
  226. o.shipping_name,
  227. o.shipping_code,
  228. o.consignee,
  229. o.mobile,
  230. o.province,
  231. o.city,
  232. o.district,
  233. o.address,
  234. o.add_time,
  235. o.pay_id,
  236. o.shipping_status,
  237. o.shipping_fee,
  238. o.moder_sn,
  239. o.pay_transaction_id,
  240. u.id_no 'idNo',
  241. u.username AS username,
  242. p.is_payment_send,
  243. p.is_ele_order_send,
  244. p.is_customs_send,
  245. g.sku,
  246. g.goods_name,
  247. g.number,
  248. g.retail_price,
  249. s.store_name,
  250. nc.NAME ori_cnt_code,
  251. good.ciq_prod_model,
  252. good.brand,
  253. uc.NAME unit_code,
  254. good.gross_weight * g.number gross_weight,
  255. good.net_weight * g.number net_weight,
  256. t2.third_party_merch_name 'supplierThirdPartyMerchName',
  257. t2.third_party_merch_code 'supplierThirdPartyMerchCode'
  258. FROM
  259. mall_order o
  260. LEFT JOIN mall_user u ON o.user_id = u.id
  261. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  262. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  263. LEFT JOIN mall_store s ON o.store_id = s.id
  264. LEFT JOIN mall_goods good ON good.id = g.goods_id
  265. LEFT JOIN sys_cus_nation_code nc ON nc.CODE = good.ori_cnt_code
  266. LEFT JOIN sys_cus_unit_code uc ON uc.CODE = good.unit_code
  267. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  268. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  269. AND r.goods_id = g.goods_id
  270. LEFT JOIN third_merchant_biz t2 ON t2.third_merch_sn = r.supplier_third_id
  271. WHERE
  272. 1 =1
  273. <if test="storeId != null and storeId != ''">
  274. AND o.store_id = #{storeId}
  275. </if>
  276. <if test="orderStatus != null and orderStatus.trim() != ''">
  277. AND o.order_status = #{orderStatus}
  278. </if>
  279. <if test="sku != null and sku.trim() != ''">
  280. AND g.sku = #{sku}
  281. </if>
  282. <if test="startTime != null and startTime != ''">
  283. AND o.add_time <![CDATA[ > ]]> #{startTime}
  284. </if>
  285. <if test="endTime != null and endTime != ''">
  286. AND o.add_time <![CDATA[ < ]]> #{endTime}
  287. </if>
  288. <if test="storeId != null and storeId != ''">
  289. AND o.store_id = #{storeId}
  290. </if>
  291. <if test="orderBizType != null and orderBizType != ''">
  292. AND o.order_biz_type = #{orderBizType}
  293. </if>
  294. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  295. AND o.merch_order_sn = #{merchOrderSn}
  296. </if>
  297. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  298. AND t.third_merch_sn = #{thirdMerchSn}
  299. </if>
  300. <if test="supplierThirdId != null and supplierThirdId != ''">
  301. AND r.supplier_third_id = #{supplierThirdId}
  302. </if>
  303. <if test="orderSn != null and orderSn.trim() != ''">
  304. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  305. </if>
  306. <if test="payStatus != null and payStatus.trim() != ''">
  307. AND o.pay_status = #{payStatus}
  308. </if>
  309. <if test="isOnfiilineOrder != null">
  310. AND o.is_onffline_order = #{isOnfiilineOrder}
  311. </if>
  312. </select>
  313. <select id="queryTotal" resultType="int">
  314. select count(DISTINCT o.id) FROM
  315. mall_order o
  316. LEFT JOIN mall_user u ON o.user_id = u.id
  317. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  318. left join mall_store s on o.store_id = s.id
  319. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  320. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  321. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  322. AND r.goods_id = g.goods_id
  323. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  324. WHERE 1=1
  325. <if test="startTime != null and startTime != ''">
  326. AND o.add_time <![CDATA[ > ]]> #{startTime}
  327. </if>
  328. <if test="endTime != null and endTime != ''">
  329. AND o.add_time <![CDATA[ < ]]> #{endTime}
  330. </if>
  331. <if test="storeId != null and storeId != ''">
  332. AND o.store_id = #{storeId}
  333. </if>
  334. <if test="sku != null and sku.trim() != ''">
  335. AND gs.sku = #{sku}
  336. </if>
  337. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  338. AND gs.prod_barcode = #{prodBarcode}
  339. </if>
  340. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  341. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  342. </if>
  343. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  344. AND t.third_merch_sn = #{thirdMerchSn}
  345. </if>
  346. <if test="supplierThirdId != null and supplierThirdId != ''">
  347. AND r.supplier_third_id = #{supplierThirdId}
  348. </if>
  349. <if test="orderBizType != null and orderBizType != ''">
  350. AND o.order_biz_type = #{orderBizType}
  351. </if>
  352. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  353. AND o.merch_order_sn = #{merchOrderSn}
  354. </if>
  355. <if test="merchSn != null and merchSn.trim() != ''">
  356. AND o.merch_sn = #{merchSn}
  357. </if>
  358. <if test="orderSn != null and orderSn.trim() != ''">
  359. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  360. </if>
  361. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  362. AND o.shipping_status = #{shippingStatus}
  363. </if>
  364. <if test="payStatus != null and payStatus.trim() != ''">
  365. AND o.pay_status = #{payStatus}
  366. </if>
  367. <if test="orderStatus != null and orderStatus.trim() != ''">
  368. AND o.order_status = #{orderStatus}
  369. </if>
  370. <if test="shippingId != null and shippingId != 0">
  371. AND o.shipping_id = #{shippingId}
  372. </if>
  373. <if test="orderType != null and orderType.trim() != ''">
  374. AND o.order_type = #{orderType}
  375. </if>
  376. <if test="isOnfiilineOrder != null">
  377. AND o.is_onffline_order = #{isOnfiilineOrder}
  378. </if>
  379. <if test="ids != null and ids.trim() != ''">
  380. AND o.id in (${ids})
  381. </if>
  382. </select>
  383. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  384. SELECT distinct
  385. o.id,
  386. o.order_sn,
  387. u.username as userName,
  388. c.pick_up_code_sn,
  389. o.pay_name,
  390. o.mobile,
  391. o.is_onffline_order,
  392. o.order_biz_type,
  393. o.order_status,
  394. o.pay_status,
  395. o.coupon_name,
  396. o.coupon_price,
  397. o.actual_price,
  398. o.order_price,
  399. o.pay_time,
  400. o.pay_flag
  401. from mall_order o
  402. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  403. LEFT JOIN mall_sale_record record ON record.order_sn = o.order_sn
  404. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  405. LEFT JOIN mall_pick_up_code c ON o.order_sn = c.order_sn
  406. WHERE 1=1
  407. <if test="storeId != null and storeId != ''">
  408. AND o.store_id = #{storeId}
  409. </if>
  410. <if test="merchSn != null and merchSn.trim() != ''">
  411. AND o.merch_sn = #{merchSn}
  412. </if>
  413. <if test="orderSn != null and orderSn.trim() != ''">
  414. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  415. </if>
  416. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  417. AND o.shipping_status = #{shippingStatus}
  418. </if>
  419. <if test="payStatus != null and payStatus.trim() != ''">
  420. AND o.pay_status = #{payStatus}
  421. </if>
  422. <if test="orderStatus != null and orderStatus.trim() != ''">
  423. AND o.order_status = #{orderStatus}
  424. </if>
  425. <if test="shippingId != null and shippingId != 0">
  426. AND o.shipping_id = #{shippingId}
  427. </if>
  428. <if test="orderType != null and orderType.trim() != ''">
  429. AND o.order_type = #{orderType}
  430. </if>
  431. <if test="isOnfiilineOrder != null">
  432. AND o.is_onffline_order = #{isOnfiilineOrder}
  433. </if>
  434. <if test="ids != null and ids.trim() != ''">
  435. AND o.id in (${ids})
  436. </if>
  437. <choose>
  438. <when test="sidx != null and sidx.trim() != ''">
  439. order by ${sidx} ${order}
  440. </when>
  441. <otherwise>
  442. order by id desc
  443. </otherwise>
  444. </choose>
  445. <if test="offset != null and limit != null">
  446. limit #{offset}, #{limit}
  447. </if>
  448. </select>
  449. <select id="queryOffilineOrderTotal" resultType="int">
  450. select count(DISTINCT o.id) FROM
  451. mall_order o
  452. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  453. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  454. left join mall_store s on o.store_id = s.id
  455. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  456. left join mall_sale_record record on record.order_sn = o.order_sn
  457. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  458. WHERE 1=1
  459. <if test="storeId != null and storeId != ''">
  460. AND o.store_id = #{storeId}
  461. </if>
  462. <if test="merchSn != null and merchSn.trim() != ''">
  463. AND o.merch_sn = #{merchSn}
  464. </if>
  465. <if test="goodsSn != null and goodsSn.trim() != ''">
  466. AND gs.goods_sn = #{goodsSn}
  467. </if>
  468. <if test="sku != null and sku.trim() != ''">
  469. AND gs.sku = #{sku}
  470. </if>
  471. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  472. AND gs.prod_barcode = #{prodBarcode}
  473. </if>
  474. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  475. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  476. </if>
  477. <if test="orderSn != null and orderSn.trim() != ''">
  478. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  479. </if>
  480. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  481. AND o.shipping_status = #{shippingStatus}
  482. </if>
  483. <if test="payStatus != null and payStatus.trim() != ''">
  484. AND o.pay_status = #{payStatus}
  485. </if>
  486. <if test="orderStatus != null and orderStatus.trim() != ''">
  487. AND o.order_status = #{orderStatus}
  488. </if>
  489. <if test="shippingId != null and shippingId != 0">
  490. AND o.shipping_id = #{shippingId}
  491. </if>
  492. <if test="orderType != null and orderType.trim() != ''">
  493. AND o.order_type = #{orderType}
  494. </if>
  495. <if test="isOnfiilineOrder != null">
  496. AND o.is_onffline_order = #{isOnfiilineOrder}
  497. </if>
  498. <if test="ids != null and ids.trim() != ''">
  499. AND o.id in (${ids})
  500. </if>
  501. </select>
  502. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  503. insert into mall_order
  504. (
  505. `order_sn`,
  506. `user_id`,
  507. `order_status`,
  508. `shipping_status`,
  509. `pay_status`,
  510. `consignee`,
  511. `country`,
  512. `province`,
  513. `city`,
  514. `district`,
  515. `address`,
  516. `mobile`,
  517. `postscript`,
  518. `shipping_id`,
  519. `shipping_name`,
  520. `shipping_code`,
  521. `shipping_no`,
  522. `pay_id`,
  523. `pay_name`,
  524. `shipping_fee`,
  525. `actual_price`,
  526. `integral`,
  527. `integral_money`,
  528. `order_price`,
  529. `goods_price`,
  530. `add_time`,
  531. `confirm_time`,
  532. `pay_time`,
  533. `freight_price`,
  534. `coupon_id`,
  535. `coupon_price`,
  536. full_cut_price,
  537. camp_minus_id,
  538. camp_name,
  539. `callback_status`,
  540. `order_type`,
  541. `store_id`,
  542. `order_biz_type`,
  543. `is_onffline_order`,
  544. `order_sn_wx`,
  545. `pay_flag`,
  546. `merch_sn`,
  547. `create_time`,
  548. `mod_time`
  549. )
  550. values
  551. (
  552. #{orderSn},
  553. #{userId},
  554. #{orderStatus},
  555. #{shippingStatus},
  556. #{payStatus},
  557. #{consignee},
  558. #{country},
  559. #{province},
  560. #{city},
  561. #{district},
  562. #{address},
  563. #{mobile},
  564. #{postscript},
  565. #{shippingId},
  566. #{shippingName},
  567. #{shippingCode},
  568. #{shippingNo},
  569. #{payId},
  570. #{payName},
  571. #{shippingFee},
  572. #{actualPrice},
  573. #{integral},
  574. #{integralMoney},
  575. #{orderPrice},
  576. #{goodsPrice},
  577. #{addTime},
  578. #{confirmTime},
  579. #{payTime},
  580. #{freightPrice},
  581. #{couponId},
  582. #{couponPrice},
  583. #{fullCutPrice},
  584. #{campMinusId},
  585. #{campName},
  586. #{callbackStatus},
  587. #{orderType},
  588. #{storeId},
  589. #{orderBizType},
  590. #{isOnfflineOrder},
  591. #{orderSnWx},
  592. #{payFlag},
  593. #{merchSn},
  594. #{createTime},
  595. #{modTime}
  596. )
  597. </insert>
  598. <insert id="saveOrderVo" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  599. insert into mall_order
  600. (
  601. `order_sn`,
  602. `user_id`,
  603. `order_status`,
  604. `shipping_status`,
  605. `shipping_code`,
  606. `pay_status`,
  607. `consignee`,
  608. `country`,
  609. `province`,
  610. `city`,
  611. `district`,
  612. `address`,
  613. `address_id`,
  614. `mobile`,
  615. `postscript`,
  616. `pay_id`,
  617. `pay_name`,
  618. `shipping_fee`,
  619. `actual_price`,
  620. `cash_fee`,
  621. `cash_fee_type`,
  622. `total_fee`,
  623. `fee_type`,
  624. `rate`,
  625. `integral`,
  626. `integral_money`,
  627. `order_price`,
  628. `goods_price`,
  629. `add_time`,
  630. `confirm_time`,
  631. `pay_time`,
  632. `freight_price`,
  633. `coupon_id`,
  634. `coupon_price`,
  635. `full_cut_price`,
  636. camp_minus_id,
  637. camp_name,
  638. `order_type`,
  639. `activity_id`,
  640. `store_id`,
  641. `delivery_date`,
  642. `delivery_remark`,
  643. `predict_time`,
  644. `coupon_name`,
  645. `comment_count`,
  646. <if test="merchSn != null" >
  647. merch_sn,
  648. </if>
  649. <if test="merchOrderSn != null" >
  650. merch_order_sn,
  651. </if>
  652. <if test="isScan != null" >
  653. is_scan,
  654. </if>
  655. <if test="isMergePay != null" >
  656. is_merge_pay,
  657. </if>
  658. <if test="orderBizType != null" >
  659. order_biz_type,
  660. </if>
  661. <if test="payTransactionId != null" >
  662. pay_transaction_id,
  663. </if>
  664. <if test="payMobile != null" >
  665. pay_mobile,
  666. </if>
  667. <if test="buyerPayCheck != null" >
  668. buyer_pay_check,
  669. </if>
  670. <if test="isOnfflineOrder != null" >
  671. `is_onffline_order`,
  672. </if>
  673. <if test="payFlag != null" >
  674. pay_flag,
  675. </if>
  676. <if test="createrSn != null" >
  677. creater_sn,
  678. </if>
  679. <if test="createTime != null" >
  680. create_time,
  681. </if>
  682. <if test="moderSn != null" >
  683. moder_sn,
  684. </if>
  685. <if test="modTime != null" >
  686. mod_time
  687. </if>
  688. )
  689. values
  690. (
  691. #{order_sn},
  692. #{user_id},
  693. #{order_status},
  694. #{shipping_status},
  695. #{shipping_code},
  696. #{pay_status},
  697. #{consignee},
  698. #{country},
  699. #{province},
  700. #{city},
  701. #{district},
  702. #{address},
  703. #{address_id},
  704. #{mobile},
  705. #{postscript},
  706. #{pay_id},
  707. #{pay_name},
  708. #{shipping_fee},
  709. #{actual_price},
  710. #{cashFee},
  711. #{cashFeeType},
  712. #{totalFee},
  713. #{feeType},
  714. #{rate},
  715. #{integral},
  716. #{integral_money},
  717. #{order_price},
  718. #{goods_price},
  719. now(),
  720. #{confirm_time},
  721. #{pay_time},
  722. #{freight_price},
  723. #{coupon_id},
  724. #{coupon_price},
  725. #{full_cut_price},
  726. #{campMinusId},
  727. #{campName},
  728. #{order_type},
  729. #{activity_id},
  730. #{store_id},
  731. #{delivery_date},
  732. #{delivery_remark},
  733. #{predict_time},
  734. #{coupon_name},
  735. #{comment_count},
  736. <if test="merchSn != null" >
  737. #{merchSn},
  738. </if>
  739. <if test="merchOrderSn != null" >
  740. #{merchOrderSn},
  741. </if>
  742. <if test="isScan != null" >
  743. #{isScan},
  744. </if>
  745. <if test="isMergePay != null" >
  746. #{isMergePay},
  747. </if>
  748. <if test="orderBizType != null" >
  749. #{orderBizType,jdbcType=CHAR},
  750. </if>
  751. <if test="payTransactionId != null" >
  752. #{payTransactionId},
  753. </if>
  754. <if test="payMobile != null" >
  755. #{payMobile},
  756. </if>
  757. <if test="buyerPayCheck != null" >
  758. #{buyerPayCheck},
  759. </if>
  760. <if test="isOnfflineOrder != null" >
  761. #{isOnfflineOrder},
  762. </if>
  763. <if test="payFlag != null" >
  764. #{payFlag},
  765. </if>
  766. <if test="createrSn != null" >
  767. #{createrSn},
  768. </if>
  769. <if test="createTime != null" >
  770. #{createTime},
  771. </if>
  772. <if test="moderSn != null" >
  773. #{moderSn},
  774. </if>
  775. <if test="modTime != null" >
  776. #{modTime}
  777. </if>
  778. )
  779. </insert>
  780. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  781. update mall_order
  782. <set>
  783. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  784. <if test="userId != null">`user_id` = #{userId},</if>
  785. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  786. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  787. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  788. <if test="consignee != null">`consignee` = #{consignee},</if>
  789. <if test="country != null">`country` = #{country},</if>
  790. <if test="province != null">`province` = #{province},</if>
  791. <if test="city != null">`city` = #{city},</if>
  792. <if test="district != null">`district` = #{district},</if>
  793. <if test="address != null">`address` = #{address},</if>
  794. <if test="mobile != null">`mobile` = #{mobile},</if>
  795. <if test="postscript != null">`postscript` = #{postscript},</if>
  796. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  797. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  798. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  799. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  800. <if test="payId != null">`pay_id` = #{payId},</if>
  801. <if test="payName != null">`pay_name` = #{payName},</if>
  802. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  803. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  804. <if test="integral != null">`integral` = #{integral},</if>
  805. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  806. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  807. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  808. <if test="addTime != null">`add_time` = #{addTime},</if>
  809. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  810. <if test="payTime != null">`pay_time` = #{payTime},</if>
  811. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  812. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  813. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  814. <if test="fullCutPrice != null">`full_cut_price` = #{fullCutPrice},</if>
  815. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  816. <if test="campName != null">`camp_name` = #{campName},</if>
  817. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  818. <if test="AliTradeNo != null">`ali_trade_no` = #{AliTradeNo},</if>
  819. <if test="orderType != null">`order_type` = #{orderType},</if>
  820. <if test="storeId != null">`store_id` = #{storeId},</if>
  821. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  822. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  823. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  824. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  825. <if test="createTime != null">`create_time` = #{createTime},</if>
  826. <if test="modTime != null">`mod_time` = #{modTime},</if>
  827. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  828. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  829. </set>
  830. where id = #{id}
  831. </update>
  832. <delete id="delete">
  833. delete from mall_order where id = #{value}
  834. </delete>
  835. <delete id="deleteBatch">
  836. delete from mall_order where id in
  837. <foreach item="id" collection="array" open="(" separator="," close=")">
  838. #{id}
  839. </foreach>
  840. </delete>
  841. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  842. update mall_order
  843. <set>
  844. `order_status` = #{orderStatus},
  845. `shipping_status` = #{shippingStatus},
  846. `shipping_id` = #{shippingId},
  847. `shipping_name` = #{shippingName},
  848. `shipping_fee` = #{shippingFee},
  849. `shipping_no` = #{shippingNo},
  850. `shipping_mobile` = #{shippingMobile}
  851. </set>
  852. where id = #{id}
  853. </update>
  854. <select id="getYfkOrderUserSum" resultType="int">
  855. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  856. 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
  857. left join mall_store s on o.store_id = s.id
  858. where pay_status = 2
  859. <if test="storeId != null and storeId != ''">
  860. AND o.store_id = #{storeId}
  861. </if>
  862. <if test="merchSn != null and merchSn.trim() != ''">
  863. AND o.merch_sn = #{merchSn}
  864. </if>
  865. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  866. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  867. </if>
  868. group by o.user_id) u
  869. </select>
  870. <select id="getOderUserSum" resultType="int">
  871. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  872. 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
  873. left join mall_store s on o.store_id = s.id
  874. where 1=1
  875. <if test="storeId != null and storeId != ''">
  876. AND o.store_id = #{storeId}
  877. </if>
  878. <if test="merchSn != null and merchSn.trim() != ''">
  879. AND o.merch_sn = #{merchSn}
  880. </if>
  881. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  882. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  883. </if>
  884. group by o.user_id) u
  885. </select>
  886. <select id="getTodayUserOrder" resultType="int">
  887. select count(1) from mall_order o
  888. left join mall_store s on o.store_id = s.id
  889. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  890. <if test="storeId != null and storeId != ''">
  891. AND o.store_id = #{storeId}
  892. </if>
  893. <if test="merchSn != null and merchSn.trim() != ''">
  894. AND o.merch_sn = #{merchSn}
  895. </if>
  896. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  897. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  898. </if>
  899. </select>
  900. <select id="getTodayUserSales" resultType="int">
  901. select ifnull(sum(o.actual_price),0) from mall_order o
  902. 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')
  903. <if test="storeId != null and storeId != ''">
  904. AND o.store_id = #{storeId}
  905. </if>
  906. <if test="merchSn != null and merchSn.trim() != ''">
  907. AND o.merch_sn = #{merchSn}
  908. </if>
  909. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  910. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  911. </if>
  912. </select>
  913. <select id="getIncomeSum" resultType="int">
  914. select ifnull(sum(actual_price),0) from mall_order o
  915. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  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="getPayedOrderCount" resultType="int">
  927. select count(1) from mall_order o
  928. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  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="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  940. SELECT
  941. s.prom_id,
  942. o.id,
  943. o.order_sn,
  944. o.merch_order_sn,
  945. o.actual_price,
  946. o.freight_price,
  947. o.activity_id,
  948. o.order_status,
  949. o.pay_status,
  950. store.store_name storeName,
  951. u.userName userName,
  952. o.buyer_pay_check,
  953. o.order_price,
  954. o.coupon_name couponName,
  955. o.add_time,
  956. o.shipping_status,
  957. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  958. g.goods_id goodsId
  959. FROM
  960. mk_store_prom_stat s
  961. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  962. LEFT JOIN mall_order o ON r.order_id = o.id
  963. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  964. AND g.id = r.order_goods_id
  965. LEFT JOIN mall_store store ON o.store_id = store.id
  966. LEFT JOIN mall_user u ON o.user_id = u.id
  967. WHERE
  968. r.order_id IS NOT NULL
  969. <if test="promId != null and promId != ''">
  970. AND s.prom_id = #{promId}
  971. </if>
  972. <if test="startTime != null and startTime != ''">
  973. AND o.add_time <![CDATA[ > ]]> #{startTime}
  974. </if>
  975. <if test="endTime != null and endTime != ''">
  976. AND o.add_time <![CDATA[ < ]]> #{endTime}
  977. </if>
  978. <if test="storeId != null and storeId != ''">
  979. AND o.store_id = #{storeId}
  980. </if>
  981. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  982. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  983. </if>
  984. <if test="orderBizType != null and orderBizType != ''">
  985. AND o.order_biz_type = #{orderBizType}
  986. </if>
  987. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  988. AND o.merch_order_sn = #{merchOrderSn}
  989. </if>
  990. <if test="merchSn != null and merchSn.trim() != ''">
  991. AND o.merch_sn = #{merchSn}
  992. </if>
  993. <if test="orderSn != null and orderSn.trim() != ''">
  994. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  995. </if>
  996. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  997. AND o.shipping_status = #{shippingStatus}
  998. </if>
  999. <if test="payStatus != null and payStatus.trim() != ''">
  1000. AND o.pay_status = #{payStatus}
  1001. </if>
  1002. <if test="orderStatus != null and orderStatus.trim() != ''">
  1003. AND o.order_status = #{orderStatus}
  1004. </if>
  1005. <if test="shippingId != null and shippingId != 0">
  1006. AND o.shipping_id = #{shippingId}
  1007. </if>
  1008. <if test="orderType != null and orderType.trim() != ''">
  1009. AND o.order_type = #{orderType}
  1010. </if>
  1011. <if test="isOnfiilineOrder != null">
  1012. AND o.is_onffline_order = #{isOnfiilineOrder}
  1013. </if>
  1014. <choose>
  1015. <when test="sidx != null and sidx.trim() != ''">
  1016. order by ${sidx} ${order}
  1017. </when>
  1018. <otherwise>
  1019. order by o.id desc
  1020. </otherwise>
  1021. </choose>
  1022. <if test="offset != null and limit != null">
  1023. limit #{offset}, #{limit}
  1024. </if>
  1025. </select>
  1026. <select id="queryPromOrderTotal" resultType="int">
  1027. SELECT
  1028. count(*)
  1029. FROM
  1030. mk_store_prom_stat s
  1031. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1032. LEFT JOIN mall_order o ON r.order_id = o.id
  1033. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1034. AND g.id = r.order_goods_id
  1035. LEFT JOIN mall_store store ON o.store_id = store.id
  1036. LEFT JOIN mall_user u ON o.user_id = u.id
  1037. WHERE
  1038. r.order_id IS NOT NULL
  1039. <if test="promId != null and promId != ''">
  1040. AND s.prom_id = #{promId}
  1041. </if>
  1042. <if test="startTime != null and startTime != ''">
  1043. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1044. </if>
  1045. <if test="endTime != null and endTime != ''">
  1046. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1047. </if>
  1048. <if test="storeId != null and storeId != ''">
  1049. AND o.store_id = #{storeId}
  1050. </if>
  1051. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1052. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1053. </if>
  1054. <if test="orderBizType != null and orderBizType != ''">
  1055. AND o.order_biz_type = #{orderBizType}
  1056. </if>
  1057. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1058. AND o.merch_order_sn = #{merchOrderSn}
  1059. </if>
  1060. <if test="merchSn != null and merchSn.trim() != ''">
  1061. AND o.merch_sn = #{merchSn}
  1062. </if>
  1063. <if test="orderSn != null and orderSn.trim() != ''">
  1064. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1065. </if>
  1066. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1067. AND o.shipping_status = #{shippingStatus}
  1068. </if>
  1069. <if test="payStatus != null and payStatus.trim() != ''">
  1070. AND o.pay_status = #{payStatus}
  1071. </if>
  1072. <if test="orderStatus != null and orderStatus.trim() != ''">
  1073. AND o.order_status = #{orderStatus}
  1074. </if>
  1075. <if test="shippingId != null and shippingId != 0">
  1076. AND o.shipping_id = #{shippingId}
  1077. </if>
  1078. <if test="orderType != null and orderType.trim() != ''">
  1079. AND o.order_type = #{orderType}
  1080. </if>
  1081. <if test="isOnfiilineOrder != null">
  1082. AND o.is_onffline_order = #{isOnfiilineOrder}
  1083. </if>
  1084. </select>
  1085. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  1086. SELECT
  1087. s.prom_id,
  1088. o.id,
  1089. o.order_sn,
  1090. o.merch_order_sn,
  1091. o.actual_price,
  1092. g.goods_name,
  1093. g.number,
  1094. g.retail_price,
  1095. o.freight_price,
  1096. o.activity_id,
  1097. o.order_status,
  1098. o.pay_status,
  1099. store.store_name storeName,
  1100. u.userName userName,
  1101. o.buyer_pay_check,
  1102. o.order_price,
  1103. o.add_time,
  1104. o.shipping_status,
  1105. g.goods_id goodsId
  1106. FROM
  1107. mk_store_prom_stat s
  1108. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1109. LEFT JOIN mall_order o ON r.order_id = o.id
  1110. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1111. AND g.id = r.order_goods_id
  1112. LEFT JOIN mall_store store ON o.store_id = store.id
  1113. LEFT JOIN mall_user u ON o.user_id = u.id
  1114. WHERE
  1115. r.order_id IS NOT NULL
  1116. <if test="promId != null and promId != ''">
  1117. AND s.prom_id = #{promId}
  1118. </if>
  1119. <if test="startTime != null and startTime != ''">
  1120. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1121. </if>
  1122. <if test="endTime != null and endTime != ''">
  1123. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1124. </if>
  1125. <if test="storeId != null and storeId != ''">
  1126. AND o.store_id = #{storeId}
  1127. </if>
  1128. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1129. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1130. </if>
  1131. <if test="orderBizType != null and orderBizType != ''">
  1132. AND o.order_biz_type = #{orderBizType}
  1133. </if>
  1134. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1135. AND o.merch_order_sn = #{merchOrderSn}
  1136. </if>
  1137. <if test="merchSn != null and merchSn.trim() != ''">
  1138. AND o.merch_sn = #{merchSn}
  1139. </if>
  1140. <if test="orderSn != null and orderSn.trim() != ''">
  1141. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1142. </if>
  1143. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1144. AND o.shipping_status = #{shippingStatus}
  1145. </if>
  1146. <if test="payStatus != null and payStatus.trim() != ''">
  1147. AND o.pay_status = #{payStatus}
  1148. </if>
  1149. <if test="orderStatus != null and orderStatus.trim() != ''">
  1150. AND o.order_status = #{orderStatus}
  1151. </if>
  1152. <if test="shippingId != null and shippingId != 0">
  1153. AND o.shipping_id = #{shippingId}
  1154. </if>
  1155. <if test="orderType != null and orderType.trim() != ''">
  1156. AND o.order_type = #{orderType}
  1157. </if>
  1158. <if test="isOnfiilineOrder != null">
  1159. AND o.is_onffline_order = #{isOnfiilineOrder}
  1160. </if>
  1161. </select>
  1162. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  1163. SELECT
  1164. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  1165. FROM
  1166. mk_store_prom_order_real r
  1167. LEFT JOIN mall_order o ON r.order_id = o.id
  1168. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1169. AND g.id = r.order_goods_id
  1170. WHERE 1=1
  1171. AND g.goods_id = #{goodsId}
  1172. AND r.order_id = #{orderId}
  1173. <if test="statusList != null">
  1174. AND o.order_status IN
  1175. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  1176. #{statusList}
  1177. </foreach>
  1178. </if>
  1179. </select>
  1180. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1181. SELECT
  1182. s.title 'storeTopicName',
  1183. pt.prom_type_name 'storeTopicType',
  1184. ss.store_name 'storeName',
  1185. s.id 'storeTopicId',
  1186. o.id,
  1187. o.order_sn,
  1188. o.merch_order_sn,
  1189. o.actual_price,
  1190. o.freight_price,
  1191. o.activity_id,
  1192. o.coupon_id,
  1193. o.coupon_name,
  1194. o.camp_minus_id,
  1195. o.camp_name,
  1196. o.order_status,
  1197. o.pay_status,
  1198. u.userName userName,
  1199. o.order_price,
  1200. o.add_time,
  1201. o.shipping_status
  1202. FROM
  1203. mall_order o
  1204. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1205. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1206. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1207. LEFT JOIN mall_user u ON o.user_id = u.id
  1208. WHERE
  1209. 1=1
  1210. <if test="storeTopicId != null and storeTopicId != ''">
  1211. AND s.id = #{storeTopicId}
  1212. </if>
  1213. <if test="startTime != null and startTime != ''">
  1214. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1215. </if>
  1216. <if test="endTime != null and endTime != ''">
  1217. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1218. </if>
  1219. <if test="storeId != null and storeId != ''">
  1220. AND o.store_id = #{storeId}
  1221. </if>
  1222. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1223. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1224. </if>
  1225. <if test="orderBizType != null and orderBizType != ''">
  1226. AND o.order_biz_type = #{orderBizType}
  1227. </if>
  1228. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1229. AND o.merch_order_sn = #{merchOrderSn}
  1230. </if>
  1231. <if test="merchSn != null and merchSn.trim() != ''">
  1232. AND o.merch_sn = #{merchSn}
  1233. </if>
  1234. <if test="orderSn != null and orderSn.trim() != ''">
  1235. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1236. </if>
  1237. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1238. AND o.shipping_status = #{shippingStatus}
  1239. </if>
  1240. <if test="payStatus != null and payStatus.trim() != ''">
  1241. AND o.pay_status = #{payStatus}
  1242. </if>
  1243. <if test="orderStatus != null and orderStatus.trim() != ''">
  1244. AND o.order_status = #{orderStatus}
  1245. </if>
  1246. <if test="shippingId != null and shippingId != 0">
  1247. AND o.shipping_id = #{shippingId}
  1248. </if>
  1249. <if test="orderType != null and orderType.trim() != ''">
  1250. AND o.order_type = #{orderType}
  1251. </if>
  1252. <if test="isOnfiilineOrder != null">
  1253. AND o.is_onffline_order = #{isOnfiilineOrder}
  1254. </if>
  1255. order by o.id DESC
  1256. <if test="offset != null and limit != null">
  1257. limit #{offset}, #{limit}
  1258. </if>
  1259. </select>
  1260. <select id="queryStoreTopicOrderTotal" resultType="int">
  1261. SELECT
  1262. count(*)
  1263. FROM
  1264. mall_order o
  1265. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1266. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1267. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1268. LEFT JOIN mall_user u ON o.user_id = u.id
  1269. WHERE 1=1
  1270. <if test="storeTopicId != null and storeTopicId != ''">
  1271. AND s.id = #{storeTopicId}
  1272. </if>
  1273. <if test="startTime != null and startTime != ''">
  1274. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1275. </if>
  1276. <if test="endTime != null and endTime != ''">
  1277. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1278. </if>
  1279. <if test="storeId != null and storeId != ''">
  1280. AND o.store_id = #{storeId}
  1281. </if>
  1282. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1283. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1284. </if>
  1285. <if test="orderBizType != null and orderBizType != ''">
  1286. AND o.order_biz_type = #{orderBizType}
  1287. </if>
  1288. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1289. AND o.merch_order_sn = #{merchOrderSn}
  1290. </if>
  1291. <if test="merchSn != null and merchSn.trim() != ''">
  1292. AND o.merch_sn = #{merchSn}
  1293. </if>
  1294. <if test="orderSn != null and orderSn.trim() != ''">
  1295. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1296. </if>
  1297. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1298. AND o.shipping_status = #{shippingStatus}
  1299. </if>
  1300. <if test="payStatus != null and payStatus.trim() != ''">
  1301. AND o.pay_status = #{payStatus}
  1302. </if>
  1303. <if test="orderStatus != null and orderStatus.trim() != ''">
  1304. AND o.order_status = #{orderStatus}
  1305. </if>
  1306. <if test="shippingId != null and shippingId != 0">
  1307. AND o.shipping_id = #{shippingId}
  1308. </if>
  1309. <if test="orderType != null and orderType.trim() != ''">
  1310. AND o.order_type = #{orderType}
  1311. </if>
  1312. <if test="isOnfiilineOrder != null">
  1313. AND o.is_onffline_order = #{isOnfiilineOrder}
  1314. </if>
  1315. </select>
  1316. <!-- 可根据自己的需求,是否要使用 -->
  1317. <resultMap type="com.kmall.admin.dto.OrderRecognitionDto" id="orderRecognitionMap">
  1318. <result property="id" column="id"/>
  1319. <result property="merchOrderSn" column="merch_order_sn"/>
  1320. <result property="orderSn" column="order_sn"/>
  1321. <result property="userId" column="user_id"/>
  1322. <result property="orderStatus" column="order_status"/>
  1323. <result property="shippingStatus" column="shipping_status"/>
  1324. <result property="payStatus" column="pay_status"/>
  1325. <result property="consignee" column="consignee"/>
  1326. <result property="country" column="country"/>
  1327. <result property="province" column="province"/>
  1328. <result property="city" column="city"/>
  1329. <result property="district" column="district"/>
  1330. <result property="address" column="address"/>
  1331. <result property="mobile" column="mobile"/>
  1332. <result property="postscript" column="postscript"/>
  1333. <result property="shippingId" column="shipping_id"/>
  1334. <result property="shippingName" column="shipping_name"/>
  1335. <result property="shippingCode" column="shipping_code"/>
  1336. <result property="shippingNo" column="shipping_no"/>
  1337. <result property="payId" column="pay_id"/>
  1338. <result property="payName" column="pay_name"/>
  1339. <result property="shippingFee" column="shipping_fee"/>
  1340. <result property="actualPrice" column="actual_price"/>
  1341. <result property="integral" column="integral"/>
  1342. <result property="integralMoney" column="integral_money"/>
  1343. <result property="orderPrice" column="order_price"/>
  1344. <result property="goodsPrice" column="goods_price"/>
  1345. <result property="addTime" column="add_time"/>
  1346. <result property="confirmTime" column="confirm_time"/>
  1347. <result property="payTime" column="pay_time"/>
  1348. <result property="freightPrice" column="freight_price"/>
  1349. <result property="couponId" column="coupon_id"/>
  1350. <result property="couponPrice" column="coupon_price"/>
  1351. <result property="callbackStatus" column="callback_status"/>
  1352. <result property="orderType" column="order_type"/>
  1353. <result property="storeId" column="store_id"/>
  1354. <result property="userName" column="username"/>
  1355. <result property="orderType" column="order_type"/>
  1356. <result property="activityId" column="activity_id"/>
  1357. <result property="deliveryDate" column="delivery_date"/>
  1358. <result property="deliveryRemark" column="delivery_remark"/>
  1359. <result property="predictTime" column="predict_time"/>
  1360. <result property="orderBizType" column="order_biz_type"/>
  1361. <result property="isPaymentSend" column="is_payment_send"/>
  1362. <result property="isEleOrderSend" column="is_ele_order_send"/>
  1363. <result property="isCustomsSend" column="is_customs_send"/>
  1364. <result property="payFlag" column="pay_flag"/>
  1365. <result column="buyer_pay_check" property="buyerPayCheck"/>
  1366. <result property="merchSn" column="merch_sn"/>
  1367. <result property="sku" column="sku"/>
  1368. <result property="createTime" column="create_time"/>
  1369. <result property="modTime" column="mod_time"/>
  1370. <result property="isOnfflineOrder" column="is_onffline_order"/>
  1371. <result property="orderSnWx" column="order_sn_wx"/>
  1372. <result property="isMergePay" column="is_merge_pay"/>
  1373. <result property="payTransactionId" column="pay_transaction_id"/>
  1374. <result property="storeName" column="store_name"/>
  1375. <result property="moderSn" column="moder_sn"/>
  1376. <result property="unitCode" column="unit_code"/>
  1377. <result property="ciqProdModel" column="ciq_prod_model"/>
  1378. <result property="oriCntCode" column="ori_cnt_code"/>
  1379. <result property="brand" column="brand"/>
  1380. <result column="gross_weight" property="grossWeight" />
  1381. <result column="net_weight" property="netWeight" />
  1382. <result property="fullCutPrice" column="full_cut_price"/>
  1383. <result property="campMinusId" column="camp_minus_id"/>
  1384. <result property="campName" column="camp_name"/>
  1385. <result property="isTempNoti" column="is_temp_noti"/>
  1386. <result property="isFaceCheck" column="is_face_check"/>
  1387. <result property="tempNotiMsg" column="temp_noti_msg"/>
  1388. <result property="recognitionReturnMsg" column="recognition_return_msg"/>
  1389. <result property="lastFaceTime" column="last_face_time"/>
  1390. <result property="failCount" column="fail_count"/>
  1391. <result property="checkOperatorType" column="check_operator_type"/>
  1392. <result property="faceLivenessId" column="faceLivenessId"/>
  1393. </resultMap>
  1394. <select id="queryOrderListByRecognition" resultMap="orderRecognitionMap">
  1395. SELECT DISTINCT
  1396. o.order_sn,
  1397. o.merch_order_sn,
  1398. o.order_status,
  1399. o.actual_price,
  1400. o.order_biz_type,
  1401. o.shipping_no,
  1402. o.shipping_name,
  1403. o.shipping_code,
  1404. o.consignee,
  1405. o.mobile,
  1406. o.province,
  1407. o.city,
  1408. o.district,
  1409. o.address,
  1410. o.add_time,
  1411. o.pay_id,
  1412. o.pay_status,
  1413. o.shipping_status,
  1414. o.is_merge_pay,
  1415. o.buyer_pay_check,
  1416. o.order_price,
  1417. o.moder_sn,
  1418. o.id,
  1419. u.username AS username,
  1420. o.user_id,
  1421. p.is_payment_send,
  1422. p.is_ele_order_send,
  1423. p.is_customs_send,
  1424. s.store_name,
  1425. o.full_cut_price,
  1426. o.camp_minus_id,
  1427. o.camp_name,
  1428. fd.is_temp_noti,
  1429. fd.is_face_check,
  1430. fd.temp_noti_msg,
  1431. fd.recognition_return_msg,
  1432. fd.fail_count,
  1433. fd.id 'faceLivenessId',
  1434. fd.check_operator_type,
  1435. u.last_face_time,
  1436. t.is_face_check 'thirdIsFaceCheck'
  1437. FROM
  1438. mall_order o
  1439. LEFT JOIN mall_user u ON o.user_id = u.id
  1440. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1441. left join mall_store s on o.store_id = s.id
  1442. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1443. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1444. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1445. AND r.goods_id = g.goods_id
  1446. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1447. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1448. WHERE 1=1
  1449. <if test="startTime != null and startTime != ''">
  1450. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1451. </if>
  1452. <if test="endTime != null and endTime != ''">
  1453. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1454. </if>
  1455. <if test="storeId != null and storeId != ''">
  1456. AND o.store_id = #{storeId}
  1457. </if>
  1458. <if test="sku != null and sku.trim() != ''">
  1459. AND gs.sku = #{sku}
  1460. </if>
  1461. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1462. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1463. </if>
  1464. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1465. AND t.third_merch_sn = #{thirdMerchSn}
  1466. </if>
  1467. <if test="supplierThirdId != null and supplierThirdId != ''">
  1468. AND r.supplier_third_id = #{supplierThirdId}
  1469. </if>
  1470. <if test="orderBizType != null and orderBizType != ''">
  1471. AND o.order_biz_type = #{orderBizType}
  1472. </if>
  1473. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1474. AND o.merch_order_sn = #{merchOrderSn}
  1475. </if>
  1476. <if test="merchSn != null and merchSn.trim() != ''">
  1477. AND o.merch_sn = #{merchSn}
  1478. </if>
  1479. <if test="orderSn != null and orderSn.trim() != ''">
  1480. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1481. </if>
  1482. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1483. AND o.shipping_status = #{shippingStatus}
  1484. </if>
  1485. <if test="payStatus != null and payStatus.trim() != ''">
  1486. AND o.pay_status = #{payStatus}
  1487. </if>
  1488. <if test="orderStatus != null and orderStatus.trim() != ''">
  1489. AND o.order_status = #{orderStatus}
  1490. </if>
  1491. <if test="shippingId != null and shippingId != 0">
  1492. AND o.shipping_id = #{shippingId}
  1493. </if>
  1494. <if test="orderType != null and orderType.trim() != ''">
  1495. AND o.order_type = #{orderType}
  1496. </if>
  1497. <if test="isOnfiilineOrder != null">
  1498. AND o.is_onffline_order = #{isOnfiilineOrder}
  1499. </if>
  1500. <if test="ids != null and ids.trim() != ''">
  1501. AND o.id in (${ids})
  1502. </if>
  1503. <choose>
  1504. <when test="sidx != null and sidx.trim() != ''">
  1505. order by ${sidx} ${order}
  1506. </when>
  1507. <otherwise>
  1508. order by o.id desc
  1509. </otherwise>
  1510. </choose>
  1511. <if test="offset != null and limit != null">
  1512. limit #{offset}, #{limit}
  1513. </if>
  1514. </select>
  1515. <select id="queryOrderListByRecognitionTotal" resultType="int">
  1516. SELECT count(1)
  1517. FROM
  1518. mall_order o
  1519. LEFT JOIN mall_user u ON o.user_id = u.id
  1520. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1521. left join mall_store s on o.store_id = s.id
  1522. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1523. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1524. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1525. AND r.goods_id = g.goods_id
  1526. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1527. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1528. WHERE 1=1
  1529. <if test="startTime != null and startTime != ''">
  1530. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1531. </if>
  1532. <if test="endTime != null and endTime != ''">
  1533. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1534. </if>
  1535. <if test="storeId != null and storeId != ''">
  1536. AND o.store_id = #{storeId}
  1537. </if>
  1538. <if test="sku != null and sku.trim() != ''">
  1539. AND gs.sku = #{sku}
  1540. </if>
  1541. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1542. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1543. </if>
  1544. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1545. AND t.third_merch_sn = #{thirdMerchSn}
  1546. </if>
  1547. <if test="supplierThirdId != null and supplierThirdId != ''">
  1548. AND r.supplier_third_id = #{supplierThirdId}
  1549. </if>
  1550. <if test="orderBizType != null and orderBizType != ''">
  1551. AND o.order_biz_type = #{orderBizType}
  1552. </if>
  1553. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1554. AND o.merch_order_sn = #{merchOrderSn}
  1555. </if>
  1556. <if test="merchSn != null and merchSn.trim() != ''">
  1557. AND o.merch_sn = #{merchSn}
  1558. </if>
  1559. <if test="orderSn != null and orderSn.trim() != ''">
  1560. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1561. </if>
  1562. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1563. AND o.shipping_status = #{shippingStatus}
  1564. </if>
  1565. <if test="payStatus != null and payStatus.trim() != ''">
  1566. AND o.pay_status = #{payStatus}
  1567. </if>
  1568. <if test="orderStatus != null and orderStatus.trim() != ''">
  1569. AND o.order_status = #{orderStatus}
  1570. </if>
  1571. <if test="shippingId != null and shippingId != 0">
  1572. AND o.shipping_id = #{shippingId}
  1573. </if>
  1574. <if test="orderType != null and orderType.trim() != ''">
  1575. AND o.order_type = #{orderType}
  1576. </if>
  1577. <if test="isOnfiilineOrder != null">
  1578. AND o.is_onffline_order = #{isOnfiilineOrder}
  1579. </if>
  1580. <if test="ids != null and ids.trim() != ''">
  1581. AND o.id in (${ids})
  1582. </if>
  1583. </select>
  1584. <select id="queryOrderByRecogTemp" resultType="com.kmall.admin.dto.SendTempDto">
  1585. SELECT
  1586. o.add_time 'addTime',
  1587. u.weixin_openid 'openId',
  1588. o.merch_order_sn 'merchOrderSn',
  1589. o.id 'orderId',
  1590. o.order_sn 'orderSn'
  1591. FROM
  1592. mall_order o
  1593. INNER JOIN mall_user u ON o.user_id = u.id
  1594. where o.id = #{value}
  1595. </select>
  1596. <select id="queryRealtimeSales" resultType="com.kmall.admin.entity.RealtimeSalesDetection">
  1597. SELECT
  1598. s.id AS storeId,
  1599. o.merch_sn AS merchSn,
  1600. m.merch_name AS merchName,
  1601. count( 0 ) AS guestNumber,
  1602. sum( o.order_price ) AS totalSales,
  1603. sum( o.actual_price ) AS actualSales,
  1604. s.store_name AS storeName,
  1605. max( o.add_time ) AS lastSalesTime ,
  1606. sum( g.cost_price) AS totalCost
  1607. FROM
  1608. mall_order o
  1609. LEFT JOIN mall_store s ON o.store_id = s.id
  1610. LEFT JOIN mall_merch m ON o.merch_sn = m.merch_sn
  1611. LEFT JOIN mall_order_goods og ON o.id = og.order_id
  1612. LEFT JOIN mall_goods g ON og.goods_id = g.id
  1613. LEFT JOIN mall_product_store_rela sr ON sr.goods_id = g.id
  1614. LEFT JOIN mall_category c ON sr.category_id = c.id
  1615. WHERE
  1616. 1 = 1
  1617. <if test="storeId != null and storeId.trim() != ''">
  1618. and o.store_id=#{storeId}
  1619. </if>
  1620. <if test="merchSn != null and merchSn.trim() != ''">
  1621. and o.merch_sn=#{merchSn}
  1622. </if>
  1623. <choose>
  1624. <when test="compareDate != null and compareDate != ''">
  1625. and ( datediff ( o.add_time , #{compareDate} ) = 0 )
  1626. </when>
  1627. <when test="salesDate != null and salesDate != ''">
  1628. and ( datediff ( o.add_time , #{salesDate} ) = 0 )
  1629. </when >
  1630. <otherwise></otherwise>
  1631. </choose>
  1632. <if test="categoryId != null and categoryId != ''">
  1633. AND (c.parent_id = #{categoryId} or c.id = #{categoryId})
  1634. </if>
  1635. </select>
  1636. <select id="purchaseSalesInStockDetailList" resultType="com.kmall.admin.entity.PurchaseSalesInStockDetail">
  1637. select
  1638. substr(msmc.create_time,1,10) as time,
  1639. if(msmc.change_type = 1 ,'销售','期初') as type,
  1640. sum(if((msmc.change_type = 2 or msmc.change_type = 3 ),msmc.store_change_num,0)) as addNum,
  1641. sum(if(msmc.change_type = 1 ,msmc.store_change_num,0)) as lessNum,
  1642. rela.stock_num as endingInventory,
  1643. rela.stock_num as inventory,
  1644. 0 as costPrice,
  1645. rela.retail_price as retailPrice,
  1646. 0 as addAmount,
  1647. sum(if(msmc.change_type = 1 ,msmc.store_change_num,0)*rela.retail_price) as lessAmount,
  1648. 0 as price
  1649. from mall_product_store_rela rela
  1650. left join mall_store_mng_change msmc on msmc.goods_id = rela.goods_id
  1651. left join mall_goods g on g.id = msmc.goods_id
  1652. WHERE 1=1 and msmc.creater_sn <![CDATA[ <> ]]> '定时任务'
  1653. <if test="storeId != null and storeId != ''">
  1654. AND rela.store_id = #{storeId}
  1655. </if>
  1656. <if test="goodsSn != null and goodsSn.trim() != ''">
  1657. AND g.goods_sn = #{goodsSn}
  1658. </if>
  1659. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1660. AND g.prod_barcode = #{prodBarcode}
  1661. </if>
  1662. <if test="startTime != null and startTime.trim() != ''">
  1663. AND substr(msmc.create_time,1,10) <![CDATA[ >= ]]> #{startTime}
  1664. </if>
  1665. <if test="endTime != null and endTime.trim() != ''">
  1666. AND substr(msmc.create_time,1,10) <![CDATA[ <= ]]> #{endTime}
  1667. </if>
  1668. group by substr(msmc.create_time,1,10)
  1669. <if test="offset != null and limit != null">
  1670. limit #{offset}, #{limit}
  1671. </if>
  1672. </select>
  1673. <select id="purchaseSalesInStockDetailTotal" resultType="int">
  1674. select count(1) from ( select count(DISTINCT rela.id)
  1675. from mall_product_store_rela rela
  1676. left join mall_store_mng_change msmc on msmc.goods_id = rela.goods_id
  1677. left join mall_goods g on g.id = msmc.goods_id
  1678. WHERE 1=1 and msmc.creater_sn <![CDATA[ <> ]]> '定时任务'
  1679. <if test="storeId != null and storeId != ''">
  1680. AND rela.store_id = #{storeId}
  1681. </if>
  1682. <if test="goodsSn != null and goodsSn.trim() != ''">
  1683. AND g.goods_sn = #{goodsSn}
  1684. </if>
  1685. <if test="sku != null and sku.trim() != ''">
  1686. AND g.sku = #{sku}
  1687. </if>
  1688. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1689. AND g.prod_barcode = #{prodBarcode}
  1690. </if>
  1691. <if test="startTime != null and startTime.trim() != ''">
  1692. AND substr(msmc.create_time,1,10) <![CDATA[ >= ]]> #{startTime}
  1693. </if>
  1694. <if test="endTime != null and endTime.trim() != ''">
  1695. AND substr(msmc.create_time,1,10) <![CDATA[ <= ]]> #{endTime}
  1696. </if>
  1697. group by substr(msmc.create_time,1,10)
  1698. ) b
  1699. </select>
  1700. <select id="queryTopicPriceByOrderSnAndSku" resultType="java.math.BigDecimal">
  1701. SELECT mst.topic_price FROM mall_order mo
  1702. inner JOIN mall_order_goods mog ON mo.id = mog.order_id
  1703. inner JOIN mall_store_topic mst ON mog.store_topic_id=mst.id
  1704. WHERE mo.order_sn=#{orderSn} AND mog.sku=#{sku};
  1705. </select>
  1706. <select id="queryExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1707. SELECT distinct
  1708. o.*,
  1709. u.username AS userName,
  1710. p.is_payment_send,
  1711. p.is_ele_order_send,
  1712. p.is_customs_send,
  1713. s.store_name storeName,
  1714. g.sku,
  1715. g.goods_name as goodsName,
  1716. gs.retail_price,
  1717. g.number
  1718. FROM
  1719. mall_order o
  1720. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1721. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1722. left join mall_store s on o.store_id = s.id
  1723. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1724. left join mall_sale_record record on record.order_sn = o.order_sn
  1725. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  1726. WHERE 1=1
  1727. <if test="orderSn != null and orderSn.trim() != ''">
  1728. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1729. </if>
  1730. <if test="orderStatus != null and orderStatus.trim() != ''">
  1731. AND o.order_status = #{orderStatus}
  1732. </if>
  1733. <if test="isOnfiilineOrder != null">
  1734. AND o.is_onffline_order = #{isOnfiilineOrder}
  1735. </if>
  1736. </select>
  1737. <select id="queryMasterExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1738. SELECT distinct
  1739. o.*,
  1740. u.username AS userName,
  1741. p.is_payment_send,
  1742. p.is_ele_order_send,
  1743. p.is_customs_send,
  1744. s.store_name storeName
  1745. FROM
  1746. mall_order o
  1747. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1748. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1749. left join mall_store s on o.store_id = s.id
  1750. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1751. left join mall_sale_record record on record.order_sn = o.order_sn
  1752. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  1753. WHERE 1=1
  1754. <if test="storeId != null and storeId != ''">
  1755. AND o.store_id = #{storeId}
  1756. </if>
  1757. <if test="merchSn != null and merchSn.trim() != ''">
  1758. AND o.merch_sn = #{merchSn}
  1759. </if>
  1760. <if test="goodsSn != null and goodsSn.trim() != ''">
  1761. AND gs.goods_sn = #{goodsSn}
  1762. </if>
  1763. <if test="sku != null and sku.trim() != ''">
  1764. AND gs.sku = #{sku}
  1765. </if>
  1766. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1767. AND gs.prod_barcode = #{prodBarcode}
  1768. </if>
  1769. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1770. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1771. </if>
  1772. <if test="orderSn != null and orderSn.trim() != ''">
  1773. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1774. </if>
  1775. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1776. AND o.shipping_status = #{shippingStatus}
  1777. </if>
  1778. <if test="payStatus != null and payStatus.trim() != ''">
  1779. AND o.pay_status = #{payStatus}
  1780. </if>
  1781. <if test="orderStatus != null and orderStatus.trim() != ''">
  1782. AND o.order_status = #{orderStatus}
  1783. </if>
  1784. <if test="shippingId != null and shippingId != 0">
  1785. AND o.shipping_id = #{shippingId}
  1786. </if>
  1787. <if test="orderType != null and orderType.trim() != ''">
  1788. AND o.order_type = #{orderType}
  1789. </if>
  1790. <if test="isOnfiilineOrder != null">
  1791. AND o.is_onffline_order = #{isOnfiilineOrder}
  1792. </if>
  1793. <if test="ids != null and ids.trim() != ''">
  1794. AND o.id in (${ids})
  1795. </if>
  1796. </select>
  1797. <select id="queryMasterExportList" resultType="com.kmall.admin.entity.OrderEntity">
  1798. SELECT DISTINCT
  1799. o.order_sn,
  1800. o.merch_order_sn,
  1801. o.order_status,
  1802. o.actual_price,
  1803. o.order_biz_type,
  1804. o.shipping_no,
  1805. o.shipping_name,
  1806. o.shipping_code,
  1807. o.consignee,
  1808. o.mobile,
  1809. o.province,
  1810. o.city,
  1811. o.district,
  1812. o.address,
  1813. o.add_time,
  1814. o.pay_id,
  1815. o.pay_status,
  1816. o.shipping_status,
  1817. o.is_merge_pay,
  1818. o.buyer_pay_check,
  1819. o.order_price,
  1820. o.moder_sn,
  1821. o.id,
  1822. u.username AS username,
  1823. p.is_payment_send,
  1824. p.is_ele_order_send,
  1825. p.is_customs_send,
  1826. s.store_name,
  1827. o.full_cut_price,
  1828. o.camp_minus_id,
  1829. o.camp_name
  1830. FROM
  1831. mall_order o
  1832. LEFT JOIN mall_user u ON o.user_id = u.id
  1833. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1834. left join mall_store s on o.store_id = s.id
  1835. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1836. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1837. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1838. AND r.goods_id = g.goods_id
  1839. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1840. WHERE 1=1
  1841. <if test="startTime != null and startTime != ''">
  1842. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1843. </if>
  1844. <if test="endTime != null and endTime != ''">
  1845. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1846. </if>
  1847. <if test="storeId != null and storeId != ''">
  1848. AND o.store_id = #{storeId}
  1849. </if>
  1850. <if test="sku != null and sku.trim() != ''">
  1851. AND gs.sku = #{sku}
  1852. </if>
  1853. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1854. AND gs.prod_barcode = #{prodBarcode}
  1855. </if>
  1856. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1857. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1858. </if>
  1859. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1860. AND t.third_merch_sn = #{thirdMerchSn}
  1861. </if>
  1862. <if test="supplierThirdId != null and supplierThirdId != ''">
  1863. AND r.supplier_third_id = #{supplierThirdId}
  1864. </if>
  1865. <if test="orderBizType != null and orderBizType != ''">
  1866. AND o.order_biz_type = #{orderBizType}
  1867. </if>
  1868. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1869. AND o.merch_order_sn = #{merchOrderSn}
  1870. </if>
  1871. <if test="merchSn != null and merchSn.trim() != ''">
  1872. AND o.merch_sn = #{merchSn}
  1873. </if>
  1874. <if test="orderSn != null and orderSn.trim() != ''">
  1875. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1876. </if>
  1877. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1878. AND o.shipping_status = #{shippingStatus}
  1879. </if>
  1880. <if test="payStatus != null and payStatus.trim() != ''">
  1881. AND o.pay_status = #{payStatus}
  1882. </if>
  1883. <if test="orderStatus != null and orderStatus.trim() != ''">
  1884. AND o.order_status = #{orderStatus}
  1885. </if>
  1886. <if test="shippingId != null and shippingId != 0">
  1887. AND o.shipping_id = #{shippingId}
  1888. </if>
  1889. <if test="orderType != null and orderType.trim() != ''">
  1890. AND o.order_type = #{orderType}
  1891. </if>
  1892. <if test="isOnfiilineOrder != null">
  1893. AND o.is_onffline_order = #{isOnfiilineOrder}
  1894. </if>
  1895. <if test="ids != null and ids.trim() != ''">
  1896. AND o.id in (${ids})
  1897. </if>
  1898. </select>
  1899. <select id="queryPickUpCodeList" resultType="com.kmall.admin.entity.OrderEntity">
  1900. SELECT distinct
  1901. o.*,
  1902. c.pick_up_code_sn,
  1903. c.pick_up_code_status
  1904. FROM mall_order o
  1905. LEFT JOIN mall_pick_up_code c ON c.order_sn = o.order_sn
  1906. WHERE 1=1
  1907. <if test="storeId != null and storeId != ''">
  1908. AND o.store_id = #{storeId}
  1909. </if>
  1910. <if test="isOnfiilineOrder != null">
  1911. AND o.is_onffline_order = #{isOnfiilineOrder}
  1912. </if>
  1913. <if test="orderSn != null and orderSn.trim() != ''">
  1914. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1915. </if>
  1916. <if test="payName != null and payName.trim() != ''">
  1917. AND o.pay_name = LIKE concat('%',#{payName},'%')
  1918. </if>
  1919. <if test="payMobile != null and payMobile.trim() != ''">
  1920. AND o.pay_mobile LIKE concat('%',#{pay_mobile},'%')
  1921. </if>
  1922. <if test="startTime != null and startTime.trim() != ''">
  1923. AND o.add_time &gt;= #{startTime}
  1924. </if>
  1925. <if test="endTime != null and endTime.trim() != ''">
  1926. AND o.add_time &lt; #{endTime}
  1927. </if>
  1928. order by o.id desc
  1929. </select>
  1930. <update id="updateOrderInfo" parameterType="map">
  1931. UPDATE mall_order a
  1932. <set>
  1933. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  1934. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  1935. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  1936. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  1937. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  1938. <if test="payTime != null">a.pay_time = #{payTime},</if>
  1939. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  1940. <if test="feeType != null">a.fee_type = #{feeType},</if>
  1941. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  1942. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  1943. <if test="rate != null">a.rate = #{rate},</if>
  1944. </set>
  1945. WHERE 1 = 1
  1946. AND a.id = #{orderId}
  1947. </update>
  1948. <update id="updateOrderProcessRecord" parameterType="map">
  1949. UPDATE mall_order_process_record a
  1950. <set>
  1951. <if test="payTime != null">a.pay_succ_time = #{payTime}</if>
  1952. </set>
  1953. WHERE 1 = 1
  1954. AND a.order_sn = #{orderSn}
  1955. </update>
  1956. </mapper>