OrderDao.xml 75 KB

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