OrderDao.xml 75 KB

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