UserMapper.xml 30 KB

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