UserMapper.xml 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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.order_goods_id)
  218. FROM
  219. `order` o
  220. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  221. LEFT JOIN goods g ON og.goods_id = g.goods_id
  222. where 1=1
  223. and og.`status` = 1
  224. and og.refund_status in (0,1,3)
  225. and og.pay_status in (2,3,4)
  226. and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
  227. and o.user_id = u.user_id)>0
  228. </if>
  229. <if test="gradePoint != null and gradePoint == 1" >
  230. 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
  231. </if>
  232. <if test="gradePoint != null and gradePoint == 2" >
  233. 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
  234. </if>
  235. <if test="searchKey != null and searchKey != '' and searchType == 0 ">
  236. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  237. </if>
  238. <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
  239. AND u.id_card in
  240. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  241. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  242. </foreach>
  243. </if>
  244. <if test="searchType == 1" >
  245. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
  246. u.id_card in
  247. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  248. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  249. </foreach>)
  250. </if>
  251. <if test="hasBindWx != null and hasBindWx == 1 ">
  252. AND u.union_id is not null
  253. </if>
  254. <if test="hasBindWx != null and hasBindWx == 0 ">
  255. AND u.union_id is null
  256. </if>
  257. <if test="visitStartTime != null and visitStartTime !=''">
  258. and (SELECT
  259. count(*)
  260. FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >= create_time)>0
  261. </if>
  262. <if test="studyStartTime != null and studyStartTime !=''">
  263. and (SELECT
  264. count(*)
  265. FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >= create_time)>0
  266. </if>
  267. <if test="gradeName != null and gradeName != ''">
  268. and ( SELECT
  269. count(*)
  270. FROM
  271. `order` o
  272. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  273. LEFT JOIN class_grade cg on cg.grade_id = og.grade_id
  274. where 1=1
  275. and og.`status` = 1
  276. and og.refund_status in (0,1,3)
  277. and og.pay_status in (2,3,4)
  278. and (cg.class_name like concat('%', #{gradeName}, '%'))
  279. and o.user_id = u.user_id)>0
  280. </if>
  281. ORDER BY u.user_id DESC
  282. </select>
  283. <select id="selectListNoTenant" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  284. SELECT DISTINCT
  285. u.*
  286. /* ,(case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx */
  287. <if test="getOrderNum != null and getOrderNum == 1" >
  288. ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
  289. </if>
  290. FROM
  291. `user` u
  292. <if test="getOrderNum != null and getOrderNum == 1" >
  293. LEFT JOIN (
  294. SELECT
  295. sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
  296. sum( CASE WHEN g.goods_type = 2 THEN 1 ELSE 0 END ) AS goods_bank_num,
  297. sum( CASE WHEN g.goods_type = 6 THEN 1 ELSE 0 END ) AS goods_live_num,
  298. o.user_id
  299. FROM
  300. `order` o
  301. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  302. LEFT JOIN goods g ON og.goods_id = g.goods_id
  303. WHERE o.`status` = 1
  304. AND og.refund_status in (0,1,3)
  305. AND og.pay_status in (2,3,4)
  306. GROUP BY
  307. o.user_id
  308. ) ou ON u.user_id = ou.user_id
  309. </if>
  310. <if test="businessId != null and businessId != ''">
  311. LEFT JOIN `order` o ON u.user_id = o.user_id and o.`status` = 1
  312. LEFT JOIN order_goods og ON o.order_sn = og.order_sn and og.`status` = 1
  313. LEFT JOIN goods g ON og.goods_id = g.goods_id
  314. </if>
  315. WHERE
  316. 1 = 1
  317. <if test="status != null and status.size()!=0 ">
  318. AND u.status in
  319. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  320. #{item}
  321. </foreach>
  322. </if>
  323. <if test="businessId != null and businessId != ''">
  324. and og.`status` = 1
  325. and og.refund_status in (0,1,3)
  326. and og.pay_status in (2,3,4)
  327. AND g.business_id = #{businessId}
  328. </if>
  329. <if test="startTime != null and startTime != ''">
  330. AND u.create_time &gt; #{startTime}
  331. </if>
  332. <if test="endTime != null and endTime != ''">
  333. AND u.create_time &lt; #{endTime}
  334. </if>
  335. <if test="userKerWord != null and userKerWord != ''" >
  336. 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}, '%'))
  337. </if>
  338. <if test="nickname != null and nickname != ''" >
  339. AND u.nickname like concat('%', #{nickname}, '%')
  340. </if>
  341. <if test="telphone != null and telphone != ''" >
  342. AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  343. </if>
  344. <if test="idCard != null and idCard != ''" >
  345. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  346. </if>
  347. <if test="realname != null and realname != ''" >
  348. AND u.realname like concat('%', #{realname}, '%')
  349. </if>
  350. <if test="companyName != null and companyName != ''" >
  351. AND u.company_name like concat('%', #{companyName}, '%')
  352. </if>
  353. <if test="userId != null and userId != ''" >
  354. AND u.user_id = #{userId}
  355. </if>
  356. <if test="empty != null and empty != ''" >
  357. and u.realname is NOT NULL
  358. </if>
  359. <if test="goodsSearchKey != null and goodsSearchKey != ''" >
  360. and ( SELECT
  361. count(og.order_goods_id)
  362. FROM
  363. `order` o
  364. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  365. LEFT JOIN goods g ON og.goods_id = g.goods_id
  366. where 1=1
  367. and og.`status` = 1
  368. and og.refund_status in (0,1,3)
  369. and og.pay_status in (2,3,4)
  370. and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
  371. and o.user_id = u.user_id)>0
  372. </if>
  373. <if test="gradePoint != null and gradePoint == 1" >
  374. 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
  375. </if>
  376. <if test="gradePoint != null and gradePoint == 2" >
  377. 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
  378. </if>
  379. <if test="searchKey != null and searchKey != '' and searchType == 0 ">
  380. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  381. </if>
  382. <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
  383. AND u.id_card in
  384. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  385. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  386. </foreach>
  387. </if>
  388. <if test="searchType == 1" >
  389. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
  390. u.id_card in
  391. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  392. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  393. </foreach>)
  394. </if>
  395. <if test="hasBindWx != null and hasBindWx == 1 ">
  396. AND u.union_id is not null
  397. </if>
  398. <if test="hasBindWx != null and hasBindWx == 0 ">
  399. AND u.union_id is null
  400. </if>
  401. <if test="visitStartTime != null and visitStartTime !=''">
  402. and (SELECT
  403. count(*)
  404. FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >= create_time)>0
  405. </if>
  406. <if test="studyStartTime != null and studyStartTime !=''">
  407. and (SELECT
  408. count(*)
  409. FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >= create_time)>0
  410. </if>
  411. <if test="gradeName != null and gradeName != ''">
  412. and ( SELECT
  413. count(*)
  414. FROM
  415. `order` o
  416. LEFT JOIN order_goods og on o.order_sn = og.order_sn
  417. LEFT JOIN class_grade cg on cg.grade_id = og.grade_id
  418. where 1=1
  419. and og.`status` = 1
  420. and og.refund_status in (0,1,3)
  421. and og.pay_status in (2,3,4)
  422. and (cg.class_name like concat('%', #{gradeName}, '%'))
  423. and o.user_id = u.user_id)>0
  424. </if>
  425. ORDER BY u.user_id DESC
  426. </select>
  427. <select id="selectStudyRecordList" resultMap="StudyRecordResult">
  428. SELECT
  429. usr.study_duration,
  430. c.course_name,
  431. pv.title,
  432. usr.start_time,
  433. usr.end_time,
  434. u.realname,
  435. u.telphone
  436. FROM
  437. user_study_record usr
  438. LEFT JOIN course c ON usr.course_id = c.course_id
  439. LEFT JOIN course_section cs ON usr.section_id = cs.section_id
  440. LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
  441. LEFT JOIN `user` u ON usr.user_id = u.user_id
  442. WHERE 1=1
  443. <if test="userId != null and userId != ''" >
  444. AND usr.user_id = #{userId}
  445. </if>
  446. <if test="courseName != null and courseName != ''" >
  447. AND c.course_name like concat('%', #{courseName}, '%')
  448. </if>
  449. <if test="title != null and title != ''" >
  450. AND pv.title like concat('%', #{title}, '%')
  451. </if>
  452. <if test="startTime1 != null and startTime1 != ''" >
  453. AND usr.start_time > #{startTime1}
  454. </if>
  455. <if test="startTime2 != null and startTime2 != ''" >
  456. AND #{startTime2} > usr.start_time
  457. </if>
  458. <if test="endTime1 != null and endTime1 != ''" >
  459. AND usr.end_time > #{endTime1}
  460. </if>
  461. <if test="endTime2 != null and endTime2 != ''" >
  462. AND #{endTime2} > usr.end_time
  463. </if>
  464. ORDER BY
  465. usr.record_id DESC
  466. </select>
  467. <select id="selectLookNum" parameterType="Long" resultType="integer">
  468. SELECT
  469. COUNT( user_id )
  470. FROM
  471. recruit_interview_message
  472. WHERE
  473. 1 = 1
  474. AND user_id = #{userId}
  475. AND look_status = 0
  476. </select>
  477. <select id="periodSum" parameterType="Long" resultType="Long">
  478. SELECT
  479. COUNT(1)
  480. FROM
  481. user_period up
  482. LEFT JOIN user_period_status ups ON ups.period_id = up.id
  483. LEFT JOIN class_grade_user cgu on up.grade_id = cgu.grade_id and up.user_id = cgu.user_id
  484. WHERE
  485. up.user_id = #{userId}
  486. and ups.period_status =1
  487. and cgu.change_grade = 0
  488. and ups.`status` in (0,3)
  489. </select>
  490. <select id="subscribeSum" parameterType="Long" resultType="Long">
  491. SELECT
  492. COUNT(1)
  493. FROM
  494. user_subscribe us
  495. WHERE
  496. us.user_id = #{userId}
  497. AND us.subscribe_status = 1
  498. and (us.exam_expend is null or us.exam_expend = 0)
  499. </select>
  500. <select id="informSum" parameterType="Long" resultType="Long">
  501. SELECT
  502. COUNT(1)
  503. FROM
  504. inform_user iu
  505. WHERE
  506. iu.user_id = #{userId}
  507. and iu.receipt_status = 0
  508. and iu.system_status in (1,2)
  509. </select>
  510. <select id="orderSum" parameterType="Long" resultType="Long">
  511. SELECT
  512. COUNT( 1 )
  513. FROM
  514. `order`
  515. WHERE
  516. user_id = #{userId}
  517. AND order_status =0
  518. </select>
  519. <select id="queryUserByTelphoneTenant" parameterType="map" resultMap="UserResult">
  520. SELECT
  521. *
  522. FROM
  523. `user`
  524. WHERE
  525. telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  526. AND status = 1 AND tenant_id = #{tenantId}
  527. </select>
  528. <select id="getUserByTelNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  529. SELECT
  530. *
  531. FROM
  532. `user`
  533. WHERE
  534. telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
  535. </select>
  536. <select id="getUserByIdNumNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  537. SELECT
  538. *
  539. FROM
  540. `user`
  541. WHERE
  542. id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
  543. </select>
  544. <select id="queryUserByIdNumTenant" parameterType="map" resultMap="UserResult">
  545. SELECT
  546. *
  547. FROM
  548. `user`
  549. WHERE
  550. id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  551. AND status = 1 AND tenant_id = #{tenantId}
  552. </select>
  553. <select id="selectAllUserList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  554. SELECT
  555. *
  556. FROM
  557. `user`
  558. </select>
  559. <select id="editUserInfo" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo">
  560. UPDATE `user`
  561. <trim prefix="set" suffixOverrides=",">
  562. <if test="telphone != null">
  563. telphone = #{telphone},
  564. </if>
  565. <if test="idCard != null">
  566. id_card = #{idCard},
  567. </if>
  568. </trim>
  569. WHERE
  570. user_id = #{userId}
  571. </select>
  572. <select id="getUserByTel" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  573. SELECT
  574. *
  575. FROM
  576. `user`
  577. WHERE
  578. status = 1
  579. AND(id_card = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  580. OR telphone = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler})
  581. </select>
  582. <select id="getUserByAccount" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  583. SELECT
  584. *
  585. FROM
  586. `user`
  587. WHERE
  588. status = 1
  589. AND user_account = #{userAccount}
  590. </select>
  591. <select id="listByIdsNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
  592. SELECT
  593. *
  594. FROM
  595. `user`
  596. WHERE
  597. status = 1 AND user_id IN
  598. <foreach collection="userIds" item="item" index="index" open="(" close=")" separator=",">
  599. #{item}
  600. </foreach>
  601. </select>
  602. <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
  603. SELECT
  604. *
  605. FROM
  606. `user`
  607. WHERE
  608. status = 1 AND user_id = #{userId}
  609. </select>
  610. <select id="getByCardNoTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  611. SELECT
  612. *
  613. FROM
  614. `user`
  615. WHERE
  616. status = 1 AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  617. LIMIT 1
  618. </select>
  619. <select id="getByCardTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  620. SELECT
  621. *
  622. FROM
  623. `user`
  624. WHERE
  625. status = 1 AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  626. AND tenant_id = #{tenantId}
  627. LIMIT 1
  628. </select>
  629. <select id="getByCardNoTenantNew" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
  630. SELECT
  631. u.*
  632. FROM
  633. class_grade_user cgu
  634. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  635. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  636. WHERE
  637. cgu.`status` = 1
  638. AND cg.official_name = #{bh}
  639. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  640. LIMIT 1
  641. </select>
  642. <select id="getFistStudyTime" parameterType="map" resultType="java.lang.Long">
  643. SELECT
  644. ustp.create_time
  645. FROM
  646. user_study_record usr
  647. INNER JOIN user_study_record_photo ustp ON usr.record_id = ustp.record_id
  648. LEFT JOIN goods g ON usr.goods_id = g.goods_id
  649. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  650. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  651. LEFT JOIN course_business cb ON g.business_id = cb.id
  652. LEFT JOIN class_grade cg ON usr.grade_id = cg.grade_id
  653. LEFT JOIN class_grade_user cgu ON usr.order_goods_id = cgu.order_goods_id
  654. WHERE
  655. usr.current_status = 1
  656. AND cgu.period_status = -1
  657. AND cgu.status = 1
  658. AND usr.user_id = #{userId}
  659. AND usr.tenant_id = #{tenantId}
  660. AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), #{businessName} )
  661. AND cg.class_start_time &lt;= UNIX_TIMESTAMP(NOW())
  662. AND cg.class_end_time &gt;= UNIX_TIMESTAMP(NOW())
  663. AND cg.`status` = 1
  664. ORDER BY ustp.create_time ASC LIMIT 1
  665. </select>
  666. <select id="getCourseByUser" parameterType="com.zhongzheng.modules.user.bo.UserBusinessGoodsBo" resultType="com.zhongzheng.modules.user.vo.UserBusinessGoodsVo">
  667. SELECT
  668. u.realname AS `name`,
  669. u.id_card AS idNum,
  670. CONCAT( cet.education_name, cb.business_name, cpt.project_name ) AS business_name,
  671. m.category_name AS majorName,
  672. g.goods_name AS categoryName,
  673. og.create_time AS createTimeStamp
  674. FROM
  675. `order` o
  676. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  677. LEFT JOIN goods g ON og.goods_id = g.goods_id
  678. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  679. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  680. LEFT JOIN course_business cb ON g.business_id = cb.id
  681. LEFT JOIN major m ON g.major_id = m.id
  682. LEFT JOIN `user` u ON o.user_id = u.user_id
  683. WHERE
  684. o.`status` = 1
  685. AND og.`status` = 1
  686. AND o.user_id = #{userId}
  687. AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), #{businessName} )
  688. ORDER BY
  689. og.create_time DESC
  690. </select>
  691. <select id="getBusinessPhotoSign" parameterType="java.lang.Long" resultType="java.lang.Integer">
  692. SELECT
  693. cb.photo_sign
  694. FROM
  695. order_goods og
  696. LEFT JOIN goods g ON og.goods_id = g.goods_id
  697. LEFT JOIN course_business cb ON g.business_id = cb.id
  698. WHERE
  699. og.order_goods_id = #{orderGoodsId}
  700. LIMIT 1
  701. </select>
  702. <select id="getUserOrderCount" parameterType="map" resultType="java.lang.Long">
  703. SELECT
  704. COUNT(o.order_sn)
  705. FROM
  706. `order` o
  707. INNER JOIN order_goods og ON o.order_sn = og.order_sn
  708. AND og.tenant_id = #{tenantId}
  709. INNER JOIN goods g ON og.goods_id = g.goods_id
  710. AND g.tenant_id = #{tenantId}
  711. WHERE
  712. o.`status` = 1
  713. AND o.user_id = #{userId}
  714. AND g.`code` = #{code}
  715. AND g.goods_name = #{goodsName}
  716. AND og.refund_status != 2
  717. AND og.pay_status IN ( 2, 3, 4 )
  718. AND g.`status` = 1
  719. AND og.`status` = 1
  720. AND o.tenant_id = #{tenantId}
  721. </select>
  722. <select id="dangAnList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
  723. SELECT DISTINCT u.* from `user` u
  724. <if test="educationTypeId != null or businessId != null or majorId != null" >
  725. LEFT JOIN `order` o ON o.user_id = u.user_id and o.`status` = 1
  726. LEFT JOIN order_goods og ON o.order_sn = og.order_sn AND og.pay_status IN ( 2, 3, 4 ) AND og.refund_status != 2
  727. LEFT JOIN goods g ON og.goods_id = g.goods_id
  728. </if>
  729. where 1=1
  730. <if test="telphone != null and telphone != ''" >
  731. AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  732. </if>
  733. <if test="idCard != null and idCard != ''" >
  734. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  735. </if>
  736. <if test="realname != null and realname != ''" >
  737. AND u.realname like concat('%', #{realname}, '%')
  738. </if>
  739. <if test="companyName != null and companyName != ''" >
  740. AND u.company_name like concat('%', #{companyName}, '%')
  741. </if>
  742. <if test="majorId != null and majorId != ''" >
  743. AND g.major_id = #{majorId}
  744. </if>
  745. <if test="educationTypeId != null and educationTypeId != ''" >
  746. AND g.education_type_id = #{educationTypeId}
  747. </if>
  748. <if test="businessId != null and businessId != ''" >
  749. AND g.business_id = #{businessId}
  750. </if>
  751. <if test="promiseUploadSign != null and promiseUploadSign == 1" >
  752. AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
  753. AND INSTR(up.key_value,'"fieldKey":"commitment_seal","value":"oss/images/avatar')) &gt; 0
  754. </if>
  755. <if test="promiseUploadSign != null and promiseUploadSign == 0" >
  756. AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
  757. AND INSTR(up.key_value,'"fieldKey":"commitment_seal","value":"oss/images/avatar')) = 0
  758. </if>
  759. <if test="promiseSign != null and promiseSign == 1" >
  760. AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
  761. AND INSTR(up.key_value,'"fieldKey":"commitment_electr_signature","value":"oss/images/avatar')) &gt; 0
  762. </if>
  763. <if test="promiseSign != null and promiseSign == 0" >
  764. AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
  765. AND INSTR(up.key_value,'"fieldKey":"commitment_electr_signature","value":"oss/images/avatar')) = 0
  766. </if>
  767. <if test="(applySiteExamTime != null and applySiteExamTime != '' ) or
  768. (monthStartTime != null and monthStartTime != '' ) or
  769. (monthEndTime != null and monthEndTime != '') or
  770. (applySiteStartTime != null and applySiteStartTime != '') or
  771. (applySiteEndTime != null and applySiteEndTime != '')">
  772. AND (SELECT COUNT(us.subscribe_id) FROM user_subscribe us WHERE us.user_id = u.user_id AND us.subscribe_status = 1
  773. <if test="applySiteExamTime != null and applySiteExamTime != '' ">
  774. and us.apply_site_exam_time = #{applySiteExamTime}
  775. </if>
  776. <if test="monthStartTime != null and monthStartTime != '' ">
  777. and us.apply_site_exam_time &gt;= #{monthStartTime}
  778. </if>
  779. <if test="monthEndTime != null and monthEndTime != '' ">
  780. and us.apply_site_exam_time &lt;= #{monthEndTime}
  781. </if>
  782. <if test="applySiteStartTime != null and applySiteStartTime != '' ">
  783. and us.apply_site_start_time = #{applySiteStartTime}
  784. </if>
  785. <if test="applySiteEndTime != null and applySiteEndTime != '' ">
  786. and us.apply_site_end_time = #{applySiteEndTime}
  787. </if>
  788. ) > 0
  789. </if>
  790. order by u.user_id desc
  791. </select>
  792. </mapper>