SupplyChainMapper.xml 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruixuan.isc.mapper.SupplyChainMapper">
  6. <insert id="bindUser">
  7. insert into kuaishou_item_bind_user(item_id, user_id, user_name)
  8. value
  9. (#{itemId},#{userId},#{nikeName})
  10. </insert>
  11. <delete id="unbindUser" parameterType="java.lang.Long">
  12. delete
  13. from kuaishou_item_bind_user
  14. where item_id = #{itemId}
  15. </delete>
  16. <select id="getOrderList" resultType="com.alibaba.fastjson.JSONObject">
  17. select *
  18. from (
  19. select promoter_id as 'promoterId',
  20. promoter_nick_name as 'promoterNickName',
  21. count(oid) as 'orderNum',
  22. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  23. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  24. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  25. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  26. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  27. then 1 else 0 end),4) as 'deliveryRadio'
  28. from kuaishou_supply_chain
  29. where 1= 1
  30. <if test="start != null and start != ''">
  31. and order_create_time &gt;= #{start}
  32. </if>
  33. <if test="end != null and end != ''">
  34. and order_create_time &lt;= #{end}
  35. </if>
  36. <if test="promoterId != null and promoterId != ''">
  37. and promoter_id = #{promoterId}
  38. </if>
  39. <if test="promoterNickName != null and promoterNickName != ''">
  40. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  41. </if>
  42. group by promoter_id) t
  43. order by t.orderNum desc
  44. </select>
  45. <select id="getTopOrders" resultType="com.alibaba.fastjson.JSONObject">
  46. select *
  47. from
  48. (select item_id as 'itemId',
  49. item_title as 'itemTitle',
  50. image_url as 'imageUrl',
  51. count(oid) as 'orderNum'
  52. from kuaishou_supply_chain
  53. where promoter_id = #{promoterId}
  54. <if test="start != null and start != ''">
  55. and order_create_time &gt;= #{start}
  56. </if>
  57. <if test="end != null and end != ''">
  58. and order_create_time &lt;= #{end}
  59. </if>
  60. group by item_id) t
  61. order by t.orderNum desc limit 3
  62. </select>
  63. <select id="anchorOrderDetail" resultType="com.alibaba.fastjson.JSONObject">
  64. select *
  65. from (select
  66. item_title as 'itemTitle',
  67. item_id as 'itemId',
  68. reserve_price as 'reservePrice',
  69. image_url 'imageUrl',
  70. count(oid) as 'orderNum',
  71. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  72. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  73. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  74. regimental_promotion_rate as 'regimentalPromotionRate',
  75. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  76. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  77. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  78. then 1 else 0 end),4) as 'deliveryRadio'
  79. from kuaishou_supply_chain
  80. where 1= 1
  81. <if test="promoterId != null and promoterId != ''">
  82. and promoter_id = #{promoterId}
  83. </if>
  84. <if test="start != null and start != ''">
  85. and order_create_time &gt;= #{start}
  86. </if>
  87. <if test="end != null and end != ''">
  88. and order_create_time &lt;= #{end}
  89. </if>
  90. <if test="itemId != null and itemId != ''">
  91. and item_id = #{itemId}
  92. </if>
  93. <if test="itemTitle != null and itemTitle != ''">
  94. and item_title like concat(concat('%',#{itemTitle}),'%')
  95. </if>
  96. group by item_id) t
  97. order by t.orderNum desc
  98. </select>
  99. <select id="orderStatistics" resultType="com.alibaba.fastjson.JSONObject">
  100. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  101. count(t.oid) as 'orderNum'
  102. from (select oid,
  103. order_create_time
  104. from kuaishou_supply_chain
  105. where 1 = 1
  106. <if test="promoterId != null and promoterId != ''">
  107. and promoter_id = #{promoterId}
  108. </if>
  109. <if test="start != null and start != ''">
  110. and order_create_time &gt;= #{start}
  111. </if>
  112. <if test="end != null and end != ''">
  113. and order_create_time &lt;= #{end}
  114. </if>
  115. ) t
  116. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  117. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  118. </select>
  119. <select id="itemList" resultType="com.alibaba.fastjson.JSONObject">
  120. select *
  121. from (select t2.user_id as 'userId',
  122. t2.user_name as 'userName',
  123. t1.item_id as 'itemId',
  124. t1.reserve_price as 'reservePrice',
  125. t1.item_title as 'itemTitle',
  126. t1.image_url as 'imageUrl',
  127. count(t1.oid) as 'orderNum',
  128. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  129. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
  130. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  131. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  132. round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
  133. t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
  134. t1.item_commission_rate as 'itemCommissionRate'
  135. from kuaishou_supply_chain t1
  136. left join kuaishou_item_bind_user t2
  137. on t1.item_id = t2.item_id
  138. where 1 = 1
  139. <if test="start != null and start != ''">
  140. and t1.order_create_time &gt;= #{start}
  141. </if>
  142. <if test="end != null and end != ''">
  143. and t1.order_create_time &lt;= #{end}
  144. </if>
  145. <if test="itemId != null and itemId != ''">
  146. and t1.item_id = #{itemId}
  147. </if>
  148. <if test="itemTitle != null and itemTitle != ''">
  149. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  150. </if>
  151. group by t1.item_id) t
  152. where 1 = 1
  153. <if test="userId != null and userId != ''">
  154. and t.userId = #{userId}
  155. </if>
  156. order by ${fieId} ${sort}
  157. </select>
  158. <select id="getTopPromoterByItemId" resultType="com.alibaba.fastjson.JSONObject">
  159. select
  160. *
  161. from
  162. (select promoter_id as 'promoterId',
  163. promoter_nick_name as 'promoterNickName',
  164. count(oid) as 'orderNum'
  165. from kuaishou_supply_chain
  166. where item_id = #{itemId}
  167. <if test="start != null and start != ''">
  168. and order_create_time &gt;= #{start}
  169. </if>
  170. <if test="end != null and end != ''">
  171. and order_create_time &lt;= #{end}
  172. </if>
  173. group by promoter_id) t
  174. order by t.orderNum desc limit 3
  175. </select>
  176. <select id="itemDetail" resultType="com.alibaba.fastjson.JSONObject">
  177. select *
  178. from (
  179. select
  180. promoter_nick_name as 'promoterNickName',
  181. promoter_id as 'promoterId',
  182. count(oid) as 'orderNum',
  183. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  184. regimental_promotion_rate as 'regimentalPromotionRate',
  185. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  186. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  187. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  188. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  189. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  190. then 1 else 0 end),4) as 'deliveryRadio'
  191. from kuaishou_supply_chain
  192. where 1= 1
  193. <if test="itemId != null and itemId != ''">
  194. and item_id = #{itemId}
  195. </if>
  196. <if test="start != null and start != ''">
  197. and order_create_time &gt;= #{start}
  198. </if>
  199. <if test="end != null and end != ''">
  200. and order_create_time &lt;= #{end}
  201. </if>
  202. <if test="promoterId != null and promoterId != ''">
  203. and promoter_id = #{promoterId}
  204. </if>
  205. <if test="promoterNickName != null and promoterNickName != ''">
  206. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  207. </if>
  208. group by promoter_id) t
  209. order by t.orderNum desc
  210. </select>
  211. <select id="itemServiceCharge" resultType="com.alibaba.fastjson.JSONObject">
  212. select *
  213. from (
  214. select
  215. item_id as 'itemId',
  216. item_title as 'itemTitle',
  217. image_url as 'imageUrl',
  218. count(oid) as 'orderNum',
  219. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  220. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  221. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  222. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  223. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  224. then 1 else 0 end),4) as 'deliveryRadio',
  225. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  226. regimental_promotion_rate as 'regimentalPromotionRate',
  227. sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
  228. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  229. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  230. 'totalRegimentalSettleAmount',
  231. item_commission_rate as 'itemCommissionRate'
  232. from kuaishou_supply_chain
  233. where 1= 1
  234. <if test="start != null and start != ''">
  235. and order_create_time &gt;= #{start}
  236. </if>
  237. <if test="end != null and end != ''">
  238. and order_create_time &lt;= #{end}
  239. </if>
  240. <if test="itemId != null and itemId != ''">
  241. and item_id = #{itemId}
  242. </if>
  243. <if test="itemTitle != null and itemTitle != ''">
  244. and item_title like concat(concat('%',#{itemTitle}),'%')
  245. </if>
  246. group by item_id) t
  247. order by t.orderNum desc
  248. </select>
  249. <select id="getOrderTotal" resultType="com.alibaba.fastjson.JSONObject">
  250. select
  251. count(oid) as 'orderNum',
  252. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  253. sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
  254. from kuaishou_supply_chain
  255. where 1= 1
  256. <if test="start != null and start != ''">
  257. and order_create_time &gt;= #{start}
  258. </if>
  259. <if test="end != null and end != ''">
  260. and order_create_time &lt;= #{end}
  261. </if>
  262. </select>
  263. <select id="getOrderTotalRatio" resultType="java.lang.Double">
  264. select
  265. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
  266. from (select count(oid) as 'oid'
  267. from kuaishou_supply_chain
  268. where 1= 1
  269. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  270. and order_create_time &gt;= #{nowStartHourTemp}
  271. </if>
  272. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  273. and order_create_time &lt;= #{nowEndHourTemp}
  274. </if>
  275. ) t1
  276. join (select count(oid) as 'oid'
  277. from kuaishou_supply_chain
  278. where 1=1
  279. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  280. and order_create_time &gt;= #{yesterdayStartHourTemp}
  281. </if>
  282. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  283. and order_create_time &lt;= #{yesterdayEndHourTemp}
  284. </if>
  285. ) t2
  286. </select>
  287. <select id="getAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  288. select
  289. sum(order_amount) as 'orderAmount',
  290. sum(base_amount) as 'baseAmount',
  291. sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
  292. sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
  293. 'totalRegimentalSettleAmount'
  294. from kuaishou_supply_chain
  295. where 1= 1
  296. <if test="start != null and start != ''">
  297. and order_create_time &gt;= #{start}
  298. </if>
  299. <if test="end != null and end != ''">
  300. and order_create_time &lt;= #{end}
  301. </if>
  302. </select>
  303. <select id="getAmountTotalRatio" resultType="java.lang.Double">
  304. select
  305. round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
  306. from (select sum(pay_amount) as 'payAmount'
  307. from kuaishou_supply_chain
  308. where 1= 1
  309. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  310. and order_create_time &gt;= #{nowStartHourTemp}
  311. </if>
  312. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  313. and order_create_time &lt;= #{nowEndHourTemp}
  314. </if>
  315. ) t1
  316. join (select sum(pay_amount) as 'payAmount'
  317. from kuaishou_supply_chain
  318. where 1=1
  319. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  320. and order_create_time &gt;= #{yesterdayStartHourTemp}
  321. </if>
  322. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  323. and order_create_time &lt;= #{yesterdayEndHourTemp}
  324. </if>
  325. ) t2
  326. </select>
  327. <select id="getServiceAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  328. select
  329. count(distinct promoter_id) as 'promoterNum',
  330. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  331. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  332. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  333. as 'deliveryRadio'
  334. from kuaishou_supply_chain
  335. where 1= 1
  336. <if test="start != null and start != ''">
  337. and order_create_time &gt;= #{start}
  338. </if>
  339. <if test="end != null and end != ''">
  340. and order_create_time &lt;= #{end}
  341. </if>
  342. </select>
  343. <select id="getOrderRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  344. select
  345. t1.*,
  346. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  347. from (select
  348. item_id as 'itemId',
  349. item_title as 'itemTitle',
  350. image_url as 'imageUrl',
  351. count(oid) as 'orderNum',
  352. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  353. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  354. sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
  355. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  356. round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
  357. as 'deliveryRadio'
  358. from kuaishou_supply_chain
  359. where 1= 1
  360. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  361. and order_create_time &gt;= #{nowStartHourTemp}
  362. </if>
  363. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  364. and order_create_time &lt;= #{nowEndHourTemp}
  365. </if>
  366. group by item_id
  367. ) t1
  368. left join (select
  369. item_id as 'itemId',
  370. count(oid) as 'orderNum'
  371. from kuaishou_supply_chain
  372. where 1=1
  373. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  374. and order_create_time &gt;= #{yesterdayStartHourTemp}
  375. </if>
  376. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  377. and order_create_time &lt;= #{yesterdayEndHourTemp}
  378. </if>
  379. group by item_id
  380. ) t2 on t1.itemId = t2.itemId
  381. order by t1.orderNum desc
  382. </select>
  383. <select id="getOrderRankList" resultType="com.alibaba.fastjson.JSONObject">
  384. select * from (
  385. select
  386. item_id as 'itemId',
  387. item_title as 'itemTitle',
  388. image_url as 'imageUrl',
  389. count(oid) as 'orderNum',
  390. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  391. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
  392. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  393. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  394. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  395. then 1 else 0 end),4) as 'deliveryRadio'
  396. from kuaishou_supply_chain
  397. where 1= 1
  398. <if test="start != null and start != ''">
  399. and order_create_time &gt;= #{start}
  400. </if>
  401. <if test="end != null and end != ''">
  402. and order_create_time &lt;= #{end}
  403. </if>
  404. group by item_id) t
  405. order by t.orderNum desc
  406. </select>
  407. <select id="getPromoterRankRatioList" resultType="com.alibaba.fastjson.JSONObject">
  408. select
  409. t1.*,
  410. round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
  411. from (
  412. select
  413. promoter_id as 'promoterId',
  414. promoter_nick_name as 'promoterNickName',
  415. count(oid) as 'orderNum',
  416. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  417. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  418. from kuaishou_supply_chain
  419. where 1= 1
  420. <if test='promoterIds != null and promoterIds.size() > 0'>
  421. AND promoter_id IN
  422. <foreach collection="promoterIds" item="item" separator=","
  423. open="(" close=")">
  424. #{item}
  425. </foreach>
  426. </if>
  427. <if test="nowStartHourTemp != null and nowStartHourTemp != ''">
  428. and order_create_time &gt;= #{nowStartHourTemp}
  429. </if>
  430. <if test="nowEndHourTemp != null and nowEndHourTemp != ''">
  431. and order_create_time &lt;= #{nowEndHourTemp}
  432. </if>
  433. group by promoter_id
  434. ) t1
  435. left join (select
  436. promoter_id as 'promoterId',
  437. count(oid) as 'orderNum'
  438. from kuaishou_supply_chain
  439. where 1=1
  440. <if test='promoterIds != null and promoterIds.size() > 0'>
  441. AND promoter_id IN
  442. <foreach collection="promoterIds" item="item" separator=","
  443. open="(" close=")">
  444. #{item}
  445. </foreach>
  446. </if>
  447. <if test="yesterdayStartHourTemp != null and yesterdayStartHourTemp != ''">
  448. and order_create_time &gt;= #{yesterdayStartHourTemp}
  449. </if>
  450. <if test="yesterdayEndHourTemp != null and yesterdayEndHourTemp != ''">
  451. and order_create_time &lt;= #{yesterdayEndHourTemp}
  452. </if>
  453. group by promoter_id
  454. ) t2 on t1.promoterId = t2.promoterId
  455. order by t1.orderNum desc
  456. </select>
  457. <select id="getPromoterRatioList" resultType="com.alibaba.fastjson.JSONObject">
  458. select * from (
  459. select
  460. promoter_id as 'promoterId',
  461. promoter_nick_name as 'promoterNickName',
  462. count(oid) as 'orderNum',
  463. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  464. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
  465. from kuaishou_supply_chain
  466. where 1= 1
  467. <if test="start != null and start != ''">
  468. and order_create_time &gt;= #{start}
  469. </if>
  470. <if test="end != null and end != ''">
  471. and order_create_time &lt;= #{end}
  472. </if>
  473. group by promoter_id) t
  474. order by t.orderNum desc
  475. </select>
  476. <select id="exportPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  477. select *
  478. from (
  479. select
  480. promoter_id as 'promoterId',
  481. promoter_nick_name as 'promoterNickName',
  482. count(oid) as 'orderNum',
  483. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  484. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  485. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  486. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  487. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  488. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  489. from kuaishou_supply_chain
  490. where 1= 1
  491. <if test="start != null and start != ''">
  492. and order_create_time &gt;= #{start}
  493. </if>
  494. <if test="end != null and end != ''">
  495. and order_create_time &lt;= #{end}
  496. </if>
  497. <if test="promoterId != null and promoterId != ''">
  498. and promoter_id = #{promoterId}
  499. </if>
  500. <if test="promoterNickName != null and promoterNickName != ''">
  501. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  502. </if>
  503. <if test="itemId != null and itemId != ''">
  504. and item_id = #{itemId}
  505. </if>
  506. <if test="itemTitle != null and itemTitle != ''">
  507. and item_title like concat(concat('%',#{itemTitle}),'%')
  508. </if>
  509. group by promoter_id) t
  510. order by t.orderNum desc
  511. </select>
  512. <select id="exportPromoter" resultType="com.alibaba.fastjson.JSONObject">
  513. select *
  514. from (
  515. select
  516. promoter_id as 'promoterId',
  517. promoter_nick_name as 'promoterNickName',
  518. item_id as 'itemId',
  519. item_title as 'itemTitle',
  520. image_url as 'imageUrl',
  521. count(oid) as 'orderNum',
  522. sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  523. round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
  524. sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
  525. sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  526. round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
  527. then 1 else 0 end) * 100,2) as 'deliveryRadio'
  528. from kuaishou_supply_chain
  529. where 1= 1
  530. <if test="start != null and start != ''">
  531. and order_create_time &gt;= #{start}
  532. </if>
  533. <if test="end != null and end != ''">
  534. and order_create_time &lt;= #{end}
  535. </if>
  536. <if test="promoterId != null and promoterId != ''">
  537. and promoter_id = #{promoterId}
  538. </if>
  539. <if test="promoterNickName != null and promoterNickName != ''">
  540. and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  541. </if>
  542. <if test="itemId != null and itemId != ''">
  543. and item_id = #{itemId}
  544. </if>
  545. <if test="itemTitle != null and itemTitle != ''">
  546. and item_title like concat(concat('%',#{itemTitle}),'%')
  547. </if>
  548. group by promoter_id,item_id) t
  549. order by t.promoterId,t.orderNum desc
  550. </select>
  551. <select id="exportOrder" resultType="com.alibaba.fastjson.JSONObject">
  552. select *
  553. from (select
  554. t2.user_id as 'userId',
  555. t2.user_name as 'userName',
  556. t1.item_id as 'itemId',
  557. t1.item_title as 'itemTitle',
  558. t1.image_url as 'imageUrl',
  559. count(t1.oid) as 'orderNum',
  560. sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  561. round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
  562. sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  563. sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  564. round(sum(case when t1.send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
  565. != 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
  566. round(t1.item_commission_rate / 10,2) as 'itemCommissionRate'
  567. from kuaishou_supply_chain t1
  568. left join kuaishou_item_bind_user t2
  569. on t1.item_id = t2.item_id
  570. where 1 = 1
  571. <if test="start != null and start != ''">
  572. and t1.order_create_time &gt;= #{start}
  573. </if>
  574. <if test="end != null and end != ''">
  575. and t1.order_create_time &lt;= #{end}
  576. </if>
  577. <if test="promoterId != null and promoterId != ''">
  578. and t1.promoter_id = #{promoterId}
  579. </if>
  580. <if test="promoterNickName != null and promoterNickName != ''">
  581. and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
  582. </if>
  583. <if test="itemId != null and itemId != ''">
  584. and t1.item_id = #{itemId}
  585. </if>
  586. <if test="itemTitle != null and itemTitle != ''">
  587. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  588. </if>
  589. group by t1.item_id) t
  590. where 1 = 1
  591. <if test="userId != null and userId != ''">
  592. and t.userId = #{userId}
  593. </if>
  594. order by t.orderNum desc
  595. </select>
  596. <select id="bindUserItemList" resultType="com.alibaba.fastjson.JSONObject">
  597. select *
  598. from (select t1.item_id as 'itemId',
  599. t1.item_title as 'itemTitle',
  600. t1.reserve_price as 'reservePrice',
  601. t1.image_url as 'imageUrl',
  602. t1.activity_id as 'activityId',
  603. t1.regimental_promotion_rate as 'regimentalPromotionRate',
  604. t2.user_id as 'userId',
  605. case when t2.user_id is null then 1 else 2 end as 'status',
  606. t2.user_name as 'userName',
  607. t2.create_time as 'bindTime',
  608. t1.item_commission_rate as 'itemCommissionRate'
  609. from kuaishou_item_info t1
  610. left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
  611. where 1 = 1
  612. <if test="userId != null and userId != ''">
  613. and t2.user_id = #{userId}
  614. </if>
  615. <if test="itemId != null and itemId != ''">
  616. and t1.item_id = #{itemId}
  617. </if>
  618. <if test="itemTitle != null and itemTitle != ''">
  619. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  620. </if>
  621. <if test="activityId != null and activityId != ''">
  622. and t1.activity_id = #{activityId}
  623. </if>
  624. order by t1.create_time desc) t
  625. where 1 = 1
  626. <if test="status != null and status != ''">
  627. and t.status = #{status}
  628. </if>
  629. </select>
  630. <select id="getSupplyChainUserList" resultType="com.alibaba.fastjson.JSONObject">
  631. select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
  632. from sys_role t1
  633. left join sys_user_role t2 on t1.role_id = t2.role_id
  634. left join sys_user t3 on t2.user_id = t3.user_id
  635. where t1.role_key in (
  636. 'supplyChainAdmin',
  637. 'associationManager',
  638. 'bd',
  639. 'bdManager',
  640. 'association',
  641. 'courtshipManager',
  642. 'courtship'
  643. )
  644. group by t3.user_id
  645. order by t3.create_time asc
  646. </select>
  647. <select id="adminReportList" resultType="com.alibaba.fastjson.JSONObject">
  648. select *
  649. from (select t1.user_id as 'userId',
  650. t1.user_name as 'userName',
  651. count(distinct t2.item_id) as 'itemCount',
  652. count(t2.oid) as 'orderNum',
  653. sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
  654. round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
  655. sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
  656. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  657. round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
  658. when t2.order_status != 80
  659. then 1
  660. else 0 end),
  661. 4) as 'deliveryRadio',
  662. sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
  663. sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
  664. sum(case
  665. when t2.order_status != 80 then t2.regimental_promotion_amount
  666. else 0 end) as 'regimentalPromotionAmount',
  667. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  668. 'totalRegimentalSettleAmount'
  669. from kuaishou_item_bind_user t1
  670. left join kuaishou_supply_chain t2
  671. on t1.item_id = t2.item_id
  672. where 1= 1
  673. <if test="start != null and start != ''">
  674. and t2.order_create_time &gt;= #{start}
  675. </if>
  676. <if test="end != null and end != ''">
  677. and t2.order_create_time &lt;= #{end}
  678. </if>
  679. group by t1.user_id) t
  680. where 1 =1
  681. <if test="userId != null and userId != ''">
  682. and t.userId = #{userId}
  683. </if>
  684. order by t.orderNum desc
  685. </select>
  686. <select id="userItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  687. SELECT
  688. *
  689. FROM
  690. (
  691. SELECT
  692. t1.user_id,
  693. t1.user_name AS 'userName',
  694. t2.item_id AS 'itemId',
  695. t2.item_title AS 'itemTitle',
  696. t2.image_url AS 'imageUrl',
  697. t2.reserve_price AS 'reservePrice',
  698. count(t2.oid) AS 'orderNum',
  699. sum(
  700. CASE
  701. WHEN t2.order_status != 80 THEN 1
  702. ELSE 0
  703. END
  704. ) AS 'validOrderNUm',
  705. round(
  706. sum(
  707. CASE
  708. WHEN t2.order_status != 80 THEN 1
  709. ELSE 0
  710. END
  711. ) / count(t2.oid),
  712. 4
  713. ) AS 'validRadio',
  714. sum(
  715. CASE
  716. WHEN t2.send_status = 1
  717. AND t2.order_status != 80 THEN 1
  718. ELSE 0
  719. END
  720. ) AS 'deliveryNum',
  721. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  722. round(
  723. sum(
  724. CASE
  725. WHEN t2.send_status = 1
  726. AND t2.order_status != 80 THEN 1
  727. ELSE 0
  728. END
  729. ) / sum(
  730. CASE
  731. WHEN t2.order_status != 80 THEN 1
  732. ELSE 0
  733. END
  734. ),
  735. 4
  736. ) AS 'deliveryRadio',
  737. sum(
  738. CASE
  739. WHEN t2.order_status = 80 THEN 1
  740. ELSE 0
  741. END
  742. ) AS 'invalidOrderNUm',
  743. sum(
  744. CASE
  745. WHEN t2.order_status != 80 THEN t2.pay_amount
  746. ELSE 0
  747. END
  748. ) AS 'payAmount',
  749. t2.regimental_promotion_rate AS 'regimentalPromotionRate',
  750. sum(
  751. CASE
  752. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  753. ELSE 0
  754. END
  755. ) AS 'regimentalPromotionAmount',
  756. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  757. 'totalRegimentalSettleAmount',
  758. t2.item_commission_rate as 'itemCommissionRate'
  759. FROM
  760. kuaishou_item_bind_user t1
  761. LEFT JOIN
  762. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  763. WHERE
  764. 1 = 1
  765. <if test="start != null and start != ''">
  766. and t2.order_create_time &gt;= #{start}
  767. </if>
  768. <if test="end != null and end != ''">
  769. and t2.order_create_time &lt;= #{end}
  770. </if>
  771. <if test="itemId != null and itemId != ''">
  772. and t1.item_id = #{itemId}
  773. </if>
  774. <if test="itemTitle != null and itemTitle != ''">
  775. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  776. </if>
  777. GROUP BY
  778. t1.item_id
  779. ) t
  780. where 1 = 1
  781. <if test="userId != null and userId != ''">
  782. and t.user_id = #{userId}
  783. </if>
  784. order by ${fieId} ${sort}
  785. </select>
  786. <select id="getTimeIntervalRatio" resultType="com.alibaba.fastjson.JSONObject">
  787. select
  788. round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
  789. round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
  790. from (
  791. select count(oid) as 'oid',
  792. sum(order_amount) as 'orderAmount'
  793. from kuaishou_supply_chain
  794. where 1= 1
  795. <if test="thisCycleStartTemp != null and thisCycleStartTemp != ''">
  796. and order_create_time &gt;= #{thisCycleStartTemp}
  797. </if>
  798. <if test="thisCycleEndTemp != null and thisCycleEndTemp != ''">
  799. and order_create_time &lt;= #{thisCycleEndTemp}
  800. </if>
  801. ) t1
  802. join (
  803. select count(oid) as 'oid',
  804. sum(order_amount) as 'orderAmount'
  805. from kuaishou_supply_chain
  806. where 1=1
  807. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  808. and order_create_time &gt;= #{lastCycleStartTemp}
  809. </if>
  810. <if test="lastCycleStartTemp != null and lastCycleStartTemp != ''">
  811. and order_create_time &lt;= #{lastCycleEndTemp}
  812. </if>
  813. ) t2
  814. </select>
  815. <select id="indexStatistics" resultType="com.alibaba.fastjson.JSONObject">
  816. select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
  817. <if test="type == 'orderNum' ">
  818. count(t.oid) as 'orderNum'
  819. </if>
  820. <if test="type == 'validOrderNum' ">
  821. sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
  822. </if>
  823. <if test="type == 'orderAmount' ">
  824. sum(t.order_amount) as 'orderAmount'
  825. </if>
  826. <if test="type == 'baseAmount' ">
  827. sum(t.base_amount) as 'baseAmount'
  828. </if>
  829. <if test="type == 'deliveryNum' ">
  830. sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
  831. </if>
  832. from (select
  833. oid,
  834. order_status,
  835. order_amount,
  836. base_amount,
  837. send_status,
  838. order_create_time
  839. from kuaishou_supply_chain
  840. where 1 = 1
  841. <if test="startTemp != null and startTemp != ''">
  842. and order_create_time &gt;= #{startTemp}
  843. </if>
  844. <if test="endTemp != null and endTemp != ''">
  845. and order_create_time &lt;= #{endTemp}
  846. </if>
  847. ) t
  848. group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
  849. order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
  850. </select>
  851. <select id="itemBindSummary" resultType="com.alibaba.fastjson.JSONObject">
  852. select count(t1.item_id) as 'itemTotal', sum(case when t2.item_id is not null then 1 else 0 end) as 'claimCount', sum(case when t2.item_id is null then 1 else 0 end) as 'unClaimCount'
  853. from kuaishou_item_info t1
  854. left join kuaishou_item_bind_user t2
  855. on t1.item_id = t2.item_id
  856. where 1 = 1
  857. </select>
  858. <select id="userItemTotal" resultType="com.alibaba.fastjson.JSONObject">
  859. SELECT count(t2.oid) AS 'orderNum',
  860. sum(
  861. CASE
  862. WHEN t2.order_status != 80 THEN 1
  863. ELSE 0
  864. END
  865. ) AS 'validOrderNUm',
  866. round(
  867. sum(
  868. CASE
  869. WHEN t2.order_status != 80 THEN 1
  870. ELSE 0
  871. END
  872. ) / count(t2.oid),
  873. 4
  874. ) AS 'validRadio',
  875. sum(
  876. CASE
  877. WHEN t2.send_status = 1
  878. AND t2.order_status != 80 THEN 1
  879. ELSE 0
  880. END
  881. ) AS 'deliveryNum',
  882. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  883. round(
  884. sum(
  885. CASE
  886. WHEN t2.send_status = 1
  887. AND t2.order_status != 80 THEN 1
  888. ELSE 0
  889. END
  890. ) / sum(
  891. CASE
  892. WHEN t2.order_status != 80 THEN 1
  893. ELSE 0
  894. END
  895. ),
  896. 4
  897. ) AS 'deliveryRadio',
  898. sum(
  899. CASE
  900. WHEN t2.order_status = 80 THEN 1
  901. ELSE 0
  902. END
  903. ) AS 'invalidOrderNUm',
  904. sum(
  905. CASE
  906. WHEN t2.order_status != 80 THEN t2.pay_amount
  907. ELSE 0
  908. END
  909. ) AS 'payAmount',
  910. sum(
  911. CASE
  912. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  913. ELSE 0
  914. END
  915. ) AS 'regimentalPromotionAmount',
  916. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
  917. 'totalRegimentalSettleAmount'
  918. FROM kuaishou_item_bind_user t1
  919. LEFT JOIN
  920. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  921. WHERE 1 = 1
  922. <if test="start != null and start != ''">
  923. and t2.order_create_time &gt;= #{start}
  924. </if>
  925. <if test="end != null and end != ''">
  926. and t2.order_create_time &lt;= #{end}
  927. </if>
  928. <if test="userId != null and userId != ''">
  929. and t1.user_id = #{userId}
  930. </if>
  931. </select>
  932. <select id="exportUserItemDetail" resultType="com.alibaba.fastjson.JSONObject">
  933. SELECT
  934. *
  935. FROM
  936. (
  937. SELECT
  938. t1.user_id as 'user_id',
  939. t1.user_name AS 'userName',
  940. t2.item_id AS 'itemId',
  941. t2.item_title AS 'itemTitle',
  942. t2.image_url AS 'imageUrl',
  943. round(t2.reserve_price / 100,2) AS 'reservePrice',
  944. count(t2.oid) AS 'orderNum',
  945. sum(
  946. CASE
  947. WHEN t2.order_status != 80 THEN 1
  948. ELSE 0
  949. END
  950. ) AS 'validOrderNUm',
  951. round(
  952. sum(
  953. CASE
  954. WHEN t2.order_status != 80 THEN 1
  955. ELSE 0
  956. END
  957. ) / count(t2.oid) * 100,
  958. 2
  959. ) AS 'validRadio',
  960. sum(
  961. CASE
  962. WHEN t2.send_status = 1
  963. AND t2.order_status != 80 THEN 1
  964. ELSE 0
  965. END
  966. ) AS 'deliveryNum',
  967. sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
  968. round(
  969. sum(
  970. CASE
  971. WHEN t2.send_status = 1
  972. AND t2.order_status != 80 THEN 1
  973. ELSE 0
  974. END
  975. ) / sum(
  976. CASE
  977. WHEN t2.order_status != 80 THEN 1
  978. ELSE 0
  979. END
  980. ) * 100,
  981. 2
  982. ) AS 'deliveryRadio',
  983. sum(
  984. CASE
  985. WHEN t2.order_status = 80 THEN 1
  986. ELSE 0
  987. END
  988. ) AS 'invalidOrderNUm',
  989. round( sum(
  990. CASE
  991. WHEN t2.order_status != 80 THEN t2.pay_amount
  992. ELSE 0
  993. END
  994. )/ 100,2 )AS 'payAmount',
  995. concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
  996. round(
  997. sum(
  998. CASE
  999. WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
  1000. ELSE 0
  1001. END
  1002. ) / 100 , 2)AS 'regimentalPromotionAmount',
  1003. round(
  1004. sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
  1005. 'totalRegimentalSettleAmount',
  1006. concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate'
  1007. FROM
  1008. kuaishou_item_bind_user t1
  1009. LEFT JOIN
  1010. kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
  1011. WHERE
  1012. 1 = 1
  1013. <if test="start != null and start != ''">
  1014. and t2.order_create_time &gt;= #{start}
  1015. </if>
  1016. <if test="end != null and end != ''">
  1017. and t2.order_create_time &lt;= #{end}
  1018. </if>
  1019. <if test="itemId != null and itemId != ''">
  1020. and t1.item_id = #{itemId}
  1021. </if>
  1022. <if test="itemTitle != null and itemTitle != ''">
  1023. and t1.item_title like concat(concat('%',#{itemTitle}),'%')
  1024. </if>
  1025. GROUP BY
  1026. t1.item_id
  1027. ) t
  1028. where 1 = 1
  1029. <if test="userId != null and userId != ''">
  1030. and t.user_id = #{userId}
  1031. </if>
  1032. order by t.orderNum desc
  1033. </select>
  1034. <select id="getCookie" resultType="java.lang.String">
  1035. select cookie
  1036. from ruixuan.kuaishou_supply_chain_cookie limit 1
  1037. </select>
  1038. <select id="selectOrderInfo" resultType="com.alibaba.fastjson.JSONObject">
  1039. SELECT COUNT(oid) as 'allNumber', IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
  1040. 'validOrderNUm', IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
  1041. IFNULL(
  1042. SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
  1043. 0) AS 'regimentalPromotionAmount', IFNULL(sum(base_amount), 0) as 'baseAmount'
  1044. FROM kuaishou_supply_chain
  1045. WHERE stat_date >= #{startDate}
  1046. AND stat_date &lt;= #{endDate}
  1047. <if test='promoterIds != null and promoterIds.size() > 0'>
  1048. AND promoter_id in
  1049. <foreach collection="promoterIds" item="item" separator=","
  1050. open="(" close=")">
  1051. #{item}
  1052. </foreach>
  1053. </if>
  1054. </select>
  1055. <select id="selectOrderInfoByItemIds" resultType="com.alibaba.fastjson.JSONObject">
  1056. SELECT t.*,
  1057. CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
  1058. FROM (SELECT COUNT(oid) as 'allNumber',
  1059. IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
  1060. 'validOrderNUm',
  1061. IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
  1062. IFNULL(
  1063. SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
  1064. 0) AS 'regimentalPromotionAmount',
  1065. IFNULL(sum(base_amount), 0) as 'baseAmount',
  1066. IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
  1067. FROM kuaishou_supply_chain
  1068. WHERE stat_date >= #{startDate}
  1069. AND stat_date &lt;= #{endDate}
  1070. <if test='itemIds != null and itemIds.size() > 0'>
  1071. AND item_id in
  1072. <foreach collection="itemIds" item="item" separator=","
  1073. open="(" close=")">
  1074. #{item}
  1075. </foreach>
  1076. </if>
  1077. ) t
  1078. </select>
  1079. <select id="selectOrderRate" resultType="com.alibaba.fastjson.JSONObject">
  1080. SELECT
  1081. count(oid) as 'allNumber',
  1082. IFNULL(sum(
  1083. CASE
  1084. WHEN order_status != 80 THEN order_amount
  1085. ELSE 0
  1086. END
  1087. ),0) AS 'orderAmount'
  1088. FROM kuaishou_supply_chain
  1089. WHERE stat_date >= #{statDate}
  1090. AND stat_date &lt;= #{endDate}
  1091. <if test='promoterIds != null and promoterIds.size() > 0'>
  1092. AND promoter_id in
  1093. <foreach collection="promoterIds" item="item" separator=","
  1094. open="(" close=")">
  1095. #{item}
  1096. </foreach>
  1097. </if>
  1098. <if test='itemIds != null and itemIds.size() > 0'>
  1099. AND item_id in
  1100. <foreach collection="itemIds" item="item" separator=","
  1101. open="(" close=")">
  1102. #{item}
  1103. </foreach>
  1104. </if>
  1105. </select>
  1106. <select id="getMonthOrderAmount" resultType="com.alibaba.fastjson.JSONObject">
  1107. SELECT
  1108. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1109. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1110. IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
  1111. IFNULL(promoterCount,0) AS 'promoterCount'
  1112. FROM kuaishou_supply_chain t1
  1113. LEFT JOIN (
  1114. SELECT count(promoter_id) as 'promoterCount', DATE_FORMAT(create_time, '%Y-%m-%d') as 'date'
  1115. FROM kuaishou_promoter
  1116. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
  1117. AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
  1118. <if test="userList != null and userList.size() > 0 ">
  1119. AND user_id in
  1120. <foreach collection="userList" item="item" separator=","
  1121. open="(" close=")">
  1122. #{item}
  1123. </foreach>
  1124. </if>
  1125. GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
  1126. ) t2 ON FROM_UNIXTIME(t1.order_create_time / 1000, '%Y-%m-%d') = t2.date
  1127. WHERE order_status != 80
  1128. <if test='promoterIds != null and promoterIds.size() > 0'>
  1129. AND promoter_id in
  1130. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1131. #{item}
  1132. </foreach>
  1133. </if>
  1134. AND order_create_time >= #{startLong}
  1135. AND order_create_time &lt;= #{endLong}
  1136. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1137. </select>
  1138. <select id="getMonthOrderAmountByItems" resultType="com.alibaba.fastjson.JSONObject">
  1139. SELECT
  1140. FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
  1141. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1142. IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
  1143. count(oid) AS 'orderCount'
  1144. FROM kuaishou_supply_chain
  1145. WHERE order_status != 80
  1146. <if test='itemIds != null and itemIds.size() > 0'>
  1147. AND item_id in
  1148. <foreach collection="itemIds" item="item" separator=","
  1149. open="(" close=")">
  1150. #{item}
  1151. </foreach>
  1152. </if>
  1153. AND order_create_time >= #{startLong}
  1154. AND order_create_time &lt;= #{endLong}
  1155. GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
  1156. </select>
  1157. <select id="getMonthOrderAmountTotal" resultType="com.alibaba.fastjson.JSONObject">
  1158. SELECT
  1159. t1.orderAmount,
  1160. t1.totalRegimentalSettleAmount,
  1161. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1162. CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
  1163. 'totalRegimentalSettleAmountRate'
  1164. FROM
  1165. (
  1166. SELECT
  1167. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1168. IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount'
  1169. FROM kuaishou_supply_chain t1
  1170. WHERE order_status != 80
  1171. <if test='promoterIds != null and promoterIds.size() > 0'>
  1172. AND promoter_id in
  1173. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1174. #{item}
  1175. </foreach>
  1176. </if>
  1177. AND order_create_time >= #{startLong}
  1178. AND order_create_time &lt;= #{endLong}) t1
  1179. LEFT JOIN
  1180. (
  1181. SELECT
  1182. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1183. IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount'
  1184. FROM kuaishou_supply_chain t1
  1185. WHERE order_status != 80
  1186. <if test='promoterIds != null and promoterIds.size() > 0'>
  1187. AND promoter_id in
  1188. <foreach collection="promoterIds" item="item" separator="," open="(" close=")">
  1189. #{item}
  1190. </foreach>
  1191. </if>
  1192. AND order_create_time >= #{toStartLong}
  1193. AND order_create_time &lt;= #{endLong})t2 ON 1=1
  1194. </select>
  1195. <select id="getMonthOrderAmountTotalByItems" resultType="com.alibaba.fastjson.JSONObject">
  1196. SELECT
  1197. t1.orderAmount,
  1198. t1.totalRegimentalSettleAmount,
  1199. t1.orderCount,
  1200. CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
  1201. CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
  1202. CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
  1203. 'totalRegimentalSettleAmountRate'
  1204. FROM
  1205. (
  1206. SELECT
  1207. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1208. IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
  1209. COUNT(oid) as 'orderCount'
  1210. FROM kuaishou_supply_chain t1
  1211. WHERE order_status != 80
  1212. <if test='itemIds != null and itemIds.size() > 0'>
  1213. AND item_id in
  1214. <foreach collection="itemIds" item="item" separator=","
  1215. open="(" close=")">
  1216. #{item}
  1217. </foreach>
  1218. </if>
  1219. AND order_create_time >= #{startLong}
  1220. AND order_create_time &lt;= #{endLong}
  1221. )t1
  1222. LEFT JOIN
  1223. (
  1224. SELECT
  1225. IFNULL(SUM(order_amount),0) AS 'orderAmount',
  1226. IFNULL(SUM(regimental_promotion_amount),0) AS 'totalRegimentalSettleAmount',
  1227. COUNT(oid) as 'orderCount'
  1228. FROM kuaishou_supply_chain t1
  1229. WHERE order_status != 80
  1230. <if test='itemIds != null and itemIds.size() > 0'>
  1231. AND item_id in
  1232. <foreach collection="itemIds" item="item" separator=","
  1233. open="(" close=")">
  1234. #{item}
  1235. </foreach>
  1236. </if>
  1237. AND order_create_time >= #{toStartLong}
  1238. AND order_create_time &lt;= #{endLong}
  1239. )t2 ON 1=1
  1240. </select>
  1241. </mapper>