OrderDao.xml 76 KB

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