OrderDao.xml 68 KB

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