UserMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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.zhongzheng.modules.user.mapper.UserMapper">
  6. <resultMap type="com.zhongzheng.modules.user.domain.User" id="UserResult">
  7. <result property="userId" column="user_id"/>
  8. <result property="userAccount" column="user_account"/>
  9. <result property="nickname" column="nickname"/>
  10. <result property="realname" column="realname"/>
  11. <result property="sex" column="sex"/>
  12. <result property="idCard" column="id_card"/>
  13. <result property="telphone" column="telphone"/>
  14. <result property="userLevel" column="user_level"/>
  15. <result property="userBirth" column="user_birth"/>
  16. <result property="eduLevel" column="edu_level"/>
  17. <result property="schoolId" column="school_id"/>
  18. <result property="major" column="major"/>
  19. <result property="entranceTime" column="entrance_time"/>
  20. <result property="openId" column="open_id"/>
  21. <result property="idCardImg1" column="id_card_img1"/>
  22. <result property="idCardImg2" column="id_card_img2"/>
  23. <result property="country" column="country"/>
  24. <result property="province" column="province"/>
  25. <result property="city" column="city"/>
  26. <result property="integral" column="integral"/>
  27. <result property="createTime" column="create_time"/>
  28. <result property="updateTime" column="update_time"/>
  29. <result property="status" column="status"/>
  30. <result property="unionId" column="union_id"/>
  31. <result property="registerPlat" column="register_plat"/>
  32. <result property="lastLoginIp" column="last_login_ip"/>
  33. <result property="lastLoginTime" column="last_login_time"/>
  34. <result property="certified" column="certified"/>
  35. <result property="certifiedTime" column="certified_time"/>
  36. <result property="district" column="district"/>
  37. <result property="marry" column="marry"/>
  38. <result property="houseProvince" column="house_province"/>
  39. <result property="houseCity" column="house_city"/>
  40. <result property="houseDistrict" column="house_district"/>
  41. <result property="oneInchPhotos" column="one_inch_photos"/>
  42. <result property="politic" column="politic"/>
  43. <result property="email" column="email"/>
  44. <result property="avatar" column="avatar"/>
  45. <result property="inviteUserAccount" column="invite_user_account"/>
  46. <result property="courseNum" column="course_num"/>
  47. <result property="studyTime" column="study_time"/>
  48. <result property="password" column="password"/>
  49. <result property="goodsCourseNum" column="goods_course_num"/>
  50. <result property="goodsBankNum" column="goods_bank_num"/>
  51. </resultMap>
  52. <resultMap type="com.zhongzheng.modules.user.vo.RanKingUser" id="RanKingUserResult">
  53. <result property="hourse" column="sum_study"/>
  54. <result property="avatar" column="avatar"/>
  55. <result property="nickname" column="nickname"/>
  56. <result property="rank" column="pm"/>
  57. </resultMap>
  58. <resultMap type="com.zhongzheng.modules.user.vo.UserStudyRecordVo" id="StudyRecordResult">
  59. <result property="telphone" column="telphone"/>
  60. <result property="realname" column="realname"/>
  61. <result property="endTime" column="end_time"/>
  62. <result property="startTime" column="start_time"/>
  63. <result property="title" column="title"/>
  64. <result property="courseName" column="course_name"/>
  65. <result property="studyDuration" column="study_duration"/>
  66. </resultMap>
  67. <select id="selectByRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
  68. SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
  69. LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
  70. <if test="userId != null and userId != ''">
  71. AND u.user_id = #{userId}
  72. </if>
  73. <if test="startTime != null and startTime != ''">
  74. AND s.create_time BETWEEN #{startTime} and #{endTime}
  75. </if>
  76. GROUP BY u.user_id
  77. </select>
  78. <select id="selectByRanks" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
  79. SELECT A.*
  80. FROM
  81. (
  82. SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
  83. LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
  84. <if test="startTime != null and startTime != ''">
  85. AND s.create_time BETWEEN #{startTime} and #{endTime}
  86. </if>
  87. GROUP BY u.user_id ORDER BY sum_study desc LIMIT 20
  88. ) A where
  89. A.sum_study >0
  90. </select>
  91. <select id="selectByRankOne" parameterType="integer" resultType="int">
  92. SELECT
  93. COUNT(s.sum_study)
  94. FROM
  95. (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1 GROUP BY s.user_id) s
  96. WHERE s.sum_study >= #{hourse}
  97. </select>
  98. <select id="selectByRankOneByTime" parameterType="map" resultType="int">
  99. SELECT
  100. COUNT(s.sum_study)
  101. FROM
  102. (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1
  103. <if test="startTime != null and startTime != ''">
  104. and s.create_time BETWEEN #{startTime} and #{endTime}
  105. </if>
  106. GROUP BY s.user_id) s
  107. WHERE s.sum_study >= #{hourse}
  108. </select>
  109. <select id="selectByOneRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
  110. SELECT u.nickname,u.avatar FROM `user` u
  111. where 1=1
  112. <if test="userId != null and userId != ''">
  113. AND u.user_id = #{userId}
  114. </if>
  115. GROUP BY u.user_id
  116. </select>
  117. <select id="selectUserNum" parameterType="integer" resultType="int">
  118. SELECT
  119. COUNT(user_id)
  120. FROM
  121. `user`
  122. WHERE 1=1 and user_level = #{grade}
  123. </select>
  124. <select id="selectList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  125. SELECT
  126. u.*
  127. <if test="getOrderNum != null and getOrderNum == 1" >
  128. ,ou.goods_course_num,ou.goods_bank_num
  129. </if>
  130. FROM
  131. `user` u
  132. <if test="getOrderNum != null and getOrderNum == 1" >
  133. LEFT JOIN (
  134. SELECT
  135. sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
  136. sum( CASE WHEN g.goods_type = 2 THEN 1 ELSE 0 END ) AS goods_bank_num,
  137. o.user_id
  138. FROM
  139. `order` o
  140. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  141. LEFT JOIN goods g ON og.goods_id = g.goods_id
  142. WHERE o.`status` = 1
  143. AND og.refund_status in (0,1,3)
  144. AND og.pay_status in (2,3)
  145. GROUP BY
  146. o.user_id
  147. ) ou ON u.user_id = ou.user_id
  148. </if>
  149. WHERE
  150. 1 = 1
  151. <if test="status != null and status.size()!=0 ">
  152. AND u.status in
  153. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. <if test="nickname != null and nickname != ''" >
  158. AND u.nickname like concat('%', #{nickname}, '%')
  159. </if>
  160. <if test="telphone != null and telphone != ''" >
  161. AND u.telphone = #{telphone}
  162. </if>
  163. <if test="idCard != null and idCard != ''" >
  164. AND u.id_card = #{idCard}
  165. </if>
  166. <if test="realname != null and realname != ''" >
  167. AND u.realname like concat('%', #{realname}, '%')
  168. </if>
  169. <if test="userId != null and userId != ''" >
  170. AND u.user_id = #{userId}
  171. </if>
  172. <if test="empty != null and empty != ''" >
  173. and u.realname is NOT NULL
  174. </if>
  175. <if test="gradePoint != null and gradePoint == 1" >
  176. AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) > 0
  177. </if>
  178. <if test="gradePoint != null and gradePoint == 2" >
  179. AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) = 0
  180. </if>
  181. </select>
  182. <select id="selectStudyRecordList" resultMap="StudyRecordResult">
  183. SELECT
  184. usr.study_duration,
  185. c.course_name,
  186. pv.title,
  187. usr.start_time,
  188. usr.end_time,
  189. u.realname,
  190. u.telphone
  191. FROM
  192. user_study_record usr
  193. LEFT JOIN course c ON usr.course_id = c.course_id
  194. LEFT JOIN course_section cs ON usr.section_id = cs.section_id
  195. LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
  196. LEFT JOIN `user` u ON usr.user_id = u.user_id
  197. WHERE 1=1
  198. <if test="userId != null and userId != ''" >
  199. AND usr.user_id = #{userId}
  200. </if>
  201. <if test="courseName != null and courseName != ''" >
  202. AND c.course_name like concat('%', #{courseName}, '%')
  203. </if>
  204. <if test="title != null and title != ''" >
  205. AND pv.title like concat('%', #{title}, '%')
  206. </if>
  207. <if test="startTime1 != null and startTime1 != ''" >
  208. AND usr.start_time > #{startTime1}
  209. </if>
  210. <if test="startTime2 != null and startTime2 != ''" >
  211. AND #{startTime2} > usr.start_time
  212. </if>
  213. <if test="endTime1 != null and endTime1 != ''" >
  214. AND usr.end_time > #{endTime1}
  215. </if>
  216. <if test="endTime2 != null and endTime2 != ''" >
  217. AND #{endTime2} > usr.end_time
  218. </if>
  219. ORDER BY
  220. usr.record_id DESC
  221. </select>
  222. <select id="selectLookNum" parameterType="Long" resultType="integer">
  223. SELECT
  224. COUNT( user_id )
  225. FROM
  226. recruit_interview_message
  227. WHERE
  228. 1 = 1
  229. AND user_id = #{userId}
  230. AND look_status = 0
  231. </select>
  232. <select id="periodSum" parameterType="Long" resultType="Long">
  233. SELECT
  234. COUNT(1)
  235. FROM
  236. user_period up
  237. LEFT JOIN user_period_status ups ON ups.period_id = up.id
  238. LEFT JOIN class_grade_user cgu on up.grade_id = cgu.grade_id and up.user_id = cgu.user_id
  239. WHERE
  240. up.user_id = #{userId}
  241. and ups.period_status =1
  242. and cgu.change_grade = 0
  243. and ups.`status` in (0,3)
  244. </select>
  245. <select id="subscribeSum" parameterType="Long" resultType="Long">
  246. SELECT
  247. COUNT(1)
  248. FROM
  249. user_subscribe us
  250. WHERE
  251. us.user_id = #{userId}
  252. AND us.subscribe_status = 1
  253. and (us.exam_expend is null or us.exam_expend = 0)
  254. </select>
  255. <select id="informSum" parameterType="Long" resultType="Long">
  256. SELECT
  257. COUNT(1)
  258. FROM
  259. inform_user iu
  260. WHERE
  261. iu.user_id = #{userId}
  262. and iu.receipt_status = 0
  263. and iu.system_status in (1,2)
  264. </select>
  265. <select id="orderSum" parameterType="Long" resultType="Long">
  266. SELECT
  267. COUNT( 1 )
  268. FROM
  269. `order`
  270. WHERE
  271. user_id = #{userId}
  272. AND order_status =0
  273. </select>
  274. </mapper>