OrderDao.xml 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391
  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="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  158. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  159. </if>
  160. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  161. AND t.third_merch_sn = #{thirdMerchSn}
  162. </if>
  163. <if test="supplierThirdId != null and supplierThirdId != ''">
  164. AND r.supplier_third_id = #{supplierThirdId}
  165. </if>
  166. <if test="orderBizType != null and orderBizType != ''">
  167. AND o.order_biz_type = #{orderBizType}
  168. </if>
  169. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  170. AND o.merch_order_sn = #{merchOrderSn}
  171. </if>
  172. <if test="merchSn != null and merchSn.trim() != ''">
  173. AND o.merch_sn = #{merchSn}
  174. </if>
  175. <if test="orderSn != null and orderSn.trim() != ''">
  176. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  177. </if>
  178. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  179. AND o.shipping_status = #{shippingStatus}
  180. </if>
  181. <if test="payStatus != null and payStatus.trim() != ''">
  182. AND o.pay_status = #{payStatus}
  183. </if>
  184. <if test="orderStatus != null and orderStatus.trim() != ''">
  185. AND o.order_status = #{orderStatus}
  186. </if>
  187. <if test="shippingId != null and shippingId != 0">
  188. AND o.shipping_id = #{shippingId}
  189. </if>
  190. <if test="orderType != null and orderType.trim() != ''">
  191. AND o.order_type = #{orderType}
  192. </if>
  193. <if test="isOnfiilineOrder != null">
  194. AND o.is_onffline_order = #{isOnfiilineOrder}
  195. </if>
  196. <if test="ids != null and ids.trim() != ''">
  197. AND o.id in (${ids})
  198. </if>
  199. <choose>
  200. <when test="sidx != null and sidx.trim() != ''">
  201. order by ${sidx} ${order}
  202. </when>
  203. <otherwise>
  204. order by o.id desc
  205. </otherwise>
  206. </choose>
  207. <if test="offset != null and limit != null">
  208. limit #{offset}, #{limit}
  209. </if>
  210. </select>
  211. <select id="queryExportList" resultType="com.kmall.admin.entity.OrderEntity">
  212. SELECT
  213. o.order_sn,
  214. o.merch_order_sn,
  215. o.order_status,
  216. o.actual_price,
  217. o.order_biz_type,
  218. o.shipping_no,
  219. o.shipping_name,
  220. o.shipping_code,
  221. o.consignee,
  222. o.mobile,
  223. o.province,
  224. o.city,
  225. o.district,
  226. o.address,
  227. o.add_time,
  228. o.pay_id,
  229. o.pay_transaction_id,
  230. u.id_no 'idNo',
  231. u.username AS username,
  232. p.is_payment_send,
  233. p.is_ele_order_send,
  234. p.is_customs_send,
  235. g.sku,
  236. g.goods_name,
  237. g.number,
  238. g.retail_price,
  239. s.store_name,
  240. nc.NAME ori_cnt_code,
  241. good.ciq_prod_model,
  242. good.brand,
  243. uc.NAME unit_code,
  244. good.gross_weight * g.number gross_weight,
  245. good.net_weight * g.number net_weight,
  246. t2.third_party_merch_name 'supplierThirdPartyMerchName',
  247. t2.third_party_merch_code 'supplierThirdPartyMerchCode'
  248. FROM
  249. mall_order o
  250. LEFT JOIN mall_user u ON o.user_id = u.id
  251. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  252. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  253. LEFT JOIN mall_store s ON o.store_id = s.id
  254. LEFT JOIN mall_goods good ON good.id = g.goods_id
  255. LEFT JOIN sys_cus_nation_code nc ON nc.CODE = good.ori_cnt_code
  256. LEFT JOIN sys_cus_unit_code uc ON uc.CODE = good.unit_code
  257. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  258. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  259. AND r.goods_id = g.goods_id
  260. LEFT JOIN third_merchant_biz t2 ON t2.third_merch_sn = r.supplier_third_id
  261. WHERE
  262. 1 =1
  263. <if test="startTime != null and startTime != ''">
  264. AND o.add_time <![CDATA[ > ]]> #{startTime}
  265. </if>
  266. <if test="endTime != null and endTime != ''">
  267. AND o.add_time <![CDATA[ < ]]> #{endTime}
  268. </if>
  269. <if test="storeId != null and storeId != ''">
  270. AND o.store_id = #{storeId}
  271. </if>
  272. <if test="orderBizType != null and orderBizType != ''">
  273. AND o.order_biz_type = #{orderBizType}
  274. </if>
  275. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  276. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  277. </if>
  278. <if test="sku != null and sku.trim() != ''">
  279. AND good.sku = #{sku}
  280. </if>
  281. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  282. AND o.merch_order_sn = #{merchOrderSn}
  283. </if>
  284. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  285. AND t.third_merch_sn = #{thirdMerchSn}
  286. </if>
  287. <if test="supplierThirdId != null and supplierThirdId != ''">
  288. AND r.supplier_third_id = #{supplierThirdId}
  289. </if>
  290. <if test="merchSn != null and merchSn.trim() != ''">
  291. AND o.merch_sn = #{merchSn}
  292. </if>
  293. <if test="orderSn != null and orderSn.trim() != ''">
  294. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  295. </if>
  296. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  297. AND o.shipping_status = #{shippingStatus}
  298. </if>
  299. <if test="payStatus != null and payStatus.trim() != ''">
  300. AND o.pay_status = #{payStatus}
  301. </if>
  302. <if test="orderStatus != null and orderStatus.trim() != ''">
  303. AND o.order_status = #{orderStatus}
  304. </if>
  305. <if test="shippingId != null and shippingId != 0">
  306. AND o.shipping_id = #{shippingId}
  307. </if>
  308. <if test="orderType != null and orderType.trim() != ''">
  309. AND o.order_type = #{orderType}
  310. </if>
  311. <if test="isOnfiilineOrder != null">
  312. AND o.is_onffline_order = #{isOnfiilineOrder}
  313. </if>
  314. <if test="ids != null and ids.trim() != ''">
  315. AND o.id in (${ids})
  316. </if>
  317. <choose>
  318. <when test="sidx != null and sidx.trim() != ''">
  319. order by ${sidx} ${order}
  320. </when>
  321. <otherwise>
  322. order by o.id desc
  323. </otherwise>
  324. </choose>
  325. <if test="offset != null and limit != null">
  326. limit #{offset}, #{limit}
  327. </if>
  328. </select>
  329. <select id="queryTotal" resultType="int">
  330. select count(DISTINCT o.id) FROM
  331. mall_order o
  332. LEFT JOIN mall_user u ON o.user_id = u.id
  333. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  334. left join mall_store s on o.store_id = s.id
  335. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  336. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  337. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  338. AND r.goods_id = g.goods_id
  339. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  340. WHERE 1=1
  341. <if test="startTime != null and startTime != ''">
  342. AND o.add_time <![CDATA[ > ]]> #{startTime}
  343. </if>
  344. <if test="endTime != null and endTime != ''">
  345. AND o.add_time <![CDATA[ < ]]> #{endTime}
  346. </if>
  347. <if test="storeId != null and storeId != ''">
  348. AND o.store_id = #{storeId}
  349. </if>
  350. <if test="sku != null and sku.trim() != ''">
  351. AND gs.sku = #{sku}
  352. </if>
  353. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  354. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  355. </if>
  356. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  357. AND t.third_merch_sn = #{thirdMerchSn}
  358. </if>
  359. <if test="supplierThirdId != null and supplierThirdId != ''">
  360. AND r.supplier_third_id = #{supplierThirdId}
  361. </if>
  362. <if test="orderBizType != null and orderBizType != ''">
  363. AND o.order_biz_type = #{orderBizType}
  364. </if>
  365. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  366. AND o.merch_order_sn = #{merchOrderSn}
  367. </if>
  368. <if test="merchSn != null and merchSn.trim() != ''">
  369. AND o.merch_sn = #{merchSn}
  370. </if>
  371. <if test="orderSn != null and orderSn.trim() != ''">
  372. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  373. </if>
  374. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  375. AND o.shipping_status = #{shippingStatus}
  376. </if>
  377. <if test="payStatus != null and payStatus.trim() != ''">
  378. AND o.pay_status = #{payStatus}
  379. </if>
  380. <if test="orderStatus != null and orderStatus.trim() != ''">
  381. AND o.order_status = #{orderStatus}
  382. </if>
  383. <if test="shippingId != null and shippingId != 0">
  384. AND o.shipping_id = #{shippingId}
  385. </if>
  386. <if test="orderType != null and orderType.trim() != ''">
  387. AND o.order_type = #{orderType}
  388. </if>
  389. <if test="isOnfiilineOrder != null">
  390. AND o.is_onffline_order = #{isOnfiilineOrder}
  391. </if>
  392. <if test="ids != null and ids.trim() != ''">
  393. AND o.id in (${ids})
  394. </if>
  395. </select>
  396. <select id="queryOffilineOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  397. SELECT
  398. o.*,
  399. u.username AS username,
  400. p.is_payment_send,
  401. p.is_ele_order_send,
  402. p.is_customs_send
  403. FROM
  404. mall_order o
  405. LEFT JOIN sys_user u ON o.user_id = u.user_id
  406. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  407. left join mall_store s on o.store_id = s.id
  408. WHERE 1=1
  409. <if test="storeId != null and storeId != ''">
  410. AND o.store_id = #{storeId}
  411. </if>
  412. <if test="merchSn != null and merchSn.trim() != ''">
  413. AND o.merch_sn = #{merchSn}
  414. </if>
  415. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  416. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  417. </if>
  418. <if test="orderSn != null and orderSn.trim() != ''">
  419. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  420. </if>
  421. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  422. AND o.shipping_status = #{shippingStatus}
  423. </if>
  424. <if test="payStatus != null and payStatus.trim() != ''">
  425. AND o.pay_status = #{payStatus}
  426. </if>
  427. <if test="orderStatus != null and orderStatus.trim() != ''">
  428. AND o.order_status = #{orderStatus}
  429. </if>
  430. <if test="shippingId != null and shippingId != 0">
  431. AND o.shipping_id = #{shippingId}
  432. </if>
  433. <if test="orderType != null and orderType.trim() != ''">
  434. AND o.order_type = #{orderType}
  435. </if>
  436. <if test="isOnfiilineOrder != null">
  437. AND o.is_onffline_order = #{isOnfiilineOrder}
  438. </if>
  439. <if test="ids != null and ids.trim() != ''">
  440. AND o.id in (${ids})
  441. </if>
  442. <choose>
  443. <when test="sidx != null and sidx.trim() != ''">
  444. order by ${sidx} ${order}
  445. </when>
  446. <otherwise>
  447. order by id desc
  448. </otherwise>
  449. </choose>
  450. <if test="offset != null and limit != null">
  451. limit #{offset}, #{limit}
  452. </if>
  453. </select>
  454. <insert id="save" parameterType="com.kmall.admin.entity.OrderEntity" useGeneratedKeys="true" keyProperty="id">
  455. insert into mall_order
  456. (
  457. `order_sn`,
  458. `user_id`,
  459. `order_status`,
  460. `shipping_status`,
  461. `pay_status`,
  462. `consignee`,
  463. `country`,
  464. `province`,
  465. `city`,
  466. `district`,
  467. `address`,
  468. `mobile`,
  469. `postscript`,
  470. `shipping_id`,
  471. `shipping_name`,
  472. `shipping_code`,
  473. `shipping_no`,
  474. `pay_id`,
  475. `pay_name`,
  476. `shipping_fee`,
  477. `actual_price`,
  478. `integral`,
  479. `integral_money`,
  480. `order_price`,
  481. `goods_price`,
  482. `add_time`,
  483. `confirm_time`,
  484. `pay_time`,
  485. `freight_price`,
  486. `coupon_id`,
  487. `coupon_price`,
  488. full_cut_price,
  489. camp_minus_id,
  490. camp_name,
  491. `callback_status`,
  492. `order_type`,
  493. `store_id`,
  494. `order_biz_type`,
  495. `is_onffline_order`,
  496. `order_sn_wx`,
  497. `pay_flag`,
  498. `merch_sn`,
  499. `create_time`,
  500. `mod_time`
  501. )
  502. values
  503. (
  504. #{orderSn},
  505. #{userId},
  506. #{orderStatus},
  507. #{shippingStatus},
  508. #{payStatus},
  509. #{consignee},
  510. #{country},
  511. #{province},
  512. #{city},
  513. #{district},
  514. #{address},
  515. #{mobile},
  516. #{postscript},
  517. #{shippingId},
  518. #{shippingName},
  519. #{shippingCode},
  520. #{shippingNo},
  521. #{payId},
  522. #{payName},
  523. #{shippingFee},
  524. #{actualPrice},
  525. #{integral},
  526. #{integralMoney},
  527. #{orderPrice},
  528. #{goodsPrice},
  529. #{addTime},
  530. #{confirmTime},
  531. #{payTime},
  532. #{freightPrice},
  533. #{couponId},
  534. #{couponPrice},
  535. #{fullCutPrice},
  536. #{campMinusId},
  537. #{campName},
  538. #{callbackStatus},
  539. #{orderType},
  540. #{storeId},
  541. #{orderBizType},
  542. #{isOnfflineOrder},
  543. #{orderSnWx},
  544. #{payFlag},
  545. #{merchSn},
  546. #{createTime},
  547. #{modTime}
  548. )
  549. </insert>
  550. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  551. update mall_order
  552. <set>
  553. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  554. <if test="userId != null">`user_id` = #{userId},</if>
  555. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  556. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  557. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  558. <if test="consignee != null">`consignee` = #{consignee},</if>
  559. <if test="country != null">`country` = #{country},</if>
  560. <if test="province != null">`province` = #{province},</if>
  561. <if test="city != null">`city` = #{city},</if>
  562. <if test="district != null">`district` = #{district},</if>
  563. <if test="address != null">`address` = #{address},</if>
  564. <if test="mobile != null">`mobile` = #{mobile},</if>
  565. <if test="postscript != null">`postscript` = #{postscript},</if>
  566. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  567. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  568. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  569. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  570. <if test="payId != null">`pay_id` = #{payId},</if>
  571. <if test="payName != null">`pay_name` = #{payName},</if>
  572. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  573. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  574. <if test="integral != null">`integral` = #{integral},</if>
  575. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  576. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  577. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  578. <if test="addTime != null">`add_time` = #{addTime},</if>
  579. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  580. <if test="payTime != null">`pay_time` = #{payTime},</if>
  581. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  582. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  583. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  584. <if test="fullCutPrice != null">`full_cut_price` = #{fullCutPrice},</if>
  585. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  586. <if test="campName != null">`camp_name` = #{campName},</if>
  587. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  588. <if test="orderType != null">`order_type` = #{orderType},</if>
  589. <if test="storeId != null">`store_id` = #{storeId},</if>
  590. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  591. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  592. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  593. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  594. <if test="createTime != null">`create_time` = #{createTime},</if>
  595. <if test="modTime != null">`mod_time` = #{modTime},</if>
  596. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  597. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  598. </set>
  599. where id = #{id}
  600. </update>
  601. <delete id="delete">
  602. delete from mall_order where id = #{value}
  603. </delete>
  604. <delete id="deleteBatch">
  605. delete from mall_order where id in
  606. <foreach item="id" collection="array" open="(" separator="," close=")">
  607. #{id}
  608. </foreach>
  609. </delete>
  610. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  611. update mall_order
  612. <set>
  613. `order_status` = #{orderStatus},
  614. `shipping_status` = #{shippingStatus},
  615. `shipping_id` = #{shippingId},
  616. `shipping_name` = #{shippingName},
  617. `shipping_fee` = #{shippingFee},
  618. `shipping_no` = #{shippingNo},
  619. `shipping_mobile` = #{shippingMobile}
  620. </set>
  621. where id = #{id}
  622. </update>
  623. <select id="getYfkOrderUserSum" resultType="int">
  624. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  625. 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
  626. left join mall_store s on o.store_id = s.id
  627. where pay_status = 2
  628. <if test="storeId != null and storeId != ''">
  629. AND o.store_id = #{storeId}
  630. </if>
  631. <if test="merchSn != null and merchSn.trim() != ''">
  632. AND o.merch_sn = #{merchSn}
  633. </if>
  634. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  635. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  636. </if>
  637. group by o.user_id) u
  638. </select>
  639. <select id="getOderUserSum" resultType="int">
  640. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  641. 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
  642. left join mall_store s on o.store_id = s.id
  643. where 1=1
  644. <if test="storeId != null and storeId != ''">
  645. AND o.store_id = #{storeId}
  646. </if>
  647. <if test="merchSn != null and merchSn.trim() != ''">
  648. AND o.merch_sn = #{merchSn}
  649. </if>
  650. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  651. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  652. </if>
  653. group by o.user_id) u
  654. </select>
  655. <select id="getTodayUserOrder" resultType="int">
  656. select count(1) from mall_order o
  657. left join mall_store s on o.store_id = s.id
  658. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  659. <if test="storeId != null and storeId != ''">
  660. AND o.store_id = #{storeId}
  661. </if>
  662. <if test="merchSn != null and merchSn.trim() != ''">
  663. AND o.merch_sn = #{merchSn}
  664. </if>
  665. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  666. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  667. </if>
  668. </select>
  669. <select id="getTodayUserSales" resultType="int">
  670. select ifnull(sum(o.actual_price),0) from mall_order o
  671. 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')
  672. <if test="storeId != null and storeId != ''">
  673. AND o.store_id = #{storeId}
  674. </if>
  675. <if test="merchSn != null and merchSn.trim() != ''">
  676. AND o.merch_sn = #{merchSn}
  677. </if>
  678. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  679. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  680. </if>
  681. </select>
  682. <select id="getIncomeSum" resultType="int">
  683. select ifnull(sum(actual_price),0) from mall_order o
  684. left join mall_store s on o.store_id = s.id where o.pay_status = 2
  685. <if test="storeId != null and storeId != ''">
  686. AND o.store_id = #{storeId}
  687. </if>
  688. <if test="merchSn != null and merchSn.trim() != ''">
  689. AND o.merch_sn = #{merchSn}
  690. </if>
  691. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  692. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  693. </if>
  694. </select>
  695. <select id="getPayedOrderCount" resultType="int">
  696. select count(1) from mall_order o
  697. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  698. <if test="storeId != null and storeId != ''">
  699. AND o.store_id = #{storeId}
  700. </if>
  701. <if test="merchSn != null and merchSn.trim() != ''">
  702. AND o.merch_sn = #{merchSn}
  703. </if>
  704. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  705. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  706. </if>
  707. </select>
  708. <select id="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  709. SELECT
  710. s.prom_id,
  711. o.id,
  712. o.order_sn,
  713. o.merch_order_sn,
  714. o.actual_price,
  715. o.freight_price,
  716. o.activity_id,
  717. o.order_status,
  718. o.pay_status,
  719. store.store_name storeName,
  720. u.userName userName,
  721. o.buyer_pay_check,
  722. o.order_price,
  723. o.coupon_name couponName,
  724. o.add_time,
  725. o.shipping_status,
  726. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  727. g.goods_id goodsId
  728. FROM
  729. mk_store_prom_stat s
  730. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  731. LEFT JOIN mall_order o ON r.order_id = o.id
  732. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  733. AND g.id = r.order_goods_id
  734. LEFT JOIN mall_store store ON o.store_id = store.id
  735. LEFT JOIN mall_user u ON o.user_id = u.id
  736. WHERE
  737. r.order_id IS NOT NULL
  738. <if test="promId != null and promId != ''">
  739. AND s.prom_id = #{promId}
  740. </if>
  741. <if test="startTime != null and startTime != ''">
  742. AND o.add_time <![CDATA[ > ]]> #{startTime}
  743. </if>
  744. <if test="endTime != null and endTime != ''">
  745. AND o.add_time <![CDATA[ < ]]> #{endTime}
  746. </if>
  747. <if test="storeId != null and storeId != ''">
  748. AND o.store_id = #{storeId}
  749. </if>
  750. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  751. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  752. </if>
  753. <if test="orderBizType != null and orderBizType != ''">
  754. AND o.order_biz_type = #{orderBizType}
  755. </if>
  756. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  757. AND o.merch_order_sn = #{merchOrderSn}
  758. </if>
  759. <if test="merchSn != null and merchSn.trim() != ''">
  760. AND o.merch_sn = #{merchSn}
  761. </if>
  762. <if test="orderSn != null and orderSn.trim() != ''">
  763. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  764. </if>
  765. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  766. AND o.shipping_status = #{shippingStatus}
  767. </if>
  768. <if test="payStatus != null and payStatus.trim() != ''">
  769. AND o.pay_status = #{payStatus}
  770. </if>
  771. <if test="orderStatus != null and orderStatus.trim() != ''">
  772. AND o.order_status = #{orderStatus}
  773. </if>
  774. <if test="shippingId != null and shippingId != 0">
  775. AND o.shipping_id = #{shippingId}
  776. </if>
  777. <if test="orderType != null and orderType.trim() != ''">
  778. AND o.order_type = #{orderType}
  779. </if>
  780. <if test="isOnfiilineOrder != null">
  781. AND o.is_onffline_order = #{isOnfiilineOrder}
  782. </if>
  783. <choose>
  784. <when test="sidx != null and sidx.trim() != ''">
  785. order by ${sidx} ${order}
  786. </when>
  787. <otherwise>
  788. order by o.id desc
  789. </otherwise>
  790. </choose>
  791. <if test="offset != null and limit != null">
  792. limit #{offset}, #{limit}
  793. </if>
  794. </select>
  795. <select id="queryPromOrderTotal" resultType="int">
  796. SELECT
  797. count(*)
  798. FROM
  799. mk_store_prom_stat s
  800. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  801. LEFT JOIN mall_order o ON r.order_id = o.id
  802. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  803. AND g.id = r.order_goods_id
  804. LEFT JOIN mall_store store ON o.store_id = store.id
  805. LEFT JOIN mall_user u ON o.user_id = u.id
  806. WHERE
  807. r.order_id IS NOT NULL
  808. <if test="promId != null and promId != ''">
  809. AND s.prom_id = #{promId}
  810. </if>
  811. <if test="startTime != null and startTime != ''">
  812. AND o.add_time <![CDATA[ > ]]> #{startTime}
  813. </if>
  814. <if test="endTime != null and endTime != ''">
  815. AND o.add_time <![CDATA[ < ]]> #{endTime}
  816. </if>
  817. <if test="storeId != null and storeId != ''">
  818. AND o.store_id = #{storeId}
  819. </if>
  820. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  821. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  822. </if>
  823. <if test="orderBizType != null and orderBizType != ''">
  824. AND o.order_biz_type = #{orderBizType}
  825. </if>
  826. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  827. AND o.merch_order_sn = #{merchOrderSn}
  828. </if>
  829. <if test="merchSn != null and merchSn.trim() != ''">
  830. AND o.merch_sn = #{merchSn}
  831. </if>
  832. <if test="orderSn != null and orderSn.trim() != ''">
  833. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  834. </if>
  835. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  836. AND o.shipping_status = #{shippingStatus}
  837. </if>
  838. <if test="payStatus != null and payStatus.trim() != ''">
  839. AND o.pay_status = #{payStatus}
  840. </if>
  841. <if test="orderStatus != null and orderStatus.trim() != ''">
  842. AND o.order_status = #{orderStatus}
  843. </if>
  844. <if test="shippingId != null and shippingId != 0">
  845. AND o.shipping_id = #{shippingId}
  846. </if>
  847. <if test="orderType != null and orderType.trim() != ''">
  848. AND o.order_type = #{orderType}
  849. </if>
  850. <if test="isOnfiilineOrder != null">
  851. AND o.is_onffline_order = #{isOnfiilineOrder}
  852. </if>
  853. </select>
  854. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  855. SELECT
  856. s.prom_id,
  857. o.id,
  858. o.order_sn,
  859. o.merch_order_sn,
  860. o.actual_price,
  861. g.goods_name,
  862. g.number,
  863. g.retail_price,
  864. o.freight_price,
  865. o.activity_id,
  866. o.order_status,
  867. o.pay_status,
  868. store.store_name storeName,
  869. u.userName userName,
  870. o.buyer_pay_check,
  871. o.order_price,
  872. o.add_time,
  873. o.shipping_status,
  874. g.goods_id goodsId
  875. FROM
  876. mk_store_prom_stat s
  877. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  878. LEFT JOIN mall_order o ON r.order_id = o.id
  879. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  880. AND g.id = r.order_goods_id
  881. LEFT JOIN mall_store store ON o.store_id = store.id
  882. LEFT JOIN mall_user u ON o.user_id = u.id
  883. WHERE
  884. r.order_id IS NOT NULL
  885. <if test="promId != null and promId != ''">
  886. AND s.prom_id = #{promId}
  887. </if>
  888. <if test="startTime != null and startTime != ''">
  889. AND o.add_time <![CDATA[ > ]]> #{startTime}
  890. </if>
  891. <if test="endTime != null and endTime != ''">
  892. AND o.add_time <![CDATA[ < ]]> #{endTime}
  893. </if>
  894. <if test="storeId != null and storeId != ''">
  895. AND o.store_id = #{storeId}
  896. </if>
  897. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  898. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  899. </if>
  900. <if test="orderBizType != null and orderBizType != ''">
  901. AND o.order_biz_type = #{orderBizType}
  902. </if>
  903. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  904. AND o.merch_order_sn = #{merchOrderSn}
  905. </if>
  906. <if test="merchSn != null and merchSn.trim() != ''">
  907. AND o.merch_sn = #{merchSn}
  908. </if>
  909. <if test="orderSn != null and orderSn.trim() != ''">
  910. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  911. </if>
  912. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  913. AND o.shipping_status = #{shippingStatus}
  914. </if>
  915. <if test="payStatus != null and payStatus.trim() != ''">
  916. AND o.pay_status = #{payStatus}
  917. </if>
  918. <if test="orderStatus != null and orderStatus.trim() != ''">
  919. AND o.order_status = #{orderStatus}
  920. </if>
  921. <if test="shippingId != null and shippingId != 0">
  922. AND o.shipping_id = #{shippingId}
  923. </if>
  924. <if test="orderType != null and orderType.trim() != ''">
  925. AND o.order_type = #{orderType}
  926. </if>
  927. <if test="isOnfiilineOrder != null">
  928. AND o.is_onffline_order = #{isOnfiilineOrder}
  929. </if>
  930. </select>
  931. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  932. SELECT
  933. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  934. FROM
  935. mk_store_prom_order_real r
  936. LEFT JOIN mall_order o ON r.order_id = o.id
  937. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  938. AND g.id = r.order_goods_id
  939. WHERE 1=1
  940. AND g.goods_id = #{goodsId}
  941. AND r.order_id = #{orderId}
  942. <if test="statusList != null">
  943. AND o.order_status IN
  944. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  945. #{statusList}
  946. </foreach>
  947. </if>
  948. </select>
  949. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  950. SELECT
  951. s.title 'storeTopicName',
  952. pt.prom_type_name 'storeTopicType',
  953. ss.store_name 'storeName',
  954. s.id 'storeTopicId',
  955. o.id,
  956. o.order_sn,
  957. o.merch_order_sn,
  958. o.actual_price,
  959. o.freight_price,
  960. o.activity_id,
  961. o.coupon_id,
  962. o.coupon_name,
  963. o.camp_minus_id,
  964. o.camp_name,
  965. o.order_status,
  966. o.pay_status,
  967. u.userName userName,
  968. o.order_price,
  969. o.add_time,
  970. o.shipping_status
  971. FROM
  972. mall_order o
  973. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  974. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  975. LEFT JOIN mall_store ss ON o.store_id = ss.id
  976. LEFT JOIN mall_user u ON o.user_id = u.id
  977. WHERE
  978. 1=1
  979. <if test="storeTopicId != null and storeTopicId != ''">
  980. AND s.id = #{storeTopicId}
  981. </if>
  982. <if test="startTime != null and startTime != ''">
  983. AND o.add_time <![CDATA[ > ]]> #{startTime}
  984. </if>
  985. <if test="endTime != null and endTime != ''">
  986. AND o.add_time <![CDATA[ < ]]> #{endTime}
  987. </if>
  988. <if test="storeId != null and storeId != ''">
  989. AND o.store_id = #{storeId}
  990. </if>
  991. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  992. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  993. </if>
  994. <if test="orderBizType != null and orderBizType != ''">
  995. AND o.order_biz_type = #{orderBizType}
  996. </if>
  997. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  998. AND o.merch_order_sn = #{merchOrderSn}
  999. </if>
  1000. <if test="merchSn != null and merchSn.trim() != ''">
  1001. AND o.merch_sn = #{merchSn}
  1002. </if>
  1003. <if test="orderSn != null and orderSn.trim() != ''">
  1004. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1005. </if>
  1006. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1007. AND o.shipping_status = #{shippingStatus}
  1008. </if>
  1009. <if test="payStatus != null and payStatus.trim() != ''">
  1010. AND o.pay_status = #{payStatus}
  1011. </if>
  1012. <if test="orderStatus != null and orderStatus.trim() != ''">
  1013. AND o.order_status = #{orderStatus}
  1014. </if>
  1015. <if test="shippingId != null and shippingId != 0">
  1016. AND o.shipping_id = #{shippingId}
  1017. </if>
  1018. <if test="orderType != null and orderType.trim() != ''">
  1019. AND o.order_type = #{orderType}
  1020. </if>
  1021. <if test="isOnfiilineOrder != null">
  1022. AND o.is_onffline_order = #{isOnfiilineOrder}
  1023. </if>
  1024. order by o.id DESC
  1025. <if test="offset != null and limit != null">
  1026. limit #{offset}, #{limit}
  1027. </if>
  1028. </select>
  1029. <select id="queryStoreTopicOrderTotal" resultType="int">
  1030. SELECT
  1031. count(*)
  1032. FROM
  1033. mall_order o
  1034. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1035. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1036. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1037. LEFT JOIN mall_user u ON o.user_id = u.id
  1038. WHERE 1=1
  1039. <if test="storeTopicId != null and storeTopicId != ''">
  1040. AND s.id = #{storeTopicId}
  1041. </if>
  1042. <if test="startTime != null and startTime != ''">
  1043. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1044. </if>
  1045. <if test="endTime != null and endTime != ''">
  1046. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1047. </if>
  1048. <if test="storeId != null and storeId != ''">
  1049. AND o.store_id = #{storeId}
  1050. </if>
  1051. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1052. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1053. </if>
  1054. <if test="orderBizType != null and orderBizType != ''">
  1055. AND o.order_biz_type = #{orderBizType}
  1056. </if>
  1057. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1058. AND o.merch_order_sn = #{merchOrderSn}
  1059. </if>
  1060. <if test="merchSn != null and merchSn.trim() != ''">
  1061. AND o.merch_sn = #{merchSn}
  1062. </if>
  1063. <if test="orderSn != null and orderSn.trim() != ''">
  1064. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1065. </if>
  1066. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1067. AND o.shipping_status = #{shippingStatus}
  1068. </if>
  1069. <if test="payStatus != null and payStatus.trim() != ''">
  1070. AND o.pay_status = #{payStatus}
  1071. </if>
  1072. <if test="orderStatus != null and orderStatus.trim() != ''">
  1073. AND o.order_status = #{orderStatus}
  1074. </if>
  1075. <if test="shippingId != null and shippingId != 0">
  1076. AND o.shipping_id = #{shippingId}
  1077. </if>
  1078. <if test="orderType != null and orderType.trim() != ''">
  1079. AND o.order_type = #{orderType}
  1080. </if>
  1081. <if test="isOnfiilineOrder != null">
  1082. AND o.is_onffline_order = #{isOnfiilineOrder}
  1083. </if>
  1084. </select>
  1085. <!-- 可根据自己的需求,是否要使用 -->
  1086. <resultMap type="com.kmall.admin.dto.OrderRecognitionDto" id="orderRecognitionMap">
  1087. <result property="id" column="id"/>
  1088. <result property="merchOrderSn" column="merch_order_sn"/>
  1089. <result property="orderSn" column="order_sn"/>
  1090. <result property="userId" column="user_id"/>
  1091. <result property="orderStatus" column="order_status"/>
  1092. <result property="shippingStatus" column="shipping_status"/>
  1093. <result property="payStatus" column="pay_status"/>
  1094. <result property="consignee" column="consignee"/>
  1095. <result property="country" column="country"/>
  1096. <result property="province" column="province"/>
  1097. <result property="city" column="city"/>
  1098. <result property="district" column="district"/>
  1099. <result property="address" column="address"/>
  1100. <result property="mobile" column="mobile"/>
  1101. <result property="postscript" column="postscript"/>
  1102. <result property="shippingId" column="shipping_id"/>
  1103. <result property="shippingName" column="shipping_name"/>
  1104. <result property="shippingCode" column="shipping_code"/>
  1105. <result property="shippingNo" column="shipping_no"/>
  1106. <result property="payId" column="pay_id"/>
  1107. <result property="payName" column="pay_name"/>
  1108. <result property="shippingFee" column="shipping_fee"/>
  1109. <result property="actualPrice" column="actual_price"/>
  1110. <result property="integral" column="integral"/>
  1111. <result property="integralMoney" column="integral_money"/>
  1112. <result property="orderPrice" column="order_price"/>
  1113. <result property="goodsPrice" column="goods_price"/>
  1114. <result property="addTime" column="add_time"/>
  1115. <result property="confirmTime" column="confirm_time"/>
  1116. <result property="payTime" column="pay_time"/>
  1117. <result property="freightPrice" column="freight_price"/>
  1118. <result property="couponId" column="coupon_id"/>
  1119. <result property="couponPrice" column="coupon_price"/>
  1120. <result property="callbackStatus" column="callback_status"/>
  1121. <result property="orderType" column="order_type"/>
  1122. <result property="storeId" column="store_id"/>
  1123. <result property="userName" column="username"/>
  1124. <result property="orderType" column="order_type"/>
  1125. <result property="activityId" column="activity_id"/>
  1126. <result property="deliveryDate" column="delivery_date"/>
  1127. <result property="deliveryRemark" column="delivery_remark"/>
  1128. <result property="predictTime" column="predict_time"/>
  1129. <result property="orderBizType" column="order_biz_type"/>
  1130. <result property="isPaymentSend" column="is_payment_send"/>
  1131. <result property="isEleOrderSend" column="is_ele_order_send"/>
  1132. <result property="isCustomsSend" column="is_customs_send"/>
  1133. <result property="payFlag" column="pay_flag"/>
  1134. <result column="buyer_pay_check" property="buyerPayCheck"/>
  1135. <result property="merchSn" column="merch_sn"/>
  1136. <result property="sku" column="sku"/>
  1137. <result property="createTime" column="create_time"/>
  1138. <result property="modTime" column="mod_time"/>
  1139. <result property="isOnfflineOrder" column="is_onffline_order"/>
  1140. <result property="orderSnWx" column="order_sn_wx"/>
  1141. <result property="isMergePay" column="is_merge_pay"/>
  1142. <result property="payTransactionId" column="pay_transaction_id"/>
  1143. <result property="storeName" column="store_name"/>
  1144. <result property="moderSn" column="moder_sn"/>
  1145. <result property="unitCode" column="unit_code"/>
  1146. <result property="ciqProdModel" column="ciq_prod_model"/>
  1147. <result property="oriCntCode" column="ori_cnt_code"/>
  1148. <result property="brand" column="brand"/>
  1149. <result column="gross_weight" property="grossWeight" />
  1150. <result column="net_weight" property="netWeight" />
  1151. <result property="fullCutPrice" column="full_cut_price"/>
  1152. <result property="campMinusId" column="camp_minus_id"/>
  1153. <result property="campName" column="camp_name"/>
  1154. <result property="isTempNoti" column="is_temp_noti"/>
  1155. <result property="isFaceCheck" column="is_face_check"/>
  1156. <result property="tempNotiMsg" column="temp_noti_msg"/>
  1157. <result property="recognitionReturnMsg" column="recognition_return_msg"/>
  1158. <result property="lastFaceTime" column="last_face_time"/>
  1159. <result property="failCount" column="fail_count"/>
  1160. <result property="checkOperatorType" column="check_operator_type"/>
  1161. <result property="faceLivenessId" column="faceLivenessId"/>
  1162. </resultMap>
  1163. <select id="queryOrderListByRecognition" resultMap="orderRecognitionMap">
  1164. SELECT DISTINCT
  1165. o.order_sn,
  1166. o.merch_order_sn,
  1167. o.order_status,
  1168. o.actual_price,
  1169. o.order_biz_type,
  1170. o.shipping_no,
  1171. o.shipping_name,
  1172. o.shipping_code,
  1173. o.consignee,
  1174. o.mobile,
  1175. o.province,
  1176. o.city,
  1177. o.district,
  1178. o.address,
  1179. o.add_time,
  1180. o.pay_id,
  1181. o.pay_status,
  1182. o.shipping_status,
  1183. o.is_merge_pay,
  1184. o.buyer_pay_check,
  1185. o.order_price,
  1186. o.moder_sn,
  1187. o.id,
  1188. u.username AS username,
  1189. o.user_id,
  1190. p.is_payment_send,
  1191. p.is_ele_order_send,
  1192. p.is_customs_send,
  1193. s.store_name,
  1194. o.full_cut_price,
  1195. o.camp_minus_id,
  1196. o.camp_name,
  1197. fd.is_temp_noti,
  1198. fd.is_face_check,
  1199. fd.temp_noti_msg,
  1200. fd.recognition_return_msg,
  1201. fd.fail_count,
  1202. fd.id 'faceLivenessId',
  1203. fd.check_operator_type,
  1204. u.last_face_time,
  1205. t.is_face_check 'thirdIsFaceCheck'
  1206. FROM
  1207. mall_order o
  1208. LEFT JOIN mall_user u ON o.user_id = u.id
  1209. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1210. left join mall_store s on o.store_id = s.id
  1211. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1212. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1213. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1214. AND r.goods_id = g.goods_id
  1215. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1216. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1217. WHERE 1=1
  1218. <if test="startTime != null and startTime != ''">
  1219. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1220. </if>
  1221. <if test="endTime != null and endTime != ''">
  1222. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1223. </if>
  1224. <if test="storeId != null and storeId != ''">
  1225. AND o.store_id = #{storeId}
  1226. </if>
  1227. <if test="sku != null and sku.trim() != ''">
  1228. AND gs.sku = #{sku}
  1229. </if>
  1230. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1231. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1232. </if>
  1233. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1234. AND t.third_merch_sn = #{thirdMerchSn}
  1235. </if>
  1236. <if test="supplierThirdId != null and supplierThirdId != ''">
  1237. AND r.supplier_third_id = #{supplierThirdId}
  1238. </if>
  1239. <if test="orderBizType != null and orderBizType != ''">
  1240. AND o.order_biz_type = #{orderBizType}
  1241. </if>
  1242. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1243. AND o.merch_order_sn = #{merchOrderSn}
  1244. </if>
  1245. <if test="merchSn != null and merchSn.trim() != ''">
  1246. AND o.merch_sn = #{merchSn}
  1247. </if>
  1248. <if test="orderSn != null and orderSn.trim() != ''">
  1249. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1250. </if>
  1251. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1252. AND o.shipping_status = #{shippingStatus}
  1253. </if>
  1254. <if test="payStatus != null and payStatus.trim() != ''">
  1255. AND o.pay_status = #{payStatus}
  1256. </if>
  1257. <if test="orderStatus != null and orderStatus.trim() != ''">
  1258. AND o.order_status = #{orderStatus}
  1259. </if>
  1260. <if test="shippingId != null and shippingId != 0">
  1261. AND o.shipping_id = #{shippingId}
  1262. </if>
  1263. <if test="orderType != null and orderType.trim() != ''">
  1264. AND o.order_type = #{orderType}
  1265. </if>
  1266. <if test="isOnfiilineOrder != null">
  1267. AND o.is_onffline_order = #{isOnfiilineOrder}
  1268. </if>
  1269. <if test="ids != null and ids.trim() != ''">
  1270. AND o.id in (${ids})
  1271. </if>
  1272. <choose>
  1273. <when test="sidx != null and sidx.trim() != ''">
  1274. order by ${sidx} ${order}
  1275. </when>
  1276. <otherwise>
  1277. order by o.id desc
  1278. </otherwise>
  1279. </choose>
  1280. <if test="offset != null and limit != null">
  1281. limit #{offset}, #{limit}
  1282. </if>
  1283. </select>
  1284. <select id="queryOrderListByRecognitionTotal" resultType="int">
  1285. SELECT count(1)
  1286. FROM
  1287. mall_order o
  1288. LEFT JOIN mall_user u ON o.user_id = u.id
  1289. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1290. left join mall_store s on o.store_id = s.id
  1291. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1292. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1293. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1294. AND r.goods_id = g.goods_id
  1295. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1296. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1297. WHERE 1=1
  1298. <if test="startTime != null and startTime != ''">
  1299. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1300. </if>
  1301. <if test="endTime != null and endTime != ''">
  1302. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1303. </if>
  1304. <if test="storeId != null and storeId != ''">
  1305. AND o.store_id = #{storeId}
  1306. </if>
  1307. <if test="sku != null and sku.trim() != ''">
  1308. AND gs.sku = #{sku}
  1309. </if>
  1310. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1311. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1312. </if>
  1313. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1314. AND t.third_merch_sn = #{thirdMerchSn}
  1315. </if>
  1316. <if test="supplierThirdId != null and supplierThirdId != ''">
  1317. AND r.supplier_third_id = #{supplierThirdId}
  1318. </if>
  1319. <if test="orderBizType != null and orderBizType != ''">
  1320. AND o.order_biz_type = #{orderBizType}
  1321. </if>
  1322. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1323. AND o.merch_order_sn = #{merchOrderSn}
  1324. </if>
  1325. <if test="merchSn != null and merchSn.trim() != ''">
  1326. AND o.merch_sn = #{merchSn}
  1327. </if>
  1328. <if test="orderSn != null and orderSn.trim() != ''">
  1329. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1330. </if>
  1331. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1332. AND o.shipping_status = #{shippingStatus}
  1333. </if>
  1334. <if test="payStatus != null and payStatus.trim() != ''">
  1335. AND o.pay_status = #{payStatus}
  1336. </if>
  1337. <if test="orderStatus != null and orderStatus.trim() != ''">
  1338. AND o.order_status = #{orderStatus}
  1339. </if>
  1340. <if test="shippingId != null and shippingId != 0">
  1341. AND o.shipping_id = #{shippingId}
  1342. </if>
  1343. <if test="orderType != null and orderType.trim() != ''">
  1344. AND o.order_type = #{orderType}
  1345. </if>
  1346. <if test="isOnfiilineOrder != null">
  1347. AND o.is_onffline_order = #{isOnfiilineOrder}
  1348. </if>
  1349. <if test="ids != null and ids.trim() != ''">
  1350. AND o.id in (${ids})
  1351. </if>
  1352. </select>
  1353. <select id="queryOrderByRecogTemp" resultType="com.kmall.admin.dto.SendTempDto">
  1354. SELECT
  1355. o.add_time 'addTime',
  1356. u.weixin_openid 'openId',
  1357. o.merch_order_sn 'merchOrderSn',
  1358. o.id 'orderId',
  1359. o.order_sn 'orderSn'
  1360. FROM
  1361. mall_order o
  1362. INNER JOIN mall_user u ON o.user_id = u.id
  1363. where o.id = #{value}
  1364. </select>
  1365. </mapper>