UserMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  13. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  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. <result property="importNo" column="import_no"/>
  52. <result property="goodsLiveNum" column="goods_live_num"/>
  53. <result property="userBindWx" column="user_bind_wx"/>
  54. <result property="userFollowWx" column="user_follow_wx"/>
  55. <result property="lastVisitTime" column="last_visit_time"/>
  56. <result property="visitFromPlat" column="visit_from_plat"/>
  57. <result property="studyFromPlat" column="study_from_plat"/>
  58. <result property="lastStudyTime" column="last_study_time"/>
  59. <result property="job" column="job"/>
  60. <result property="shareCode" column="share_code"/>
  61. <result property="pwdTime" column="pwd_time"/>
  62. </resultMap>
  63. <resultMap type="com.zhongzheng.modules.user.vo.RanKingUser" id="RanKingUserResult">
  64. <result property="hourse" column="sum_study"/>
  65. <result property="avatar" column="avatar"/>
  66. <result property="nickname" column="nickname"/>
  67. <result property="rank" column="pm"/>
  68. </resultMap>
  69. <resultMap type="com.zhongzheng.modules.user.vo.UserStudyRecordVo" id="StudyRecordResult">
  70. <result property="telphone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  71. <result property="realname" column="realname"/>
  72. <result property="endTime" column="end_time"/>
  73. <result property="startTime" column="start_time"/>
  74. <result property="title" column="title"/>
  75. <result property="courseName" column="course_name"/>
  76. <result property="studyDuration" column="study_duration"/>
  77. </resultMap>
  78. <select id="selectByRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
  79. SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
  80. LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
  81. <if test="userId != null and userId != ''">
  82. AND u.user_id = #{userId}
  83. </if>
  84. <if test="startTime != null and startTime != ''">
  85. AND s.create_time BETWEEN #{startTime} and #{endTime}
  86. </if>
  87. GROUP BY u.user_id
  88. </select>
  89. <select id="selectByRanks" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
  90. SELECT A.*
  91. FROM
  92. (
  93. SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
  94. LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
  95. <if test="startTime != null and startTime != ''">
  96. AND s.create_time BETWEEN #{startTime} and #{endTime}
  97. </if>
  98. GROUP BY u.user_id ORDER BY sum_study desc LIMIT 20
  99. ) A where
  100. A.sum_study >0
  101. </select>
  102. <select id="selectByRankOne" parameterType="integer" resultType="int">
  103. SELECT
  104. COUNT(s.sum_study)
  105. FROM
  106. (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1 GROUP BY s.user_id) s
  107. WHERE s.sum_study >= #{hourse}
  108. </select>
  109. <select id="selectByRankOneByTime" parameterType="map" resultType="int">
  110. SELECT
  111. COUNT(s.sum_study)
  112. FROM
  113. (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1
  114. <if test="startTime != null and startTime != ''">
  115. and s.create_time BETWEEN #{startTime} and #{endTime}
  116. </if>
  117. GROUP BY s.user_id) s
  118. WHERE s.sum_study >= #{hourse}
  119. </select>
  120. <select id="selectByOneRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
  121. SELECT u.nickname,u.avatar FROM `user` u
  122. where 1=1
  123. <if test="userId != null and userId != ''">
  124. AND u.user_id = #{userId}
  125. </if>
  126. GROUP BY u.user_id
  127. </select>
  128. <select id="selectUserNum" parameterType="integer" resultType="int">
  129. SELECT
  130. COUNT(user_id)
  131. FROM
  132. `user`
  133. WHERE 1=1 and user_level = #{grade}
  134. </select>
  135. <select id="selectList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  136. SELECT DISTINCT
  137. u.*,
  138. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx
  139. <if test="getOrderNum != null and getOrderNum == 1" >
  140. ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
  141. </if>
  142. FROM
  143. `user` u
  144. <if test="getOrderNum != null and getOrderNum == 1" >
  145. LEFT JOIN (
  146. SELECT
  147. sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
  148. sum( CASE WHEN g.goods_type = 2 THEN 1 ELSE 0 END ) AS goods_bank_num,
  149. sum( CASE WHEN g.goods_type = 6 THEN 1 ELSE 0 END ) AS goods_live_num,
  150. o.user_id
  151. FROM
  152. `order` o
  153. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  154. LEFT JOIN goods g ON og.goods_id = g.goods_id
  155. WHERE o.`status` = 1
  156. AND og.refund_status in (0,1,3)
  157. AND og.pay_status in (2,3,4)
  158. GROUP BY
  159. o.user_id
  160. ) ou ON u.user_id = ou.user_id
  161. </if>
  162. <if test="businessId != null and businessId != ''">
  163. LEFT JOIN `order` o ON u.user_id = o.user_id and o.`status` = 1
  164. LEFT JOIN order_goods og ON o.order_sn = og.order_sn and og.`status` = 1
  165. LEFT JOIN goods g ON og.goods_id = g.goods_id
  166. </if>
  167. WHERE
  168. 1 = 1
  169. <if test="status != null and status.size()!=0 ">
  170. AND u.status in
  171. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  172. #{item}
  173. </foreach>
  174. </if>
  175. <if test="businessId != null and businessId != ''">
  176. and og.`status` = 1
  177. and og.refund_status in (0,1,3)
  178. and og.pay_status in (2,3,4)
  179. AND g.business_id = #{businessId}
  180. </if>
  181. <if test="startTime != null and startTime != ''">
  182. AND u.create_time &gt; #{startTime}
  183. </if>
  184. <if test="endTime != null and endTime != ''">
  185. AND u.create_time &lt; #{endTime}
  186. </if>
  187. <if test="userKerWord != null and userKerWord != ''" >
  188. AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  189. </if>
  190. <if test="nickname != null and nickname != ''" >
  191. AND u.nickname like concat('%', #{nickname}, '%')
  192. </if>
  193. <if test="telphone != null and telphone != ''" >
  194. AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  195. </if>
  196. <if test="idCard != null and idCard != ''" >
  197. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  198. </if>
  199. <if test="realname != null and realname != ''" >
  200. AND u.realname like concat('%', #{realname}, '%')
  201. </if>
  202. <if test="companyName != null and companyName != ''" >
  203. AND u.company_name like concat('%', #{companyName}, '%')
  204. </if>
  205. <if test="userId != null and userId != ''" >
  206. AND u.user_id = #{userId}
  207. </if>
  208. <if test="empty != null and empty != ''" >
  209. and u.realname is NOT NULL
  210. </if>
  211. <if test="goodsSearchKey != null and goodsSearchKey != ''" >
  212. and ( SELECT
  213. count(og.*)
  214. FROM
  215. `order` o
  216. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  217. where 1=1
  218. and og.`status` = 1
  219. and og.refund_status in (0,1,3)
  220. and og.pay_status in (2,3,4))
  221. and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
  222. and o.user_id = u.user_id)>0
  223. </if>
  224. <if test="goodsSearchKey != null and goodsSearchKey != ''" >
  225. and ( SELECT
  226. count(*)
  227. FROM
  228. `order` o
  229. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  230. LEFT JOIN goods g on og.goods_id = g.goods_id
  231. where 1=1
  232. and og.`status` = 1
  233. and og.refund_status in (0,1,3)
  234. and og.pay_status in (2,3,4)
  235. and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
  236. and o.user_id = u.user_id)>0
  237. </if>
  238. <if test="gradePoint != null and gradePoint == 1" >
  239. 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
  240. </if>
  241. <if test="gradePoint != null and gradePoint == 2" >
  242. 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
  243. </if>
  244. <if test="searchKey != null and searchKey != '' and searchType == 0 ">
  245. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  246. </if>
  247. <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
  248. AND u.id_card in
  249. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  250. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  251. </foreach>
  252. </if>
  253. <if test="searchType == 1" >
  254. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
  255. u.id_card in
  256. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  257. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  258. </foreach>)
  259. </if>
  260. <if test="hasBindWx != null and hasBindWx == 1 ">
  261. AND u.union_id is not null
  262. </if>
  263. <if test="hasBindWx != null and hasBindWx == 0 ">
  264. AND u.union_id is null
  265. </if>
  266. <if test="visitStartTime != null and visitStartTime !=''">
  267. and (SELECT
  268. count(*)
  269. FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >= create_time)>0
  270. </if>
  271. <if test="studyStartTime != null and studyStartTime !=''">
  272. and (SELECT
  273. count(*)
  274. FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >= create_time)>0
  275. </if>
  276. <if test="gradeName != null and gradeName != ''">
  277. and ( SELECT
  278. count(*)
  279. FROM
  280. `order` o
  281. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  282. LEFT JOIN class_grade cg on cg.grade_id = og.grade_id
  283. where 1=1
  284. and og.`status` = 1
  285. and og.refund_status in (0,1,3)
  286. and og.pay_status in (2,3,4)
  287. and (cg.class_name like concat('%', #{gradeName}, '%'))
  288. and o.user_id = u.user_id)>0
  289. </if>
  290. ORDER BY u.user_id DESC
  291. </select>
  292. <select id="selectListNoTenant" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  293. SELECT DISTINCT
  294. u.*,
  295. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx
  296. <if test="getOrderNum != null and getOrderNum == 1" >
  297. ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
  298. </if>
  299. FROM
  300. `user` u
  301. <if test="getOrderNum != null and getOrderNum == 1" >
  302. LEFT JOIN (
  303. SELECT
  304. sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
  305. sum( CASE WHEN g.goods_type = 2 THEN 1 ELSE 0 END ) AS goods_bank_num,
  306. sum( CASE WHEN g.goods_type = 6 THEN 1 ELSE 0 END ) AS goods_live_num,
  307. o.user_id
  308. FROM
  309. `order` o
  310. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  311. LEFT JOIN goods g ON og.goods_id = g.goods_id
  312. WHERE o.`status` = 1
  313. AND og.refund_status in (0,1,3)
  314. AND og.pay_status in (2,3,4)
  315. GROUP BY
  316. o.user_id
  317. ) ou ON u.user_id = ou.user_id
  318. </if>
  319. <if test="businessId != null and businessId != ''">
  320. LEFT JOIN `order` o ON u.user_id = o.user_id and o.`status` = 1
  321. LEFT JOIN order_goods og ON o.order_sn = og.order_sn and og.`status` = 1
  322. LEFT JOIN goods g ON og.goods_id = g.goods_id
  323. </if>
  324. WHERE
  325. 1 = 1
  326. <if test="status != null and status.size()!=0 ">
  327. AND u.status in
  328. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  329. #{item}
  330. </foreach>
  331. </if>
  332. <if test="businessId != null and businessId != ''">
  333. and og.`status` = 1
  334. and og.refund_status in (0,1,3)
  335. and og.pay_status in (2,3,4)
  336. AND g.business_id = #{businessId}
  337. </if>
  338. <if test="startTime != null and startTime != ''">
  339. AND u.create_time &gt; #{startTime}
  340. </if>
  341. <if test="endTime != null and endTime != ''">
  342. AND u.create_time &lt; #{endTime}
  343. </if>
  344. <if test="userKerWord != null and userKerWord != ''" >
  345. AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  346. </if>
  347. <if test="nickname != null and nickname != ''" >
  348. AND u.nickname like concat('%', #{nickname}, '%')
  349. </if>
  350. <if test="telphone != null and telphone != ''" >
  351. AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  352. </if>
  353. <if test="idCard != null and idCard != ''" >
  354. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  355. </if>
  356. <if test="realname != null and realname != ''" >
  357. AND u.realname like concat('%', #{realname}, '%')
  358. </if>
  359. <if test="companyName != null and companyName != ''" >
  360. AND u.company_name like concat('%', #{companyName}, '%')
  361. </if>
  362. <if test="userId != null and userId != ''" >
  363. AND u.user_id = #{userId}
  364. </if>
  365. <if test="empty != null and empty != ''" >
  366. and u.realname is NOT NULL
  367. </if>
  368. <if test="goodsSearchKey != null and goodsSearchKey != ''" >
  369. and ( SELECT
  370. count(og.*)
  371. FROM
  372. `order` o
  373. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  374. where 1=1
  375. and og.`status` = 1
  376. and og.refund_status in (0,1,3)
  377. and og.pay_status in (2,3,4))
  378. and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
  379. and o.user_id = u.user_id)>0
  380. </if>
  381. <if test="goodsSearchKey != null and goodsSearchKey != ''" >
  382. and ( SELECT
  383. count(*)
  384. FROM
  385. `order` o
  386. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  387. LEFT JOIN goods g on og.goods_id = g.goods_id
  388. where 1=1
  389. and og.`status` = 1
  390. and og.refund_status in (0,1,3)
  391. and og.pay_status in (2,3,4)
  392. and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
  393. and o.user_id = u.user_id)>0
  394. </if>
  395. <if test="gradePoint != null and gradePoint == 1" >
  396. 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
  397. </if>
  398. <if test="gradePoint != null and gradePoint == 2" >
  399. 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
  400. </if>
  401. <if test="searchKey != null and searchKey != '' and searchType == 0 ">
  402. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  403. </if>
  404. <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
  405. AND u.id_card in
  406. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  407. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  408. </foreach>
  409. </if>
  410. <if test="searchType == 1" >
  411. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
  412. u.id_card in
  413. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  414. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  415. </foreach>)
  416. </if>
  417. <if test="hasBindWx != null and hasBindWx == 1 ">
  418. AND u.union_id is not null
  419. </if>
  420. <if test="hasBindWx != null and hasBindWx == 0 ">
  421. AND u.union_id is null
  422. </if>
  423. <if test="visitStartTime != null and visitStartTime !=''">
  424. and (SELECT
  425. count(*)
  426. FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >= create_time)>0
  427. </if>
  428. <if test="studyStartTime != null and studyStartTime !=''">
  429. and (SELECT
  430. count(*)
  431. FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >= create_time)>0
  432. </if>
  433. <if test="gradeName != null and gradeName != ''">
  434. and ( SELECT
  435. count(*)
  436. FROM
  437. `order` o
  438. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  439. LEFT JOIN class_grade cg on cg.grade_id = og.grade_id
  440. where 1=1
  441. and og.`status` = 1
  442. and og.refund_status in (0,1,3)
  443. and og.pay_status in (2,3,4)
  444. and (cg.class_name like concat('%', #{gradeName}, '%'))
  445. and o.user_id = u.user_id)>0
  446. </if>
  447. ORDER BY u.user_id DESC
  448. </select>
  449. <select id="selectStudyRecordList" resultMap="StudyRecordResult">
  450. SELECT
  451. usr.study_duration,
  452. c.course_name,
  453. pv.title,
  454. usr.start_time,
  455. usr.end_time,
  456. u.realname,
  457. u.telphone
  458. FROM
  459. user_study_record usr
  460. LEFT JOIN course c ON usr.course_id = c.course_id
  461. LEFT JOIN course_section cs ON usr.section_id = cs.section_id
  462. LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
  463. LEFT JOIN `user` u ON usr.user_id = u.user_id
  464. WHERE 1=1
  465. <if test="userId != null and userId != ''" >
  466. AND usr.user_id = #{userId}
  467. </if>
  468. <if test="courseName != null and courseName != ''" >
  469. AND c.course_name like concat('%', #{courseName}, '%')
  470. </if>
  471. <if test="title != null and title != ''" >
  472. AND pv.title like concat('%', #{title}, '%')
  473. </if>
  474. <if test="startTime1 != null and startTime1 != ''" >
  475. AND usr.start_time > #{startTime1}
  476. </if>
  477. <if test="startTime2 != null and startTime2 != ''" >
  478. AND #{startTime2} > usr.start_time
  479. </if>
  480. <if test="endTime1 != null and endTime1 != ''" >
  481. AND usr.end_time > #{endTime1}
  482. </if>
  483. <if test="endTime2 != null and endTime2 != ''" >
  484. AND #{endTime2} > usr.end_time
  485. </if>
  486. ORDER BY
  487. usr.record_id DESC
  488. </select>
  489. <select id="selectLookNum" parameterType="Long" resultType="integer">
  490. SELECT
  491. COUNT( user_id )
  492. FROM
  493. recruit_interview_message
  494. WHERE
  495. 1 = 1
  496. AND user_id = #{userId}
  497. AND look_status = 0
  498. </select>
  499. <select id="periodSum" parameterType="Long" resultType="Long">
  500. SELECT
  501. COUNT(1)
  502. FROM
  503. user_period up
  504. LEFT JOIN user_period_status ups ON ups.period_id = up.id
  505. LEFT JOIN class_grade_user cgu on up.grade_id = cgu.grade_id and up.user_id = cgu.user_id
  506. WHERE
  507. up.user_id = #{userId}
  508. and ups.period_status =1
  509. and cgu.change_grade = 0
  510. and ups.`status` in (0,3)
  511. </select>
  512. <select id="subscribeSum" parameterType="Long" resultType="Long">
  513. SELECT
  514. COUNT(1)
  515. FROM
  516. user_subscribe us
  517. WHERE
  518. us.user_id = #{userId}
  519. AND us.subscribe_status = 1
  520. and (us.exam_expend is null or us.exam_expend = 0)
  521. </select>
  522. <select id="informSum" parameterType="Long" resultType="Long">
  523. SELECT
  524. COUNT(1)
  525. FROM
  526. inform_user iu
  527. WHERE
  528. iu.user_id = #{userId}
  529. and iu.receipt_status = 0
  530. and iu.system_status in (1,2)
  531. </select>
  532. <select id="orderSum" parameterType="Long" resultType="Long">
  533. SELECT
  534. COUNT( 1 )
  535. FROM
  536. `order`
  537. WHERE
  538. user_id = #{userId}
  539. AND order_status =0
  540. </select>
  541. <select id="queryUserByTelphoneTenant" parameterType="map" resultMap="UserResult">
  542. SELECT
  543. *
  544. FROM
  545. `user`
  546. WHERE
  547. telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  548. AND status = 1 AND tenant_id = #{tenantId}
  549. </select>
  550. <select id="getUserByTelNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  551. SELECT
  552. *
  553. FROM
  554. `user`
  555. WHERE
  556. telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
  557. </select>
  558. <select id="getUserByIdNumNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  559. SELECT
  560. *
  561. FROM
  562. `user`
  563. WHERE
  564. id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
  565. </select>
  566. <select id="queryUserByIdNumTenant" parameterType="map" resultMap="UserResult">
  567. SELECT
  568. *
  569. FROM
  570. `user`
  571. WHERE
  572. id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  573. AND status = 1 AND tenant_id = #{tenantId}
  574. </select>
  575. <select id="selectAllUserList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  576. SELECT
  577. *
  578. FROM
  579. `user`
  580. </select>
  581. <select id="editUserInfo" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo">
  582. UPDATE `user`
  583. <trim prefix="set" suffixOverrides=",">
  584. <if test="telphone != null">
  585. telphone = #{telphone},
  586. </if>
  587. <if test="idCard != null">
  588. id_card = #{idCard},
  589. </if>
  590. </trim>
  591. WHERE
  592. user_id = #{userId}
  593. </select>
  594. <select id="getUserByTel" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  595. SELECT
  596. *
  597. FROM
  598. `user`
  599. WHERE
  600. status = 1
  601. AND(id_card = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  602. OR telphone = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler})
  603. </select>
  604. <select id="getUserByAccount" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  605. SELECT
  606. *
  607. FROM
  608. `user`
  609. WHERE
  610. status = 1
  611. AND user_account = #{userAccount}
  612. </select>
  613. <select id="listByIdsNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
  614. SELECT
  615. *
  616. FROM
  617. `user`
  618. WHERE
  619. status = 1 AND user_id IN
  620. <foreach collection="userIds" item="item" index="index" open="(" close=")" separator=",">
  621. #{item}
  622. </foreach>
  623. </select>
  624. <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
  625. SELECT
  626. *
  627. FROM
  628. `user`
  629. WHERE
  630. status = 1 AND user_id = #{userId}
  631. </select>
  632. <select id="getByCardNoTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  633. SELECT
  634. *
  635. FROM
  636. `user`
  637. WHERE
  638. status = 1 AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  639. LIMIT 1
  640. </select>
  641. <select id="getUserOrderCount" parameterType="map" resultType="java.lang.Long">
  642. SELECT
  643. COUNT(o.order_sn)
  644. FROM
  645. `order` o
  646. INNER JOIN order_goods og ON o.order_sn = og.order_sn
  647. AND og.tenant_id = #{tenantId}
  648. INNER JOIN goods g ON og.goods_id = g.goods_id
  649. AND g.tenant_id = #{tenantId}
  650. WHERE
  651. o.`status` = 1
  652. AND o.user_id = #{userId}
  653. AND g.`code` = #{code}
  654. AND g.goods_name = #{goodsName}
  655. AND og.refund_status != 2
  656. AND og.pay_status IN ( 2, 3, 4 )
  657. AND g.`status` = 1
  658. AND og.`status` = 1
  659. AND o.tenant_id = #{tenantId}
  660. </select>
  661. </mapper>