1
0

OrderDao.xml 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kmall.admin.dao.OrderDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.OrderEntity" id="orderMap">
  6. <result property="id" column="id"/>
  7. <result property="merchOrderSn" column="merch_order_sn"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="orderStatus" column="order_status"/>
  11. <result property="shippingStatus" column="shipping_status"/>
  12. <result property="payStatus" column="pay_status"/>
  13. <result property="consignee" column="consignee"/>
  14. <result property="country" column="country"/>
  15. <result property="province" column="province"/>
  16. <result property="city" column="city"/>
  17. <result property="district" column="district"/>
  18. <result property="address" column="address"/>
  19. <result property="mobile" column="mobile"/>
  20. <result property="postscript" column="postscript"/>
  21. <result property="shippingId" column="shipping_id"/>
  22. <result property="shippingName" column="shipping_name"/>
  23. <result property="shippingCode" column="shipping_code"/>
  24. <result property="shippingNo" column="shipping_no"/>
  25. <result property="payId" column="pay_id"/>
  26. <result property="payName" column="pay_name"/>
  27. <result property="payMobile" column="pay_mobile"/>
  28. <result property="shippingFee" column="shipping_fee"/>
  29. <result property="actualPrice" column="actual_price"/>
  30. <result property="integral" column="integral"/>
  31. <result property="integralMoney" column="integral_money"/>
  32. <result property="orderPrice" column="order_price"/>
  33. <result property="goodsPrice" column="goods_price"/>
  34. <result property="addTime" column="add_time"/>
  35. <result property="confirmTime" column="confirm_time"/>
  36. <result property="payTime" column="pay_time"/>
  37. <result property="freightPrice" column="freight_price"/>
  38. <result property="couponId" column="coupon_id"/>
  39. <result property="couponPrice" column="coupon_price"/>
  40. <result property="callbackStatus" column="callback_status"/>
  41. <result property="orderType" column="order_type"/>
  42. <result property="storeId" column="store_id"/>
  43. <result property="userName" column="username"/>
  44. <result property="orderType" column="order_type"/>
  45. <result property="activityId" column="activity_id"/>
  46. <result property="deliveryDate" column="delivery_date"/>
  47. <result property="deliveryRemark" column="delivery_remark"/>
  48. <result property="predictTime" column="predict_time"/>
  49. <result property="orderBizType" column="order_biz_type"/>
  50. <result property="isPaymentSend" column="is_payment_send"/>
  51. <result property="isEleOrderSend" column="is_ele_order_send"/>
  52. <result property="isCustomsSend" column="is_customs_send"/>
  53. <result property="payFlag" column="pay_flag"/>
  54. <result column="buyer_pay_check" property="buyerPayCheck"/>
  55. <result property="merchSn" column="merch_sn"/>
  56. <result property="sku" column="sku"/>
  57. <result property="createTime" column="create_time"/>
  58. <result property="modTime" column="mod_time"/>
  59. <result property="isOnfflineOrder" column="is_onffline_order"/>
  60. <result property="orderSnWx" column="order_sn_wx"/>
  61. <result property="isMergePay" column="is_merge_pay"/>
  62. <result property="payTransactionId" column="pay_transaction_id"/>
  63. <result property="storeName" column="store_name"/>
  64. <result property="moderSn" column="moder_sn"/>
  65. <result property="unitCode" column="unit_code"/>
  66. <result property="ciqProdModel" column="ciq_prod_model"/>
  67. <result property="oriCntCode" column="ori_cnt_code"/>
  68. <result property="brand" column="brand"/>
  69. <result column="gross_weight" property="grossWeight" />
  70. <result column="net_weight" property="netWeight" />
  71. <result property="fullCutPrice" column="full_cut_price"/>
  72. <result property="campMinusId" column="camp_minus_id"/>
  73. <result property="campName" column="camp_name"/>
  74. <result property="pickUpCodeSn" column="pick_up_code_sn"/>
  75. <result property="pickUpCodeStatus" column="pick_up_code_status"/>
  76. <result property="pickUpCodeSn" column="pick_up_code_sn"/>
  77. </resultMap>
  78. <select id="queryObject" resultType="com.kmall.admin.entity.OrderEntity">
  79. select o.*,u.username as username
  80. from mall_order o
  81. left join mall_user u on o.user_id = u.id
  82. where o.id = #{value}
  83. </select>
  84. <select id="queryObjectBySysUser" resultType="com.kmall.admin.entity.OrderEntity">
  85. select o.*,u.username as username
  86. from mall_order o
  87. left join sys_user u on o.user_id = u.user_id
  88. where o.id = #{value}
  89. </select>
  90. <select id="queryObjectByActivityId" resultType="com.kmall.admin.entity.OrderEntity">
  91. select o.*,u.username as username
  92. from mall_order o
  93. left join mall_user u on o.user_id = u.id
  94. where o.activity_id = #{activityId}
  95. </select>
  96. <select id="getTotalActualPrice" resultType="java.lang.Double">
  97. select sum(a.actual_price) 'totalActualPrice' from mall_order a where merch_order_sn = #{merchOrderSn}
  98. </select>
  99. <select id="queryObjectByMerchOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  100. select * from mall_order a where merch_order_sn = #{merchOrderSn}
  101. </select>
  102. <select id="queryObjectByOrderSn" resultType="com.kmall.admin.entity.OrderEntity">
  103. select o.*,c.pick_up_code_sn
  104. from mall_order o
  105. left join mall_pick_up_code c
  106. on c.order_sn = o.order_sn where o.order_sn = #{orderSn}
  107. </select>
  108. <select id="queryList" resultType="com.kmall.admin.entity.OrderEntity">
  109. SELECT DISTINCT
  110. o.order_sn,
  111. o.merch_order_sn,
  112. o.order_status,
  113. o.actual_price,
  114. o.order_biz_type,
  115. o.shipping_no,
  116. o.shipping_name,
  117. o.shipping_code,
  118. o.consignee,
  119. o.mobile,
  120. o.province,
  121. o.city,
  122. o.district,
  123. o.address,
  124. o.add_time,
  125. o.pay_id,
  126. o.pay_status,
  127. o.shipping_status,
  128. o.is_merge_pay,
  129. o.buyer_pay_check,
  130. o.order_price,
  131. o.moder_sn,
  132. o.id,
  133. u.username AS username,
  134. p.is_payment_send,
  135. p.is_ele_order_send,
  136. p.is_customs_send,
  137. s.store_name,
  138. o.full_cut_price,
  139. o.camp_minus_id,
  140. o.camp_name
  141. FROM
  142. mall_order o
  143. LEFT JOIN mall_user u ON o.user_id = u.id
  144. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  145. left join mall_store s on o.store_id = s.id
  146. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  147. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  148. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  149. AND r.goods_id = g.goods_id
  150. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  151. WHERE 1=1
  152. <if test="startTime != null and startTime != ''">
  153. AND o.add_time <![CDATA[ > ]]> #{startTime}
  154. </if>
  155. <if test="endTime != null and endTime != ''">
  156. AND o.add_time <![CDATA[ < ]]> #{endTime}
  157. </if>
  158. <if test="storeId != null and storeId != ''">
  159. AND o.store_id = #{storeId}
  160. </if>
  161. <if test="sku != null and sku.trim() != ''">
  162. AND gs.sku = #{sku}
  163. </if>
  164. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  165. AND gs.prod_barcode = #{prodBarcode}
  166. </if>
  167. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  168. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  169. </if>
  170. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  171. AND t.third_merch_sn = #{thirdMerchSn}
  172. </if>
  173. <if test="supplierThirdId != null and supplierThirdId != ''">
  174. AND r.supplier_third_id = #{supplierThirdId}
  175. </if>
  176. <if test="orderBizType != null and orderBizType != ''">
  177. AND o.order_biz_type = #{orderBizType}
  178. </if>
  179. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  180. AND o.merch_order_sn = #{merchOrderSn}
  181. </if>
  182. <if test="merchSn != null and merchSn.trim() != ''">
  183. AND o.merch_sn = #{merchSn}
  184. </if>
  185. <if test="orderSn != null and orderSn.trim() != ''">
  186. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  187. </if>
  188. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  189. AND o.shipping_status = #{shippingStatus}
  190. </if>
  191. <if test="payStatus != null and payStatus.trim() != ''">
  192. AND o.pay_status = #{payStatus}
  193. </if>
  194. <if test="orderStatus != null and orderStatus.trim() != ''">
  195. AND o.order_status = #{orderStatus}
  196. </if>
  197. <if test="shippingId != null and shippingId != 0">
  198. AND o.shipping_id = #{shippingId}
  199. </if>
  200. <if test="orderType != null and orderType.trim() != ''">
  201. AND o.order_type = #{orderType}
  202. </if>
  203. <if test="isOnfiilineOrder != null">
  204. AND o.is_onffline_order = #{isOnfiilineOrder}
  205. </if>
  206. <if test="ids != null and ids.trim() != ''">
  207. AND o.id in (${ids})
  208. </if>
  209. <choose>
  210. <when test="sidx != null and sidx.trim() != ''">
  211. order by ${sidx} ${order}
  212. </when>
  213. <otherwise>
  214. order by o.id desc
  215. </otherwise>
  216. </choose>
  217. <if test="offset != null and limit != null">
  218. limit #{offset}, #{limit}
  219. </if>
  220. </select>
  221. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  222. SELECT
  223. o.order_sn,
  224. o.merch_order_sn,
  225. o.order_status,
  226. o.actual_price,
  227. o.order_biz_type,
  228. o.shipping_no,
  229. o.shipping_name,
  230. o.shipping_code,
  231. o.consignee,
  232. o.mobile,
  233. o.province,
  234. o.city,
  235. o.district,
  236. o.address,
  237. o.add_time,
  238. o.pay_id,
  239. o.shipping_status,
  240. o.shipping_fee,
  241. o.moder_sn,
  242. o.pay_transaction_id,
  243. u.id_no 'idNo',
  244. u.username AS username,
  245. p.is_payment_send,
  246. p.is_ele_order_send,
  247. p.is_customs_send,
  248. g.sku,
  249. g.goods_name,
  250. g.number,
  251. g.retail_price,
  252. s.store_name,
  253. nc.NAME ori_cnt_code,
  254. good.ciq_prod_model,
  255. good.brand,
  256. uc.NAME unit_code,
  257. good.gross_weight * g.number gross_weight,
  258. good.net_weight * g.number net_weight,
  259. t2.third_party_merch_name 'supplierThirdPartyMerchName',
  260. t2.third_party_merch_code 'supplierThirdPartyMerchCode'
  261. FROM
  262. mall_order o
  263. LEFT JOIN mall_user u ON o.user_id = u.id
  264. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  265. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  266. LEFT JOIN mall_store s ON o.store_id = s.id
  267. LEFT JOIN mall_goods good ON good.id = g.goods_id
  268. LEFT JOIN sys_cus_nation_code nc ON nc.CODE = good.ori_cnt_code
  269. LEFT JOIN sys_cus_unit_code uc ON uc.CODE = good.unit_code
  270. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  271. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  272. AND r.goods_id = g.goods_id
  273. LEFT JOIN third_merchant_biz t2 ON t2.third_merch_sn = r.supplier_third_id
  274. WHERE
  275. 1 =1
  276. <if test="storeId != null and storeId != ''">
  277. AND o.store_id = #{storeId}
  278. </if>
  279. <if test="orderStatus != null and orderStatus.trim() != ''">
  280. AND o.order_status = #{orderStatus}
  281. </if>
  282. <if test="sku != null and sku.trim() != ''">
  283. AND g.sku = #{sku}
  284. </if>
  285. <if test="startTime != null and startTime != ''">
  286. AND o.add_time <![CDATA[ > ]]> #{startTime}
  287. </if>
  288. <if test="endTime != null and endTime != ''">
  289. AND o.add_time <![CDATA[ < ]]> #{endTime}
  290. </if>
  291. <if test="storeId != null and storeId != ''">
  292. AND o.store_id = #{storeId}
  293. </if>
  294. <if test="orderBizType != null and orderBizType != ''">
  295. AND o.order_biz_type = #{orderBizType}
  296. </if>
  297. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  298. AND o.merch_order_sn = #{merchOrderSn}
  299. </if>
  300. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  301. AND t.third_merch_sn = #{thirdMerchSn}
  302. </if>
  303. <if test="supplierThirdId != null and supplierThirdId != ''">
  304. AND r.supplier_third_id = #{supplierThirdId}
  305. </if>
  306. <if test="orderSn != null and orderSn.trim() != ''">
  307. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  308. </if>
  309. <if test="payStatus != null and payStatus.trim() != ''">
  310. AND o.pay_status = #{payStatus}
  311. </if>
  312. <if test="isOnfiilineOrder != null">
  313. AND o.is_onffline_order = #{isOnfiilineOrder}
  314. </if>
  315. </select>
  316. <select id="queryTotal" resultType="int">
  317. select count(DISTINCT o.id) FROM
  318. mall_order o
  319. LEFT JOIN mall_user u ON o.user_id = u.id
  320. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  321. left join mall_store s on o.store_id = s.id
  322. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  323. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  324. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  325. AND r.goods_id = g.goods_id
  326. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  327. WHERE 1=1
  328. <if test="startTime != null and startTime != ''">
  329. AND o.add_time <![CDATA[ > ]]> #{startTime}
  330. </if>
  331. <if test="endTime != null and endTime != ''">
  332. AND o.add_time <![CDATA[ < ]]> #{endTime}
  333. </if>
  334. <if test="storeId != null and storeId != ''">
  335. AND o.store_id = #{storeId}
  336. </if>
  337. <if test="sku != null and sku.trim() != ''">
  338. AND gs.sku = #{sku}
  339. </if>
  340. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  341. AND gs.prod_barcode = #{prodBarcode}
  342. </if>
  343. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  344. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  345. </if>
  346. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  347. AND t.third_merch_sn = #{thirdMerchSn}
  348. </if>
  349. <if test="supplierThirdId != null and supplierThirdId != ''">
  350. AND r.supplier_third_id = #{supplierThirdId}
  351. </if>
  352. <if test="orderBizType != null and orderBizType != ''">
  353. AND o.order_biz_type = #{orderBizType}
  354. </if>
  355. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  356. AND o.merch_order_sn = #{merchOrderSn}
  357. </if>
  358. <if test="merchSn != null and merchSn.trim() != ''">
  359. AND o.merch_sn = #{merchSn}
  360. </if>
  361. <if test="orderSn != null and orderSn.trim() != ''">
  362. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  363. </if>
  364. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  365. AND o.shipping_status = #{shippingStatus}
  366. </if>
  367. <if test="payStatus != null and payStatus.trim() != ''">
  368. AND o.pay_status = #{payStatus}
  369. </if>
  370. <if test="orderStatus != null and orderStatus.trim() != ''">
  371. AND o.order_status = #{orderStatus}
  372. </if>
  373. <if test="shippingId != null and shippingId != 0">
  374. AND o.shipping_id = #{shippingId}
  375. </if>
  376. <if test="orderType != null and orderType.trim() != ''">
  377. AND o.order_type = #{orderType}
  378. </if>
  379. <if test="isOnfiilineOrder != null">
  380. AND o.is_onffline_order = #{isOnfiilineOrder}
  381. </if>
  382. <if test="ids != null and ids.trim() != ''">
  383. AND o.id in (${ids})
  384. </if>
  385. </select>
  386. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  387. SELECT distinct
  388. o.id,
  389. o.order_sn,
  390. s.store_name storeName,
  391. o.pay_name,
  392. u.userName userName,
  393. o.mobile,
  394. o.is_onffline_order,
  395. o.order_biz_type,
  396. o.order_status,
  397. o.pay_status,
  398. o.coupon_name,
  399. o.coupon_price,
  400. o.actual_price,
  401. o.order_price,
  402. o.pay_time,
  403. o.pay_flag
  404. from mall_order o
  405. LEFT JOIN mall_store s on o.store_id = s.id
  406. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  407. LEFT JOIN mall_user u ON o.user_id = u.id
  408. WHERE 1=1
  409. <if test="storeId != null and storeId != ''">
  410. AND o.store_id = #{storeId}
  411. </if>
  412. <if test="storeName != null and storeName != ''">
  413. AND s.store_name LIKE concat('%',#{storeName},'%')
  414. </if>
  415. <if test="merchSn != null and merchSn.trim() != ''">
  416. AND o.merch_sn = #{merchSn}
  417. </if>
  418. <if test="goodsSn != null and goodsSn.trim() != ''">
  419. AND g.goods_sn = #{goodsSn}
  420. </if>
  421. <if test="sku != null and sku.trim() != ''">
  422. AND gs.sku = #{sku}
  423. </if>
  424. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  425. AND gs.prod_barcode = #{prodBarcode}
  426. </if>
  427. <if test="startTime != null and startTime != ''">
  428. AND o.add_time <![CDATA[ > ]]> #{startTime}
  429. </if>
  430. <if test="endTime != null and endTime != ''">
  431. AND o.add_time <![CDATA[ < ]]> #{endTime}
  432. </if>
  433. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  434. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  435. </if>
  436. <if test="orderSn != null and orderSn.trim() != ''">
  437. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  438. </if>
  439. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  440. AND o.shipping_status = #{shippingStatus}
  441. </if>
  442. <if test="payStatus != null and payStatus.trim() != ''">
  443. AND o.pay_status = #{payStatus}
  444. </if>
  445. <if test="orderStatus != null and orderStatus.trim() != ''">
  446. AND o.order_status = #{orderStatus}
  447. </if>
  448. <if test="shippingId != null and shippingId != 0">
  449. AND o.shipping_id = #{shippingId}
  450. </if>
  451. <if test="orderType != null and orderType.trim() != ''">
  452. AND o.order_type = #{orderType}
  453. </if>
  454. <if test="isOnfiilineOrder != null">
  455. AND o.is_onffline_order = #{isOnfiilineOrder}
  456. </if>
  457. <if test="ids != null and ids.trim() != ''">
  458. AND o.id in (${ids})
  459. </if>
  460. <choose>
  461. <when test="sidx != null and sidx.trim() != ''">
  462. order by ${sidx} ${order}
  463. </when>
  464. <otherwise>
  465. order by id desc
  466. </otherwise>
  467. </choose>
  468. <if test="offset != null and limit != null">
  469. limit #{offset}, #{limit}
  470. </if>
  471. </select>
  472. <select id="queryOffilineOrderTotal" resultType="int">
  473. select count(DISTINCT o.id) FROM
  474. mall_order o
  475. LEFT JOIN mall_store s on o.store_id = s.id
  476. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  477. WHERE 1=1
  478. <if test="storeId != null and storeId != ''">
  479. AND o.store_id = #{storeId}
  480. </if>
  481. <if test="storeName != null and storeName != ''">
  482. AND s.store_name LIKE concat('%',#{storeName},'%')
  483. </if>
  484. <if test="merchSn != null and merchSn.trim() != ''">
  485. AND o.merch_sn = #{merchSn}
  486. </if>
  487. <if test="goodsSn != null and goodsSn.trim() != ''">
  488. AND g.goods_sn = #{goodsSn}
  489. </if>
  490. <if test="sku != null and sku.trim() != ''">
  491. AND gs.sku = #{sku}
  492. </if>
  493. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  494. AND gs.prod_barcode = #{prodBarcode}
  495. </if>
  496. <if test="startTime != null and startTime != ''">
  497. AND o.add_time <![CDATA[ > ]]> #{startTime}
  498. </if>
  499. <if test="endTime != null and endTime != ''">
  500. AND o.add_time <![CDATA[ < ]]> #{endTime}
  501. </if>
  502. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  503. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  504. </if>
  505. <if test="orderSn != null and orderSn.trim() != ''">
  506. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  507. </if>
  508. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  509. AND o.shipping_status = #{shippingStatus}
  510. </if>
  511. <if test="payStatus != null and payStatus.trim() != ''">
  512. AND o.pay_status = #{payStatus}
  513. </if>
  514. <if test="orderStatus != null and orderStatus.trim() != ''">
  515. AND o.order_status = #{orderStatus}
  516. </if>
  517. <if test="shippingId != null and shippingId != 0">
  518. AND o.shipping_id = #{shippingId}
  519. </if>
  520. <if test="orderType != null and orderType.trim() != ''">
  521. AND o.order_type = #{orderType}
  522. </if>
  523. <if test="isOnfiilineOrder != null">
  524. AND o.is_onffline_order = #{isOnfiilineOrder}
  525. </if>
  526. <if test="ids != null and ids.trim() != ''">
  527. AND o.id in (${ids})
  528. </if>
  529. </select>
  530. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  531. insert into mall_order
  532. (
  533. `order_sn`,
  534. `user_id`,
  535. `order_status`,
  536. `shipping_status`,
  537. `pay_status`,
  538. `consignee`,
  539. `country`,
  540. `province`,
  541. `city`,
  542. `district`,
  543. `address`,
  544. `mobile`,
  545. `postscript`,
  546. `shipping_id`,
  547. `shipping_name`,
  548. `shipping_code`,
  549. `shipping_no`,
  550. `pay_id`,
  551. `pay_name`,
  552. `shipping_fee`,
  553. `actual_price`,
  554. `integral`,
  555. `integral_money`,
  556. `order_price`,
  557. `goods_price`,
  558. `add_time`,
  559. `confirm_time`,
  560. `pay_time`,
  561. `freight_price`,
  562. `coupon_id`,
  563. `coupon_price`,
  564. full_cut_price,
  565. camp_minus_id,
  566. camp_name,
  567. `callback_status`,
  568. `order_type`,
  569. `store_id`,
  570. `order_biz_type`,
  571. `is_onffline_order`,
  572. `order_sn_wx`,
  573. `pay_flag`,
  574. `merch_sn`,
  575. `create_time`,
  576. `mod_time`
  577. )
  578. values
  579. (
  580. #{orderSn},
  581. #{userId},
  582. #{orderStatus},
  583. #{shippingStatus},
  584. #{payStatus},
  585. #{consignee},
  586. #{country},
  587. #{province},
  588. #{city},
  589. #{district},
  590. #{address},
  591. #{mobile},
  592. #{postscript},
  593. #{shippingId},
  594. #{shippingName},
  595. #{shippingCode},
  596. #{shippingNo},
  597. #{payId},
  598. #{payName},
  599. #{shippingFee},
  600. #{actualPrice},
  601. #{integral},
  602. #{integralMoney},
  603. #{orderPrice},
  604. #{goodsPrice},
  605. #{addTime},
  606. #{confirmTime},
  607. #{payTime},
  608. #{freightPrice},
  609. #{couponId},
  610. #{couponPrice},
  611. #{fullCutPrice},
  612. #{campMinusId},
  613. #{campName},
  614. #{callbackStatus},
  615. #{orderType},
  616. #{storeId},
  617. #{orderBizType},
  618. #{isOnfflineOrder},
  619. #{orderSnWx},
  620. #{payFlag},
  621. #{merchSn},
  622. #{createTime},
  623. #{modTime}
  624. )
  625. </insert>
  626. <insert id="saveOrderVo" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  627. insert into mall_order
  628. (
  629. `order_sn`,
  630. `user_id`,
  631. `order_status`,
  632. `shipping_status`,
  633. `shipping_code`,
  634. `pay_status`,
  635. `consignee`,
  636. `country`,
  637. `province`,
  638. `city`,
  639. `district`,
  640. `address`,
  641. `address_id`,
  642. `mobile`,
  643. `postscript`,
  644. `pay_id`,
  645. `pay_name`,
  646. `shipping_fee`,
  647. `actual_price`,
  648. `cash_fee`,
  649. `cash_fee_type`,
  650. `total_fee`,
  651. `fee_type`,
  652. `rate`,
  653. `integral`,
  654. `integral_money`,
  655. `order_price`,
  656. `goods_price`,
  657. `add_time`,
  658. `confirm_time`,
  659. `pay_time`,
  660. `freight_price`,
  661. `coupon_id`,
  662. `coupon_price`,
  663. `full_cut_price`,
  664. camp_minus_id,
  665. camp_name,
  666. `order_type`,
  667. `activity_id`,
  668. `store_id`,
  669. `delivery_date`,
  670. `delivery_remark`,
  671. `predict_time`,
  672. `coupon_name`,
  673. `comment_count`,
  674. <if test="merchSn != null" >
  675. merch_sn,
  676. </if>
  677. <if test="merchOrderSn != null" >
  678. merch_order_sn,
  679. </if>
  680. <if test="isScan != null" >
  681. is_scan,
  682. </if>
  683. <if test="isMergePay != null" >
  684. is_merge_pay,
  685. </if>
  686. <if test="orderBizType != null" >
  687. order_biz_type,
  688. </if>
  689. <if test="payTransactionId != null" >
  690. pay_transaction_id,
  691. </if>
  692. <if test="payMobile != null" >
  693. pay_mobile,
  694. </if>
  695. <if test="buyerPayCheck != null" >
  696. buyer_pay_check,
  697. </if>
  698. <if test="isOnfflineOrder != null" >
  699. `is_onffline_order`,
  700. </if>
  701. <if test="payFlag != null" >
  702. pay_flag,
  703. </if>
  704. <if test="createrSn != null" >
  705. creater_sn,
  706. </if>
  707. <if test="createTime != null" >
  708. create_time,
  709. </if>
  710. <if test="moderSn != null" >
  711. moder_sn,
  712. </if>
  713. <if test="modTime != null" >
  714. mod_time
  715. </if>
  716. )
  717. values
  718. (
  719. #{order_sn},
  720. #{user_id},
  721. #{order_status},
  722. #{shipping_status},
  723. #{shipping_code},
  724. #{pay_status},
  725. #{consignee},
  726. #{country},
  727. #{province},
  728. #{city},
  729. #{district},
  730. #{address},
  731. #{address_id},
  732. #{mobile},
  733. #{postscript},
  734. #{pay_id},
  735. #{pay_name},
  736. #{shipping_fee},
  737. #{actual_price},
  738. #{cashFee},
  739. #{cashFeeType},
  740. #{totalFee},
  741. #{feeType},
  742. #{rate},
  743. #{integral},
  744. #{integral_money},
  745. #{order_price},
  746. #{goods_price},
  747. now(),
  748. #{confirm_time},
  749. #{pay_time},
  750. #{freight_price},
  751. #{coupon_id},
  752. #{coupon_price},
  753. #{full_cut_price},
  754. #{campMinusId},
  755. #{campName},
  756. #{order_type},
  757. #{activity_id},
  758. #{store_id},
  759. #{delivery_date},
  760. #{delivery_remark},
  761. #{predict_time},
  762. #{coupon_name},
  763. #{comment_count},
  764. <if test="merchSn != null" >
  765. #{merchSn},
  766. </if>
  767. <if test="merchOrderSn != null" >
  768. #{merchOrderSn},
  769. </if>
  770. <if test="isScan != null" >
  771. #{isScan},
  772. </if>
  773. <if test="isMergePay != null" >
  774. #{isMergePay},
  775. </if>
  776. <if test="orderBizType != null" >
  777. #{orderBizType,jdbcType=CHAR},
  778. </if>
  779. <if test="payTransactionId != null" >
  780. #{payTransactionId},
  781. </if>
  782. <if test="payMobile != null" >
  783. #{payMobile},
  784. </if>
  785. <if test="buyerPayCheck != null" >
  786. #{buyerPayCheck},
  787. </if>
  788. <if test="isOnfflineOrder != null" >
  789. #{isOnfflineOrder},
  790. </if>
  791. <if test="payFlag != null" >
  792. #{payFlag},
  793. </if>
  794. <if test="createrSn != null" >
  795. #{createrSn},
  796. </if>
  797. <if test="createTime != null" >
  798. #{createTime},
  799. </if>
  800. <if test="moderSn != null" >
  801. #{moderSn},
  802. </if>
  803. <if test="modTime != null" >
  804. #{modTime}
  805. </if>
  806. )
  807. </insert>
  808. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  809. update mall_order
  810. <set>
  811. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  812. <if test="userId != null">`user_id` = #{userId},</if>
  813. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  814. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  815. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  816. <if test="consignee != null">`consignee` = #{consignee},</if>
  817. <if test="country != null">`country` = #{country},</if>
  818. <if test="province != null">`province` = #{province},</if>
  819. <if test="city != null">`city` = #{city},</if>
  820. <if test="district != null">`district` = #{district},</if>
  821. <if test="address != null">`address` = #{address},</if>
  822. <if test="mobile != null">`mobile` = #{mobile},</if>
  823. <if test="postscript != null">`postscript` = #{postscript},</if>
  824. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  825. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  826. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  827. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  828. <if test="payId != null">`pay_id` = #{payId},</if>
  829. <if test="payName != null">`pay_name` = #{payName},</if>
  830. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  831. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  832. <if test="integral != null">`integral` = #{integral},</if>
  833. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  834. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  835. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  836. <if test="addTime != null">`add_time` = #{addTime},</if>
  837. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  838. <if test="payTime != null">`pay_time` = #{payTime},</if>
  839. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  840. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  841. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  842. <if test="fullCutPrice != null">`full_cut_price` = #{fullCutPrice},</if>
  843. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  844. <if test="campName != null">`camp_name` = #{campName},</if>
  845. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  846. <if test="AliTradeNo != null">`ali_trade_no` = #{AliTradeNo},</if>
  847. <if test="orderType != null">`order_type` = #{orderType},</if>
  848. <if test="storeId != null">`store_id` = #{storeId},</if>
  849. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  850. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  851. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  852. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  853. <if test="createTime != null">`create_time` = #{createTime},</if>
  854. <if test="modTime != null">`mod_time` = #{modTime},</if>
  855. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  856. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  857. </set>
  858. where id = #{id}
  859. </update>
  860. <delete id="delete">
  861. delete from mall_order where id = #{value}
  862. </delete>
  863. <delete id="deleteBatch">
  864. delete from mall_order where id in
  865. <foreach item="id" collection="array" open="(" separator="," close=")">
  866. #{id}
  867. </foreach>
  868. </delete>
  869. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  870. update mall_order
  871. <set>
  872. `order_status` = #{orderStatus},
  873. `shipping_status` = #{shippingStatus},
  874. `shipping_id` = #{shippingId},
  875. `shipping_name` = #{shippingName},
  876. `shipping_fee` = #{shippingFee},
  877. `shipping_no` = #{shippingNo},
  878. `shipping_mobile` = #{shippingMobile}
  879. </set>
  880. where id = #{id}
  881. </update>
  882. <select id="getYfkOrderUserSum" resultType="int">
  883. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  884. 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
  885. left join mall_store s on o.store_id = s.id
  886. where pay_status = 2
  887. <if test="storeId != null and storeId != ''">
  888. AND o.store_id = #{storeId}
  889. </if>
  890. <if test="merchSn != null and merchSn.trim() != ''">
  891. AND o.merch_sn = #{merchSn}
  892. </if>
  893. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  894. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  895. </if>
  896. group by o.user_id) u
  897. </select>
  898. <select id="getOderUserSum" resultType="int">
  899. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  900. 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
  901. left join mall_store s on o.store_id = s.id
  902. where 1=1
  903. <if test="storeId != null and storeId != ''">
  904. AND o.store_id = #{storeId}
  905. </if>
  906. <if test="merchSn != null and merchSn.trim() != ''">
  907. AND o.merch_sn = #{merchSn}
  908. </if>
  909. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  910. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  911. </if>
  912. group by o.user_id) u
  913. </select>
  914. <select id="getTodayUserOrder" resultType="int">
  915. select count(1) from mall_order o
  916. left join mall_store s on o.store_id = s.id
  917. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  918. <if test="storeId != null and storeId != ''">
  919. AND o.store_id = #{storeId}
  920. </if>
  921. <if test="merchSn != null and merchSn.trim() != ''">
  922. AND o.merch_sn = #{merchSn}
  923. </if>
  924. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  925. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  926. </if>
  927. </select>
  928. <select id="getTodayUserSales" resultType="int">
  929. select ifnull(sum(o.actual_price),0) from mall_order o
  930. 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')
  931. <if test="storeId != null and storeId != ''">
  932. AND o.store_id = #{storeId}
  933. </if>
  934. <if test="merchSn != null and merchSn.trim() != ''">
  935. AND o.merch_sn = #{merchSn}
  936. </if>
  937. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  938. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  939. </if>
  940. </select>
  941. <select id="getIncomeSum" resultType="int">
  942. select ifnull(sum(actual_price),0) from mall_order o
  943. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  944. <if test="storeId != null and storeId != ''">
  945. AND o.store_id = #{storeId}
  946. </if>
  947. <if test="merchSn != null and merchSn.trim() != ''">
  948. AND o.merch_sn = #{merchSn}
  949. </if>
  950. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  951. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  952. </if>
  953. </select>
  954. <select id="getPayedOrderCount" resultType="int">
  955. select count(1) from mall_order o
  956. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  957. <if test="storeId != null and storeId != ''">
  958. AND o.store_id = #{storeId}
  959. </if>
  960. <if test="merchSn != null and merchSn.trim() != ''">
  961. AND o.merch_sn = #{merchSn}
  962. </if>
  963. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  964. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  965. </if>
  966. </select>
  967. <select id="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  968. SELECT
  969. s.prom_id,
  970. o.id,
  971. o.order_sn,
  972. o.merch_order_sn,
  973. o.actual_price,
  974. o.freight_price,
  975. o.activity_id,
  976. o.order_status,
  977. o.pay_status,
  978. store.store_name storeName,
  979. u.userName userName,
  980. o.buyer_pay_check,
  981. o.order_price,
  982. o.coupon_name couponName,
  983. o.add_time,
  984. o.shipping_status,
  985. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  986. g.goods_id goodsId
  987. FROM
  988. mk_store_prom_stat s
  989. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  990. LEFT JOIN mall_order o ON r.order_id = o.id
  991. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  992. AND g.id = r.order_goods_id
  993. LEFT JOIN mall_store store ON o.store_id = store.id
  994. LEFT JOIN mall_user u ON o.user_id = u.id
  995. WHERE
  996. r.order_id IS NOT NULL
  997. <if test="promId != null and promId != ''">
  998. AND s.prom_id = #{promId}
  999. </if>
  1000. <if test="startTime != null and startTime != ''">
  1001. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1002. </if>
  1003. <if test="endTime != null and endTime != ''">
  1004. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1005. </if>
  1006. <if test="storeId != null and storeId != ''">
  1007. AND o.store_id = #{storeId}
  1008. </if>
  1009. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1010. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1011. </if>
  1012. <if test="orderBizType != null and orderBizType != ''">
  1013. AND o.order_biz_type = #{orderBizType}
  1014. </if>
  1015. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1016. AND o.merch_order_sn = #{merchOrderSn}
  1017. </if>
  1018. <if test="merchSn != null and merchSn.trim() != ''">
  1019. AND o.merch_sn = #{merchSn}
  1020. </if>
  1021. <if test="orderSn != null and orderSn.trim() != ''">
  1022. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1023. </if>
  1024. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1025. AND o.shipping_status = #{shippingStatus}
  1026. </if>
  1027. <if test="payStatus != null and payStatus.trim() != ''">
  1028. AND o.pay_status = #{payStatus}
  1029. </if>
  1030. <if test="orderStatus != null and orderStatus.trim() != ''">
  1031. AND o.order_status = #{orderStatus}
  1032. </if>
  1033. <if test="shippingId != null and shippingId != 0">
  1034. AND o.shipping_id = #{shippingId}
  1035. </if>
  1036. <if test="orderType != null and orderType.trim() != ''">
  1037. AND o.order_type = #{orderType}
  1038. </if>
  1039. <if test="isOnfiilineOrder != null">
  1040. AND o.is_onffline_order = #{isOnfiilineOrder}
  1041. </if>
  1042. <choose>
  1043. <when test="sidx != null and sidx.trim() != ''">
  1044. order by ${sidx} ${order}
  1045. </when>
  1046. <otherwise>
  1047. order by o.id desc
  1048. </otherwise>
  1049. </choose>
  1050. <if test="offset != null and limit != null">
  1051. limit #{offset}, #{limit}
  1052. </if>
  1053. </select>
  1054. <select id="queryPromOrderTotal" resultType="int">
  1055. SELECT
  1056. count(*)
  1057. FROM
  1058. mk_store_prom_stat s
  1059. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1060. LEFT JOIN mall_order o ON r.order_id = o.id
  1061. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1062. AND g.id = r.order_goods_id
  1063. LEFT JOIN mall_store store ON o.store_id = store.id
  1064. LEFT JOIN mall_user u ON o.user_id = u.id
  1065. WHERE
  1066. r.order_id IS NOT NULL
  1067. <if test="promId != null and promId != ''">
  1068. AND s.prom_id = #{promId}
  1069. </if>
  1070. <if test="startTime != null and startTime != ''">
  1071. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1072. </if>
  1073. <if test="endTime != null and endTime != ''">
  1074. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1075. </if>
  1076. <if test="storeId != null and storeId != ''">
  1077. AND o.store_id = #{storeId}
  1078. </if>
  1079. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1080. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1081. </if>
  1082. <if test="orderBizType != null and orderBizType != ''">
  1083. AND o.order_biz_type = #{orderBizType}
  1084. </if>
  1085. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1086. AND o.merch_order_sn = #{merchOrderSn}
  1087. </if>
  1088. <if test="merchSn != null and merchSn.trim() != ''">
  1089. AND o.merch_sn = #{merchSn}
  1090. </if>
  1091. <if test="orderSn != null and orderSn.trim() != ''">
  1092. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1093. </if>
  1094. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1095. AND o.shipping_status = #{shippingStatus}
  1096. </if>
  1097. <if test="payStatus != null and payStatus.trim() != ''">
  1098. AND o.pay_status = #{payStatus}
  1099. </if>
  1100. <if test="orderStatus != null and orderStatus.trim() != ''">
  1101. AND o.order_status = #{orderStatus}
  1102. </if>
  1103. <if test="shippingId != null and shippingId != 0">
  1104. AND o.shipping_id = #{shippingId}
  1105. </if>
  1106. <if test="orderType != null and orderType.trim() != ''">
  1107. AND o.order_type = #{orderType}
  1108. </if>
  1109. <if test="isOnfiilineOrder != null">
  1110. AND o.is_onffline_order = #{isOnfiilineOrder}
  1111. </if>
  1112. </select>
  1113. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  1114. SELECT
  1115. s.prom_id,
  1116. o.id,
  1117. o.order_sn,
  1118. o.merch_order_sn,
  1119. o.actual_price,
  1120. g.goods_name,
  1121. g.number,
  1122. g.retail_price,
  1123. o.freight_price,
  1124. o.activity_id,
  1125. o.order_status,
  1126. o.pay_status,
  1127. store.store_name storeName,
  1128. u.userName userName,
  1129. o.buyer_pay_check,
  1130. o.order_price,
  1131. o.add_time,
  1132. o.shipping_status,
  1133. g.goods_id goodsId
  1134. FROM
  1135. mk_store_prom_stat s
  1136. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1137. LEFT JOIN mall_order o ON r.order_id = o.id
  1138. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1139. AND g.id = r.order_goods_id
  1140. LEFT JOIN mall_store store ON o.store_id = store.id
  1141. LEFT JOIN mall_user u ON o.user_id = u.id
  1142. WHERE
  1143. r.order_id IS NOT NULL
  1144. <if test="promId != null and promId != ''">
  1145. AND s.prom_id = #{promId}
  1146. </if>
  1147. <if test="startTime != null and startTime != ''">
  1148. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1149. </if>
  1150. <if test="endTime != null and endTime != ''">
  1151. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1152. </if>
  1153. <if test="storeId != null and storeId != ''">
  1154. AND o.store_id = #{storeId}
  1155. </if>
  1156. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1157. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1158. </if>
  1159. <if test="orderBizType != null and orderBizType != ''">
  1160. AND o.order_biz_type = #{orderBizType}
  1161. </if>
  1162. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1163. AND o.merch_order_sn = #{merchOrderSn}
  1164. </if>
  1165. <if test="merchSn != null and merchSn.trim() != ''">
  1166. AND o.merch_sn = #{merchSn}
  1167. </if>
  1168. <if test="orderSn != null and orderSn.trim() != ''">
  1169. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1170. </if>
  1171. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1172. AND o.shipping_status = #{shippingStatus}
  1173. </if>
  1174. <if test="payStatus != null and payStatus.trim() != ''">
  1175. AND o.pay_status = #{payStatus}
  1176. </if>
  1177. <if test="orderStatus != null and orderStatus.trim() != ''">
  1178. AND o.order_status = #{orderStatus}
  1179. </if>
  1180. <if test="shippingId != null and shippingId != 0">
  1181. AND o.shipping_id = #{shippingId}
  1182. </if>
  1183. <if test="orderType != null and orderType.trim() != ''">
  1184. AND o.order_type = #{orderType}
  1185. </if>
  1186. <if test="isOnfiilineOrder != null">
  1187. AND o.is_onffline_order = #{isOnfiilineOrder}
  1188. </if>
  1189. </select>
  1190. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  1191. SELECT
  1192. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  1193. FROM
  1194. mk_store_prom_order_real r
  1195. LEFT JOIN mall_order o ON r.order_id = o.id
  1196. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1197. AND g.id = r.order_goods_id
  1198. WHERE 1=1
  1199. AND g.goods_id = #{goodsId}
  1200. AND r.order_id = #{orderId}
  1201. <if test="statusList != null">
  1202. AND o.order_status IN
  1203. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  1204. #{statusList}
  1205. </foreach>
  1206. </if>
  1207. </select>
  1208. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1209. SELECT
  1210. s.title 'storeTopicName',
  1211. pt.prom_type_name 'storeTopicType',
  1212. ss.store_name 'storeName',
  1213. s.id 'storeTopicId',
  1214. o.id,
  1215. o.order_sn,
  1216. o.merch_order_sn,
  1217. o.actual_price,
  1218. o.freight_price,
  1219. o.activity_id,
  1220. o.coupon_id,
  1221. o.coupon_name,
  1222. o.camp_minus_id,
  1223. o.camp_name,
  1224. o.order_status,
  1225. o.pay_status,
  1226. u.userName userName,
  1227. o.order_price,
  1228. o.add_time,
  1229. o.shipping_status
  1230. FROM
  1231. mall_order o
  1232. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1233. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1234. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1235. LEFT JOIN mall_user u ON o.user_id = u.id
  1236. WHERE
  1237. 1=1
  1238. <if test="storeTopicId != null and storeTopicId != ''">
  1239. AND s.id = #{storeTopicId}
  1240. </if>
  1241. <if test="startTime != null and startTime != ''">
  1242. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1243. </if>
  1244. <if test="endTime != null and endTime != ''">
  1245. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1246. </if>
  1247. <if test="storeId != null and storeId != ''">
  1248. AND o.store_id = #{storeId}
  1249. </if>
  1250. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1251. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1252. </if>
  1253. <if test="orderBizType != null and orderBizType != ''">
  1254. AND o.order_biz_type = #{orderBizType}
  1255. </if>
  1256. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1257. AND o.merch_order_sn = #{merchOrderSn}
  1258. </if>
  1259. <if test="merchSn != null and merchSn.trim() != ''">
  1260. AND o.merch_sn = #{merchSn}
  1261. </if>
  1262. <if test="orderSn != null and orderSn.trim() != ''">
  1263. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1264. </if>
  1265. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1266. AND o.shipping_status = #{shippingStatus}
  1267. </if>
  1268. <if test="payStatus != null and payStatus.trim() != ''">
  1269. AND o.pay_status = #{payStatus}
  1270. </if>
  1271. <if test="orderStatus != null and orderStatus.trim() != ''">
  1272. AND o.order_status = #{orderStatus}
  1273. </if>
  1274. <if test="shippingId != null and shippingId != 0">
  1275. AND o.shipping_id = #{shippingId}
  1276. </if>
  1277. <if test="orderType != null and orderType.trim() != ''">
  1278. AND o.order_type = #{orderType}
  1279. </if>
  1280. <if test="isOnfiilineOrder != null">
  1281. AND o.is_onffline_order = #{isOnfiilineOrder}
  1282. </if>
  1283. order by o.id DESC
  1284. <if test="offset != null and limit != null">
  1285. limit #{offset}, #{limit}
  1286. </if>
  1287. </select>
  1288. <select id="queryStoreTopicOrderTotal" resultType="int">
  1289. SELECT
  1290. count(*)
  1291. FROM
  1292. mall_order o
  1293. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1294. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1295. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1296. LEFT JOIN mall_user u ON o.user_id = u.id
  1297. WHERE 1=1
  1298. <if test="storeTopicId != null and storeTopicId != ''">
  1299. AND s.id = #{storeTopicId}
  1300. </if>
  1301. <if test="startTime != null and startTime != ''">
  1302. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1303. </if>
  1304. <if test="endTime != null and endTime != ''">
  1305. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1306. </if>
  1307. <if test="storeId != null and storeId != ''">
  1308. AND o.store_id = #{storeId}
  1309. </if>
  1310. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1311. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1312. </if>
  1313. <if test="orderBizType != null and orderBizType != ''">
  1314. AND o.order_biz_type = #{orderBizType}
  1315. </if>
  1316. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1317. AND o.merch_order_sn = #{merchOrderSn}
  1318. </if>
  1319. <if test="merchSn != null and merchSn.trim() != ''">
  1320. AND o.merch_sn = #{merchSn}
  1321. </if>
  1322. <if test="orderSn != null and orderSn.trim() != ''">
  1323. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1324. </if>
  1325. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1326. AND o.shipping_status = #{shippingStatus}
  1327. </if>
  1328. <if test="payStatus != null and payStatus.trim() != ''">
  1329. AND o.pay_status = #{payStatus}
  1330. </if>
  1331. <if test="orderStatus != null and orderStatus.trim() != ''">
  1332. AND o.order_status = #{orderStatus}
  1333. </if>
  1334. <if test="shippingId != null and shippingId != 0">
  1335. AND o.shipping_id = #{shippingId}
  1336. </if>
  1337. <if test="orderType != null and orderType.trim() != ''">
  1338. AND o.order_type = #{orderType}
  1339. </if>
  1340. <if test="isOnfiilineOrder != null">
  1341. AND o.is_onffline_order = #{isOnfiilineOrder}
  1342. </if>
  1343. </select>
  1344. <!-- 可根据自己的需求,是否要使用 -->
  1345. <resultMap type="com.kmall.admin.dto.OrderRecognitionDto" id="orderRecognitionMap">
  1346. <result property="id" column="id"/>
  1347. <result property="merchOrderSn" column="merch_order_sn"/>
  1348. <result property="orderSn" column="order_sn"/>
  1349. <result property="userId" column="user_id"/>
  1350. <result property="orderStatus" column="order_status"/>
  1351. <result property="shippingStatus" column="shipping_status"/>
  1352. <result property="payStatus" column="pay_status"/>
  1353. <result property="consignee" column="consignee"/>
  1354. <result property="country" column="country"/>
  1355. <result property="province" column="province"/>
  1356. <result property="city" column="city"/>
  1357. <result property="district" column="district"/>
  1358. <result property="address" column="address"/>
  1359. <result property="mobile" column="mobile"/>
  1360. <result property="postscript" column="postscript"/>
  1361. <result property="shippingId" column="shipping_id"/>
  1362. <result property="shippingName" column="shipping_name"/>
  1363. <result property="shippingCode" column="shipping_code"/>
  1364. <result property="shippingNo" column="shipping_no"/>
  1365. <result property="payId" column="pay_id"/>
  1366. <result property="payName" column="pay_name"/>
  1367. <result property="shippingFee" column="shipping_fee"/>
  1368. <result property="actualPrice" column="actual_price"/>
  1369. <result property="integral" column="integral"/>
  1370. <result property="integralMoney" column="integral_money"/>
  1371. <result property="orderPrice" column="order_price"/>
  1372. <result property="goodsPrice" column="goods_price"/>
  1373. <result property="addTime" column="add_time"/>
  1374. <result property="confirmTime" column="confirm_time"/>
  1375. <result property="payTime" column="pay_time"/>
  1376. <result property="freightPrice" column="freight_price"/>
  1377. <result property="couponId" column="coupon_id"/>
  1378. <result property="couponPrice" column="coupon_price"/>
  1379. <result property="callbackStatus" column="callback_status"/>
  1380. <result property="orderType" column="order_type"/>
  1381. <result property="storeId" column="store_id"/>
  1382. <result property="userName" column="username"/>
  1383. <result property="orderType" column="order_type"/>
  1384. <result property="activityId" column="activity_id"/>
  1385. <result property="deliveryDate" column="delivery_date"/>
  1386. <result property="deliveryRemark" column="delivery_remark"/>
  1387. <result property="predictTime" column="predict_time"/>
  1388. <result property="orderBizType" column="order_biz_type"/>
  1389. <result property="isPaymentSend" column="is_payment_send"/>
  1390. <result property="isEleOrderSend" column="is_ele_order_send"/>
  1391. <result property="isCustomsSend" column="is_customs_send"/>
  1392. <result property="payFlag" column="pay_flag"/>
  1393. <result column="buyer_pay_check" property="buyerPayCheck"/>
  1394. <result property="merchSn" column="merch_sn"/>
  1395. <result property="sku" column="sku"/>
  1396. <result property="createTime" column="create_time"/>
  1397. <result property="modTime" column="mod_time"/>
  1398. <result property="isOnfflineOrder" column="is_onffline_order"/>
  1399. <result property="orderSnWx" column="order_sn_wx"/>
  1400. <result property="isMergePay" column="is_merge_pay"/>
  1401. <result property="payTransactionId" column="pay_transaction_id"/>
  1402. <result property="storeName" column="store_name"/>
  1403. <result property="moderSn" column="moder_sn"/>
  1404. <result property="unitCode" column="unit_code"/>
  1405. <result property="ciqProdModel" column="ciq_prod_model"/>
  1406. <result property="oriCntCode" column="ori_cnt_code"/>
  1407. <result property="brand" column="brand"/>
  1408. <result column="gross_weight" property="grossWeight" />
  1409. <result column="net_weight" property="netWeight" />
  1410. <result property="fullCutPrice" column="full_cut_price"/>
  1411. <result property="campMinusId" column="camp_minus_id"/>
  1412. <result property="campName" column="camp_name"/>
  1413. <result property="isTempNoti" column="is_temp_noti"/>
  1414. <result property="isFaceCheck" column="is_face_check"/>
  1415. <result property="tempNotiMsg" column="temp_noti_msg"/>
  1416. <result property="recognitionReturnMsg" column="recognition_return_msg"/>
  1417. <result property="lastFaceTime" column="last_face_time"/>
  1418. <result property="failCount" column="fail_count"/>
  1419. <result property="checkOperatorType" column="check_operator_type"/>
  1420. <result property="faceLivenessId" column="faceLivenessId"/>
  1421. </resultMap>
  1422. <select id="queryOrderListByRecognition" resultMap="orderRecognitionMap">
  1423. SELECT DISTINCT
  1424. o.order_sn,
  1425. o.merch_order_sn,
  1426. o.order_status,
  1427. o.actual_price,
  1428. o.order_biz_type,
  1429. o.shipping_no,
  1430. o.shipping_name,
  1431. o.shipping_code,
  1432. o.consignee,
  1433. o.mobile,
  1434. o.province,
  1435. o.city,
  1436. o.district,
  1437. o.address,
  1438. o.add_time,
  1439. o.pay_id,
  1440. o.pay_status,
  1441. o.shipping_status,
  1442. o.is_merge_pay,
  1443. o.buyer_pay_check,
  1444. o.order_price,
  1445. o.moder_sn,
  1446. o.id,
  1447. u.username AS username,
  1448. o.user_id,
  1449. p.is_payment_send,
  1450. p.is_ele_order_send,
  1451. p.is_customs_send,
  1452. s.store_name,
  1453. o.full_cut_price,
  1454. o.camp_minus_id,
  1455. o.camp_name,
  1456. fd.is_temp_noti,
  1457. fd.is_face_check,
  1458. fd.temp_noti_msg,
  1459. fd.recognition_return_msg,
  1460. fd.fail_count,
  1461. fd.id 'faceLivenessId',
  1462. fd.check_operator_type,
  1463. u.last_face_time,
  1464. t.is_face_check 'thirdIsFaceCheck'
  1465. FROM
  1466. mall_order o
  1467. LEFT JOIN mall_user u ON o.user_id = u.id
  1468. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1469. left join mall_store s on o.store_id = s.id
  1470. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1471. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1472. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1473. AND r.goods_id = g.goods_id
  1474. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1475. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1476. WHERE 1=1
  1477. <if test="startTime != null and startTime != ''">
  1478. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1479. </if>
  1480. <if test="endTime != null and endTime != ''">
  1481. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1482. </if>
  1483. <if test="storeId != null and storeId != ''">
  1484. AND o.store_id = #{storeId}
  1485. </if>
  1486. <if test="sku != null and sku.trim() != ''">
  1487. AND gs.sku = #{sku}
  1488. </if>
  1489. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1490. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1491. </if>
  1492. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1493. AND t.third_merch_sn = #{thirdMerchSn}
  1494. </if>
  1495. <if test="supplierThirdId != null and supplierThirdId != ''">
  1496. AND r.supplier_third_id = #{supplierThirdId}
  1497. </if>
  1498. <if test="orderBizType != null and orderBizType != ''">
  1499. AND o.order_biz_type = #{orderBizType}
  1500. </if>
  1501. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1502. AND o.merch_order_sn = #{merchOrderSn}
  1503. </if>
  1504. <if test="merchSn != null and merchSn.trim() != ''">
  1505. AND o.merch_sn = #{merchSn}
  1506. </if>
  1507. <if test="orderSn != null and orderSn.trim() != ''">
  1508. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1509. </if>
  1510. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1511. AND o.shipping_status = #{shippingStatus}
  1512. </if>
  1513. <if test="payStatus != null and payStatus.trim() != ''">
  1514. AND o.pay_status = #{payStatus}
  1515. </if>
  1516. <if test="orderStatus != null and orderStatus.trim() != ''">
  1517. AND o.order_status = #{orderStatus}
  1518. </if>
  1519. <if test="shippingId != null and shippingId != 0">
  1520. AND o.shipping_id = #{shippingId}
  1521. </if>
  1522. <if test="orderType != null and orderType.trim() != ''">
  1523. AND o.order_type = #{orderType}
  1524. </if>
  1525. <if test="isOnfiilineOrder != null">
  1526. AND o.is_onffline_order = #{isOnfiilineOrder}
  1527. </if>
  1528. <if test="ids != null and ids.trim() != ''">
  1529. AND o.id in (${ids})
  1530. </if>
  1531. <choose>
  1532. <when test="sidx != null and sidx.trim() != ''">
  1533. order by ${sidx} ${order}
  1534. </when>
  1535. <otherwise>
  1536. order by o.id desc
  1537. </otherwise>
  1538. </choose>
  1539. <if test="offset != null and limit != null">
  1540. limit #{offset}, #{limit}
  1541. </if>
  1542. </select>
  1543. <select id="queryOrderListByRecognitionTotal" resultType="int">
  1544. SELECT count(1)
  1545. FROM
  1546. mall_order o
  1547. LEFT JOIN mall_user u ON o.user_id = u.id
  1548. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1549. left join mall_store s on o.store_id = s.id
  1550. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1551. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1552. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1553. AND r.goods_id = g.goods_id
  1554. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1555. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1556. WHERE 1=1
  1557. <if test="startTime != null and startTime != ''">
  1558. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1559. </if>
  1560. <if test="endTime != null and endTime != ''">
  1561. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1562. </if>
  1563. <if test="storeId != null and storeId != ''">
  1564. AND o.store_id = #{storeId}
  1565. </if>
  1566. <if test="sku != null and sku.trim() != ''">
  1567. AND gs.sku = #{sku}
  1568. </if>
  1569. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1570. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1571. </if>
  1572. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1573. AND t.third_merch_sn = #{thirdMerchSn}
  1574. </if>
  1575. <if test="supplierThirdId != null and supplierThirdId != ''">
  1576. AND r.supplier_third_id = #{supplierThirdId}
  1577. </if>
  1578. <if test="orderBizType != null and orderBizType != ''">
  1579. AND o.order_biz_type = #{orderBizType}
  1580. </if>
  1581. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1582. AND o.merch_order_sn = #{merchOrderSn}
  1583. </if>
  1584. <if test="merchSn != null and merchSn.trim() != ''">
  1585. AND o.merch_sn = #{merchSn}
  1586. </if>
  1587. <if test="orderSn != null and orderSn.trim() != ''">
  1588. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1589. </if>
  1590. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1591. AND o.shipping_status = #{shippingStatus}
  1592. </if>
  1593. <if test="payStatus != null and payStatus.trim() != ''">
  1594. AND o.pay_status = #{payStatus}
  1595. </if>
  1596. <if test="orderStatus != null and orderStatus.trim() != ''">
  1597. AND o.order_status = #{orderStatus}
  1598. </if>
  1599. <if test="shippingId != null and shippingId != 0">
  1600. AND o.shipping_id = #{shippingId}
  1601. </if>
  1602. <if test="orderType != null and orderType.trim() != ''">
  1603. AND o.order_type = #{orderType}
  1604. </if>
  1605. <if test="isOnfiilineOrder != null">
  1606. AND o.is_onffline_order = #{isOnfiilineOrder}
  1607. </if>
  1608. <if test="ids != null and ids.trim() != ''">
  1609. AND o.id in (${ids})
  1610. </if>
  1611. </select>
  1612. <select id="queryOrderByRecogTemp" resultType="com.kmall.admin.dto.SendTempDto">
  1613. SELECT
  1614. o.add_time 'addTime',
  1615. u.weixin_openid 'openId',
  1616. o.merch_order_sn 'merchOrderSn',
  1617. o.id 'orderId',
  1618. o.order_sn 'orderSn'
  1619. FROM
  1620. mall_order o
  1621. INNER JOIN mall_user u ON o.user_id = u.id
  1622. where o.id = #{value}
  1623. </select>
  1624. <select id="queryRealtimeSales" resultType="com.kmall.admin.entity.RealtimeSalesDetection">
  1625. SELECT
  1626. s.id AS storeId,
  1627. o.merch_sn AS merchSn,
  1628. m.merch_name AS merchName,
  1629. count( distinct o.order_sn ) AS guestNumber,
  1630. sum( og.actual_payment_amount) + sum(og.discounted_price)AS totalSales,
  1631. sum( og.actual_payment_amount) - sum(og.tax_price) + sum(og.discounted_price) AS actualSales,
  1632. s.store_name AS storeName,
  1633. max( o.add_time ) AS lastSalesTime ,
  1634. sum( sr.bottom_line_price) AS totalCost
  1635. FROM
  1636. mall_order o
  1637. LEFT JOIN mall_store s ON o.store_id = s.id
  1638. LEFT JOIN mall_merch m ON o.merch_sn = m.merch_sn
  1639. LEFT JOIN mall_order_goods og ON o.id = og.order_id
  1640. LEFT JOIN mall_goods g ON og.goods_id = g.id
  1641. LEFT JOIN mall_product_store_rela sr ON sr.goods_id = g.id and sr.store_id = o.store_id
  1642. LEFT JOIN mall_category c ON sr.category_id = c.id
  1643. WHERE
  1644. 1 = 1
  1645. and (o.order_status = '300' or o.order_status = '201')
  1646. <if test="storeId != null and storeId.trim() != ''">
  1647. and o.store_id=#{storeId}
  1648. </if>
  1649. <if test="merchSn != null and merchSn.trim() != ''">
  1650. and o.merch_sn=#{merchSn}
  1651. </if>
  1652. <choose>
  1653. <when test="compareDate != null and compareDate != ''">
  1654. and ( datediff ( o.add_time , #{compareDate} ) = 0 )
  1655. </when>
  1656. <when test="salesDate != null and salesDate != ''">
  1657. and ( datediff ( o.add_time , #{salesDate} ) = 0 )
  1658. </when >
  1659. <otherwise></otherwise>
  1660. </choose>
  1661. <if test="categoryId != null and categoryId != ''">
  1662. AND (c.parent_id = #{categoryId} or c.id = #{categoryId})
  1663. </if>
  1664. </select>
  1665. <select id="purchaseSalesInStockDetailList" resultType="com.kmall.admin.entity.PurchaseSalesInStockDetail">
  1666. select
  1667. substr(msmc.create_time,1,10) as time,
  1668. if(msmc.change_type = 1 ,'销售','期初') as type,
  1669. sum(if((msmc.change_type = 2 or msmc.change_type = 3 ),msmc.store_change_num,0)) as addNum,
  1670. sum(if(msmc.change_type = 1 ,msmc.store_change_num,0)) as lessNum,
  1671. rela.stock_num as endingInventory,
  1672. rela.stock_num as inventory,
  1673. 0 as costPrice,
  1674. rela.retail_price as retailPrice,
  1675. 0 as addAmount,
  1676. sum(if(msmc.change_type = 1 ,msmc.store_change_num,0)*rela.retail_price) as lessAmount,
  1677. 0 as price
  1678. from mall_product_store_rela rela
  1679. left join mall_store_mng_change msmc on msmc.goods_id = rela.goods_id
  1680. left join mall_goods g on g.id = msmc.goods_id
  1681. WHERE 1=1 and msmc.creater_sn <![CDATA[ <> ]]> '定时任务'
  1682. <if test="storeId != null and storeId != ''">
  1683. AND rela.store_id = #{storeId}
  1684. </if>
  1685. <if test="goodsSn != null and goodsSn.trim() != ''">
  1686. AND g.goods_sn = #{goodsSn}
  1687. </if>
  1688. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1689. AND g.prod_barcode = #{prodBarcode}
  1690. </if>
  1691. <if test="startTime != null and startTime.trim() != ''">
  1692. AND substr(msmc.create_time,1,10) <![CDATA[ >= ]]> #{startTime}
  1693. </if>
  1694. <if test="endTime != null and endTime.trim() != ''">
  1695. AND substr(msmc.create_time,1,10) <![CDATA[ <= ]]> #{endTime}
  1696. </if>
  1697. group by substr(msmc.create_time,1,10)
  1698. <if test="offset != null and limit != null">
  1699. limit #{offset}, #{limit}
  1700. </if>
  1701. </select>
  1702. <select id="purchaseSalesInStockDetailTotal" resultType="int">
  1703. select count(1) from ( select count(DISTINCT rela.id)
  1704. from mall_product_store_rela rela
  1705. left join mall_store_mng_change msmc on msmc.goods_id = rela.goods_id
  1706. left join mall_goods g on g.id = msmc.goods_id
  1707. WHERE 1=1 and msmc.creater_sn <![CDATA[ <> ]]> '定时任务'
  1708. <if test="storeId != null and storeId != ''">
  1709. AND rela.store_id = #{storeId}
  1710. </if>
  1711. <if test="goodsSn != null and goodsSn.trim() != ''">
  1712. AND g.goods_sn = #{goodsSn}
  1713. </if>
  1714. <if test="sku != null and sku.trim() != ''">
  1715. AND g.sku = #{sku}
  1716. </if>
  1717. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1718. AND g.prod_barcode = #{prodBarcode}
  1719. </if>
  1720. <if test="startTime != null and startTime.trim() != ''">
  1721. AND substr(msmc.create_time,1,10) <![CDATA[ >= ]]> #{startTime}
  1722. </if>
  1723. <if test="endTime != null and endTime.trim() != ''">
  1724. AND substr(msmc.create_time,1,10) <![CDATA[ <= ]]> #{endTime}
  1725. </if>
  1726. group by substr(msmc.create_time,1,10)
  1727. ) b
  1728. </select>
  1729. <select id="queryTopicPriceByOrderSnAndSku" resultType="java.math.BigDecimal">
  1730. SELECT mst.topic_price FROM mall_order mo
  1731. inner JOIN mall_order_goods mog ON mo.id = mog.order_id
  1732. inner JOIN mall_store_topic mst ON mog.store_topic_id=mst.id
  1733. WHERE mo.order_sn=#{orderSn} AND mog.sku=#{sku};
  1734. </select>
  1735. <select id="queryExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1736. SELECT distinct
  1737. o.id,
  1738. o.order_sn,
  1739. u.username as userName,
  1740. o.pay_name,
  1741. o.mobile,
  1742. o.is_onffline_order,
  1743. o.order_biz_type,
  1744. o.order_status,
  1745. o.pay_status,
  1746. o.coupon_name,
  1747. o.coupon_price,
  1748. g.actual_payment_amount as actualPrice,
  1749. o.order_price,
  1750. o.pay_time,
  1751. o.pay_flag,
  1752. u.username AS userName,
  1753. g.discounted_price as couponPrice ,
  1754. s.store_name storeName,
  1755. g.sku,
  1756. g.goods_name as goodsName,
  1757. g.retail_price,
  1758. g.number
  1759. FROM
  1760. mall_order o
  1761. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1762. left join mall_store s on o.store_id = s.id
  1763. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1764. left join mall_sale_record record on record.order_sn = o.order_sn
  1765. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  1766. WHERE 1=1
  1767. <if test="orderSn != null and orderSn.trim() != ''">
  1768. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1769. </if>
  1770. <if test="orderStatus != null and orderStatus.trim() != ''">
  1771. AND o.order_status = #{orderStatus}
  1772. </if>
  1773. <if test="isOnfiilineOrder != null">
  1774. AND o.is_onffline_order = #{isOnfiilineOrder}
  1775. </if>
  1776. <if test="startTime != null and startTime != ''">
  1777. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1778. </if>
  1779. <if test="endTime != null and endTime != ''">
  1780. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1781. </if>
  1782. <if test="storeName != null and storeName != ''">
  1783. AND s.store_name LIKE concat('%',#{storeName},'%')
  1784. </if>
  1785. </select>
  1786. <select id="queryMasterExportOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1787. SELECT distinct
  1788. o.id,
  1789. o.order_sn,
  1790. u.username as userName,
  1791. o.pay_name,
  1792. o.mobile,
  1793. o.is_onffline_order,
  1794. o.order_biz_type,
  1795. o.order_status,
  1796. o.pay_status,
  1797. o.coupon_name,
  1798. o.coupon_price,
  1799. o.actual_price,
  1800. o.order_price,
  1801. o.pay_time,
  1802. o.pay_flag,
  1803. u.username AS userName,
  1804. s.store_name storeName
  1805. FROM
  1806. mall_order o
  1807. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1808. left join mall_store s on o.store_id = s.id
  1809. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1810. left join mall_sale_record record on record.order_sn = o.order_sn
  1811. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  1812. WHERE 1=1
  1813. <if test="storeId != null and storeId != ''">
  1814. AND o.store_id = #{storeId}
  1815. </if>
  1816. <if test="merchSn != null and merchSn.trim() != ''">
  1817. AND o.merch_sn = #{merchSn}
  1818. </if>
  1819. <if test="goodsSn != null and goodsSn.trim() != ''">
  1820. AND gs.goods_sn = #{goodsSn}
  1821. </if>
  1822. <if test="sku != null and sku.trim() != ''">
  1823. AND gs.sku = #{sku}
  1824. </if>
  1825. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1826. AND gs.prod_barcode = #{prodBarcode}
  1827. </if>
  1828. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1829. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1830. </if>
  1831. <if test="orderSn != null and orderSn.trim() != ''">
  1832. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1833. </if>
  1834. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1835. AND o.shipping_status = #{shippingStatus}
  1836. </if>
  1837. <if test="payStatus != null and payStatus.trim() != ''">
  1838. AND o.pay_status = #{payStatus}
  1839. </if>
  1840. <if test="orderStatus != null and orderStatus.trim() != ''">
  1841. AND o.order_status = #{orderStatus}
  1842. </if>
  1843. <if test="shippingId != null and shippingId != 0">
  1844. AND o.shipping_id = #{shippingId}
  1845. </if>
  1846. <if test="orderType != null and orderType.trim() != ''">
  1847. AND o.order_type = #{orderType}
  1848. </if>
  1849. <if test="isOnfiilineOrder != null">
  1850. AND o.is_onffline_order = #{isOnfiilineOrder}
  1851. </if>
  1852. <if test="ids != null and ids.trim() != ''">
  1853. AND o.id in (${ids})
  1854. </if>
  1855. <if test="startTime != null and startTime != ''">
  1856. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1857. </if>
  1858. <if test="endTime != null and endTime != ''">
  1859. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1860. </if>
  1861. <if test="billDate != null and billDate != ''">
  1862. AND DATE_FORMAT(o.add_time,'%Y-%m-%d') = #{billDate}
  1863. </if>
  1864. <if test="storeId != null and storeId != ''">
  1865. AND o.store_id = #{storeId}
  1866. </if>
  1867. <if test="storeName != null and storeName != ''">
  1868. AND s.store_name LIKE concat('%',#{storeName},'%')
  1869. </if>
  1870. order by o.order_status
  1871. </select>
  1872. <select id="queryMasterExportList" resultType="com.kmall.admin.entity.OrderEntity">
  1873. SELECT DISTINCT
  1874. o.order_sn,
  1875. o.merch_order_sn,
  1876. o.order_status,
  1877. o.actual_price,
  1878. o.order_biz_type,
  1879. o.shipping_no,
  1880. o.shipping_name,
  1881. o.shipping_code,
  1882. o.consignee,
  1883. o.mobile,
  1884. o.province,
  1885. o.city,
  1886. o.district,
  1887. o.address,
  1888. o.add_time,
  1889. o.pay_id,
  1890. o.pay_status,
  1891. o.shipping_status,
  1892. o.is_merge_pay,
  1893. o.buyer_pay_check,
  1894. o.order_price,
  1895. o.moder_sn,
  1896. o.id,
  1897. u.username AS username,
  1898. p.is_payment_send,
  1899. p.is_ele_order_send,
  1900. p.is_customs_send,
  1901. s.store_name,
  1902. o.full_cut_price,
  1903. o.camp_minus_id,
  1904. o.camp_name
  1905. FROM
  1906. mall_order o
  1907. LEFT JOIN mall_user u ON o.user_id = u.id
  1908. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1909. left join mall_store s on o.store_id = s.id
  1910. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1911. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1912. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1913. AND r.goods_id = g.goods_id
  1914. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1915. WHERE 1=1
  1916. <if test="startTime != null and startTime != ''">
  1917. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1918. </if>
  1919. <if test="endTime != null and endTime != ''">
  1920. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1921. </if>
  1922. <if test="storeId != null and storeId != ''">
  1923. AND o.store_id = #{storeId}
  1924. </if>
  1925. <if test="sku != null and sku.trim() != ''">
  1926. AND gs.sku = #{sku}
  1927. </if>
  1928. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  1929. AND gs.prod_barcode = #{prodBarcode}
  1930. </if>
  1931. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1932. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1933. </if>
  1934. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1935. AND t.third_merch_sn = #{thirdMerchSn}
  1936. </if>
  1937. <if test="supplierThirdId != null and supplierThirdId != ''">
  1938. AND r.supplier_third_id = #{supplierThirdId}
  1939. </if>
  1940. <if test="orderBizType != null and orderBizType != ''">
  1941. AND o.order_biz_type = #{orderBizType}
  1942. </if>
  1943. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1944. AND o.merch_order_sn = #{merchOrderSn}
  1945. </if>
  1946. <if test="merchSn != null and merchSn.trim() != ''">
  1947. AND o.merch_sn = #{merchSn}
  1948. </if>
  1949. <if test="orderSn != null and orderSn.trim() != ''">
  1950. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1951. </if>
  1952. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1953. AND o.shipping_status = #{shippingStatus}
  1954. </if>
  1955. <if test="payStatus != null and payStatus.trim() != ''">
  1956. AND o.pay_status = #{payStatus}
  1957. </if>
  1958. <if test="orderStatus != null and orderStatus.trim() != ''">
  1959. AND o.order_status = #{orderStatus}
  1960. </if>
  1961. <if test="shippingId != null and shippingId != 0">
  1962. AND o.shipping_id = #{shippingId}
  1963. </if>
  1964. <if test="orderType != null and orderType.trim() != ''">
  1965. AND o.order_type = #{orderType}
  1966. </if>
  1967. <if test="isOnfiilineOrder != null">
  1968. AND o.is_onffline_order = #{isOnfiilineOrder}
  1969. </if>
  1970. <if test="ids != null and ids.trim() != ''">
  1971. AND o.id in (${ids})
  1972. </if>
  1973. </select>
  1974. <select id="queryPickUpCodeList" resultType="com.kmall.admin.entity.OrderEntity">
  1975. SELECT distinct
  1976. o.*,
  1977. c.pick_up_code_sn,
  1978. c.pick_up_code_status
  1979. FROM mall_order o
  1980. LEFT JOIN mall_pick_up_code c ON c.order_sn = o.order_sn
  1981. WHERE 1=1
  1982. <if test="storeId != null and storeId != ''">
  1983. AND o.store_id = #{storeId}
  1984. </if>
  1985. <if test="isOnfiilineOrder != null">
  1986. AND o.is_onffline_order = #{isOnfiilineOrder}
  1987. </if>
  1988. <if test="orderSn != null and orderSn.trim() != ''">
  1989. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1990. </if>
  1991. <if test="payName != null and payName.trim() != ''">
  1992. AND o.pay_name LIKE concat('%',#{payName},'%')
  1993. </if>
  1994. <if test="payMobile != null and payMobile.trim() != ''">
  1995. AND o.pay_mobile LIKE concat('%',#{payMobile},'%')
  1996. </if>
  1997. <if test="startTime != null and startTime.trim() != ''">
  1998. AND c.pick_up_code_createtime &gt;= #{startTime}
  1999. </if>
  2000. <if test="endTime != null and endTime.trim() != ''">
  2001. AND c.pick_up_code_createtime &lt;= #{endTime}
  2002. </if>
  2003. order by o.id desc
  2004. </select>
  2005. <select id="queryExportSystemFormatList" resultType="com.kmall.admin.dto.SystemFormatDto">
  2006. SELECT distinct
  2007. o.id,
  2008. g.goods_id,
  2009. o.order_sn as receiptNo,
  2010. u.username as cashRegisterNo,
  2011. o.create_time as timeStampDetails,
  2012. u.username as staffID,
  2013. u.username as staffName,
  2014. gs.hs_code as hsCode,
  2015. gs.hs_code_name as hsCodeName,
  2016. gs.goods_sn as ematouCode,
  2017. gs.plu as plu,
  2018. gs.mychem_id as mychemID,
  2019. gs.english_name as productNameEN,
  2020. gs.name as productNameCN,
  2021. gs.prod_barcode as barcode,
  2022. gs.ciq_prod_model as packSize,
  2023. gs.goods_number as goodsNumber,
  2024. uc.name as productSpecification,
  2025. b.name as brand,
  2026. gs.daily_price as edlp,
  2027. sr.bottom_line_price as costPrice,
  2028. sr.bottom_line_price*gs.goods_number as primeCost,
  2029. g.number as unitSold,
  2030. g.actual_payment_amount as totalSalesInclTax,
  2031. gs.goods_rate as taxRate,
  2032. '专柜单品' as productCategory,
  2033. sup.child_supplier_name as supplierName,
  2034. '300' as orderStatus,
  2035. g.tax_price as taxPrice,
  2036. s.store_name as storeName,
  2037. o.pay_flag as payFlag,
  2038. o.pay_transaction_id as orderSnWx,
  2039. o.ali_trade_no as orderSnAli
  2040. FROM
  2041. mall_order o
  2042. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2043. left join mall_store s on o.store_id = s.id
  2044. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2045. left join mall_sale_record record on record.order_sn = o.order_sn
  2046. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2047. left join sys_cus_unit_code uc on uc.code = gs.unit_code
  2048. left join mall_product_store_rela sr on sr.goods_id=gs.id and sr.store_id = o.store_id
  2049. left join mall_brand b on b.id=sr.brand_id
  2050. left join mall_supplier sup on gs.supplier_id = sup.id
  2051. WHERE 1=1
  2052. <if test="orderSn != null and orderSn.trim() != ''">
  2053. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  2054. </if>
  2055. <choose>
  2056. <when test="orderStatus != null and orderStatus.trim() != ''">
  2057. AND o.order_status = #{orderStatus}
  2058. </when>
  2059. <otherwise>
  2060. AND o.order_status in ('401','300')
  2061. </otherwise>
  2062. </choose>
  2063. <if test="isOnfiilineOrder != null">
  2064. AND o.is_onffline_order = #{isOnfiilineOrder}
  2065. </if>
  2066. <if test="startTime != null and startTime != ''">
  2067. AND o.add_time <![CDATA[ > ]]> #{startTime}
  2068. </if>
  2069. <if test="endTime != null and endTime != ''">
  2070. AND o.add_time <![CDATA[ < ]]> #{endTime}
  2071. </if>
  2072. <if test="storeName != null and storeName != ''">
  2073. AND s.store_name LIKE concat('%',#{storeName},'%')
  2074. </if>
  2075. union
  2076. SELECT distinct
  2077. o.id,
  2078. g.goods_id,
  2079. o.order_sn as receiptNo,
  2080. u.username as cashRegisterNo,
  2081. mor.create_time as timeStampDetails,
  2082. u.username as staffID,
  2083. u.username as staffName,
  2084. gs.hs_code as hsCode,
  2085. gs.hs_code_name as hsCodeName,
  2086. gs.goods_sn as ematouCode,
  2087. gs.plu as plu,
  2088. gs.mychem_id as mychemID,
  2089. gs.english_name as productNameEN,
  2090. gs.name as productNameCN,
  2091. gs.prod_barcode as barcode,
  2092. gs.ciq_prod_model as packSize,
  2093. gs.goods_number as goodsNumber,
  2094. uc.name as productSpecification,
  2095. b.name as brand,
  2096. gs.daily_price as edlp,
  2097. sr.bottom_line_price as costPrice,
  2098. sr.bottom_line_price*gs.goods_number as primeCost,
  2099. g.number as unitSold,
  2100. g.actual_payment_amount as totalSalesInclTax,
  2101. gs.goods_rate as taxRate,
  2102. '专柜单品' as productCategory,
  2103. sup.child_supplier_name as supplierName,
  2104. o.order_status as orderStatus,
  2105. g.tax_price as taxPrice,
  2106. s.store_name as storeName,
  2107. o.pay_flag as payFlag,
  2108. o.pay_transaction_id as orderSnWx,
  2109. o.ali_trade_no as orderSnAli
  2110. FROM
  2111. mall_order o
  2112. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2113. left join mall_store s on o.store_id = s.id
  2114. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2115. left join mall_sale_record record on record.order_sn = o.order_sn
  2116. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2117. left join sys_cus_unit_code uc on uc.code = gs.unit_code
  2118. left join mall_product_store_rela sr on sr.goods_id=gs.id and sr.store_id = o.store_id
  2119. left join mall_brand b on b.id=sr.brand_id
  2120. left join mall_supplier sup on gs.supplier_id = sup.id
  2121. left join mall_order_refund mor on mor.out_refund_no = o.order_sn
  2122. WHERE 1=1
  2123. <if test="orderSn != null and orderSn.trim() != ''">
  2124. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  2125. </if>
  2126. <choose>
  2127. <when test="orderStatus != null and orderStatus.trim() != ''">
  2128. AND o.order_status = #{orderStatus}
  2129. </when>
  2130. <otherwise>
  2131. AND o.order_status = '401'
  2132. </otherwise>
  2133. </choose>
  2134. <if test="isOnfiilineOrder != null">
  2135. AND o.is_onffline_order = #{isOnfiilineOrder}
  2136. </if>
  2137. <if test="startTime != null and startTime != ''">
  2138. AND mor.create_time <![CDATA[ > ]]> #{startTime}
  2139. </if>
  2140. <if test="endTime != null and endTime != ''">
  2141. AND mor.create_time <![CDATA[ < ]]> #{endTime}
  2142. </if>
  2143. <if test="storeName != null and storeName != ''">
  2144. AND s.store_name LIKE concat('%',#{storeName},'%')
  2145. </if>
  2146. </select>
  2147. <update id="updateOrderInfo" parameterType="map">
  2148. UPDATE mall_order a
  2149. <set>
  2150. <if test="orderStatus != null">a.order_status = #{orderStatus},</if>
  2151. <if test="payStatus != null">a.pay_status = #{payStatus},</if>
  2152. <if test="payFlag != null">a.pay_flag = #{payFlag},</if>
  2153. <if test="orderSnWx != null">a.order_sn_wx = #{orderSnWx},</if>
  2154. <if test="payTransactionId != null">a.pay_transaction_id = #{payTransactionId},</if>
  2155. <if test="payTime != null">a.pay_time = #{payTime},</if>
  2156. <if test="totalFee != null">a.total_fee = #{totalFee},</if>
  2157. <if test="feeType != null">a.fee_type = #{feeType},</if>
  2158. <if test="cashFee != null">a.cash_fee = #{cashFee},</if>
  2159. <if test="cashFeeType != null">a.cash_fee_type = #{cashFeeType},</if>
  2160. <if test="rate != null">a.rate = #{rate},</if>
  2161. </set>
  2162. WHERE 1 = 1
  2163. AND a.id = #{orderId}
  2164. </update>
  2165. <update id="updateOrderProcessRecord" parameterType="map">
  2166. UPDATE mall_order_process_record a
  2167. <set>
  2168. <if test="payTime != null">a.pay_succ_time = #{payTime}</if>
  2169. </set>
  2170. WHERE 1 = 1
  2171. AND a.order_sn = #{orderSn}
  2172. </update>
  2173. <select id="totalAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
  2174. select
  2175. ifnull(sum(actual_price),0) as totalAmount
  2176. ,ifnull(count(1),0) as totalCount
  2177. from
  2178. mall_order
  2179. where
  2180. order_status = 300
  2181. and DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
  2182. <if test="storeId != ''">
  2183. and store_id = #{storeId}
  2184. </if>
  2185. </select>
  2186. <select id="refundCurrentAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
  2187. select
  2188. ifnull(sum(actual_price),0) as refundCurrentAmount,
  2189. ifnull(count(1),0) as refundCurrentCount
  2190. from
  2191. mall_order
  2192. where
  2193. DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
  2194. and id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
  2195. <if test="storeId != ''">
  2196. and store_id = #{storeId}
  2197. </if>
  2198. </select>
  2199. <select id="refundPreviousAmount" resultType="com.kmall.admin.dto.ExportExcelDto">
  2200. select
  2201. ifnull(sum(actual_price),0) as refundPreviousAmount
  2202. ,ifnull(count(1),0) as refundPreviousCount
  2203. from
  2204. mall_order
  2205. where
  2206. DATE_FORMAT(pay_time,'%Y-%m-%d') != #{billDate}
  2207. and id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
  2208. <if test="storeId != ''">
  2209. and store_id = #{storeId}
  2210. </if>
  2211. </select>
  2212. <select id="currentTax" resultType="com.kmall.admin.dto.ExportExcelDto">
  2213. select
  2214. ifnull(sum(tax_price),0) as currentTax
  2215. from
  2216. mall_order_goods t1
  2217. where
  2218. DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate}
  2219. and order_id in (
  2220. select id from mall_order where order_status = 300 and DATE_FORMAT(pay_time,'%Y-%m-%d') = #{billDate}
  2221. <if test="storeId != ''">
  2222. and store_id = #{storeId}
  2223. </if>
  2224. )
  2225. </select>
  2226. <select id="refundPreviousTax" resultType="com.kmall.admin.dto.ExportExcelDto">
  2227. select
  2228. ifnull(sum(tax_price),0) as previousTax
  2229. from
  2230. mall_order_goods t1
  2231. where
  2232. DATE_FORMAT(create_time,'%Y-%m-%d') != #{billDate}
  2233. and order_id in (
  2234. select distinct mor.order_id from mall_order_refund mor , mall_order o where mor.out_refund_no = o.order_sn and DATE_FORMAT(mor.create_time,'%Y-%m-%d') = #{billDate}
  2235. <if test="storeId != ''">
  2236. and o.store_id = #{storeId}
  2237. </if>
  2238. )
  2239. </select>
  2240. <select id="queryCurrentPreviousOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  2241. SELECT distinct
  2242. o.id,
  2243. o.order_sn,
  2244. u.username as userName,
  2245. o.pay_name,
  2246. o.mobile,
  2247. o.is_onffline_order,
  2248. o.order_biz_type,
  2249. o.order_status,
  2250. o.pay_status,
  2251. o.coupon_name,
  2252. o.coupon_price,
  2253. if(o.order_status=401,concat("-",o.actual_price),o.actual_price) as actualPrice
  2254. , if(o.order_status=401,concat("-",o.order_price),o.order_price) as orderPrice,
  2255. o.pay_time,
  2256. o.pay_flag,
  2257. u.username AS userName,
  2258. s.store_name storeName
  2259. FROM
  2260. mall_order o
  2261. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2262. left join mall_store s on o.store_id = s.id
  2263. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2264. left join mall_sale_record record on record.order_sn = o.order_sn
  2265. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2266. WHERE
  2267. (DATE_FORMAT(o.create_time,'%Y-%m-%d') = #{billDate})
  2268. <if test="storeId != ''">
  2269. and o.store_id = #{storeId}
  2270. </if>
  2271. order by o.order_status
  2272. </select>
  2273. <select id="queryRefundPreviousOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  2274. SELECT distinct
  2275. o.id,
  2276. o.order_sn,
  2277. u.username as userName,
  2278. o.pay_name,
  2279. o.mobile,
  2280. o.is_onffline_order,
  2281. o.order_biz_type,
  2282. o.order_status,
  2283. o.pay_status,
  2284. o.coupon_name,
  2285. o.coupon_price,
  2286. if(o.order_status=401,concat("-",o.actual_price),o.actual_price) as actualPrice
  2287. , if(o.order_status=401,concat("-",o.order_price),o.order_price) as orderPrice,
  2288. o.pay_time,
  2289. o.pay_flag,
  2290. u.username AS userName,
  2291. s.store_name storeName
  2292. FROM
  2293. mall_order o
  2294. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  2295. left join mall_store s on o.store_id = s.id
  2296. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  2297. left join mall_sale_record record on record.order_sn = o.order_sn
  2298. LEFT JOIN sys_user u ON record.saller_id = u.user_id
  2299. WHERE
  2300. (DATE_FORMAT(o.create_time,'%Y-%m-%d') != #{billDate})
  2301. and o.id in (select r.order_id from mall_order_refund r where (DATE_FORMAT(r.create_time,'%Y-%m-%d') = #{billDate}))
  2302. <if test="storeId != ''">
  2303. and o.store_id = #{storeId}
  2304. </if>
  2305. order by o.order_status
  2306. </select>
  2307. <select id="queryCurrentTaxDetailList" resultType="com.kmall.admin.dto.TaxDetailDto">
  2308. select o.order_sn as orderSn,s.id as storeId, s.store_name as storeName,g.goods_sn as sku,
  2309. imp_consum_tax_rate as saleTaxRate , value_added_tax_rate as vatRate,
  2310. og.tax_price as tax , o.mod_time as receiveTaxTime,og.actual_payment_amount as postTaxPrice
  2311. from mall_order o ,mall_order_goods og , mall_goods g , mall_store s where o.id = og.order_id and og.sku = g.goods_sn and o.store_id = s.id and o.order_status = 300
  2312. and DATE_FORMAT(o.pay_time,'%Y-%m-%d') = #{billDate}
  2313. <if test="storeId != ''">
  2314. and o.store_id = #{storeId}
  2315. </if>
  2316. </select>
  2317. <select id="queryRefundPreviousTaxDetailList" resultType="com.kmall.admin.dto.TaxDetailDto">
  2318. select o.order_sn as orderSn,s.id as storeId, s.store_name as storeName,g.goods_sn as sku,
  2319. imp_consum_tax_rate as preSaleTax , value_added_tax_rate as preVat,
  2320. og.tax_price as preTax , o.mod_time as preTaxTime,og.actual_payment_amount as postTaxPrice
  2321. from mall_order o ,mall_order_goods og , mall_goods g , mall_store s where o.id = og.order_id and og.sku = g.goods_sn and o.store_id = s.id
  2322. and DATE_FORMAT(o.pay_time,'%Y-%m-%d') != #{billDate} and o.id in (select distinct order_id from mall_order_refund where DATE_FORMAT(create_time,'%Y-%m-%d') = #{billDate})
  2323. <if test="storeId != ''">
  2324. and o.store_id = #{storeId}
  2325. </if>
  2326. </select>
  2327. <select id="queryAll201Order" resultType="com.kmall.admin.entity.OrderEntity">
  2328. SELECT
  2329. *
  2330. FROM
  2331. mall_order
  2332. WHERE
  2333. DATE_FORMAT( create_time, '%Y-%m-%d' ) = #{date}
  2334. AND order_status = 201
  2335. AND now( ) - INTERVAL 5 MINUTE >= pay_time
  2336. ORDER BY
  2337. create_time DESC
  2338. </select>
  2339. </mapper>