KuaishouPromoterMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  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.KuaishouPromoterMapper">
  6. <resultMap type="com.ruixuan.isc.entity.KuaishouPromoter" id="KuaishouPromoterResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="mediaId" column="media_id"/>
  10. <result property="userName" column="user_name"/>
  11. <result property="promoterId" column="promoter_id"/>
  12. <result property="promoterNickName" column="promoter_nick_name"/>
  13. <result property="state" column="state"/>
  14. <result property="province" column="province"/>
  15. <result property="commissionRequirement" column="commission_requirement"/>
  16. <result property="categoryRequirement" column="category_requirement"/>
  17. <result property="createTime" column="create_time"/>
  18. <result property="promoterUrl" column="promoter_url"/>
  19. <result property="totalSale" column="total_sale"/>
  20. <result property="fansNumber" column="fans_number"/>
  21. <result property="phone" column="phone"/>
  22. <result property="consignee" column="consignee"/>
  23. <result property="promoterAddress" column="promoter_address"/>
  24. <result property="avgVideoSales" column="avg_video_sales"/>
  25. <result property="videoSales" column="video_sales"/>
  26. <result property="updateTime" column="update_time"/>
  27. <result property="monthDayGmv" column="30day_gmv"/>
  28. <result property="monthDayOrderNum" column="30day_order_num"/>
  29. <result property="validAmount" column="valid_amount"/>
  30. <result property="followerIncr" column="follower_incr"/>
  31. <result property="liveCount30" column="live_count_30"/>
  32. <result property="awemeAvgDiggCount30" column="aweme_avg_digg_count_30"/>
  33. <result property="awemeDiggFollowerRation" column="aweme_digg_follower_ration"/>
  34. <result property="liveAverageUser30" column="live_average_user_30"/>
  35. <result property="followUpRecord" column="txt"/>
  36. </resultMap>
  37. <sql id="selectKuaishouPromoterVo">
  38. select id,
  39. media_id,
  40. user_id,
  41. user_name,
  42. promoter_id,
  43. promoter_nick_name,
  44. `state`,
  45. province,
  46. commission_requirement,
  47. category_requirement,
  48. promoter_url,
  49. phone,
  50. consignee,
  51. promoter_address,
  52. total_sale,
  53. fans_number,
  54. avg_video_sales,
  55. video_sales,
  56. create_time,
  57. update_time
  58. from kuaishou_promoter
  59. </sql>
  60. <select id="selectKuaishouPromoterList" resultMap="KuaishouPromoterResult">
  61. SELECT
  62. t1.id,
  63. t1.user_id,
  64. t1.media_id,
  65. t1.user_name,
  66. t1.promoter_id,
  67. t1.promoter_nick_name,
  68. t1.`state`,
  69. t1.province,
  70. t1.commission_requirement,
  71. t1.category_requirement,
  72. t1.promoter_url,
  73. t1.phone,
  74. t1.consignee,
  75. t1.promoter_address,
  76. if(t1.media_id = 1, t1.total_sale,t3.total_sale ) as 'total_sale',
  77. if(t1.media_id = 1, t1.fans_number,t3.fans_number ) as 'fans_number',
  78. if(t1.media_id = 1, t1.avg_video_sales,t3.avg_video_sales ) as 'avg_video_sales',
  79. if(t1.media_id = 1,t1.video_sales ,t3.video_sales ) as 'video_sales',
  80. t1.create_time,
  81. t2.30day_gmv,
  82. t2.30day_order_num,
  83. t1.follower_incr,
  84. t1.live_count_30,
  85. t1.aweme_avg_digg_count_30,
  86. t1.aweme_digg_follower_ration,
  87. t1.live_average_user_30,
  88. case
  89. WHEN t3.total_sale like '%万%'
  90. then SUBSTRING_INDEX(t3.total_sale,'-',-1)+0
  91. else SUBSTRING_INDEX(t3.total_sale,'-',-1)/10000 end as 'totalSaleOrder',
  92. case
  93. WHEN t3.video_sales like '%万%'
  94. then SUBSTRING_INDEX(t3.video_sales,'-',-1)+0
  95. else SUBSTRING_INDEX(t3.video_sales,'-',-1)/10000 end as 'videoSalesOrder',
  96. case
  97. WHEN t3.avg_video_sales like '%万%'
  98. then SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)+0
  99. else SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)/10000 end as 'avgVideoSalesOrder',
  100. t4.rule_id,
  101. t4.rule_name
  102. FROM
  103. kuaishou_promoter t1
  104. LEFT JOIN promoter_oerder_amount t2 on t1.promoter_id = t2.promoter_id
  105. LEFT JOIN promoter_sales_info t3 ON t1.promoter_id = t3.promoter_id
  106. left join promoter_bind_rule t4 on t1.promoter_id = t4.promoter_id
  107. <where>
  108. <if test="userList != null and userList.size() > 0 ">
  109. and t1.user_id in
  110. <foreach collection="userList" item="userId" open="(" separator="," close=")">
  111. #{userId}
  112. </foreach>
  113. </if>
  114. <if test="promoterId != null ">
  115. and t1.promoter_id = #{promoterId}
  116. </if>
  117. <if test="promoterNickName != null and promoterNickName != ''">
  118. and t1.promoter_nick_name like concat('%', #{promoterNickName}, '%')
  119. </if>
  120. <if test="mediaId != null and mediaId != ''">
  121. and t1.media_id = #{mediaId}
  122. </if>
  123. </where>
  124. order by ${parameter} ${orderBy}
  125. </select>
  126. <select id="selectKuaishouPromoterList3" resultType="com.ruixuan.isc.entity.JYKuaishouPromoter">
  127. SELECT
  128. t1.id,
  129. t1.user_id,
  130. t1.type,
  131. t1.media_id,
  132. t1.user_name,
  133. t1.promoter_id,
  134. t1.promoter_nick_name,
  135. t1.`state`,
  136. t1.province,
  137. t1.commission_requirement,
  138. t1.category_requirement,
  139. t1.promoter_url,
  140. t1.phone,
  141. t1.consignee,
  142. t1.promoter_address,
  143. if(t1.media_id = 1, t1.total_sale,t3.total_sale ) as 'total_sale',
  144. if(t1.media_id = 1, t1.fans_number,t3.fans_number ) as 'fans_number',
  145. if(t1.media_id = 1, t1.avg_video_sales,t3.avg_video_sales ) as 'avg_video_sales',
  146. if(t1.media_id = 1,t1.video_sales ,t3.video_sales ) as 'video_sales',
  147. t1.create_time,
  148. t2.30day_gmv,
  149. t2.30day_order_num,
  150. t1.follower_incr,
  151. t1.live_count_30,
  152. t1.aweme_avg_digg_count_30,
  153. t1.aweme_digg_follower_ration,
  154. t1.live_average_user_30,
  155. case
  156. WHEN t3.total_sale like '%万%'
  157. then SUBSTRING_INDEX(t3.total_sale,'-',-1)+0
  158. else SUBSTRING_INDEX(t3.total_sale,'-',-1)/10000 end as 'totalSaleOrder',
  159. case
  160. WHEN t3.video_sales like '%万%'
  161. then SUBSTRING_INDEX(t3.video_sales,'-',-1)+0
  162. else SUBSTRING_INDEX(t3.video_sales,'-',-1)/10000 end as 'videoSalesOrder',
  163. case
  164. WHEN t3.avg_video_sales like '%万%'
  165. then SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)+0
  166. else SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)/10000 end as 'avgVideoSalesOrder',
  167. t4.rule_id,
  168. t4.rule_name
  169. FROM
  170. jy_kuaishou_promoter t1
  171. LEFT JOIN promoter_oerder_amount t2 on t1.promoter_id = t2.promoter_id
  172. LEFT JOIN promoter_sales_info t3 ON t1.promoter_id = t3.promoter_id
  173. left join promoter_bind_rule t4 on t1.promoter_id = t4.promoter_id
  174. <where>
  175. <if test="userList != null and userList.size() > 0 ">
  176. and t1.user_id in
  177. <foreach collection="userList" item="userId" open="(" separator="," close=")">
  178. #{userId}
  179. </foreach>
  180. </if>
  181. <if test="promoterId != null ">
  182. and t1.promoter_id = #{promoterId}
  183. </if>
  184. <if test="promoterNickName != null and promoterNickName != ''">
  185. and t1.promoter_nick_name like concat('%', #{promoterNickName}, '%')
  186. </if>
  187. <if test="mediaId != null and mediaId != ''">
  188. and t1.media_id = #{mediaId}
  189. </if>
  190. <if test="type != null and type != ''">
  191. and t1.type = #{type}
  192. </if>
  193. </where>
  194. order by ${parameter} ${orderBy}
  195. </select>
  196. <select id="selectAllPromoterList" resultType="com.alibaba.fastjson.JSONObject">
  197. SELECT *
  198. FROM (
  199. SELECT
  200. t1.promoter_id AS 'promoterId',
  201. (CASE WHEN t2.promoter_id IS NULL THEN 2 ELSE 1 END) AS 'status',
  202. IF(t0.promoter_name is null,t2.promoter_nick_name,t0.promoter_name) AS 'promoterNickName',
  203. IFNULL(t2.userName,'') AS 'userName',
  204. IFNULL(t2.commission_requirement,'') AS 'commissionRequirement',
  205. IF(t0.handurl is null,t2.promoter_url,t0.handurl) AS 'promoterUrl',
  206. t1.30day_gmv AS 'monthDayGmv',
  207. t1.30day_order_num AS 'monthDayOrderNum',+
  208. t1.valid_amount AS 'validAmount',
  209. t3.fans_number AS 'fansNumber',
  210. t3.video_sales AS 'videoSales',
  211. t3.avg_video_sales AS 'avgVideoSales',
  212. t3.total_sale AS 'totalSale',
  213. case
  214. WHEN t3.video_sales like '%万%'
  215. then SUBSTRING_INDEX(t3.video_sales,'-',-1)+0
  216. else SUBSTRING_INDEX(t3.video_sales,'-',-1)/10000 end as 'videoSalesOrder',
  217. case
  218. WHEN t3.avg_video_sales like '%万%'
  219. then SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)+0
  220. else SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)/10000 end as 'avgVideoSalesOrder'
  221. FROM
  222. promoter_oerder_amount t1
  223. LEFT JOIN promoter_info t0 ON t1.promoter_id = t0.promoter_id
  224. LEFT JOIN promoter_sales_info t3 ON t1.promoter_id = t3.promoter_id
  225. <choose>
  226. <when test="userId !=null and userId !='' ">
  227. RIGHT
  228. </when>
  229. <otherwise>
  230. LEFT
  231. </otherwise>
  232. </choose>
  233. JOIN (
  234. SELECT
  235. promoter_id,
  236. group_concat( user_name ) AS 'userName',
  237. fans_number, promoter_url,
  238. commission_requirement,
  239. promoter_nick_name,
  240. avg_video_sales,
  241. video_sales
  242. FROM kuaishou_promoter
  243. <where>
  244. <if test="userId != null ">
  245. and user_id = #{userId}
  246. </if>
  247. </where>
  248. GROUP BY promoter_id
  249. ) t2 ON t1.promoter_id = t2.promoter_id
  250. <where>
  251. <if test="promoterId != null ">
  252. and t1.promoter_id = #{promoterId}
  253. </if>
  254. <if test="promoterNickName != null and promoterNickName != ''">
  255. and t0.promoter_name like concat('%', #{promoterNickName}, '%')
  256. </if>
  257. </where>
  258. ) t
  259. <where>
  260. <if test="status != null ">
  261. and `status` = #{status}
  262. </if>
  263. </where>
  264. order by ${parameter} ${orderBy}
  265. </select>
  266. <select id="selectKuaishouPromoterById" parameterType="Long" resultMap="KuaishouPromoterResult">
  267. <include refid="selectKuaishouPromoterVo"/>
  268. where id = #{id}
  269. </select>
  270. <select id="selectKuaishouPromoterById3" parameterType="Long" resultType="com.ruixuan.isc.entity.JYKuaishouPromoter">
  271. select id,
  272. media_id,
  273. user_id,
  274. user_name,
  275. promoter_id,
  276. promoter_nick_name,
  277. `state`,
  278. province,
  279. commission_requirement,
  280. category_requirement,
  281. promoter_url,
  282. phone,
  283. consignee,
  284. promoter_address,
  285. total_sale,
  286. fans_number,
  287. avg_video_sales,
  288. video_sales,
  289. create_time,
  290. update_time
  291. from jy_kuaishou_promoter
  292. where id = #{id}
  293. </select>
  294. <select id="getFailInfo" resultMap="KuaishouPromoterResult">
  295. <include refid="selectKuaishouPromoterVo"/>
  296. where (promoter_nick_name = '' or promoter_nick_name is null)
  297. AND state =1
  298. </select>
  299. <select id="getFailInfo3" resultType="com.ruixuan.isc.entity.JYKuaishouPromoter">
  300. select id,
  301. media_id,
  302. user_id,
  303. user_name,
  304. promoter_id,
  305. promoter_nick_name,
  306. `state`,
  307. province,
  308. commission_requirement,
  309. category_requirement,
  310. promoter_url,
  311. phone,
  312. consignee,
  313. promoter_address,
  314. total_sale,
  315. fans_number,
  316. avg_video_sales,
  317. video_sales,
  318. create_time,
  319. update_time
  320. from jy_kuaishou_promoter
  321. where (promoter_nick_name = '' or promoter_nick_name is null)
  322. AND state = 1
  323. </select>
  324. <select id="getBoundPromoterRoleKey" resultType="com.alibaba.fastjson.JSONObject">
  325. SELECT t1.user_id,
  326. t3.role_key,
  327. t1.user_name
  328. FROM kuaishou_promoter t1
  329. LEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id
  330. LEFT JOIN sys_role t3 ON t2.role_id = t3.role_id
  331. Where t1.promoter_id = #{promoterId}
  332. </select>
  333. <select id="selectPromoterIdList" resultType="String">
  334. select promoter_id
  335. from kuaishou_promoter
  336. <where>
  337. <if test="userList != null ">
  338. AND user_id in
  339. <foreach collection="userList" item="item" separator=","
  340. open="(" close=")">
  341. #{item}
  342. </foreach>
  343. </if>
  344. <if test="mediaId != null ">
  345. AND media_id =#{mediaId}
  346. </if>
  347. </where>
  348. </select>
  349. <select id="selectPromoterIdListByTime" resultType="String">
  350. select promoter_id
  351. from promoter_bind_channel_date
  352. WHERE stat_date >= #{startDate}
  353. AND stat_date &lt;= #{endDate}
  354. <if test="userList != null ">
  355. AND user_id in
  356. <foreach collection="userList" item="item" separator=","
  357. open="(" close=")">
  358. #{item}
  359. </foreach>
  360. </if>
  361. </select>
  362. <select id="getOneByIdAndPromoterId" resultMap="KuaishouPromoterResult">
  363. <include refid="selectKuaishouPromoterVo"/>
  364. where promoter_id = #{promoterId}
  365. <if test="userId != null ">
  366. AND user_id = #{userId}
  367. </if>
  368. limit 1
  369. </select>
  370. <select id="getOneByIdAndPromoterId3" resultType="com.ruixuan.isc.entity.JYKuaishouPromoter">
  371. select
  372. id,
  373. media_id,
  374. `type`,
  375. user_id,
  376. user_name,
  377. promoter_id,
  378. promoter_nick_name,
  379. `state`,
  380. province,
  381. commission_requirement,
  382. category_requirement,
  383. promoter_url,
  384. phone,
  385. consignee,
  386. promoter_address,
  387. total_sale,
  388. fans_number,
  389. avg_video_sales,
  390. video_sales,
  391. create_time,
  392. update_time
  393. from jy_kuaishou_promoter
  394. where promoter_id = #{promoterId}
  395. <if test="userId != null ">
  396. AND user_id = #{userId}
  397. </if>
  398. limit 1
  399. </select>
  400. <select id="getgetMonthPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  401. SELECT t1.count,
  402. CONCAT(ROUND(t2.count / t1.count * 100, 2), '%') as 'rate'
  403. FROM
  404. (
  405. SELECT count(promoter_id) as 'count'
  406. FROM kuaishou_promoter
  407. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
  408. AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
  409. AND media_id = #{mediaId}
  410. <if test="userList != null and userList.size() > 0 ">
  411. AND user_id in
  412. <foreach collection="userList" item="item" separator=","
  413. open="(" close=")">
  414. #{item}
  415. </foreach>
  416. </if>
  417. ) t1
  418. LEFT JOIN
  419. (SELECT count(promoter_id) as 'count'
  420. FROM kuaishou_promoter
  421. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') = #{end}
  422. AND media_id = #{mediaId}
  423. <if test="userList != null and userList.size() > 0 ">
  424. AND user_id in
  425. <foreach collection="userList" item="item" separator=","
  426. open="(" close=")">
  427. #{item}
  428. </foreach>
  429. </if>
  430. ) t2 ON 1 = 1
  431. </select>
  432. <insert id="insertKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter" useGeneratedKeys="true"
  433. keyProperty="id">
  434. insert into kuaishou_promoter
  435. <trim prefix="(" suffix=")" suffixOverrides=",">
  436. <if test="userId != null">user_id,</if>
  437. <if test="mediaId != null">media_id,</if>
  438. <if test="userName != null">user_name,</if>
  439. <if test="promoterId != null">promoter_id,</if>
  440. <if test="promoterNickName != null">promoter_nick_name,</if>
  441. <if test="state != null">state,</if>
  442. <if test="province != null">province,</if>
  443. <if test="commissionRequirement != null">commission_requirement,</if>
  444. <if test="categoryRequirement != null">category_requirement,</if>
  445. <if test="createTime != null">create_time,</if>
  446. <if test="updateTime != null">update_time,</if>
  447. <if test="totalSale != null">total_sale,</if>
  448. <if test="fansNumber != null">fans_number,</if>
  449. <if test="promoterUrl != null">promoter_url,</if>
  450. <if test="phone != null">phone,</if>
  451. <if test="consignee != null">consignee,</if>
  452. <if test="promoterAddress != null">promoter_address,</if>
  453. </trim>
  454. <trim prefix="values (" suffix=")" suffixOverrides=",">
  455. <if test="userId != null">#{userId},</if>
  456. <if test="mediaId != null">#{mediaId},</if>
  457. <if test="userName != null">#{userName},</if>
  458. <if test="promoterId != null">#{promoterId},</if>
  459. <if test="promoterNickName != null">#{promoterNickName},</if>
  460. <if test="state != null">#{state},</if>
  461. <if test="province != null">#{province},</if>
  462. <if test="commissionRequirement != null">#{commissionRequirement},</if>
  463. <if test="categoryRequirement != null">#{categoryRequirement},</if>
  464. <if test="createTime != null">#{createTime},</if>
  465. <if test="updateTime != null">#{updateTime},</if>
  466. <if test="totalSale != null">#{totalSale},</if>
  467. <if test="fansNumber != null">#{fansNumber},</if>
  468. <if test="promoterUrl != null">#{promoterUrl},</if>
  469. <if test="phone != null">#{phone},</if>
  470. <if test="consignee != null">#{consignee},</if>
  471. <if test="promoterAddress != null">#{promoterAddress},</if>
  472. </trim>
  473. </insert>
  474. <insert id="insertKuaishouPromoter3" parameterType="com.ruixuan.isc.entity.JYKuaishouPromoter" useGeneratedKeys="true"
  475. keyProperty="id">
  476. insert into jy_kuaishou_promoter
  477. <trim prefix="(" suffix=")" suffixOverrides=",">
  478. <if test="userId != null">user_id,</if>
  479. <if test="mediaId != null">media_id,</if>
  480. <if test="type != null">type,</if>
  481. <if test="userName != null">user_name,</if>
  482. <if test="promoterId != null">promoter_id,</if>
  483. <if test="promoterNickName != null">promoter_nick_name,</if>
  484. <if test="state != null">state,</if>
  485. <if test="province != null">province,</if>
  486. <if test="commissionRequirement != null">commission_requirement,</if>
  487. <if test="categoryRequirement != null">category_requirement,</if>
  488. <if test="createTime != null">create_time,</if>
  489. <if test="updateTime != null">update_time,</if>
  490. <if test="totalSale != null">total_sale,</if>
  491. <if test="fansNumber != null">fans_number,</if>
  492. <if test="promoterUrl != null">promoter_url,</if>
  493. <if test="phone != null">phone,</if>
  494. <if test="consignee != null">consignee,</if>
  495. <if test="promoterAddress != null">promoter_address,</if>
  496. </trim>
  497. <trim prefix="values (" suffix=")" suffixOverrides=",">
  498. <if test="userId != null">#{userId},</if>
  499. <if test="mediaId != null">#{mediaId},</if>
  500. <if test="type != null">#{type},</if>
  501. <if test="userName != null">#{userName},</if>
  502. <if test="promoterId != null">#{promoterId},</if>
  503. <if test="promoterNickName != null">#{promoterNickName},</if>
  504. <if test="state != null">#{state},</if>
  505. <if test="province != null">#{province},</if>
  506. <if test="commissionRequirement != null">#{commissionRequirement},</if>
  507. <if test="categoryRequirement != null">#{categoryRequirement},</if>
  508. <if test="createTime != null">#{createTime},</if>
  509. <if test="updateTime != null">#{updateTime},</if>
  510. <if test="totalSale != null">#{totalSale},</if>
  511. <if test="fansNumber != null">#{fansNumber},</if>
  512. <if test="promoterUrl != null">#{promoterUrl},</if>
  513. <if test="phone != null">#{phone},</if>
  514. <if test="consignee != null">#{consignee},</if>
  515. <if test="promoterAddress != null">#{promoterAddress},</if>
  516. </trim>
  517. </insert>
  518. <insert id="addFollowUpRecords">
  519. insert into kuaishou_promoter_follow_up_record
  520. (promoter_id,
  521. user_id,
  522. txt)
  523. values (#{result.promoterId},
  524. #{result.userId},
  525. #{result.txt})
  526. </insert>
  527. <update id="updateFollowUpRecords">
  528. update kuaishou_promoter_follow_up_record
  529. Set txt =#{result.txt}
  530. where id = #{result.id}
  531. </update>
  532. <update id="updateKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
  533. update kuaishou_promoter
  534. <trim prefix="SET" suffixOverrides=",">
  535. <if test="userId != null">user_id = #{userId},</if>
  536. <if test="mediaId != null">media_id = #{mediaId},</if>
  537. <if test="userName != null">user_name = #{userName},</if>
  538. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  539. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  540. <if test="totalSale != null">total_sale = #{totalSale},</if>
  541. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  542. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  543. <if test="phone != null">phone = #{phone},</if>
  544. <if test="consignee != null">consignee = #{consignee},</if>
  545. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  546. <if test="state != null">state = #{state},</if>
  547. <if test="province != null">province = #{province},</if>
  548. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  549. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  550. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  551. <if test="videoSales != null">video_sales = #{videoSales},</if>
  552. <if test="createTime != null">create_time = #{createTime},</if>
  553. <if test="updateTime != null">update_time = #{updateTime},</if>
  554. </trim>
  555. where id = #{id}
  556. </update>
  557. <update id="updateKuaishouPromoter3" parameterType="com.ruixuan.isc.entity.JYKuaishouPromoter">
  558. update jy_kuaishou_promoter
  559. <trim prefix="SET" suffixOverrides=",">
  560. <if test="userId != null">user_id = #{userId},</if>
  561. <if test="mediaId != null">media_id = #{mediaId},</if>
  562. <if test="type != null">type = #{type},</if>
  563. <if test="userName != null">user_name = #{userName},</if>
  564. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  565. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  566. <if test="totalSale != null">total_sale = #{totalSale},</if>
  567. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  568. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  569. <if test="phone != null">phone = #{phone},</if>
  570. <if test="consignee != null">consignee = #{consignee},</if>
  571. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  572. <if test="state != null">state = #{state},</if>
  573. <if test="province != null">province = #{province},</if>
  574. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  575. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  576. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  577. <if test="videoSales != null">video_sales = #{videoSales},</if>
  578. <if test="createTime != null">create_time = #{createTime},</if>
  579. <if test="updateTime != null">update_time = #{updateTime},</if>
  580. </trim>
  581. where id = #{id}
  582. </update>
  583. <update id="updateKuaishouPromoterByPromoterId" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
  584. update kuaishou_promoter
  585. <trim prefix="SET" suffixOverrides=",">
  586. <if test="userId != null">user_id = #{userId},</if>
  587. <if test="mediaId != null">media_id = #{mediaId},</if>
  588. <if test="userName != null">user_name = #{userName},</if>
  589. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  590. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  591. <if test="totalSale != null">total_sale = #{totalSale},</if>
  592. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  593. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  594. <if test="phone != null">phone = #{phone},</if>
  595. <if test="consignee != null">consignee = #{consignee},</if>
  596. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  597. <if test="state != null">state = #{state},</if>
  598. <if test="province != null">province = #{province},</if>
  599. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  600. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  601. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  602. <if test="videoSales != null">video_sales = #{videoSales},</if>
  603. <if test="createTime != null">create_time = #{createTime},</if>
  604. <if test="updateTime != null">update_time = #{updateTime},</if>
  605. <if test="followerIncr != null">follower_incr = #{followerIncr},</if>
  606. <if test="liveCount30 != null">live_count_30 = #{liveCount30},</if>
  607. <if test="awemeAvgDiggCount30 != null">aweme_avg_digg_count_30 = #{awemeAvgDiggCount30},</if>
  608. <if test="awemeDiggFollowerRation != null">aweme_digg_follower_ration = #{awemeDiggFollowerRation},</if>
  609. <if test="liveAverageUser30 != null">live_average_user_30 = #{liveAverageUser30},</if>
  610. </trim>
  611. where promoter_id = #{promoterId}
  612. </update>
  613. <update id="updateKuaishouPromoterByPromoterId3" parameterType="com.ruixuan.isc.entity.JYKuaishouPromoter">
  614. update jy_kuaishou_promoter
  615. <trim prefix="SET" suffixOverrides=",">
  616. <if test="userId != null">user_id = #{userId},</if>
  617. <if test="type != null">`type` = #{type},</if>
  618. <if test="mediaId != null">media_id = #{mediaId},</if>
  619. <if test="userName != null">user_name = #{userName},</if>
  620. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  621. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  622. <if test="totalSale != null">total_sale = #{totalSale},</if>
  623. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  624. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  625. <if test="phone != null">phone = #{phone},</if>
  626. <if test="consignee != null">consignee = #{consignee},</if>
  627. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  628. <if test="state != null">`state` = #{state},</if>
  629. <if test="province != null">province = #{province},</if>
  630. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  631. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  632. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  633. <if test="videoSales != null">video_sales = #{videoSales},</if>
  634. <if test="createTime != null">create_time = #{createTime},</if>
  635. <if test="updateTime != null">update_time = #{updateTime},</if>
  636. <if test="followerIncr != null">follower_incr = #{followerIncr},</if>
  637. <if test="liveCount30 != null">live_count_30 = #{liveCount30},</if>
  638. <if test="awemeAvgDiggCount30 != null">aweme_avg_digg_count_30 = #{awemeAvgDiggCount30},</if>
  639. <if test="awemeDiggFollowerRation != null">aweme_digg_follower_ration = #{awemeDiggFollowerRation},</if>
  640. <if test="liveAverageUser30 != null">live_average_user_30 = #{liveAverageUser30},</if>
  641. </trim>
  642. where promoter_id = #{promoterId}
  643. </update>
  644. <delete id="deleteKuaishouPromoterById" parameterType="Long">
  645. delete
  646. from kuaishou_promoter
  647. where id = #{id}
  648. </delete>
  649. <delete id="deleteKuaishouPromoterById3" parameterType="Long">
  650. delete
  651. from jy_kuaishou_promoter
  652. where id = #{id}
  653. </delete>
  654. <delete id="deleteKuaishouPromoterByIds" parameterType="String">
  655. delete from kuaishou_promoter where id in
  656. <foreach item="id" collection="array" open="(" separator="," close=")">
  657. #{id}
  658. </foreach>
  659. </delete>
  660. <delete id="deletePromoterLabel" parameterType="String">
  661. delete
  662. from kuaishou_promoter_label_rel
  663. where promoter_id = #{promoterId}
  664. AND user_id = #{userId}
  665. </delete>
  666. <insert id="insertPromoterLabels">
  667. insert into kuaishou_promoter_label_rel
  668. (promoter_id,user_id, label_id)
  669. values
  670. <foreach collection="list" item="ent" separator=",">
  671. (#{ent.promoterId},#{ent.userId}, #{ent.labelId})
  672. </foreach>
  673. </insert>
  674. <select id="getNearlyMonthGmv" resultType="com.alibaba.fastjson.JSONObject">
  675. SELECT SUM(order_amount) as 'orderAmount', CONCAT(IFNULL(ROUND((SELECT COUNT(1)
  676. FROM kuaishou_item_collect_samples
  677. WHERE collect_sample_status = 7
  678. AND promoter_id = #{promoterId})
  679. / (SELECT COUNT(1)
  680. FROM kuaishou_item_collect_samples
  681. WHERE collect_sample_status!=1 AND collect_sample_status!=2 AND promoter_id = #{promoterId})*100,2), 0),
  682. '%') as 'operationCompletionRate'
  683. FROM kuaishou_supply_chain
  684. WHERE promoter_id = #{promoterId}
  685. AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') >= #{start}
  686. AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') &lt;= #{end}
  687. </select>
  688. <insert id="insertKuaishouPromoterRecord" parameterType="com.alibaba.fastjson.JSONObject" useGeneratedKeys="true"
  689. keyProperty="id">
  690. insert into kuaishou_promoter_record
  691. <trim prefix="(" suffix=")" suffixOverrides=",">
  692. <if test="promoterId != null">promoter_id,</if>
  693. <if test="userId != null">user_id,</if>
  694. <if test="operatorId != null">operator_id,</if>
  695. <if test="roleName != null">role_name,</if>
  696. <if test="roleKey != null">role_key,</if>
  697. </trim>
  698. <trim prefix="values (" suffix=")" suffixOverrides=",">
  699. <if test="promoterId != null">#{promoterId},</if>
  700. <if test="userId != null">#{userId},</if>
  701. <if test="operatorId != null">#{operatorId},</if>
  702. <if test="roleName != null">#{roleName},</if>
  703. <if test="roleKey != null">#{roleKey},</if>
  704. </trim>
  705. </insert>
  706. <select id="getFollowUpRecordsByUserId" resultType="com.alibaba.fastjson.JSONObject">
  707. SELECT id,
  708. txt
  709. FROM kuaishou_promoter_follow_up_record
  710. Where promoter_id = #{promoterId}
  711. AND user_id = #{userId}
  712. ORDER BY update_time DESC LIMIT 1
  713. </select>
  714. <select id="getFollowUpRecordListByPromoterId" resultType="com.alibaba.fastjson.JSONObject">
  715. SELECT t1.id,
  716. txt,
  717. t2.nick_name as 'userName',
  718. t1.update_time as 'updateTime'
  719. FROM kuaishou_promoter_follow_up_record t1
  720. LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
  721. Where t1.promoter_id = #{promoterId}
  722. <if test="id != null">
  723. AND t1.id != #{id}
  724. </if>
  725. ORDER BY t1.update_time DESC
  726. </select>
  727. <select id="getPromoterLabel" resultType="com.alibaba.fastjson.JSONObject">
  728. SELECT t2.id as 'labelId', t2.label_colour as 'labelColour', t2.label_name as 'labelName'
  729. FROM kuaishou_promoter_label_rel t1
  730. LEFT JOIN kuaishou_label t2 ON t1.label_id = t2.id
  731. WHERE t1.promoter_id = #{promoterId}
  732. AND user_id = #{userId}
  733. order by t2.id
  734. </select>
  735. <select id="getOnlyPromoterInfoByUserId" resultType="com.ruixuan.isc.entity.KuaishouPromoter">
  736. <include refid="selectKuaishouPromoterVo"/>
  737. where promoter_id = #{promoterId}
  738. <if test="userId != null ">
  739. AND user_id = #{userId}
  740. </if>
  741. limit 1
  742. </select>
  743. <select id="getUserPromotersCount" resultType="java.lang.Integer">
  744. select promoters_count
  745. from user_promoters_count
  746. where user_id = #{userId}
  747. AND media_id = #{mediaId}
  748. </select>
  749. <select id="getBoundCount" resultType="java.lang.Integer">
  750. SELECT COUNT(1)
  751. FROM `kuaishou_promoter`
  752. WHERE user_id = #{userId}
  753. </select>
  754. <select id="getRuleName" resultType="java.lang.String" parameterType="java.lang.Long">
  755. select rule_name
  756. from kuaishou_settlement_rules
  757. where id = #{ruleId}
  758. </select>
  759. <insert id="addPromotersCount">
  760. replace
  761. into user_promoters_count
  762. (user_id, promoters_count,media_id)
  763. values
  764. (
  765. #{userId},
  766. #{promotersCount},
  767. #{mediaId}
  768. )
  769. </insert>
  770. <insert id="addRule">
  771. replace
  772. into
  773. promoter_bind_rule(promoter_id,rule_id,rule_name,create_time,update_time)
  774. values
  775. (
  776. #{promoterId},
  777. #{ruleId},
  778. #{ruleName},
  779. now
  780. (
  781. ),
  782. now
  783. (
  784. )
  785. )
  786. </insert>
  787. </mapper>