OrderDao.xml 68 KB

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