OrderDao.xml 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  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 sys_user u ON o.user_id = u.user_id
  413. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  414. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  415. left join mall_store s on o.store_id = s.id
  416. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  417. WHERE 1=1
  418. <if test="storeId != null and storeId != ''">
  419. AND o.store_id = #{storeId}
  420. </if>
  421. <if test="merchSn != null and merchSn.trim() != ''">
  422. AND o.merch_sn = #{merchSn}
  423. </if>
  424. <if test="sku != null and sku.trim() != ''">
  425. AND gs.sku = #{sku}
  426. </if>
  427. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  428. AND gs.prod_barcode = #{prodBarcode}
  429. </if>
  430. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  431. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  432. </if>
  433. <if test="orderSn != null and orderSn.trim() != ''">
  434. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  435. </if>
  436. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  437. AND o.shipping_status = #{shippingStatus}
  438. </if>
  439. <if test="payStatus != null and payStatus.trim() != ''">
  440. AND o.pay_status = #{payStatus}
  441. </if>
  442. <if test="orderStatus != null and orderStatus.trim() != ''">
  443. AND o.order_status = #{orderStatus}
  444. </if>
  445. <if test="shippingId != null and shippingId != 0">
  446. AND o.shipping_id = #{shippingId}
  447. </if>
  448. <if test="orderType != null and orderType.trim() != ''">
  449. AND o.order_type = #{orderType}
  450. </if>
  451. <if test="isOnfiilineOrder != null">
  452. AND o.is_onffline_order = #{isOnfiilineOrder}
  453. </if>
  454. <if test="ids != null and ids.trim() != ''">
  455. AND o.id in (${ids})
  456. </if>
  457. <choose>
  458. <when test="sidx != null and sidx.trim() != ''">
  459. order by ${sidx} ${order}
  460. </when>
  461. <otherwise>
  462. order by id desc
  463. </otherwise>
  464. </choose>
  465. <if test="offset != null and limit != null">
  466. limit #{offset}, #{limit}
  467. </if>
  468. </select>
  469. <insert id="save" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  470. insert into mall_order
  471. (
  472. `order_sn`,
  473. `user_id`,
  474. `order_status`,
  475. `shipping_status`,
  476. `pay_status`,
  477. `consignee`,
  478. `country`,
  479. `province`,
  480. `city`,
  481. `district`,
  482. `address`,
  483. `mobile`,
  484. `postscript`,
  485. `shipping_id`,
  486. `shipping_name`,
  487. `shipping_code`,
  488. `shipping_no`,
  489. `pay_id`,
  490. `pay_name`,
  491. `shipping_fee`,
  492. `actual_price`,
  493. `integral`,
  494. `integral_money`,
  495. `order_price`,
  496. `goods_price`,
  497. `add_time`,
  498. `confirm_time`,
  499. `pay_time`,
  500. `freight_price`,
  501. `coupon_id`,
  502. `coupon_price`,
  503. full_cut_price,
  504. camp_minus_id,
  505. camp_name,
  506. `callback_status`,
  507. `order_type`,
  508. `store_id`,
  509. `order_biz_type`,
  510. `is_onffline_order`,
  511. `order_sn_wx`,
  512. `pay_flag`,
  513. `merch_sn`,
  514. `create_time`,
  515. `mod_time`
  516. )
  517. values
  518. (
  519. #{orderSn},
  520. #{userId},
  521. #{orderStatus},
  522. #{shippingStatus},
  523. #{payStatus},
  524. #{consignee},
  525. #{country},
  526. #{province},
  527. #{city},
  528. #{district},
  529. #{address},
  530. #{mobile},
  531. #{postscript},
  532. #{shippingId},
  533. #{shippingName},
  534. #{shippingCode},
  535. #{shippingNo},
  536. #{payId},
  537. #{payName},
  538. #{shippingFee},
  539. #{actualPrice},
  540. #{integral},
  541. #{integralMoney},
  542. #{orderPrice},
  543. #{goodsPrice},
  544. #{addTime},
  545. #{confirmTime},
  546. #{payTime},
  547. #{freightPrice},
  548. #{couponId},
  549. #{couponPrice},
  550. #{fullCutPrice},
  551. #{campMinusId},
  552. #{campName},
  553. #{callbackStatus},
  554. #{orderType},
  555. #{storeId},
  556. #{orderBizType},
  557. #{isOnfflineOrder},
  558. #{orderSnWx},
  559. #{payFlag},
  560. #{merchSn},
  561. #{createTime},
  562. #{modTime}
  563. )
  564. </insert>
  565. <insert id="saveOrderVo" parameterType="com.kmall.api.entity.OrderVo" useGeneratedKeys="true" keyProperty="id">
  566. insert into mall_order
  567. (
  568. `order_sn`,
  569. `user_id`,
  570. `order_status`,
  571. `shipping_status`,
  572. `shipping_code`,
  573. `pay_status`,
  574. `consignee`,
  575. `country`,
  576. `province`,
  577. `city`,
  578. `district`,
  579. `address`,
  580. `address_id`,
  581. `mobile`,
  582. `postscript`,
  583. `pay_id`,
  584. `pay_name`,
  585. `shipping_fee`,
  586. `actual_price`,
  587. `cash_fee`,
  588. `cash_fee_type`,
  589. `total_fee`,
  590. `fee_type`,
  591. `rate`,
  592. `integral`,
  593. `integral_money`,
  594. `order_price`,
  595. `goods_price`,
  596. `add_time`,
  597. `confirm_time`,
  598. `pay_time`,
  599. `freight_price`,
  600. `coupon_id`,
  601. `coupon_price`,
  602. `full_cut_price`,
  603. camp_minus_id,
  604. camp_name,
  605. `order_type`,
  606. `activity_id`,
  607. `store_id`,
  608. `delivery_date`,
  609. `delivery_remark`,
  610. `predict_time`,
  611. `coupon_name`,
  612. `comment_count`,
  613. <if test="merchSn != null" >
  614. merch_sn,
  615. </if>
  616. <if test="merchOrderSn != null" >
  617. merch_order_sn,
  618. </if>
  619. <if test="isScan != null" >
  620. is_scan,
  621. </if>
  622. <if test="isMergePay != null" >
  623. is_merge_pay,
  624. </if>
  625. <if test="orderBizType != null" >
  626. order_biz_type,
  627. </if>
  628. <if test="payTransactionId != null" >
  629. pay_transaction_id,
  630. </if>
  631. <if test="payMobile != null" >
  632. pay_mobile,
  633. </if>
  634. <if test="buyerPayCheck != null" >
  635. buyer_pay_check,
  636. </if>
  637. <if test="isOnfflineOrder != null" >
  638. `is_onffline_order`,
  639. </if>
  640. <if test="payFlag != null" >
  641. pay_flag,
  642. </if>
  643. <if test="createrSn != null" >
  644. creater_sn,
  645. </if>
  646. <if test="createTime != null" >
  647. create_time,
  648. </if>
  649. <if test="moderSn != null" >
  650. moder_sn,
  651. </if>
  652. <if test="modTime != null" >
  653. mod_time
  654. </if>
  655. )
  656. values
  657. (
  658. #{order_sn},
  659. #{user_id},
  660. #{order_status},
  661. #{shipping_status},
  662. #{shipping_code},
  663. #{pay_status},
  664. #{consignee},
  665. #{country},
  666. #{province},
  667. #{city},
  668. #{district},
  669. #{address},
  670. #{address_id},
  671. #{mobile},
  672. #{postscript},
  673. #{pay_id},
  674. #{pay_name},
  675. #{shipping_fee},
  676. #{actual_price},
  677. #{cashFee},
  678. #{cashFeeType},
  679. #{totalFee},
  680. #{feeType},
  681. #{rate},
  682. #{integral},
  683. #{integral_money},
  684. #{order_price},
  685. #{goods_price},
  686. now(),
  687. #{confirm_time},
  688. #{pay_time},
  689. #{freight_price},
  690. #{coupon_id},
  691. #{coupon_price},
  692. #{full_cut_price},
  693. #{campMinusId},
  694. #{campName},
  695. #{order_type},
  696. #{activity_id},
  697. #{store_id},
  698. #{delivery_date},
  699. #{delivery_remark},
  700. #{predict_time},
  701. #{coupon_name},
  702. #{comment_count},
  703. <if test="merchSn != null" >
  704. #{merchSn},
  705. </if>
  706. <if test="merchOrderSn != null" >
  707. #{merchOrderSn},
  708. </if>
  709. <if test="isScan != null" >
  710. #{isScan},
  711. </if>
  712. <if test="isMergePay != null" >
  713. #{isMergePay},
  714. </if>
  715. <if test="orderBizType != null" >
  716. #{orderBizType,jdbcType=CHAR},
  717. </if>
  718. <if test="payTransactionId != null" >
  719. #{payTransactionId},
  720. </if>
  721. <if test="payMobile != null" >
  722. #{payMobile},
  723. </if>
  724. <if test="buyerPayCheck != null" >
  725. #{buyerPayCheck},
  726. </if>
  727. <if test="isOnfflineOrder != null" >
  728. #{isOnfflineOrder},
  729. </if>
  730. <if test="payFlag != null" >
  731. #{payFlag},
  732. </if>
  733. <if test="createrSn != null" >
  734. #{createrSn},
  735. </if>
  736. <if test="createTime != null" >
  737. #{createTime},
  738. </if>
  739. <if test="moderSn != null" >
  740. #{moderSn},
  741. </if>
  742. <if test="modTime != null" >
  743. #{modTime}
  744. </if>
  745. )
  746. </insert>
  747. <update id="update" parameterType="com.kmall.admin.entity.OrderEntity">
  748. update mall_order
  749. <set>
  750. <if test="orderSn != null">`order_sn` = #{orderSn},</if>
  751. <if test="userId != null">`user_id` = #{userId},</if>
  752. <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
  753. <if test="shippingStatus != null">`shipping_status` = #{shippingStatus},</if>
  754. <if test="payStatus != null">`pay_status` = #{payStatus},</if>
  755. <if test="consignee != null">`consignee` = #{consignee},</if>
  756. <if test="country != null">`country` = #{country},</if>
  757. <if test="province != null">`province` = #{province},</if>
  758. <if test="city != null">`city` = #{city},</if>
  759. <if test="district != null">`district` = #{district},</if>
  760. <if test="address != null">`address` = #{address},</if>
  761. <if test="mobile != null">`mobile` = #{mobile},</if>
  762. <if test="postscript != null">`postscript` = #{postscript},</if>
  763. <if test="shippingId != null">`shipping_id` = #{shippingId},</if>
  764. <if test="shippingName != null">`shipping_name` = #{shippingName},</if>
  765. <if test="shippingCode != null">`shipping_code` = #{shippingCode},</if>
  766. <if test="shippingNo != null">`shipping_no` = #{shippingNo},</if>
  767. <if test="payId != null">`pay_id` = #{payId},</if>
  768. <if test="payName != null">`pay_name` = #{payName},</if>
  769. <if test="shippingFee != null">`shipping_fee` = #{shippingFee},</if>
  770. <if test="actualPrice != null">`actual_price` = #{actualPrice},</if>
  771. <if test="integral != null">`integral` = #{integral},</if>
  772. <if test="integralMoney != null">`integral_money` = #{integralMoney},</if>
  773. <if test="orderPrice != null">`order_price` = #{orderPrice},</if>
  774. <if test="goodsPrice != null">`goods_price` = #{goodsPrice},</if>
  775. <if test="addTime != null">`add_time` = #{addTime},</if>
  776. <if test="confirmTime != null">`confirm_time` = #{confirmTime},</if>
  777. <if test="payTime != null">`pay_time` = #{payTime},</if>
  778. <if test="freightPrice != null">`freight_price` = #{freightPrice},</if>
  779. <if test="couponId != null">`coupon_id` = #{couponId},</if>
  780. <if test="couponPrice != null">`coupon_price` = #{couponPrice},</if>
  781. <if test="fullCutPrice != null">`full_cut_price` = #{fullCutPrice},</if>
  782. <if test="campMinusId != null">`camp_minus_id` = #{campMinusId},</if>
  783. <if test="campName != null">`camp_name` = #{campName},</if>
  784. <if test="callbackStatus != null">`callback_status` = #{callbackStatus},</if>
  785. <if test="AliTradeNo != null">`ali_trade_no` = #{AliTradeNo},</if>
  786. <if test="orderType != null">`order_type` = #{orderType},</if>
  787. <if test="storeId != null">`store_id` = #{storeId},</if>
  788. <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
  789. <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
  790. <if test="orderBizType != null">`order_biz_type` = #{orderBizType},</if>
  791. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  792. <if test="createTime != null">`create_time` = #{createTime},</if>
  793. <if test="modTime != null">`mod_time` = #{modTime},</if>
  794. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  795. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  796. </set>
  797. where id = #{id}
  798. </update>
  799. <delete id="delete">
  800. delete from mall_order where id = #{value}
  801. </delete>
  802. <delete id="deleteBatch">
  803. delete from mall_order where id in
  804. <foreach item="id" collection="array" open="(" separator="," close=")">
  805. #{id}
  806. </foreach>
  807. </delete>
  808. <update id="riderOrderUpdate" parameterType="com.kmall.admin.entity.OrderEntity">
  809. update mall_order
  810. <set>
  811. `order_status` = #{orderStatus},
  812. `shipping_status` = #{shippingStatus},
  813. `shipping_id` = #{shippingId},
  814. `shipping_name` = #{shippingName},
  815. `shipping_fee` = #{shippingFee},
  816. `shipping_no` = #{shippingNo},
  817. `shipping_mobile` = #{shippingMobile}
  818. </set>
  819. where id = #{id}
  820. </update>
  821. <select id="getYfkOrderUserSum" resultType="int">
  822. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  823. 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
  824. left join mall_store s on o.store_id = s.id
  825. where pay_status = 2
  826. <if test="storeId != null and storeId != ''">
  827. AND o.store_id = #{storeId}
  828. </if>
  829. <if test="merchSn != null and merchSn.trim() != ''">
  830. AND o.merch_sn = #{merchSn}
  831. </if>
  832. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  833. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  834. </if>
  835. group by o.user_id) u
  836. </select>
  837. <select id="getOderUserSum" resultType="int">
  838. select count(1) from (select o.user_id,count(o.user_id) as counts from mall_order o
  839. 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
  840. left join mall_store s on o.store_id = s.id
  841. where 1=1
  842. <if test="storeId != null and storeId != ''">
  843. AND o.store_id = #{storeId}
  844. </if>
  845. <if test="merchSn != null and merchSn.trim() != ''">
  846. AND o.merch_sn = #{merchSn}
  847. </if>
  848. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  849. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  850. </if>
  851. group by o.user_id) u
  852. </select>
  853. <select id="getTodayUserOrder" resultType="int">
  854. select count(1) from mall_order o
  855. left join mall_store s on o.store_id = s.id
  856. where pay_status = 2 and pay_time > date_format(sysdate(), '%Y-%m-%d')
  857. <if test="storeId != null and storeId != ''">
  858. AND o.store_id = #{storeId}
  859. </if>
  860. <if test="merchSn != null and merchSn.trim() != ''">
  861. AND o.merch_sn = #{merchSn}
  862. </if>
  863. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  864. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  865. </if>
  866. </select>
  867. <select id="getTodayUserSales" resultType="int">
  868. select ifnull(sum(o.actual_price),0) from mall_order o
  869. 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')
  870. <if test="storeId != null and storeId != ''">
  871. AND o.store_id = #{storeId}
  872. </if>
  873. <if test="merchSn != null and merchSn.trim() != ''">
  874. AND o.merch_sn = #{merchSn}
  875. </if>
  876. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  877. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  878. </if>
  879. </select>
  880. <select id="getIncomeSum" resultType="int">
  881. select ifnull(sum(actual_price),0) from mall_order o
  882. left join mall_store s on o.store_id = s.id where o.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. </select>
  893. <select id="getPayedOrderCount" resultType="int">
  894. select count(1) from mall_order o
  895. left join mall_store s on o.store_id = s.id where o.pay_status = 2 and o.is_onffline_order = 0
  896. <if test="storeId != null and storeId != ''">
  897. AND o.store_id = #{storeId}
  898. </if>
  899. <if test="merchSn != null and merchSn.trim() != ''">
  900. AND o.merch_sn = #{merchSn}
  901. </if>
  902. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  903. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  904. </if>
  905. </select>
  906. <select id="promOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  907. SELECT
  908. s.prom_id,
  909. o.id,
  910. o.order_sn,
  911. o.merch_order_sn,
  912. o.actual_price,
  913. o.freight_price,
  914. o.activity_id,
  915. o.order_status,
  916. o.pay_status,
  917. store.store_name storeName,
  918. u.userName userName,
  919. o.buyer_pay_check,
  920. o.order_price,
  921. o.coupon_name couponName,
  922. o.add_time,
  923. o.shipping_status,
  924. (select count(1) from mall_order_goods where order_id = o.id) orderDetailCount,
  925. g.goods_id goodsId
  926. FROM
  927. mk_store_prom_stat s
  928. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  929. LEFT JOIN mall_order o ON r.order_id = o.id
  930. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  931. AND g.id = r.order_goods_id
  932. LEFT JOIN mall_store store ON o.store_id = store.id
  933. LEFT JOIN mall_user u ON o.user_id = u.id
  934. WHERE
  935. r.order_id IS NOT NULL
  936. <if test="promId != null and promId != ''">
  937. AND s.prom_id = #{promId}
  938. </if>
  939. <if test="startTime != null and startTime != ''">
  940. AND o.add_time <![CDATA[ > ]]> #{startTime}
  941. </if>
  942. <if test="endTime != null and endTime != ''">
  943. AND o.add_time <![CDATA[ < ]]> #{endTime}
  944. </if>
  945. <if test="storeId != null and storeId != ''">
  946. AND o.store_id = #{storeId}
  947. </if>
  948. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  949. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  950. </if>
  951. <if test="orderBizType != null and orderBizType != ''">
  952. AND o.order_biz_type = #{orderBizType}
  953. </if>
  954. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  955. AND o.merch_order_sn = #{merchOrderSn}
  956. </if>
  957. <if test="merchSn != null and merchSn.trim() != ''">
  958. AND o.merch_sn = #{merchSn}
  959. </if>
  960. <if test="orderSn != null and orderSn.trim() != ''">
  961. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  962. </if>
  963. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  964. AND o.shipping_status = #{shippingStatus}
  965. </if>
  966. <if test="payStatus != null and payStatus.trim() != ''">
  967. AND o.pay_status = #{payStatus}
  968. </if>
  969. <if test="orderStatus != null and orderStatus.trim() != ''">
  970. AND o.order_status = #{orderStatus}
  971. </if>
  972. <if test="shippingId != null and shippingId != 0">
  973. AND o.shipping_id = #{shippingId}
  974. </if>
  975. <if test="orderType != null and orderType.trim() != ''">
  976. AND o.order_type = #{orderType}
  977. </if>
  978. <if test="isOnfiilineOrder != null">
  979. AND o.is_onffline_order = #{isOnfiilineOrder}
  980. </if>
  981. <choose>
  982. <when test="sidx != null and sidx.trim() != ''">
  983. order by ${sidx} ${order}
  984. </when>
  985. <otherwise>
  986. order by o.id desc
  987. </otherwise>
  988. </choose>
  989. <if test="offset != null and limit != null">
  990. limit #{offset}, #{limit}
  991. </if>
  992. </select>
  993. <select id="queryPromOrderTotal" resultType="int">
  994. SELECT
  995. count(*)
  996. FROM
  997. mk_store_prom_stat s
  998. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  999. LEFT JOIN mall_order o ON r.order_id = o.id
  1000. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1001. AND g.id = r.order_goods_id
  1002. LEFT JOIN mall_store store ON o.store_id = store.id
  1003. LEFT JOIN mall_user u ON o.user_id = u.id
  1004. WHERE
  1005. r.order_id IS NOT NULL
  1006. <if test="promId != null and promId != ''">
  1007. AND s.prom_id = #{promId}
  1008. </if>
  1009. <if test="startTime != null and startTime != ''">
  1010. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1011. </if>
  1012. <if test="endTime != null and endTime != ''">
  1013. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1014. </if>
  1015. <if test="storeId != null and storeId != ''">
  1016. AND o.store_id = #{storeId}
  1017. </if>
  1018. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1019. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1020. </if>
  1021. <if test="orderBizType != null and orderBizType != ''">
  1022. AND o.order_biz_type = #{orderBizType}
  1023. </if>
  1024. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1025. AND o.merch_order_sn = #{merchOrderSn}
  1026. </if>
  1027. <if test="merchSn != null and merchSn.trim() != ''">
  1028. AND o.merch_sn = #{merchSn}
  1029. </if>
  1030. <if test="orderSn != null and orderSn.trim() != ''">
  1031. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1032. </if>
  1033. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1034. AND o.shipping_status = #{shippingStatus}
  1035. </if>
  1036. <if test="payStatus != null and payStatus.trim() != ''">
  1037. AND o.pay_status = #{payStatus}
  1038. </if>
  1039. <if test="orderStatus != null and orderStatus.trim() != ''">
  1040. AND o.order_status = #{orderStatus}
  1041. </if>
  1042. <if test="shippingId != null and shippingId != 0">
  1043. AND o.shipping_id = #{shippingId}
  1044. </if>
  1045. <if test="orderType != null and orderType.trim() != ''">
  1046. AND o.order_type = #{orderType}
  1047. </if>
  1048. <if test="isOnfiilineOrder != null">
  1049. AND o.is_onffline_order = #{isOnfiilineOrder}
  1050. </if>
  1051. </select>
  1052. <select id="promOrderListExport" resultType="com.kmall.admin.entity.OrderEntity">
  1053. SELECT
  1054. s.prom_id,
  1055. o.id,
  1056. o.order_sn,
  1057. o.merch_order_sn,
  1058. o.actual_price,
  1059. g.goods_name,
  1060. g.number,
  1061. g.retail_price,
  1062. o.freight_price,
  1063. o.activity_id,
  1064. o.order_status,
  1065. o.pay_status,
  1066. store.store_name storeName,
  1067. u.userName userName,
  1068. o.buyer_pay_check,
  1069. o.order_price,
  1070. o.add_time,
  1071. o.shipping_status,
  1072. g.goods_id goodsId
  1073. FROM
  1074. mk_store_prom_stat s
  1075. LEFT JOIN mk_store_prom_order_real r ON s.prom_id = r.prom_id
  1076. LEFT JOIN mall_order o ON r.order_id = o.id
  1077. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1078. AND g.id = r.order_goods_id
  1079. LEFT JOIN mall_store store ON o.store_id = store.id
  1080. LEFT JOIN mall_user u ON o.user_id = u.id
  1081. WHERE
  1082. r.order_id IS NOT NULL
  1083. <if test="promId != null and promId != ''">
  1084. AND s.prom_id = #{promId}
  1085. </if>
  1086. <if test="startTime != null and startTime != ''">
  1087. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1088. </if>
  1089. <if test="endTime != null and endTime != ''">
  1090. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1091. </if>
  1092. <if test="storeId != null and storeId != ''">
  1093. AND o.store_id = #{storeId}
  1094. </if>
  1095. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1096. AND store.third_party_merch_code = #{thirdPartyMerchCode}
  1097. </if>
  1098. <if test="orderBizType != null and orderBizType != ''">
  1099. AND o.order_biz_type = #{orderBizType}
  1100. </if>
  1101. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1102. AND o.merch_order_sn = #{merchOrderSn}
  1103. </if>
  1104. <if test="merchSn != null and merchSn.trim() != ''">
  1105. AND o.merch_sn = #{merchSn}
  1106. </if>
  1107. <if test="orderSn != null and orderSn.trim() != ''">
  1108. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1109. </if>
  1110. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1111. AND o.shipping_status = #{shippingStatus}
  1112. </if>
  1113. <if test="payStatus != null and payStatus.trim() != ''">
  1114. AND o.pay_status = #{payStatus}
  1115. </if>
  1116. <if test="orderStatus != null and orderStatus.trim() != ''">
  1117. AND o.order_status = #{orderStatus}
  1118. </if>
  1119. <if test="shippingId != null and shippingId != 0">
  1120. AND o.shipping_id = #{shippingId}
  1121. </if>
  1122. <if test="orderType != null and orderType.trim() != ''">
  1123. AND o.order_type = #{orderType}
  1124. </if>
  1125. <if test="isOnfiilineOrder != null">
  1126. AND o.is_onffline_order = #{isOnfiilineOrder}
  1127. </if>
  1128. </select>
  1129. <select id="getActualPriceByOutProm" parameterType="map" resultType="java.lang.Double">
  1130. SELECT
  1131. o.actual_price - ( o.actual_price - g.retail_price * g.number ) promActualPrice
  1132. FROM
  1133. mk_store_prom_order_real r
  1134. LEFT JOIN mall_order o ON r.order_id = o.id
  1135. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1136. AND g.id = r.order_goods_id
  1137. WHERE 1=1
  1138. AND g.goods_id = #{goodsId}
  1139. AND r.order_id = #{orderId}
  1140. <if test="statusList != null">
  1141. AND o.order_status IN
  1142. <foreach item="statusList" collection="statusList" open="(" separator="," close=")">
  1143. #{statusList}
  1144. </foreach>
  1145. </if>
  1146. </select>
  1147. <select id="storeTopicOrderList" resultType="com.kmall.admin.entity.OrderEntity">
  1148. SELECT
  1149. s.title 'storeTopicName',
  1150. pt.prom_type_name 'storeTopicType',
  1151. ss.store_name 'storeName',
  1152. s.id 'storeTopicId',
  1153. o.id,
  1154. o.order_sn,
  1155. o.merch_order_sn,
  1156. o.actual_price,
  1157. o.freight_price,
  1158. o.activity_id,
  1159. o.coupon_id,
  1160. o.coupon_name,
  1161. o.camp_minus_id,
  1162. o.camp_name,
  1163. o.order_status,
  1164. o.pay_status,
  1165. u.userName userName,
  1166. o.order_price,
  1167. o.add_time,
  1168. o.shipping_status
  1169. FROM
  1170. mall_order o
  1171. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1172. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1173. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1174. LEFT JOIN mall_user u ON o.user_id = u.id
  1175. WHERE
  1176. 1=1
  1177. <if test="storeTopicId != null and storeTopicId != ''">
  1178. AND s.id = #{storeTopicId}
  1179. </if>
  1180. <if test="startTime != null and startTime != ''">
  1181. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1182. </if>
  1183. <if test="endTime != null and endTime != ''">
  1184. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1185. </if>
  1186. <if test="storeId != null and storeId != ''">
  1187. AND o.store_id = #{storeId}
  1188. </if>
  1189. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1190. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1191. </if>
  1192. <if test="orderBizType != null and orderBizType != ''">
  1193. AND o.order_biz_type = #{orderBizType}
  1194. </if>
  1195. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1196. AND o.merch_order_sn = #{merchOrderSn}
  1197. </if>
  1198. <if test="merchSn != null and merchSn.trim() != ''">
  1199. AND o.merch_sn = #{merchSn}
  1200. </if>
  1201. <if test="orderSn != null and orderSn.trim() != ''">
  1202. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1203. </if>
  1204. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1205. AND o.shipping_status = #{shippingStatus}
  1206. </if>
  1207. <if test="payStatus != null and payStatus.trim() != ''">
  1208. AND o.pay_status = #{payStatus}
  1209. </if>
  1210. <if test="orderStatus != null and orderStatus.trim() != ''">
  1211. AND o.order_status = #{orderStatus}
  1212. </if>
  1213. <if test="shippingId != null and shippingId != 0">
  1214. AND o.shipping_id = #{shippingId}
  1215. </if>
  1216. <if test="orderType != null and orderType.trim() != ''">
  1217. AND o.order_type = #{orderType}
  1218. </if>
  1219. <if test="isOnfiilineOrder != null">
  1220. AND o.is_onffline_order = #{isOnfiilineOrder}
  1221. </if>
  1222. order by o.id DESC
  1223. <if test="offset != null and limit != null">
  1224. limit #{offset}, #{limit}
  1225. </if>
  1226. </select>
  1227. <select id="queryStoreTopicOrderTotal" resultType="int">
  1228. SELECT
  1229. count(*)
  1230. FROM
  1231. mall_order o
  1232. INNER JOIN mall_store_topic s ON o.activity_id = s.id
  1233. LEFT JOIN mk_store_prom_type pt ON s.prom_type_id = pt.prom_type_id
  1234. LEFT JOIN mall_store ss ON o.store_id = ss.id
  1235. LEFT JOIN mall_user u ON o.user_id = u.id
  1236. WHERE 1=1
  1237. <if test="storeTopicId != null and storeTopicId != ''">
  1238. AND s.id = #{storeTopicId}
  1239. </if>
  1240. <if test="startTime != null and startTime != ''">
  1241. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1242. </if>
  1243. <if test="endTime != null and endTime != ''">
  1244. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1245. </if>
  1246. <if test="storeId != null and storeId != ''">
  1247. AND o.store_id = #{storeId}
  1248. </if>
  1249. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1250. AND ss.third_party_merch_code = #{thirdPartyMerchCode}
  1251. </if>
  1252. <if test="orderBizType != null and orderBizType != ''">
  1253. AND o.order_biz_type = #{orderBizType}
  1254. </if>
  1255. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1256. AND o.merch_order_sn = #{merchOrderSn}
  1257. </if>
  1258. <if test="merchSn != null and merchSn.trim() != ''">
  1259. AND o.merch_sn = #{merchSn}
  1260. </if>
  1261. <if test="orderSn != null and orderSn.trim() != ''">
  1262. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1263. </if>
  1264. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1265. AND o.shipping_status = #{shippingStatus}
  1266. </if>
  1267. <if test="payStatus != null and payStatus.trim() != ''">
  1268. AND o.pay_status = #{payStatus}
  1269. </if>
  1270. <if test="orderStatus != null and orderStatus.trim() != ''">
  1271. AND o.order_status = #{orderStatus}
  1272. </if>
  1273. <if test="shippingId != null and shippingId != 0">
  1274. AND o.shipping_id = #{shippingId}
  1275. </if>
  1276. <if test="orderType != null and orderType.trim() != ''">
  1277. AND o.order_type = #{orderType}
  1278. </if>
  1279. <if test="isOnfiilineOrder != null">
  1280. AND o.is_onffline_order = #{isOnfiilineOrder}
  1281. </if>
  1282. </select>
  1283. <!-- 可根据自己的需求,是否要使用 -->
  1284. <resultMap type="com.kmall.admin.dto.OrderRecognitionDto" id="orderRecognitionMap">
  1285. <result property="id" column="id"/>
  1286. <result property="merchOrderSn" column="merch_order_sn"/>
  1287. <result property="orderSn" column="order_sn"/>
  1288. <result property="userId" column="user_id"/>
  1289. <result property="orderStatus" column="order_status"/>
  1290. <result property="shippingStatus" column="shipping_status"/>
  1291. <result property="payStatus" column="pay_status"/>
  1292. <result property="consignee" column="consignee"/>
  1293. <result property="country" column="country"/>
  1294. <result property="province" column="province"/>
  1295. <result property="city" column="city"/>
  1296. <result property="district" column="district"/>
  1297. <result property="address" column="address"/>
  1298. <result property="mobile" column="mobile"/>
  1299. <result property="postscript" column="postscript"/>
  1300. <result property="shippingId" column="shipping_id"/>
  1301. <result property="shippingName" column="shipping_name"/>
  1302. <result property="shippingCode" column="shipping_code"/>
  1303. <result property="shippingNo" column="shipping_no"/>
  1304. <result property="payId" column="pay_id"/>
  1305. <result property="payName" column="pay_name"/>
  1306. <result property="shippingFee" column="shipping_fee"/>
  1307. <result property="actualPrice" column="actual_price"/>
  1308. <result property="integral" column="integral"/>
  1309. <result property="integralMoney" column="integral_money"/>
  1310. <result property="orderPrice" column="order_price"/>
  1311. <result property="goodsPrice" column="goods_price"/>
  1312. <result property="addTime" column="add_time"/>
  1313. <result property="confirmTime" column="confirm_time"/>
  1314. <result property="payTime" column="pay_time"/>
  1315. <result property="freightPrice" column="freight_price"/>
  1316. <result property="couponId" column="coupon_id"/>
  1317. <result property="couponPrice" column="coupon_price"/>
  1318. <result property="callbackStatus" column="callback_status"/>
  1319. <result property="orderType" column="order_type"/>
  1320. <result property="storeId" column="store_id"/>
  1321. <result property="userName" column="username"/>
  1322. <result property="orderType" column="order_type"/>
  1323. <result property="activityId" column="activity_id"/>
  1324. <result property="deliveryDate" column="delivery_date"/>
  1325. <result property="deliveryRemark" column="delivery_remark"/>
  1326. <result property="predictTime" column="predict_time"/>
  1327. <result property="orderBizType" column="order_biz_type"/>
  1328. <result property="isPaymentSend" column="is_payment_send"/>
  1329. <result property="isEleOrderSend" column="is_ele_order_send"/>
  1330. <result property="isCustomsSend" column="is_customs_send"/>
  1331. <result property="payFlag" column="pay_flag"/>
  1332. <result column="buyer_pay_check" property="buyerPayCheck"/>
  1333. <result property="merchSn" column="merch_sn"/>
  1334. <result property="sku" column="sku"/>
  1335. <result property="createTime" column="create_time"/>
  1336. <result property="modTime" column="mod_time"/>
  1337. <result property="isOnfflineOrder" column="is_onffline_order"/>
  1338. <result property="orderSnWx" column="order_sn_wx"/>
  1339. <result property="isMergePay" column="is_merge_pay"/>
  1340. <result property="payTransactionId" column="pay_transaction_id"/>
  1341. <result property="storeName" column="store_name"/>
  1342. <result property="moderSn" column="moder_sn"/>
  1343. <result property="unitCode" column="unit_code"/>
  1344. <result property="ciqProdModel" column="ciq_prod_model"/>
  1345. <result property="oriCntCode" column="ori_cnt_code"/>
  1346. <result property="brand" column="brand"/>
  1347. <result column="gross_weight" property="grossWeight" />
  1348. <result column="net_weight" property="netWeight" />
  1349. <result property="fullCutPrice" column="full_cut_price"/>
  1350. <result property="campMinusId" column="camp_minus_id"/>
  1351. <result property="campName" column="camp_name"/>
  1352. <result property="isTempNoti" column="is_temp_noti"/>
  1353. <result property="isFaceCheck" column="is_face_check"/>
  1354. <result property="tempNotiMsg" column="temp_noti_msg"/>
  1355. <result property="recognitionReturnMsg" column="recognition_return_msg"/>
  1356. <result property="lastFaceTime" column="last_face_time"/>
  1357. <result property="failCount" column="fail_count"/>
  1358. <result property="checkOperatorType" column="check_operator_type"/>
  1359. <result property="faceLivenessId" column="faceLivenessId"/>
  1360. </resultMap>
  1361. <select id="queryOrderListByRecognition" resultMap="orderRecognitionMap">
  1362. SELECT DISTINCT
  1363. o.order_sn,
  1364. o.merch_order_sn,
  1365. o.order_status,
  1366. o.actual_price,
  1367. o.order_biz_type,
  1368. o.shipping_no,
  1369. o.shipping_name,
  1370. o.shipping_code,
  1371. o.consignee,
  1372. o.mobile,
  1373. o.province,
  1374. o.city,
  1375. o.district,
  1376. o.address,
  1377. o.add_time,
  1378. o.pay_id,
  1379. o.pay_status,
  1380. o.shipping_status,
  1381. o.is_merge_pay,
  1382. o.buyer_pay_check,
  1383. o.order_price,
  1384. o.moder_sn,
  1385. o.id,
  1386. u.username AS username,
  1387. o.user_id,
  1388. p.is_payment_send,
  1389. p.is_ele_order_send,
  1390. p.is_customs_send,
  1391. s.store_name,
  1392. o.full_cut_price,
  1393. o.camp_minus_id,
  1394. o.camp_name,
  1395. fd.is_temp_noti,
  1396. fd.is_face_check,
  1397. fd.temp_noti_msg,
  1398. fd.recognition_return_msg,
  1399. fd.fail_count,
  1400. fd.id 'faceLivenessId',
  1401. fd.check_operator_type,
  1402. u.last_face_time,
  1403. t.is_face_check 'thirdIsFaceCheck'
  1404. FROM
  1405. mall_order o
  1406. LEFT JOIN mall_user u ON o.user_id = u.id
  1407. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1408. left join mall_store s on o.store_id = s.id
  1409. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1410. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1411. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1412. AND r.goods_id = g.goods_id
  1413. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1414. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1415. WHERE 1=1
  1416. <if test="startTime != null and startTime != ''">
  1417. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1418. </if>
  1419. <if test="endTime != null and endTime != ''">
  1420. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1421. </if>
  1422. <if test="storeId != null and storeId != ''">
  1423. AND o.store_id = #{storeId}
  1424. </if>
  1425. <if test="sku != null and sku.trim() != ''">
  1426. AND gs.sku = #{sku}
  1427. </if>
  1428. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1429. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1430. </if>
  1431. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1432. AND t.third_merch_sn = #{thirdMerchSn}
  1433. </if>
  1434. <if test="supplierThirdId != null and supplierThirdId != ''">
  1435. AND r.supplier_third_id = #{supplierThirdId}
  1436. </if>
  1437. <if test="orderBizType != null and orderBizType != ''">
  1438. AND o.order_biz_type = #{orderBizType}
  1439. </if>
  1440. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1441. AND o.merch_order_sn = #{merchOrderSn}
  1442. </if>
  1443. <if test="merchSn != null and merchSn.trim() != ''">
  1444. AND o.merch_sn = #{merchSn}
  1445. </if>
  1446. <if test="orderSn != null and orderSn.trim() != ''">
  1447. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1448. </if>
  1449. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1450. AND o.shipping_status = #{shippingStatus}
  1451. </if>
  1452. <if test="payStatus != null and payStatus.trim() != ''">
  1453. AND o.pay_status = #{payStatus}
  1454. </if>
  1455. <if test="orderStatus != null and orderStatus.trim() != ''">
  1456. AND o.order_status = #{orderStatus}
  1457. </if>
  1458. <if test="shippingId != null and shippingId != 0">
  1459. AND o.shipping_id = #{shippingId}
  1460. </if>
  1461. <if test="orderType != null and orderType.trim() != ''">
  1462. AND o.order_type = #{orderType}
  1463. </if>
  1464. <if test="isOnfiilineOrder != null">
  1465. AND o.is_onffline_order = #{isOnfiilineOrder}
  1466. </if>
  1467. <if test="ids != null and ids.trim() != ''">
  1468. AND o.id in (${ids})
  1469. </if>
  1470. <choose>
  1471. <when test="sidx != null and sidx.trim() != ''">
  1472. order by ${sidx} ${order}
  1473. </when>
  1474. <otherwise>
  1475. order by o.id desc
  1476. </otherwise>
  1477. </choose>
  1478. <if test="offset != null and limit != null">
  1479. limit #{offset}, #{limit}
  1480. </if>
  1481. </select>
  1482. <select id="queryOrderListByRecognitionTotal" resultType="int">
  1483. SELECT count(1)
  1484. FROM
  1485. mall_order o
  1486. LEFT JOIN mall_user u ON o.user_id = u.id
  1487. LEFT JOIN mall_order_process_record p ON o.order_sn = p.order_sn
  1488. left join mall_store s on o.store_id = s.id
  1489. LEFT JOIN third_merchant_biz t ON t.third_party_merch_code = s.third_party_merch_code
  1490. LEFT JOIN mall_order_goods g ON o.id = g.order_id
  1491. LEFT JOIN mall_product_store_rela r ON o.store_id = r.store_id
  1492. AND r.goods_id = g.goods_id
  1493. LEFT JOIN mall_goods gs ON g.goods_id = gs.id
  1494. INNER JOIN face_liveness_recognition_return_data fd on fd.order_sn = o.order_sn and fd.user_id = o.user_id
  1495. WHERE 1=1
  1496. <if test="startTime != null and startTime != ''">
  1497. AND o.add_time <![CDATA[ > ]]> #{startTime}
  1498. </if>
  1499. <if test="endTime != null and endTime != ''">
  1500. AND o.add_time <![CDATA[ < ]]> #{endTime}
  1501. </if>
  1502. <if test="storeId != null and storeId != ''">
  1503. AND o.store_id = #{storeId}
  1504. </if>
  1505. <if test="sku != null and sku.trim() != ''">
  1506. AND gs.sku = #{sku}
  1507. </if>
  1508. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  1509. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  1510. </if>
  1511. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  1512. AND t.third_merch_sn = #{thirdMerchSn}
  1513. </if>
  1514. <if test="supplierThirdId != null and supplierThirdId != ''">
  1515. AND r.supplier_third_id = #{supplierThirdId}
  1516. </if>
  1517. <if test="orderBizType != null and orderBizType != ''">
  1518. AND o.order_biz_type = #{orderBizType}
  1519. </if>
  1520. <if test="merchOrderSn != null and merchOrderSn.trim() != ''">
  1521. AND o.merch_order_sn = #{merchOrderSn}
  1522. </if>
  1523. <if test="merchSn != null and merchSn.trim() != ''">
  1524. AND o.merch_sn = #{merchSn}
  1525. </if>
  1526. <if test="orderSn != null and orderSn.trim() != ''">
  1527. AND o.order_sn LIKE concat('%',#{orderSn},'%')
  1528. </if>
  1529. <if test="shippingStatus != null and shippingStatus.trim() != ''">
  1530. AND o.shipping_status = #{shippingStatus}
  1531. </if>
  1532. <if test="payStatus != null and payStatus.trim() != ''">
  1533. AND o.pay_status = #{payStatus}
  1534. </if>
  1535. <if test="orderStatus != null and orderStatus.trim() != ''">
  1536. AND o.order_status = #{orderStatus}
  1537. </if>
  1538. <if test="shippingId != null and shippingId != 0">
  1539. AND o.shipping_id = #{shippingId}
  1540. </if>
  1541. <if test="orderType != null and orderType.trim() != ''">
  1542. AND o.order_type = #{orderType}
  1543. </if>
  1544. <if test="isOnfiilineOrder != null">
  1545. AND o.is_onffline_order = #{isOnfiilineOrder}
  1546. </if>
  1547. <if test="ids != null and ids.trim() != ''">
  1548. AND o.id in (${ids})
  1549. </if>
  1550. </select>
  1551. <select id="queryOrderByRecogTemp" resultType="com.kmall.admin.dto.SendTempDto">
  1552. SELECT
  1553. o.add_time 'addTime',
  1554. u.weixin_openid 'openId',
  1555. o.merch_order_sn 'merchOrderSn',
  1556. o.id 'orderId',
  1557. o.order_sn 'orderSn'
  1558. FROM
  1559. mall_order o
  1560. INNER JOIN mall_user u ON o.user_id = u.id
  1561. where o.id = #{value}
  1562. </select>
  1563. <select id="queryRealtimeSales" resultType="com.kmall.admin.entity.RealtimeSalesDetection">
  1564. SELECT
  1565. s.id AS storeId,
  1566. o.merch_sn AS merchSn,
  1567. m.merch_name AS merchName,
  1568. count( 0 ) AS guestNumber,
  1569. sum( o.order_price ) AS totalSales,
  1570. sum( o.actual_price ) AS actualSales,
  1571. s.store_name AS storeName,
  1572. max( o.add_time ) AS lastSalesTime ,
  1573. sum( g.cost_price) AS totalCost
  1574. FROM
  1575. mall_order o
  1576. LEFT JOIN mall_store s ON o.store_id = s.id
  1577. LEFT JOIN mall_merch m ON o.merch_sn = m.merch_sn
  1578. LEFT JOIN mall_order_goods og ON o.id = og.order_id
  1579. LEFT JOIN mall_goods g ON og.goods_id = g.id
  1580. LEFT JOIN mall_product_store_rela sr ON sr.goods_id = g.id
  1581. LEFT JOIN mall_category c ON sr.category_id = c.id
  1582. WHERE
  1583. 1 = 1
  1584. <if test="storeId != null and storeId.trim() != ''">
  1585. and o.store_id=#{storeId}
  1586. </if>
  1587. <if test="merchSn != null and merchSn.trim() != ''">
  1588. and o.merch_sn=#{merchSn}
  1589. </if>
  1590. <choose>
  1591. <when test="compareDate != null and compareDate != ''">
  1592. and ( datediff ( o.add_time , #{compareDate} ) = 0 )
  1593. </when>
  1594. <when test="salesDate != null and salesDate != ''">
  1595. and ( datediff ( o.add_time , #{salesDate} ) = 0 )
  1596. </when >
  1597. <otherwise></otherwise>
  1598. </choose>
  1599. <if test="categoryId != null and categoryId != ''">
  1600. AND (c.parent_id = #{categoryId} or c.id = #{categoryId})
  1601. </if>
  1602. </select>
  1603. </mapper>