KuaishouPromoterMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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="userName" column="user_name"/>
  10. <result property="promoterId" column="promoter_id"/>
  11. <result property="promoterNickName" column="promoter_nick_name"/>
  12. <result property="state" column="state"/>
  13. <result property="province" column="province"/>
  14. <result property="commissionRequirement" column="commission_requirement"/>
  15. <result property="categoryRequirement" column="category_requirement"/>
  16. <result property="createTime" column="create_time"/>
  17. <result property="promoterUrl" column="promoter_url"/>
  18. <result property="totalSale" column="total_sale"/>
  19. <result property="fansNumber" column="fans_number"/>
  20. <result property="phone" column="phone"/>
  21. <result property="consignee" column="consignee"/>
  22. <result property="promoterAddress" column="promoter_address"/>
  23. <result property="avgVideoSales" column="avg_video_sales"/>
  24. <result property="videoSales" column="video_sales"/>
  25. <result property="updateTime" column="update_time"/>
  26. <result property="monthDayGmv" column="30day_gmv"/>
  27. <result property="monthDayOrderNum" column="30day_order_num"/>
  28. <result property="validAmount" column="valid_amount"/>
  29. </resultMap>
  30. <sql id="selectKuaishouPromoterVo">
  31. select id,
  32. user_id,
  33. user_name,
  34. promoter_id,
  35. promoter_nick_name,
  36. `state`,
  37. province,
  38. commission_requirement,
  39. category_requirement,
  40. promoter_url,
  41. phone,
  42. consignee,
  43. promoter_address,
  44. total_sale,
  45. fans_number,
  46. avg_video_sales,
  47. video_sales,
  48. create_time,
  49. update_time
  50. from kuaishou_promoter
  51. </sql>
  52. <select id="selectKuaishouPromoterList" resultMap="KuaishouPromoterResult">
  53. SELECT
  54. t1.id,
  55. t1.user_id,
  56. t1.user_name,
  57. t1.promoter_id,
  58. t1.promoter_nick_name,
  59. t1.`state`,
  60. t1.province,
  61. t1.commission_requirement,
  62. t1.category_requirement,
  63. t1.promoter_url,
  64. t1.phone,
  65. t1.consignee,
  66. t1.promoter_address,
  67. t1.total_sale,
  68. t1.fans_number,
  69. t1.avg_video_sales,
  70. t1.video_sales,
  71. t1.create_time,
  72. t2.30day_gmv,
  73. t2.30day_order_num
  74. FROM
  75. kuaishou_promoter t1
  76. LEFT JOIN promoter_oerder_amount t2 on t1.promoter_id = t2.promoter_id
  77. <where>
  78. <if test="userList != null and userList.size() > 0 ">
  79. and t1.user_id in
  80. <foreach collection="userList" item="userId" open="(" separator="," close=")">
  81. #{userId}
  82. </foreach>
  83. </if>
  84. <if test="promoterId != null ">
  85. and t1.promoter_id = #{promoterId}
  86. </if>
  87. <if test="promoterNickName != null and promoterNickName != ''">
  88. and t1.promoter_nick_name like concat('%', #{promoterNickName}, '%')
  89. </if>
  90. </where>
  91. order by t1.create_time desc
  92. </select>
  93. <select id="selectKuaishouPromoterById" parameterType="Long" resultMap="KuaishouPromoterResult">
  94. <include refid="selectKuaishouPromoterVo"/>
  95. where id = #{id}
  96. </select>
  97. <select id="selectPromoterIdList" resultType="Long">
  98. select promoter_id
  99. from kuaishou_promoter
  100. <where>
  101. <if test="userList != null ">
  102. AND user_id in
  103. <foreach collection="userList" item="item" separator=","
  104. open="(" close=")">
  105. #{item}
  106. </foreach>
  107. </if>
  108. </where>
  109. </select>
  110. <select id="getOneByIdAndPromoterId" resultMap="KuaishouPromoterResult">
  111. <include refid="selectKuaishouPromoterVo"/>
  112. where promoter_id = #{promoterId}
  113. <if test="userId != null ">
  114. AND user_id = #{userId}
  115. </if>
  116. limit 1
  117. </select>
  118. <select id="getgetMonthPromoterTotal" resultType="com.alibaba.fastjson.JSONObject">
  119. SELECT t1.count,
  120. CONCAT(ROUND(t2.count / t1.count * 100, 2), '%') as 'rate'
  121. FROM
  122. (
  123. SELECT count(promoter_id) as 'count'
  124. FROM kuaishou_promoter
  125. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
  126. AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{end}
  127. <if test="userList != null and userList.size() > 0 ">
  128. AND user_id in
  129. <foreach collection="userList" item="item" separator=","
  130. open="(" close=")">
  131. #{item}
  132. </foreach>
  133. </if>
  134. ) t1
  135. LEFT JOIN
  136. (SELECT count(promoter_id) as 'count'
  137. FROM kuaishou_promoter
  138. WHERE DATE_FORMAT(create_time, '%Y-%m-%d') = #{end}
  139. <if test="userList != null and userList.size() > 0 ">
  140. AND user_id in
  141. <foreach collection="userList" item="item" separator=","
  142. open="(" close=")">
  143. #{item}
  144. </foreach>
  145. </if>
  146. ) t2 ON 1 = 1
  147. </select>
  148. <insert id="insertKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter" useGeneratedKeys="true"
  149. keyProperty="id">
  150. insert into kuaishou_promoter
  151. <trim prefix="(" suffix=")" suffixOverrides=",">
  152. <if test="userId != null">user_id,</if>
  153. <if test="userName != null">user_name,</if>
  154. <if test="promoterId != null">promoter_id,</if>
  155. <if test="promoterNickName != null">promoter_nick_name,</if>
  156. <if test="state != null">state,</if>
  157. <if test="province != null">province,</if>
  158. <if test="commissionRequirement != null">commission_requirement,</if>
  159. <if test="categoryRequirement != null">category_requirement,</if>
  160. <if test="createTime != null">create_time,</if>
  161. <if test="updateTime != null">update_time,</if>
  162. <if test="totalSale != null">total_sale,</if>
  163. <if test="fansNumber != null">fans_number,</if>
  164. <if test="promoterUrl != null">promoter_url,</if>
  165. <if test="phone != null">phone,</if>
  166. <if test="consignee != null">consignee,</if>
  167. <if test="promoterAddress != null">promoter_address,</if>
  168. </trim>
  169. <trim prefix="values (" suffix=")" suffixOverrides=",">
  170. <if test="userId != null">#{userId},</if>
  171. <if test="userName != null">#{userName},</if>
  172. <if test="promoterId != null">#{promoterId},</if>
  173. <if test="promoterNickName != null">#{promoterNickName},</if>
  174. <if test="state != null">#{state},</if>
  175. <if test="province != null">#{province},</if>
  176. <if test="commissionRequirement != null">#{commissionRequirement},</if>
  177. <if test="categoryRequirement != null">#{categoryRequirement},</if>
  178. <if test="createTime != null">#{createTime},</if>
  179. <if test="updateTime != null">#{updateTime},</if>
  180. <if test="totalSale != null">#{totalSale},</if>
  181. <if test="fansNumber != null">#{fansNumber},</if>
  182. <if test="promoterUrl != null">#{promoterUrl},</if>
  183. <if test="phone != null">#{phone},</if>
  184. <if test="consignee != null">#{consignee},</if>
  185. <if test="promoterAddress != null">#{promoterAddress},</if>
  186. </trim>
  187. </insert>
  188. <update id="updateKuaishouPromoter" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
  189. update kuaishou_promoter
  190. <trim prefix="SET" suffixOverrides=",">
  191. <if test="userId != null">user_id = #{userId},</if>
  192. <if test="userName != null">user_name = #{userName},</if>
  193. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  194. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  195. <if test="totalSale != null">total_sale = #{totalSale},</if>
  196. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  197. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  198. <if test="phone != null">phone = #{phone},</if>
  199. <if test="consignee != null">consignee = #{consignee},</if>
  200. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  201. <if test="state != null">state = #{state},</if>
  202. <if test="province != null">province = #{province},</if>
  203. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  204. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  205. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  206. <if test="videoSales != null">video_sales = #{videoSales},</if>
  207. <if test="createTime != null">create_time = #{createTime},</if>
  208. <if test="updateTime != null">update_time = #{updateTime},</if>
  209. </trim>
  210. where id = #{id}
  211. </update>
  212. <update id="updateKuaishouPromoterByPromoterId" parameterType="com.ruixuan.isc.entity.KuaishouPromoter">
  213. update kuaishou_promoter
  214. <trim prefix="SET" suffixOverrides=",">
  215. <if test="userId != null">user_id = #{userId},</if>
  216. <if test="userName != null">user_name = #{userName},</if>
  217. <if test="promoterId != null">promoter_id = #{promoterId},</if>
  218. <if test="promoterNickName != null">promoter_nick_name = #{promoterNickName},</if>
  219. <if test="totalSale != null">total_sale = #{totalSale},</if>
  220. <if test="fansNumber != null">fans_number = #{fansNumber},</if>
  221. <if test="promoterUrl != null">promoter_url = #{promoterUrl},</if>
  222. <if test="phone != null">phone = #{phone},</if>
  223. <if test="consignee != null">consignee = #{consignee},</if>
  224. <if test="promoterAddress != null">promoter_address = #{promoterAddress},</if>
  225. <if test="state != null">state = #{state},</if>
  226. <if test="province != null">province = #{province},</if>
  227. <if test="commissionRequirement != null">commission_requirement = #{commissionRequirement},</if>
  228. <if test="categoryRequirement != null">category_requirement = #{categoryRequirement},</if>
  229. <if test="avgVideoSales != null">avg_video_sales = #{avgVideoSales},</if>
  230. <if test="videoSales != null">video_sales = #{videoSales},</if>
  231. <if test="createTime != null">create_time = #{createTime},</if>
  232. <if test="updateTime != null">update_time = #{updateTime},</if>
  233. </trim>
  234. where promoter_id = #{promoterId}
  235. </update>
  236. <delete id="deleteKuaishouPromoterById" parameterType="Long">
  237. delete
  238. from kuaishou_promoter
  239. where id = #{id}
  240. </delete>
  241. <delete id="deleteKuaishouPromoterByIds" parameterType="String">
  242. delete from kuaishou_promoter where id in
  243. <foreach item="id" collection="array" open="(" separator="," close=")">
  244. #{id}
  245. </foreach>
  246. </delete>
  247. <select id="getNearlyMonthGmv" resultType="com.alibaba.fastjson.JSONObject">
  248. SELECT SUM(order_amount) as 'orderAmount', CONCAT(IFNULL(ROUND((SELECT COUNT(1)
  249. FROM kuaishou_item_collect_samples
  250. WHERE collect_sample_status = 7
  251. AND promoter_id = #{promoterId})
  252. / (SELECT COUNT(1)
  253. FROM kuaishou_item_collect_samples
  254. WHERE collect_sample_status!=1 AND collect_sample_status!=2 AND promoter_id = #{promoterId})*100,2), 0),
  255. '%') as 'operationCompletionRate'
  256. FROM kuaishou_supply_chain
  257. WHERE promoter_id = #{promoterId}
  258. AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') >= #{start}
  259. AND FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') &lt;= #{end}
  260. </select>
  261. <insert id="insertKuaishouPromoterRecord" parameterType="com.alibaba.fastjson.JSONObject" useGeneratedKeys="true"
  262. keyProperty="id">
  263. insert into kuaishou_promoter_record
  264. <trim prefix="(" suffix=")" suffixOverrides=",">
  265. <if test="promoterId != null">promoter_id,</if>
  266. <if test="userId != null">user_id,</if>
  267. <if test="operatorId != null">operator_id,</if>
  268. </trim>
  269. <trim prefix="values (" suffix=")" suffixOverrides=",">
  270. <if test="promoterId != null">#{promoterId},</if>
  271. <if test="userId != null">#{userId},</if>
  272. <if test="operatorId != null">#{operatorId},</if>
  273. </trim>
  274. </insert>
  275. </mapper>