OrderDao.xml 89 KB

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