OrderDao.xml 75 KB

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