FsUserMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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.fs.store.mapper.FsUserMapper">
  6. <resultMap type="FsUser" id="FsUserResult">
  7. <result property="userId" column="user_id" />
  8. <result property="username" column="username" />
  9. <result property="password" column="password" />
  10. <result property="realName" column="real_name" />
  11. <result property="birthday" column="birthday" />
  12. <result property="idCard" column="id_card" />
  13. <result property="remark" column="remark" />
  14. <result property="nickname" column="nickname" />
  15. <result property="avatar" column="avatar" />
  16. <result property="phone" column="phone" />
  17. <result property="createTime" column="create_time" />
  18. <result property="updateTime" column="update_time" />
  19. <result property="lastIp" column="last_ip" />
  20. <result property="nowMoney" column="now_money" />
  21. <result property="brokeragePrice" column="brokerage_price" />
  22. <result property="integral" column="integral" />
  23. <result property="signNum" column="sign_num" />
  24. <result property="status" column="status" />
  25. <result property="level" column="level" />
  26. <result property="spreadUserId" column="spread_user_id" />
  27. <result property="spreadTime" column="spread_time" />
  28. <result property="userType" column="user_type" />
  29. <result property="isPromoter" column="is_promoter" />
  30. <result property="payCount" column="pay_count" />
  31. <result property="spreadCount" column="spread_count" />
  32. <result property="addres" column="addres" />
  33. <result property="maOpenId" column="ma_open_id" />
  34. <result property="mpOpenId" column="mp_open_id" />
  35. <result property="unionId" column="union_id" />
  36. <result property="isDel" column="is_del" />
  37. <result property="isWeixinAuth" column="is_weixin_auth" />
  38. <result property="companyId" column="company_id" />
  39. <result property="companyUserId" column="company_user_id" />
  40. <result property="registerDate" column="register_date" />
  41. <result property="registerCode" column="register_code" />
  42. <result property="source" column="source" />
  43. <result property="userCode" column="user_code" />
  44. <result property="isShow" column="is_show" />
  45. </resultMap>
  46. <sql id="selectFsUserVo">
  47. select user_id,is_show, username, password, real_name, birthday, id_card, remark, nickname, avatar, phone, create_time, update_time, last_ip, now_money, brokerage_price, integral, sign_num, status, level, spread_user_id, spread_time, user_type, is_promoter, pay_count, spread_count, addres,ma_open_id,mp_open_id,union_id, is_del,is_weixin_auth,company_id,company_user_id,register_date,register_code,source,user_code from fs_user
  48. </sql>
  49. <select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
  50. <include refid="selectFsUserVo"/>
  51. <where>
  52. <if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
  53. <if test="password != null and password != ''"> and password = #{password}</if>
  54. <if test="realName != null and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
  55. <if test="birthday != null "> and birthday = #{birthday}</if>
  56. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  57. <if test="remark != null and remark != ''"> and remark = #{remark}</if>
  58. <if test="nickname != null and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
  59. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  60. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  61. <if test="lastIp != null and lastIp != ''"> and last_ip = #{lastIp}</if>
  62. <if test="nowMoney != null "> and now_money = #{nowMoney}</if>
  63. <if test="brokeragePrice != null "> and brokerage_price = #{brokeragePrice}</if>
  64. <if test="integral != null "> and integral = #{integral}</if>
  65. <if test="signNum != null "> and sign_num = #{signNum}</if>
  66. <if test="status != null "> and status = #{status}</if>
  67. <if test="level != null "> and level = #{level}</if>
  68. <if test="spreadUserId != null "> and spread_user_id = #{spreadUserId}</if>
  69. <if test="spreadTime != null "> and spread_time = #{spreadTime}</if>
  70. <if test="userType != null and userType != ''"> and user_type = #{userType}</if>
  71. <if test="isPromoter != null "> and is_promoter = #{isPromoter}</if>
  72. <if test="payCount != null "> and pay_count = #{payCount}</if>
  73. <if test="spreadCount != null "> and spread_count = #{spreadCount}</if>
  74. <if test="addres != null and addres != ''"> and addres = #{addres}</if>
  75. <if test="isDel != null "> and is_del = #{isDel}</if>
  76. <if test="companyId != null "> and company_id = #{companyId}</if>
  77. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  78. <if test="registerDate != null "> and DATE_FORMAT(register_date,'%Y-%m-%d') = DATE_FORMAT(#{registerDate},'%Y-%m-%d')</if>
  79. <if test="registerCode != null and registerCode != '' "> and register_code = #{registerCode}</if>
  80. <if test="source != null and source != '' "> and source = #{source}</if>
  81. <if test="isShow != null "> and is_show = #{isShow}</if>
  82. </where>
  83. order by user_id desc
  84. </select>
  85. <select id="selectFsUserById" parameterType="Long" resultMap="FsUserResult">
  86. <include refid="selectFsUserVo"/>
  87. where user_id = #{userId}
  88. </select>
  89. <select id="selectFsUserListLimit" resultType="com.fs.store.domain.FsUser">
  90. <include refid="selectFsUserVo"/>
  91. <where>
  92. <if test="password != null and password != ''"> and password = #{password}</if>
  93. <if test="realName != null and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
  94. <if test="birthday != null "> and birthday = #{birthday}</if>
  95. <if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
  96. <if test="remark != null and remark != ''"> and remark = #{remark}</if>
  97. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  98. <if test="lastIp != null and lastIp != ''"> and last_ip = #{lastIp}</if>
  99. <if test="nowMoney != null "> and now_money = #{nowMoney}</if>
  100. <if test="brokeragePrice != null "> and brokerage_price = #{brokeragePrice}</if>
  101. <if test="integral != null "> and integral = #{integral}</if>
  102. <if test="signNum != null "> and sign_num = #{signNum}</if>
  103. <if test="status != null "> and status = #{status}</if>
  104. <if test="level != null "> and level = #{level}</if>
  105. <if test="spreadUserId != null "> and spread_user_id = #{spreadUserId}</if>
  106. <if test="spreadTime != null "> and spread_time = #{spreadTime}</if>
  107. <if test="userType != null and userType != ''"> and user_type = #{userType}</if>
  108. <if test="isPromoter != null "> and is_promoter = #{isPromoter}</if>
  109. <if test="payCount != null "> and pay_count = #{payCount}</if>
  110. <if test="spreadCount != null "> and spread_count = #{spreadCount}</if>
  111. <if test="addres != null and addres != ''"> and addres = #{addres}</if>
  112. <if test="isDel != null "> and is_del = #{isDel}</if>
  113. <if test="companyId != null "> and company_id = #{companyId}</if>
  114. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  115. <if test="registerDate != null "> and DATE_FORMAT(register_date,'%Y-%m-%d') = DATE_FORMAT(#{registerDate},'%Y-%m-%d')</if>
  116. <if test="registerCode != null and registerCode != '' "> and register_code = #{registerCode}</if>
  117. <if test="source != null and source != '' "> and source = #{source}</if>
  118. <if test="isShow != null "> and is_show = #{isShow}</if>
  119. <if test="(username != null and username != '') or (nickname != null and nickname != '') or (phone != null and phone != '')">
  120. and (
  121. <if test="username != null and username != ''"> username like concat('%', #{username}, '%')</if>
  122. <if test="nickname != null and nickname != ''"> or nickname like concat('%', #{nickname}, '%')</if>
  123. <if test="phone != null and phone != ''"> or phone like concat('%',#{phone},'%')</if>
  124. )
  125. </if>
  126. </where>
  127. order by user_id desc
  128. limit 10
  129. </select>
  130. <insert id="insertFsUser" parameterType="FsUser" useGeneratedKeys="true" keyProperty="userId">
  131. insert into fs_user
  132. <trim prefix="(" suffix=")" suffixOverrides=",">
  133. <if test="username != null">username,</if>
  134. <if test="password != null">password,</if>
  135. <if test="realName != null">real_name,</if>
  136. <if test="birthday != null">birthday,</if>
  137. <if test="idCard != null">id_card,</if>
  138. <if test="remark != null">remark,</if>
  139. <if test="nickname != null">nickname,</if>
  140. <if test="avatar != null">avatar,</if>
  141. <if test="phone != null">phone,</if>
  142. <if test="createTime != null">create_time,</if>
  143. <if test="updateTime != null">update_time,</if>
  144. <if test="lastIp != null">last_ip,</if>
  145. <if test="nowMoney != null">now_money,</if>
  146. <if test="brokeragePrice != null">brokerage_price,</if>
  147. <if test="integral != null">integral,</if>
  148. <if test="signNum != null">sign_num,</if>
  149. <if test="status != null">status,</if>
  150. <if test="level != null">level,</if>
  151. <if test="spreadUserId != null">spread_user_id,</if>
  152. <if test="spreadTime != null">spread_time,</if>
  153. <if test="userType != null and userType != ''">user_type,</if>
  154. <if test="isPromoter != null">is_promoter,</if>
  155. <if test="payCount != null">pay_count,</if>
  156. <if test="spreadCount != null">spread_count,</if>
  157. <if test="addres != null and addres != ''">addres,</if>
  158. <if test="maOpenId != null">ma_open_id,</if>
  159. <if test="mpOpenId != null">mp_open_id,</if>
  160. <if test="unionId != null">union_id,</if>
  161. <if test="isDel != null">is_del,</if>
  162. <if test="isWeixinAuth != null">is_weixin_auth,</if>
  163. <if test="companyId != null">company_id,</if>
  164. <if test="companyUserId != null">company_user_id,</if>
  165. <if test="registerDate != null">register_date,</if>
  166. <if test="registerCode != null">register_code,</if>
  167. <if test="source != null">source,</if>
  168. <if test="userCode != null">user_code,</if>
  169. <if test="isShow != null">is_show,</if>
  170. </trim>
  171. <trim prefix="values (" suffix=")" suffixOverrides=",">
  172. <if test="username != null">#{username},</if>
  173. <if test="password != null">#{password},</if>
  174. <if test="realName != null">#{realName},</if>
  175. <if test="birthday != null">#{birthday},</if>
  176. <if test="idCard != null">#{idCard},</if>
  177. <if test="remark != null">#{remark},</if>
  178. <if test="nickname != null">#{nickname},</if>
  179. <if test="avatar != null">#{avatar},</if>
  180. <if test="phone != null">#{phone},</if>
  181. <if test="createTime != null">#{createTime},</if>
  182. <if test="updateTime != null">#{updateTime},</if>
  183. <if test="lastIp != null">#{lastIp},</if>
  184. <if test="nowMoney != null">#{nowMoney},</if>
  185. <if test="brokeragePrice != null">#{brokeragePrice},</if>
  186. <if test="integral != null">#{integral},</if>
  187. <if test="signNum != null">#{signNum},</if>
  188. <if test="status != null">#{status},</if>
  189. <if test="level != null">#{level},</if>
  190. <if test="spreadUserId != null">#{spreadUserId},</if>
  191. <if test="spreadTime != null">#{spreadTime},</if>
  192. <if test="userType != null and userType != ''">#{userType},</if>
  193. <if test="isPromoter != null">#{isPromoter},</if>
  194. <if test="payCount != null">#{payCount},</if>
  195. <if test="spreadCount != null">#{spreadCount},</if>
  196. <if test="addres != null and addres != ''">#{addres},</if>
  197. <if test="maOpenId != null">#{maOpenId},</if>
  198. <if test="mpOpenId != null">#{mpOpenId},</if>
  199. <if test="unionId != null">#{unionId},</if>
  200. <if test="isDel != null">#{isDel},</if>
  201. <if test="isWeixinAuth != null">#{isWeixinAuth},</if>
  202. <if test="companyId != null">#{companyId},</if>
  203. <if test="companyUserId != null">#{companyUserId},</if>
  204. <if test="registerDate != null">#{registerDate},</if>
  205. <if test="registerCode != null">#{registerCode},</if>
  206. <if test="source != null">#{source},</if>
  207. <if test="userCode != null">#{userCode},</if>
  208. <if test="isShow != null">#{isShow},</if>
  209. </trim>
  210. </insert>
  211. <update id="updateFsUser" parameterType="FsUser">
  212. update fs_user
  213. <trim prefix="SET" suffixOverrides=",">
  214. <if test="username != null">username = #{username},</if>
  215. <if test="password != null">password = #{password},</if>
  216. <if test="realName != null">real_name = #{realName},</if>
  217. <if test="birthday != null">birthday = #{birthday},</if>
  218. <if test="idCard != null">id_card = #{idCard},</if>
  219. <if test="remark != null">remark = #{remark},</if>
  220. <if test="nickname != null">nickname = #{nickname},</if>
  221. <if test="avatar != null">avatar = #{avatar},</if>
  222. <if test="phone != null">phone = #{phone},</if>
  223. <if test="createTime != null">create_time = #{createTime},</if>
  224. <if test="updateTime != null">update_time = #{updateTime},</if>
  225. <if test="lastIp != null">last_ip = #{lastIp},</if>
  226. <if test="nowMoney != null">now_money = #{nowMoney},</if>
  227. <if test="brokeragePrice != null">brokerage_price = #{brokeragePrice},</if>
  228. <if test="integral != null">integral = #{integral},</if>
  229. <if test="signNum != null">sign_num = #{signNum},</if>
  230. <if test="status != null">status = #{status},</if>
  231. <if test="level != null">level = #{level},</if>
  232. <if test="spreadUserId != null">spread_user_id = #{spreadUserId},</if>
  233. <if test="spreadTime != null">spread_time = #{spreadTime},</if>
  234. <if test="userType != null and userType != ''">user_type = #{userType},</if>
  235. <if test="isPromoter != null">is_promoter = #{isPromoter},</if>
  236. <if test="payCount != null">pay_count = #{payCount},</if>
  237. <if test="spreadCount != null">spread_count = #{spreadCount},</if>
  238. <if test="addres != null and addres != ''">addres = #{addres},</if>
  239. <if test="maOpenId != null">ma_open_id = #{maOpenId},</if>
  240. <if test="mpOpenId != null">mp_open_id = #{mpOpenId},</if>
  241. <if test="unionId != null">union_id = #{unionId},</if>
  242. <if test="isDel != null">is_del = #{isDel},</if>
  243. <if test="isWeixinAuth != null">is_weixin_auth = #{isWeixinAuth},</if>
  244. <if test="companyId != null">company_id = #{companyId},</if>
  245. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  246. <if test="registerDate != null">register_date = #{registerDate},</if>
  247. <if test="registerCode != null">register_code = #{registerCode},</if>
  248. <if test="source != null">source = #{source},</if>
  249. <if test="userCode != null">user_code = #{userCode},</if>
  250. <if test="isShow != null">is_show = #{isShow},</if>
  251. </trim>
  252. where user_id = #{userId}
  253. </update>
  254. <delete id="deleteFsUserById" parameterType="Long">
  255. delete from fs_user where user_id = #{userId}
  256. </delete>
  257. <delete id="deleteFsUserByIds" parameterType="String">
  258. delete from fs_user where user_id in
  259. <foreach item="userId" collection="array" open="(" separator="," close=")">
  260. #{userId}
  261. </foreach>
  262. </delete>
  263. <select id="selectFsUserPageList" resultType="FsUserPageListVO">
  264. SELECT
  265. fs_user.*,
  266. fs_user_course_count.id,
  267. fs_user_course_count.user_id,
  268. fs_user_course_count.watch_course_count,
  269. fs_user_course_count.miss_course_count,
  270. fs_user_course_count.miss_course_status,
  271. fs_user_course_count.course_id,
  272. fs_user_course_count.part_course_count,
  273. fs_user_course_count.last_watch_date,
  274. fs_user_course_count.STATUS AS courseCountStatus,
  275. fs_user_course_count.stop_watch_days,
  276. fs_user_course_count.create_time,
  277. fs_user_course_count.complete_watch_date,
  278. company_tag.tag,
  279. company_tag_user.tag_ids,
  280. company_user.nick_name as companyUserNickName
  281. FROM
  282. fs_user
  283. left join company_user on fs_user.company_user_id = company_user.user_id
  284. LEFT JOIN fs_user_course_count ON fs_user.user_id = fs_user_course_count.user_id
  285. LEFT JOIN company_tag_user ON fs_user.user_id = company_tag_user.user_id
  286. LEFT JOIN company_tag ON FIND_IN_SET(company_tag.tag_id, company_tag_user.tag_ids) > 0
  287. where company_user.parent_id = #{userId}
  288. <if test="companyUserId != null and companyUserId !='' ">
  289. and company_user.user_id = #{companyUserId}
  290. </if>
  291. <choose>
  292. <when test = "isBlack">
  293. AND fs_user.status = 0
  294. </when>
  295. <otherwise>
  296. AND fs_user.status = 1
  297. </otherwise>
  298. </choose>
  299. <if test="keyword != null and keyword !='' ">
  300. AND (fs_user.nickname LIKE concat('%',#{keyword},'%')
  301. or fs_user.phone LIKE concat('%',#{keyword},'%')
  302. )
  303. </if>
  304. <if test="registerStartTime != null and registerStartTime !='' ">
  305. AND fs_user.create_time &gt;= #{registerStartTime}
  306. </if>
  307. <if test="registerEndTime != null and registerEndTime !='' ">
  308. AND fs_user.create_time &lt;= #{registerEndTime}
  309. </if>
  310. <if test="tagIds != null and tagIds.length > 0">
  311. AND
  312. <foreach collection="tagIds" item="item" index="index" open="(" separator="or" close=")">
  313. company_tag_user.tag_ids LIKE concat('%"',#{item},'"%')
  314. </foreach>
  315. </if>
  316. <if test="tabValue != null and tabValue !='' ">
  317. <choose>
  318. <when test = "tabValue == 1">
  319. AND DAY(fs_user.create_time) = DAY(NOW())
  320. </when>
  321. <when test = "tabValue == 2">
  322. AND DAY(fs_user_course_count.complete_watch_date) = DAY(NOW())
  323. </when>
  324. <when test = "tabValue == 3">
  325. AND fs_user_course_count.status = 3
  326. </when>
  327. </choose>
  328. </if>
  329. <if test="watchCourseType != null and watchCourseType !='' ">
  330. <choose>
  331. <when test = "watchCourseType == 1">
  332. AND fs_user_course_count.status = 3
  333. </when>
  334. <when test = "watchCourseType == 2">
  335. AND fs_user_course_count.status = 1
  336. </when>
  337. <when test = "watchCourseType == 3">
  338. AND fs_user_course_count.status = 2
  339. </when>
  340. </choose>
  341. </if>
  342. <if test="missCourseStatus != null and missCourseStatus !='' ">
  343. <choose>
  344. <when test = "missCourseStatus == 1">
  345. AND fs_user_course_count.miss_course_status = 1
  346. </when>
  347. <when test = "missCourseStatus == 2">
  348. AND fs_user_course_count.miss_course_status = 2
  349. </when>
  350. </choose>
  351. </if>
  352. <if test="continueMissCourseSort != null and continueMissCourseSort !='' ">
  353. order by
  354. <choose>
  355. <when test = "continueMissCourseSort == 0">
  356. fs_user_course_count.miss_course_days desc
  357. </when>
  358. <when test = "continueMissCourseSort == 1">
  359. fs_user_course_count.miss_course_days asc
  360. </when>
  361. <when test = "continueMissCourseSort == 2">
  362. fs_user.create_time desc
  363. </when>
  364. <when test = "continueMissCourseSort == 3">
  365. fs_user.nickname asc
  366. </when>
  367. </choose>
  368. </if>
  369. </select>
  370. <select id="getUserNumber" resultType="UserListCountVO">
  371. SELECT
  372. fs_user.`status` as status,
  373. count( fs_user.user_id ) as num
  374. FROM
  375. fs_user
  376. LEFT JOIN company_user ON fs_user.company_user_id = company_user.user_id
  377. WHERE
  378. company_user.parent_id = #{userId}
  379. GROUP BY
  380. fs_user.`status`
  381. </select>
  382. <select id="getCountAnswer" resultType="UserDetailsVO">
  383. SELECT
  384. (
  385. SELECT
  386. ifnull(count( DISTINCT log_id ), 0) AS answerTime
  387. FROM
  388. fs_course_answer_logs
  389. LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
  390. LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
  391. WHERE
  392. company_user.parent_id = #{userId}
  393. <if test="dateTag != null and dateTag !='' ">
  394. <choose>
  395. <when test = "dateTag == '今天'">
  396. and to_days(fs_course_answer_logs.create_time) = to_days(now())
  397. </when>
  398. <when test = "dateTag == ' 昨天'">
  399. and to_days(now()) - to_days(fs_course_answer_logs.create_time) &lt;= 1
  400. </when>
  401. <when test = "dateTag == '前天'">
  402. and to_days(now()) - to_days(fs_course_answer_logs.create_time) &lt;= 2
  403. </when>
  404. <when test = "dateTag == '近七天'">
  405. and DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(fs_course_answer_logs.create_time)
  406. </when>
  407. </choose>
  408. </if>
  409. GROUP BY
  410. fs_user.user_id
  411. HAVING
  412. fs_user.user_id = #{fsUserId}
  413. ) AS answerTime,
  414. (
  415. SELECT
  416. ifnull(count( DISTINCT log_id ), 0) AS answerRightTime
  417. FROM
  418. fs_course_answer_logs
  419. LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
  420. LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
  421. WHERE
  422. company_user.parent_id = #{userId}
  423. AND fs_course_answer_logs.is_right = 1
  424. <if test="dateTag != null and dateTag !='' ">
  425. <choose>
  426. <when test = "dateTag == '今天'">
  427. and to_days(fs_course_answer_logs.create_time) = to_days(now())
  428. </when>
  429. <when test = "dateTag == ' 昨天'">
  430. and to_days(now()) - to_days(fs_course_answer_logs.create_time) &lt;= 1
  431. </when>
  432. <when test = "dateTag == '前天'">
  433. and to_days(now()) - to_days(fs_course_answer_logs.create_time) &lt;= 2
  434. </when>
  435. <when test = "dateTag == '近七天'">
  436. and DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(fs_course_answer_logs.create_time)
  437. </when>
  438. </choose>
  439. </if>
  440. GROUP BY
  441. fs_user.user_id
  442. HAVING
  443. fs_user.user_id = #{fsUserId}
  444. ) AS answerRightTime;
  445. </select>
  446. <select id="getCountRedPacket" resultType="com.fs.store.vo.h5.UserDetailsVO">
  447. SELECT
  448. ifnull( count( DISTINCT log_id ), 0 ) AS answerRedPacketTime,
  449. ifnull( sum( amount ), 0 ) AS answerRedPacketAmount,
  450. ifnull( complete_watch_count, 0 ) AS completeWatchCount ,
  451. ifnull( watch_times, 0 ) AS watchTimes,
  452. fs_user.user_id
  453. FROM
  454. fs_course_red_packet_log
  455. LEFT JOIN fs_user ON fs_user.user_id = fs_course_red_packet_log.user_id
  456. LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
  457. LEFT JOIN fs_user_course_count ON fs_user_course_count.user_id = fs_user.user_id
  458. WHERE
  459. company_user.parent_id = #{userId}
  460. <if test="dateTag != null and dateTag !='' ">
  461. <choose>
  462. <when test = "dateTag == '今天'">
  463. and to_days(fs_course_red_packet_log.create_time) = to_days(now())
  464. </when>
  465. <when test = "dateTag == ' 昨天'">
  466. and to_days(now()) - to_days(fs_course_red_packet_log.create_time) &lt;= 1
  467. </when>
  468. <when test = "dateTag == '前天'">
  469. and to_days(now()) - to_days(fs_course_red_packet_log.create_time) &lt;= 2
  470. </when>
  471. <when test = "dateTag == '近七天'">
  472. and DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(fs_course_red_packet_log.create_time)
  473. </when>
  474. </choose>
  475. </if>
  476. GROUP BY
  477. fs_user.user_id
  478. HAVING
  479. fs_user.user_id = #{fsUserId}
  480. </select>
  481. <update id="batchUpdateFsUserByIds" parameterType="Long">
  482. update fs_user
  483. set status = #{status} where user_id in
  484. <foreach item="id" collection="ids" open="(" separator="," close=")">
  485. #{id}
  486. </foreach>
  487. </update>
  488. </mapper>