KuaishouPromoterMapper.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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="selectAllPromoterList" resultType="com.alibaba.fastjson.JSONObject">
  127. SELECT *
  128. FROM (
  129. SELECT
  130. t1.promoter_id AS 'promoterId',
  131. (CASE WHEN t2.promoter_id IS NULL THEN 2 ELSE 1 END) AS 'status',
  132. IF(t0.promoter_name is null,t2.promoter_nick_name,t0.promoter_name) AS 'promoterNickName',
  133. IFNULL(t2.userName,'') AS 'userName',
  134. IFNULL(t2.commission_requirement,'') AS 'commissionRequirement',
  135. IF(t0.handurl is null,t2.promoter_url,t0.handurl) AS 'promoterUrl',
  136. t1.30day_gmv AS 'monthDayGmv',
  137. t1.30day_order_num AS 'monthDayOrderNum',+
  138. t1.valid_amount AS 'validAmount',
  139. t3.fans_number AS 'fansNumber',
  140. t3.video_sales AS 'videoSales',
  141. t3.avg_video_sales AS 'avgVideoSales',
  142. t3.total_sale AS 'totalSale',
  143. case
  144. WHEN t3.video_sales like '%万%'
  145. then SUBSTRING_INDEX(t3.video_sales,'-',-1)+0
  146. else SUBSTRING_INDEX(t3.video_sales,'-',-1)/10000 end as 'videoSalesOrder',
  147. case
  148. WHEN t3.avg_video_sales like '%万%'
  149. then SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)+0
  150. else SUBSTRING_INDEX(t3.avg_video_sales,'-',-1)/10000 end as 'avgVideoSalesOrder'
  151. FROM
  152. promoter_oerder_amount t1
  153. LEFT JOIN promoter_info t0 ON t1.promoter_id = t0.promoter_id
  154. LEFT JOIN promoter_sales_info t3 ON t1.promoter_id = t3.promoter_id
  155. <choose>
  156. <when test="userId !=null and userId !='' ">
  157. RIGHT
  158. </when>
  159. <otherwise>
  160. LEFT
  161. </otherwise>
  162. </choose>
  163. JOIN (
  164. SELECT
  165. promoter_id,
  166. group_concat( user_name ) AS 'userName',
  167. fans_number, promoter_url,
  168. commission_requirement,
  169. promoter_nick_name,
  170. avg_video_sales,
  171. video_sales
  172. FROM kuaishou_promoter
  173. <where>
  174. <if test="userId != null ">
  175. and user_id = #{userId}
  176. </if>
  177. </where>
  178. GROUP BY promoter_id
  179. ) t2 ON t1.promoter_id = t2.promoter_id
  180. <where>
  181. <if test="promoterId != null ">
  182. and t1.promoter_id = #{promoterId}
  183. </if>
  184. <if test="promoterNickName != null and promoterNickName != ''">
  185. and t0.promoter_name like concat('%', #{promoterNickName}, '%')
  186. </if>
  187. </where>
  188. ) t
  189. <where>
  190. <if test="status != null ">
  191. and `status` = #{status}
  192. </if>
  193. </where>
  194. order by ${parameter} ${orderBy}
  195. </select>
  196. <select id="selectKuaishouPromoterById" parameterType="Long" resultMap="KuaishouPromoterResult">
  197. <include refid="selectKuaishouPromoterVo"/>
  198. where id = #{id}
  199. </select>
  200. <select id="getFailInfo" resultMap="KuaishouPromoterResult">
  201. <include refid="selectKuaishouPromoterVo"/>
  202. where (promoter_nick_name = '' or promoter_nick_name is null)
  203. AND state =1
  204. </select>
  205. <select id="getBoundPromoterRoleKey" resultType="com.alibaba.fastjson.JSONObject">
  206. SELECT t1.user_id,
  207. t3.role_key,
  208. t1.user_name
  209. FROM kuaishou_promoter t1
  210. LEFT JOIN sys_user_role t2 ON t1.user_id = t2.user_id
  211. LEFT JOIN sys_role t3 ON t2.role_id = t3.role_id
  212. Where t1.promoter_id = #{promoterId}
  213. </select>
  214. <select id="selectPromoterIdList" resultType="String">
  215. select promoter_id
  216. from kuaishou_promoter
  217. <where>
  218. <if test="userList != null ">
  219. AND user_id in
  220. <foreach collection="userList" item="item" separator=","
  221. open="(" close=")">
  222. #{item}
  223. </foreach>
  224. </if>
  225. <if test="mediaId != null ">
  226. AND media_id =#{mediaId}
  227. </if>
  228. </where>
  229. </select>
  230. <select id="selectPromoterIdListByTime" resultType="String">
  231. select promoter_id
  232. from promoter_bind_channel_date
  233. WHERE stat_date >= #{startDate}
  234. AND stat_date &lt;= #{endDate}
  235. <if test="userList != null ">
  236. AND user_id in
  237. <foreach collection="userList" item="item" separator=","
  238. open="(" close=")">
  239. #{item}
  240. </foreach>
  241. </if>
  242. </select>
  243. <select id="getOneByIdAndPromoterId" resultMap="KuaishouPromoterResult">
  244. <include refid="selectKuaishouPromoterVo"/>
  245. where promoter_id = #{promoterId}
  246. <if test="userId != null ">
  247. AND user_id = #{userId}
  248. </if>
  249. limit 1
  250. </select>
  251. <select id="getgetMonthPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  252. SELECT t1.count,
  253. CONCAT(ROUND(t2.count / t1.count * 100, 2), '%') as 'rate'
  254. FROM
  255. (
  256. SELECT count(promoter_id) as 'count'
  257. FROM kuaishou_promoter
  258. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
  259. AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
  260. AND media_id = #{mediaId}
  261. <if test="userList != null and userList.size() > 0 ">
  262. AND user_id in
  263. <foreach collection="userList" item="item" separator=","
  264. open="(" close=")">
  265. #{item}
  266. </foreach>
  267. </if>
  268. ) t1
  269. LEFT JOIN
  270. (SELECT count(promoter_id) as 'count'
  271. FROM kuaishou_promoter
  272. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') = #{end}
  273. AND media_id = #{mediaId}
  274. <if test="userList != null and userList.size() > 0 ">
  275. AND user_id in
  276. <foreach collection="userList" item="item" separator=","
  277. open="(" close=")">
  278. #{item}
  279. </foreach>
  280. </if>
  281. ) t2 ON 1 = 1
  282. </select>
  283. <insert id="insertKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter" useGeneratedKeys="true"
  284. keyProperty="id">
  285. insert into kuaishou_promoter
  286. <trim prefix="(" suffix=")" suffixOverrides=",">
  287. <if test="userId != null">user_id,</if>
  288. <if test="mediaId != null">media_id,</if>
  289. <if test="userName != null">user_name,</if>
  290. <if test="promoterId != null">promoter_id,</if>
  291. <if test="promoterNickName != null">promoter_nick_name,</if>
  292. <if test="state != null">state,</if>
  293. <if test="province != null">province,</if>
  294. <if test="commissionRequirement != null">commission_requirement,</if>
  295. <if test="categoryRequirement != null">category_requirement,</if>
  296. <if test="createTime != null">create_time,</if>
  297. <if test="updateTime != null">update_time,</if>
  298. <if test="totalSale != null">total_sale,</if>
  299. <if test="fansNumber != null">fans_number,</if>
  300. <if test="promoterUrl != null">promoter_url,</if>
  301. <if test="phone != null">phone,</if>
  302. <if test="consignee != null">consignee,</if>
  303. <if test="promoterAddress != null">promoter_address,</if>
  304. </trim>
  305. <trim prefix="values (" suffix=")" suffixOverrides=",">
  306. <if test="userId != null">#{userId},</if>
  307. <if test="mediaId != null">#{mediaId},</if>
  308. <if test="userName != null">#{userName},</if>
  309. <if test="promoterId != null">#{promoterId},</if>
  310. <if test="promoterNickName != null">#{promoterNickName},</if>
  311. <if test="state != null">#{state},</if>
  312. <if test="province != null">#{province},</if>
  313. <if test="commissionRequirement != null">#{commissionRequirement},</if>
  314. <if test="categoryRequirement != null">#{categoryRequirement},</if>
  315. <if test="createTime != null">#{createTime},</if>
  316. <if test="updateTime != null">#{updateTime},</if>
  317. <if test="totalSale != null">#{totalSale},</if>
  318. <if test="fansNumber != null">#{fansNumber},</if>
  319. <if test="promoterUrl != null">#{promoterUrl},</if>
  320. <if test="phone != null">#{phone},</if>
  321. <if test="consignee != null">#{consignee},</if>
  322. <if test="promoterAddress != null">#{promoterAddress},</if>
  323. </trim>
  324. </insert>
  325. <insert id="addFollowUpRecords">
  326. insert into kuaishou_promoter_follow_up_record
  327. (promoter_id,
  328. user_id,
  329. txt)
  330. values (#{result.promoterId},
  331. #{result.userId},
  332. #{result.txt})
  333. </insert>
  334. <update id="updateFollowUpRecords">
  335. update kuaishou_promoter_follow_up_record
  336. Set txt =#{result.txt}
  337. where id = #{result.id}
  338. </update>
  339. <update id="updateKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
  340. update kuaishou_promoter
  341. <trim prefix="SET" suffixOverrides=",">
  342. <if test="userId != null">user_id = #{userId},</if>
  343. <if test="mediaId != null">media_id = #{mediaId},</if>
  344. <if test="userName != null">user_name = #{userName},</if>
  345. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  346. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  347. <if test="totalSale != null">total_sale = #{totalSale},</if>
  348. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  349. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  350. <if test="phone != null">phone = #{phone},</if>
  351. <if test="consignee != null">consignee = #{consignee},</if>
  352. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  353. <if test="state != null">state = #{state},</if>
  354. <if test="province != null">province = #{province},</if>
  355. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  356. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  357. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  358. <if test="videoSales != null">video_sales = #{videoSales},</if>
  359. <if test="createTime != null">create_time = #{createTime},</if>
  360. <if test="updateTime != null">update_time = #{updateTime},</if>
  361. </trim>
  362. where id = #{id}
  363. </update>
  364. <update id="updateKuaishouPromoterByPromoterId" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
  365. update kuaishou_promoter
  366. <trim prefix="SET" suffixOverrides=",">
  367. <if test="userId != null">user_id = #{userId},</if>
  368. <if test="mediaId != null">media_id = #{mediaId},</if>
  369. <if test="userName != null">user_name = #{userName},</if>
  370. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  371. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  372. <if test="totalSale != null">total_sale = #{totalSale},</if>
  373. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  374. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  375. <if test="phone != null">phone = #{phone},</if>
  376. <if test="consignee != null">consignee = #{consignee},</if>
  377. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  378. <if test="state != null">state = #{state},</if>
  379. <if test="province != null">province = #{province},</if>
  380. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  381. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  382. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  383. <if test="videoSales != null">video_sales = #{videoSales},</if>
  384. <if test="createTime != null">create_time = #{createTime},</if>
  385. <if test="updateTime != null">update_time = #{updateTime},</if>
  386. <if test="followerIncr != null">follower_incr = #{followerIncr},</if>
  387. <if test="liveCount30 != null">live_count_30 = #{liveCount30},</if>
  388. <if test="awemeAvgDiggCount30 != null">aweme_avg_digg_count_30 = #{awemeAvgDiggCount30},</if>
  389. <if test="awemeDiggFollowerRation != null">aweme_digg_follower_ration = #{awemeDiggFollowerRation},</if>
  390. <if test="liveAverageUser30 != null">live_average_user_30 = #{liveAverageUser30},</if>
  391. </trim>
  392. where promoter_id = #{promoterId}
  393. </update>
  394. <delete id="deleteKuaishouPromoterById" parameterType="Long">
  395. delete
  396. from kuaishou_promoter
  397. where id = #{id}
  398. </delete>
  399. <delete id="deleteKuaishouPromoterByIds" parameterType="String">
  400. delete from kuaishou_promoter where id in
  401. <foreach item="id" collection="array" open="(" separator="," close=")">
  402. #{id}
  403. </foreach>
  404. </delete>
  405. <delete id="deletePromoterLabel" parameterType="String">
  406. delete
  407. from kuaishou_promoter_label_rel
  408. where promoter_id = #{promoterId}
  409. AND user_id = #{userId}
  410. </delete>
  411. <insert id="insertPromoterLabels">
  412. insert into kuaishou_promoter_label_rel
  413. (promoter_id,user_id, label_id)
  414. values
  415. <foreach collection="list" item="ent" separator=",">
  416. (#{ent.promoterId},#{ent.userId}, #{ent.labelId})
  417. </foreach>
  418. </insert>
  419. <select id="getNearlyMonthGmv" resultType="com.alibaba.fastjson.JSONObject">
  420. SELECT SUM(order_amount) as 'orderAmount', CONCAT(IFNULL(ROUND((SELECT COUNT(1)
  421. FROM kuaishou_item_collect_samples
  422. WHERE collect_sample_status = 7
  423. AND promoter_id = #{promoterId})
  424. / (SELECT COUNT(1)
  425. FROM kuaishou_item_collect_samples
  426. WHERE collect_sample_status!=1 AND collect_sample_status!=2 AND promoter_id = #{promoterId})*100,2), 0),
  427. '%') as 'operationCompletionRate'
  428. FROM kuaishou_supply_chain
  429. WHERE promoter_id = #{promoterId}
  430. AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') >= #{start}
  431. AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') &lt;= #{end}
  432. </select>
  433. <insert id="insertKuaishouPromoterRecord" parameterType="com.alibaba.fastjson.JSONObject" useGeneratedKeys="true"
  434. keyProperty="id">
  435. insert into kuaishou_promoter_record
  436. <trim prefix="(" suffix=")" suffixOverrides=",">
  437. <if test="promoterId != null">promoter_id,</if>
  438. <if test="userId != null">user_id,</if>
  439. <if test="operatorId != null">operator_id,</if>
  440. <if test="roleName != null">role_name,</if>
  441. <if test="roleKey != null">role_key,</if>
  442. </trim>
  443. <trim prefix="values (" suffix=")" suffixOverrides=",">
  444. <if test="promoterId != null">#{promoterId},</if>
  445. <if test="userId != null">#{userId},</if>
  446. <if test="operatorId != null">#{operatorId},</if>
  447. <if test="roleName != null">#{roleName},</if>
  448. <if test="roleKey != null">#{roleKey},</if>
  449. </trim>
  450. </insert>
  451. <select id="getFollowUpRecordsByUserId" resultType="com.alibaba.fastjson.JSONObject">
  452. SELECT id,
  453. txt
  454. FROM kuaishou_promoter_follow_up_record
  455. Where promoter_id = #{promoterId}
  456. AND user_id = #{userId}
  457. ORDER BY update_time DESC LIMIT 1
  458. </select>
  459. <select id="getFollowUpRecordListByPromoterId" resultType="com.alibaba.fastjson.JSONObject">
  460. SELECT t1.id,
  461. txt,
  462. t2.nick_name as 'userName',
  463. t1.update_time as 'updateTime'
  464. FROM kuaishou_promoter_follow_up_record t1
  465. LEFT JOIN sys_user t2 ON t1.user_id = t2.user_id
  466. Where t1.promoter_id = #{promoterId}
  467. <if test="id != null">
  468. AND t1.id != #{id}
  469. </if>
  470. ORDER BY t1.update_time DESC
  471. </select>
  472. <select id="getPromoterLabel" resultType="com.alibaba.fastjson.JSONObject">
  473. SELECT t2.id as 'labelId', t2.label_colour as 'labelColour', t2.label_name as 'labelName'
  474. FROM kuaishou_promoter_label_rel t1
  475. LEFT JOIN kuaishou_label t2 ON t1.label_id = t2.id
  476. WHERE t1.promoter_id = #{promoterId}
  477. AND user_id = #{userId}
  478. order by t2.id
  479. </select>
  480. <select id="getOnlyPromoterInfoByUserId" resultType="com.ruixuan.isc.entity.KuaishouPromoter">
  481. <include refid="selectKuaishouPromoterVo"/>
  482. where promoter_id = #{promoterId}
  483. <if test="userId != null ">
  484. AND user_id = #{userId}
  485. </if>
  486. limit 1
  487. </select>
  488. <select id="getUserPromotersCount" resultType="java.lang.Integer">
  489. select promoters_count
  490. from user_promoters_count
  491. where user_id = #{userId}
  492. AND media_id = #{mediaId}
  493. </select>
  494. <select id="getBoundCount" resultType="java.lang.Integer">
  495. SELECT COUNT(1)
  496. FROM `kuaishou_promoter`
  497. WHERE user_id = #{userId}
  498. </select>
  499. <select id="getRuleName" resultType="java.lang.String" parameterType="java.lang.Long">
  500. select rule_name from kuaishou_settlement_rules where id = #{ruleId}
  501. </select>
  502. <insert id="addPromotersCount">
  503. replace
  504. into user_promoters_count
  505. (user_id, promoters_count,media_id)
  506. values
  507. (
  508. #{userId},
  509. #{promotersCount},
  510. #{mediaId}
  511. )
  512. </insert>
  513. <insert id="addRule">
  514. replace into
  515. promoter_bind_rule(promoter_id,rule_id,rule_name,create_time,update_time)
  516. values
  517. (#{promoterId},#{ruleId},#{ruleName},now(),now())
  518. </insert>
  519. </mapper>