ClassGradeUserMapper.xml 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  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.grade.mapper.ClassGradeUserMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.ClassGradeUser" id="ClassGradeUserResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="gradeId" column="grade_id"/>
  10. <result property="status" column="status"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="fromType" column="from_type"/>
  15. <result property="periodStatus" column="period_status"/>
  16. <result property="orderGoodsId" column="order_goods_id"/>
  17. <result property="finishStatus" column="finish_status"/>
  18. <result property="officialStatus" column="official_status"/>
  19. <result property="learnStatus" column="learn_status"/>
  20. <result property="periodPlush" column="period_plush"/>
  21. <result property="periodTime" column="period_time"/>
  22. <result property="periodWaitTime" column="period_wait_time"/>
  23. <result property="changeGrade" column="change_grade"/>
  24. <result property="officialStatusMsg" column="official_status_msg"/>
  25. <result property="periodPlushMsg" column="period_plush_msg"/>
  26. <result property="officialStatusTime" column="official_status_time"/>
  27. <result property="periodPlushTime" column="period_plush_time"/>
  28. <result property="officialStatusNum" column="official_status_num"/>
  29. <result property="periodStatusNum" column="period_status_num"/>
  30. <result property="periodIngTime" column="period_ing_time"/>
  31. </resultMap>
  32. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserVo" id="ClassGradeUserVoResult">
  33. <result property="id" column="id"/>
  34. <result property="userId" column="user_id"/>
  35. <result property="gradeId" column="grade_id"/>
  36. <result property="className" column="class_name"/>
  37. <result property="status" column="status"/>
  38. <result property="code" column="user_account"/>
  39. <result property="realName" column="realname"/>
  40. <result property="idCard" column="id_card"/>
  41. <result property="createBy" column="create_by"/>
  42. <result property="telPhone" column="telphone"/>
  43. <result property="changeGrade" column="change_grade"/>
  44. <result property="interfacePushId" column="interface_push_id"/>
  45. <result property="classStatus" column="class_status"/>
  46. <result property="officialName" column="official_name"/>
  47. <result property="classStartTime" column="class_start_time"/>
  48. <result property="classEndTime" column="class_end_time"/>
  49. <result property="officialStatusNum" column="official_status_num"/>
  50. <result property="periodTime" column="period_time"/>
  51. <result property="periodWaitTime" column="period_wait_time"/>
  52. <result property="periodStatus" column="period_status"/>
  53. <result property="periodStatusNum" column="period_status_num"/>
  54. <result property="periodIngTime" column="period_ing_time"/>
  55. </resultMap>
  56. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserGoodsVo" id="ClassGradeUserGoodsVoResult">
  57. <result property="id" column="id"/>
  58. <result property="userId" column="user_id"/>
  59. <result property="gradeId" column="grade_id"/>
  60. <result property="status" column="status"/>
  61. <result property="goodsCode" column="goods_code"/>
  62. <result property="goodsName" column="goods_name"/>
  63. <result property="gradeStatus" column="grade_status"/>
  64. <result property="gradeCode" column="grade_code"/>
  65. <result property="gradeName" column="grade_name"/>
  66. <result property="year" column="year"/>
  67. <result property="educationName" column="education_name"/>
  68. <result property="projectName" column="project_name"/>
  69. <result property="businessName" column="business_name"/>
  70. <result property="schoolName" column="school_name"/>
  71. <result property="createTime" column="create_time"/>
  72. <result property="createBy" column="create_by"/>
  73. <result property="goodsId" column="goods_id"/>
  74. <result property="classStartTime" column="class_start_time"/>
  75. <result property="classEndTime" column="class_end_time"/>
  76. </resultMap>
  77. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo" id="ClassPeriodStudentVo">
  78. <result property="userId" column="user_id"/>
  79. <result property="gradeId" column="grade_id"/>
  80. <result property="studentCode" column="user_account"/>
  81. <result property="realName" column="realname"/>
  82. <result property="idCard" column="id_card"/>
  83. <result property="telPhone" column="telphone"/>
  84. <result property="status" column="status"/>
  85. <result property="classHours" column="class_hours"/>
  86. <result property="periodStatus" column="period_status"/>
  87. <result property="secAllNum" column="sec_all_num"/>
  88. <result property="examNum" column="exam_num"/>
  89. <result property="recordNum" column="record_num"/>
  90. <result property="periodPlush" column="period_plush"/>
  91. <result property="startTime" column="start_time"/>
  92. <result property="endTime" column="end_time"/>
  93. <result property="studyStartTime" column="study_start_time"/>
  94. <result property="studyEndTime" column="study_end_time"/>
  95. <result property="rebuildNum" column="rebuild_num"/>
  96. <result property="profileStatus" column="profile_status"/>
  97. <result property="className" column="class_name"/>
  98. <result property="goodsName" column="goods_name"/>
  99. <result property="standPrice" column="stand_price"/>
  100. <result property="goodsCode" column="goods_code"/>
  101. <result property="keyValue" column="key_value"/>
  102. <result property="classStartTime" column="class_start_time"/>
  103. <result property="classEndTime" column="class_end_time"/>
  104. <result property="periodStatusNum" column="period_status_num"/>
  105. <result property="serviceStartTime" column="service_start_time"/>
  106. <result property="serviceEndTime" column="service_end_time"/>
  107. </resultMap>
  108. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodUserVo" id="ClassPeriodUserVo">
  109. <result property="userId" column="user_id"/>
  110. <result property="studentCode" column="user_account"/>
  111. <result property="realName" column="realname"/>
  112. <result property="oneInchPhotos" column="one_inch_photos"/>
  113. <result property="idCardImg1" column="id_card_img1"/>
  114. <result property="idCardImg2" column="id_card_img2"/>
  115. <result property="idCard" column="id_card"/>
  116. <result property="telPhone" column="telphone"/>
  117. <result property="secAllNum" column="sec_all_num"/>
  118. <result property="examNum" column="exam_num"/>
  119. <result property="recordNum" column="record_num"/>
  120. <result property="pass" column="pass"/>
  121. <result property="cheat" column="cheat"/>
  122. <result property="pending" column="pending"/>
  123. <result property="examPass" column="exam_pass"/>
  124. <result property="examPending" column="exam_pending"/>
  125. <result property="examCheat" column="exam_cheat"/>
  126. <result property="keyValue" column="key_value"/>
  127. <result property="periodStatus" column="period_status"/>
  128. <result property="studyStartTime" column="study_start_time"/>
  129. <result property="studyEndTime" column="study_end_time"/>
  130. </resultMap>
  131. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodVo" id="ClassPeriodVo">
  132. <result property="userId" column="user_id"/>
  133. <result property="id" column="id"/>
  134. <result property="typeName" column="type_name"/>
  135. <result property="realName" column="realname"/>
  136. <result property="classHours" column="class_hours"/>
  137. <result property="studyStartTime" column="study_start_time"/>
  138. <result property="status" column="status"/>
  139. <result property="auditTime" column="audit_time"/>
  140. <result property="type" column="type"/>
  141. <result property="sort" column="sort"/>
  142. <result property="courseId" column="course_id"/>
  143. <result property="studyEndTime" column="study_end_time"/>
  144. <result property="durationTime" column="duration_time"/>
  145. <result property="courseSort" column="course_sort"/>
  146. </resultMap>
  147. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodChapterVo" id="ClassPeriodChapterVo">
  148. <result property="userId" column="user_id"/>
  149. <result property="id" column="id"/>
  150. <result property="courseId" column="course_id"/>
  151. <result property="typeName" column="type_name"/>
  152. <result property="realName" column="realname"/>
  153. <result property="classHours" column="class_hours"/>
  154. <result property="studyStartTime" column="study_start_time"/>
  155. <result property="status" column="status"/>
  156. <result property="auditTime" column="audit_time"/>
  157. <result property="type" column="type"/>
  158. <result property="studyEndTime" column="study_end_time"/>
  159. <result property="performance" column="performance"/>
  160. <result property="sort" column="sort"/>
  161. </resultMap>
  162. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodSectionVo" id="ClassPeriodSectionVo">
  163. <result property="userId" column="user_id"/>
  164. <result property="id" column="id"/>
  165. <result property="typeName" column="type_name"/>
  166. <result property="realName" column="realname"/>
  167. <result property="classHours" column="class_hours"/>
  168. <result property="durationTime" column="duration_time"/>
  169. <result property="studyStartTime" column="study_start_time"/>
  170. <result property="status" column="status"/>
  171. <result property="auditTime" column="audit_time"/>
  172. <result property="type" column="type"/>
  173. <result property="studyEndTime" column="study_end_time"/>
  174. <result property="auditNum" column="audit_num"/>
  175. <result property="sort" column="sort"/>
  176. </resultMap>
  177. <resultMap type="com.zhongzheng.modules.course.vo.CourseChapterVo" id="CourseChapterResultVo">
  178. <result property="chapterId" column="chapter_id"/>
  179. <result property="name" column="name"/>
  180. </resultMap>
  181. <select id="selectUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  182. resultMap="ClassGradeUserVoResult">
  183. SELECT
  184. g.*,
  185. u.user_account,
  186. u.realname,
  187. u.id_card,
  188. u.telphone,
  189. cg.class_name,
  190. cg.official_name,
  191. cg.class_status,
  192. cg.interface_push_id,
  193. cg.class_start_time,
  194. cg.class_end_time,
  195. g.official_status_num,
  196. g.period_time,
  197. g.period_wait_time,
  198. g.period_status
  199. FROM
  200. class_grade_user g
  201. LEFT JOIN `user` u ON g.user_id = u.user_id
  202. LEFT JOIN class_grade cg ON cg.grade_id = g.grade_id
  203. WHERE
  204. 1 = 1
  205. AND g.change_grade = 0
  206. AND g.grade_id = #{gradeId}
  207. AND g.user_id = #{userId}
  208. </select>
  209. <select id="select" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  210. resultMap="ClassGradeUserVoResult">
  211. SELECT
  212. g.*,
  213. u.user_account,
  214. u.realname,
  215. u.id_card,
  216. u.telphone
  217. FROM
  218. class_grade_user g
  219. LEFT JOIN `user` u ON g.user_id = u.user_id
  220. WHERE
  221. 1 = 1
  222. <if test="status != null and status.size()!=0 ">
  223. AND g.status in
  224. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  225. #{item}
  226. </foreach>
  227. </if>
  228. <if test="gradeId != null and gradeId != ''">
  229. AND g.grade_id = #{gradeId}
  230. </if>
  231. <if test="userId != null and userId != ''">
  232. AND g.user_id = #{userId}
  233. </if>
  234. <if test="classStartTime != null or classEndTime != null ">
  235. AND #{classStartTime} BETWEEN g.class_start_time
  236. </if>
  237. order by g.update_time desc
  238. </select>
  239. <select id="listUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  240. resultMap="ClassGradeUserGoodsVoResult">
  241. SELECT
  242. * ,
  243. (select `code` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  244. u.grade_id) as goods_code,
  245. (select `year` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  246. u.grade_id) as year,
  247. (select goods_name FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  248. u.grade_id) as goods_name,
  249. (select b.business_name FROM course_business b LEFT JOIN goods g on b.id = g.business_id LEFT JOIN
  250. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as business_name,
  251. (select b.project_name FROM course_project_type b LEFT JOIN goods g on b.id = g.project_id LEFT JOIN
  252. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as project_name,
  253. (select b.school_name FROM school b LEFT JOIN goods g on b.id = g.school_id LEFT JOIN class_grade_goods c on
  254. g.goods_id = c.goods_id where c.grade_id = u.grade_id) as school_name,
  255. (select b.education_name FROM course_education_type b LEFT JOIN goods g on b.id = g.education_type_id LEFT JOIN
  256. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as education_name,
  257. (SELECT g.grade_code FROM class_grade g where u.grade_id = g.grade_id) as grade_code,
  258. (SELECT g.class_name FROM class_grade g where u.grade_id = g.grade_id) as grade_name,
  259. (SELECT g.status FROM class_grade g where u.grade_id = g.grade_id) as grade_status
  260. FROM
  261. class_grade_user u
  262. where 1=1
  263. <if test="status != null and status.size()!=0 ">
  264. AND u.status in
  265. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  266. #{item}
  267. </foreach>
  268. </if>
  269. <if test="userId != null and userId != ''">
  270. and u.user_id= #{userId}
  271. </if>
  272. order by u.update_time desc
  273. </select>
  274. <select id="listUserPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  275. resultMap="ClassPeriodStudentVo">
  276. SELECT
  277. u.user_account,
  278. u.user_id,
  279. cgu.`status`,
  280. u.realname,
  281. cgg.goods_id,
  282. u.id_card,
  283. cgu.grade_id,
  284. u.telphone,
  285. up.`status` as profile_status,
  286. g.class_hours as class_hours,
  287. g.study_start_time as study_start_time,
  288. g.study_end_time as study_end_time,
  289. g.goods_name,
  290. g.code as goods_code,
  291. g.stand_price,
  292. cgu.period_status,
  293. cg.class_start_time,
  294. cg.class_end_time,
  295. cg.class_name,
  296. cgu.period_plush,
  297. cgu.period_status_num,
  298. IFNULL(ge.exam_num,0) as exam_num,
  299. <if test="userPhoto != null and userPhoto == 1">
  300. up.key_value,
  301. </if>
  302. cgu.period_time as end_time,
  303. (SELECT og.service_start_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_start_time,
  304. (SELECT og.service_end_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_end_time,
  305. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cgu.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num
  306. <if test="userPhoto == null">
  307. ,(select COUNT(up.id) from user_period up LEFT JOIN user_period_status ups on up.id=ups.period_id where up.goods_id = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) and up.grade_id = cgu.grade_id and up.user_id = u.user_id
  308. and ups.period_status=0 and ups.`status`=0 and (SELECT COUNT(upss.id) from user_period_status upss where upss.id = ups.id and upss.period_status = 1 and upss.`status` = 2) > 0 ) as rebuild_num
  309. </if>
  310. FROM
  311. class_grade_user cgu
  312. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  313. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  314. LEFT JOIN (SELECT
  315. COUNT( m.id ) AS exam_num,
  316. c.goods_id
  317. FROM
  318. course_menu_exam m
  319. LEFT JOIN goods_course c ON m.course_id = c.course_id
  320. where
  321. m.type = 1
  322. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  323. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  324. LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = ge.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
  325. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  326. where 1=1
  327. and cgu.`status` =1
  328. <if test="officialStatus != null and officialStatus != ''">
  329. AND cgu.official_status = #{officialStatus}
  330. </if>
  331. <if test="changeGrade != null and changeGrade != ''">
  332. AND cgu.change_grade = #{changeGrade}
  333. </if>
  334. <if test="profileStatus != null and profileStatus != ''">
  335. AND up.status = #{profileStatus}
  336. </if>
  337. <if test="gradeId != null and gradeId !='' ">
  338. and cgu.grade_id = #{gradeId}
  339. </if>
  340. <if test="businessId != null and businessId != ''">
  341. AND g.business_id = #{businessId}
  342. </if>
  343. <if test="educationTypeId != null and educationTypeId != ''">
  344. AND g.education_type_id = #{educationTypeId}
  345. </if>
  346. <if test="schoolId != null and schoolId != ''">
  347. AND g.school_id = #{schoolId}
  348. </if>
  349. <if test="majorId != null and majorId != ''">
  350. AND g.major_id = #{majorId}
  351. </if>
  352. <if test="periodStatus != null ">
  353. and cgu.period_status = #{periodStatus}
  354. </if>
  355. <if test="classStartTime != null and classStartTime != '' ">
  356. AND cg.class_start_time >= #{classStartTime}
  357. </if>
  358. <if test="classEndTime != null and classEndTime != '' ">
  359. AND #{classEndTime} >= cg.class_end_time
  360. </if>
  361. <if test="studyStatus != null and studyStatus == 1 ">
  362. and cgu.period_status = -1
  363. </if>
  364. <if test="studyStatus != null and studyStatus == 2 ">
  365. and cgu.period_status != -1
  366. </if>
  367. <if test="searchKey != null and searchKey != '' ">
  368. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or cg.class_name like concat('%', #{searchKey}, '%'))
  369. </if>
  370. <if test="searchStartTime != null and searchStartTime !='' ">
  371. AND cgu.create_time >=#{searchStartTime}
  372. </if>
  373. <if test="searchEndTime != null and searchEndTime !='' ">
  374. AND #{searchEndTime} >= cgu.create_time
  375. </if>
  376. <if test="periodStatus != 2 and periodStatus != 3">
  377. order by cgu.update_time desc
  378. </if>
  379. <if test="periodStatus == 2 ">
  380. order by cgu.period_wait_time,cgu.create_time
  381. </if>
  382. <if test="periodStatus == 3 ">
  383. order by cgu.period_ing_time,cgu.create_time
  384. </if>
  385. </select>
  386. <select id="listUserPeriodExport" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  387. resultMap="ClassPeriodStudentVo">
  388. SELECT
  389. u.user_account,
  390. u.user_id,
  391. cgu.`status`,
  392. u.realname,
  393. cgg.goods_id,
  394. u.id_card,
  395. cgu.grade_id,
  396. u.telphone,
  397. g.class_hours as class_hours,
  398. g.study_start_time as study_start_time,
  399. g.study_end_time as study_end_time,
  400. g.goods_name,
  401. g.code as goods_code,
  402. g.stand_price,
  403. cgu.period_status,
  404. cg.class_start_time,
  405. cg.class_end_time,
  406. cg.class_name,
  407. cgu.period_plush,
  408. cgu.period_status_num,
  409. (SELECT og.service_start_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_start_time,
  410. (SELECT og.service_end_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_end_time,
  411. <if test="userPhoto != null and userPhoto == 1">
  412. up.key_value,
  413. </if>
  414. cgu.period_time as end_time
  415. FROM
  416. class_grade_user cgu
  417. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  418. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  419. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  420. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  421. LEFT JOIN user_profile up on u.user_id =up.user_id and up.goods_id = g.goods_id and cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
  422. where 1=1
  423. and cgu.`status` =1
  424. <if test="officialStatus != null and officialStatus != ''">
  425. AND cgu.official_status = #{officialStatus}
  426. </if>
  427. <if test="changeGrade != null and changeGrade != ''">
  428. AND cgu.change_grade = #{changeGrade}
  429. </if>
  430. <if test="profileStatus != null and profileStatus != ''">
  431. AND up.status = #{profileStatus}
  432. </if>
  433. <if test="gradeId != null and gradeId !='' ">
  434. and cgu.grade_id = #{gradeId}
  435. </if>
  436. <if test="businessId != null and businessId != ''">
  437. AND g.business_id = #{businessId}
  438. </if>
  439. <if test="educationTypeId != null and educationTypeId != ''">
  440. AND g.education_type_id = #{educationTypeId}
  441. </if>
  442. <if test="schoolId != null and schoolId != ''">
  443. AND g.school_id = #{schoolId}
  444. </if>
  445. <if test="majorId != null and majorId != ''">
  446. AND g.major_id = #{majorId}
  447. </if>
  448. <if test="periodStatus != null ">
  449. and cgu.period_status = #{periodStatus}
  450. </if>
  451. <if test="classStartTime != null and classStartTime != '' ">
  452. AND cg.class_start_time >= #{classStartTime}
  453. </if>
  454. <if test="classEndTime != null and classEndTime != '' ">
  455. AND #{classEndTime} >= cg.class_end_time
  456. </if>
  457. <if test="studyStatus != null and studyStatus == 1 ">
  458. and cgu.period_status = -1
  459. </if>
  460. <if test="studyStatus != null and studyStatus == 2 ">
  461. and cgu.period_status != -1
  462. </if>
  463. <if test="searchKey != null and searchKey != '' ">
  464. and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or cg.class_name like concat('%', #{searchKey}, '%'))
  465. </if>
  466. <if test="searchStartTime != null and searchStartTime !='' ">
  467. AND cgu.create_time >=#{searchStartTime}
  468. </if>
  469. <if test="searchEndTime != null and searchEndTime !='' ">
  470. AND #{searchEndTime} >= cgu.create_time
  471. </if>
  472. <if test="periodStatus != 2 and periodStatus != 3">
  473. order by cgu.update_time desc
  474. </if>
  475. <if test="periodStatus == 2 ">
  476. order by cgu.period_wait_time,cgu.create_time
  477. </if>
  478. <if test="periodStatus == 3 ">
  479. order by cgu.period_ing_time,cgu.create_time
  480. </if>
  481. </select>
  482. <select id="userPeriodStatus" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  483. resultMap="ClassPeriodStudentVo">
  484. SELECT
  485. IFNULL(ge.exam_num,0) as exam_num,
  486. cg.class_start_time,
  487. cg.class_end_time,
  488. g.study_start_time,
  489. g.study_end_time,
  490. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id
  491. = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  492. cgu.user_id,
  493. cgg.goods_id
  494. FROM
  495. class_grade_user cgu
  496. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  497. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  498. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  499. LEFT JOIN (SELECT
  500. COUNT( m.id ) AS exam_num,
  501. c.goods_id
  502. FROM
  503. course_menu_exam m
  504. LEFT JOIN goods_course c ON m.course_id = c.course_id
  505. where
  506. m.type = 1
  507. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  508. where 1=1
  509. and cgu.`status` =1
  510. <if test="gradeId != null and gradeId !='' ">
  511. and cgu.grade_id = #{gradeId}
  512. </if>
  513. <if test="userId != null ">
  514. and cgu.user_id = #{userId}
  515. </if>
  516. LIMIT 1
  517. </select>
  518. <select id="listPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  519. resultMap="ClassPeriodUserVo">
  520. SELECT
  521. u.user_account,
  522. u.realname,
  523. u.id_card,
  524. u.user_id,
  525. u.telphone,
  526. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  527. u.one_inch_photos,
  528. u.id_card_img1,
  529. u.id_card_img2,
  530. cgu.period_status,
  531. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  532. class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type = 1 ) as exam_num,
  533. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id, ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status =1 and ubr.user_id=#{userId} and ubr.grade_id=cgu.grade_id and ubr.current_status=1) as record_num,
  534. (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  535. ups.`status` =1 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.grade_id = cgu.grade_id and up.type = 1) as pass,
  536. (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  537. ups.`status` =2 and up.grade_id = cg.grade_id and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.user_id = #{userId} and up.type = 1) as pending,
  538. (SELECT
  539. COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  540. =0 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.user_id = #{userId} and up.type = 1) as cheat,
  541. (SELECT COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where
  542. ups.`status` =1 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.grade_id = cg.grade_id and up.type = 2) as exam_pass,
  543. (SELECT
  544. COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  545. =0 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.user_id = #{userId} and up.type = 2) as exam_cheat,
  546. (SELECT
  547. COUNT(DISTINCT up.course_id,up.module_id,up.chapter_id,up.section_id) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.`status`
  548. =2 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.user_id = #{userId} and up.type = 2) as exam_pending,
  549. (SELECT up.key_value FROM user_profile up where up.goods_id = #{goodsId} and up.user_id =#{userId} and up.order_goods_id = cgu.order_goods_id and up.current_status = 1 and up.`status` = 1 and up.type_status =1 LIMIT 1) as key_value
  550. <if test="userId != null and userId !='' ">
  551. ,(SELECT MIN(first_start_time) from user_study_record where user_id = #{userId} and grade_id = #{gradeId}) as study_start_time,
  552. (SELECT MAX(end_time) from user_study_record where user_id = #{userId} and grade_id = #{gradeId}) as study_end_time
  553. </if>
  554. FROM
  555. class_grade_user cgu
  556. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  557. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  558. where 1=1
  559. <if test="userId != null and userId !='' ">
  560. and u.user_id = #{userId}
  561. </if>
  562. <if test="gradeId != null and gradeId !='' ">
  563. and cgu.grade_id = #{gradeId}
  564. </if>
  565. <if test="periodStatus != null and periodStatus !='' ">
  566. and cgu.period_status = #{periodStatus}
  567. </if>
  568. LIMIT 1
  569. </select>
  570. <select id="listPeriodAudit" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  571. resultMap="ClassPeriodVo">
  572. SELECT
  573. gc.sort as course_sort,
  574. cm.sort,
  575. cm.menu_id as id,
  576. cm.course_id,
  577. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  578. and u.user_id = #{userId}
  579. </if>) as realname,
  580. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  581. and u.user_id = #{userId}
  582. </if>) as user_id,
  583. (SELECT cm.module_name FROM course_module cm where cm.menu_id = cm.module_id) as type_name,
  584. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs LEFT JOIN course_module_chapter cmc on
  585. cmc.chapter_id=ccs.chapter_id where cmc.module_id=cm.menu_id) as class_hours,
  586. 1 as type,
  587. NULL as study_start_time,
  588. NULL as study_end_time
  589. FROM
  590. course_menu cm
  591. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  592. where 1=1
  593. <if test="goodsId != null and goodsId !='' ">
  594. and gc.goods_id=#{goodsId}
  595. </if>
  596. AND cm.type=1
  597. UNION
  598. SELECT
  599. gc.sort as course_sort,
  600. cm.sort,
  601. cm.menu_id as id,
  602. cm.course_id,
  603. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  604. and u.user_id = #{userId}
  605. </if>) as realname,
  606. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  607. and u.user_id = #{userId}
  608. </if>) as user_id,
  609. (SELECT cc.`name` FROM course_chapter cc where cm.menu_id = cc.chapter_id) as type_name,
  610. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs where ccs.chapter_id=cm.menu_id) as class_hours,
  611. 2 as type,
  612. (SELECT usr.create_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  613. ccs.section_id and ccs.chapter_id = usr.chapter_id where ccs.chapter_id = cm.menu_id AND usr.current_status = 1 AND usr.user_id=#{userId} and usr.course_id = cm.course_id and usr.goods_id = gc.goods_id and usr.grade_id = #{gradeId} ORDER BY usr.create_time ASC
  614. limit 1) as study_start_time,
  615. (SELECT usr.update_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  616. ccs.section_id and ccs.chapter_id = usr.chapter_id where ccs.chapter_id = cm.menu_id AND usr.current_status = 1 AND usr.user_id=#{userId} and usr.course_id = cm.course_id and usr.goods_id = gc.goods_id and usr.grade_id = #{gradeId} ORDER BY usr.create_time DESC
  617. limit 1) as study_end_time
  618. FROM
  619. course_menu cm
  620. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  621. where 1=1 <if test="goodsId != null and goodsId !='' ">
  622. and gc.goods_id=#{goodsId}
  623. </if> AND cm.type=2
  624. </select>
  625. <select id="listPeriodAuditSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  626. resultMap="ClassPeriodVo">
  627. SELECT
  628. gc.sort as course_sort,
  629. cm.sort,
  630. cm.menu_id as id,
  631. cm.course_id,
  632. (SELECT u.realname FROM `user` u where 1=1
  633. <if test="userId != null and userId !='' ">
  634. and u.user_id = #{userId}
  635. </if>
  636. ) as realname,
  637. (SELECT u.user_id FROM `user` u where 1=1
  638. <if test="userId != null and userId !='' ">
  639. and u.user_id = #{userId}
  640. </if>
  641. ) as user_id,
  642. cs.`name` as type_name,
  643. cs.duration_time,
  644. null as class_hours,
  645. 3 as type
  646. FROM
  647. course_menu cm
  648. LEFT JOIN course_section cs on cm.menu_id = cs.section_id
  649. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  650. where 1=1
  651. <if test="goodsId != null and goodsId !='' ">
  652. and gc.goods_id = #{goodsId}
  653. </if>
  654. AND cm.type=3
  655. </select>
  656. <select id="listPeriodAuditExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  657. SELECT
  658. cme.exam_id as id,
  659. cme.course_id,
  660. (SELECT u.realname FROM `user` u where 1=1
  661. <if test="userId != null and userId !='' ">
  662. and u.user_id = #{userId}
  663. </if>
  664. ) as realname,
  665. (SELECT u.user_id FROM `user` u where 1=1
  666. <if test="userId != null and userId !='' ">
  667. and u.user_id = #{userId}
  668. </if>
  669. ) as user_id,
  670. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  671. null as class_hours,
  672. 4 as type,
  673. (
  674. SELECT
  675. ups.record_start_time
  676. FROM
  677. user_period_status ups
  678. LEFT JOIN user_period up ON up.id = ups.period_id
  679. WHERE
  680. period_status = 1
  681. AND up.course_id = gc.course_id
  682. <if test="goodsId != null and goodsId !='' ">
  683. AND up.goods_id = #{goodsId}
  684. </if>
  685. and cme.section_id =up.section_id
  686. AND up.exam_id = cme.exam_id
  687. ) AS study_start_time,
  688. (
  689. SELECT
  690. ups.record_end_time
  691. FROM
  692. user_period_status ups
  693. LEFT JOIN user_period up ON up.id = ups.period_id
  694. WHERE
  695. period_status = 1
  696. AND up.course_id = gc.course_id
  697. <if test="goodsId != null and goodsId !='' ">
  698. AND up.goods_id = #{goodsId}
  699. </if>
  700. AND up.exam_id = cme.exam_id
  701. ) AS study_end_time,
  702. (
  703. SELECT
  704. ups.`status`
  705. FROM
  706. user_period_status ups
  707. LEFT JOIN user_period up ON up.id = ups.period_id
  708. WHERE
  709. period_status = 1
  710. AND up.course_id = gc.course_id
  711. <if test="goodsId != null and goodsId !='' ">
  712. AND up.goods_id = #{goodsId}
  713. </if>
  714. and cme.section_id =up.section_id
  715. AND up.exam_id = cme.exam_id
  716. ) AS STATUS,
  717. (
  718. SELECT
  719. ups.create_time
  720. FROM
  721. user_period_status ups
  722. LEFT JOIN user_period up ON up.id = ups.period_id
  723. WHERE
  724. period_status = 1
  725. AND up.course_id = gc.course_id
  726. <if test="goodsId != null and goodsId !='' ">
  727. AND up.goods_id = #{goodsId}
  728. </if>
  729. and cme.section_id =up.section_id
  730. AND up.exam_id = cme.exam_id
  731. ) AS audit_time,
  732. (
  733. SELECT
  734. COUNT( ups.id )
  735. FROM
  736. user_period_status ups
  737. LEFT JOIN user_period up ON up.id = ups.period_id
  738. WHERE
  739. period_status = 1
  740. AND up.course_id = gc.course_id
  741. <if test="goodsId != null and goodsId !='' ">
  742. AND up.goods_id = #{goodsId}
  743. </if>
  744. and cme.section_id =up.section_id
  745. AND up.exam_id = cme.exam_id
  746. ) AS audit_num
  747. FROM
  748. course_menu_exam cme
  749. LEFT JOIN goods_course gc on gc.course_id = cme.course_id
  750. LEFT JOIN course_menu cm on cme.section_id = cm.menu_id
  751. where 1=1
  752. <if test="goodsId != null and goodsId !='' ">
  753. and gc.goods_id= #{goodsId}
  754. </if>
  755. AND cm.type=3 and cme.chapter_id=0 and cme.module_id=0 and cme.type=1 and cm.type=3
  756. </select>
  757. <select id="listperiodChapter" parameterType="map" resultMap="ClassPeriodChapterVo">
  758. SELECT
  759. cmc.sort,
  760. cc.chapter_id as id,
  761. cm.course_id,
  762. ( SELECT u.realname FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  763. and u.user_id = #{userId}
  764. </if> LIMIT 1) AS realname,
  765. ( SELECT u.user_id FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  766. and u.user_id = #{userId}
  767. </if> LIMIT 1) AS user_id,
  768. cc.`name` as type_name,
  769. ( SELECT COUNT( ccs.section_id ) FROM course_chapter_section ccs WHERE ccs.chapter_id = cc.chapter_id ) AS
  770. class_hours,
  771. 2 AS type,
  772. (
  773. SELECT
  774. usr.create_time
  775. FROM
  776. user_study_record usr
  777. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id and ccs.chapter_id = usr.chapter_id
  778. WHERE
  779. ccs.chapter_id = cc.chapter_id
  780. AND usr.current_status = 1
  781. <if test="courseId != null and courseId !='' ">
  782. AND usr.course_id=#{courseId}
  783. </if>
  784. <if test="moduleId != null and moduleId !='' ">
  785. AND usr.module_id=#{moduleId}
  786. </if>
  787. <if test="goodsId != null and goodsId !='' ">
  788. AND usr.goods_id=#{goodsId}
  789. </if>
  790. <if test="gradeId != null and gradeId !='' ">
  791. AND usr.grade_id=#{gradeId}
  792. </if>
  793. <if test="userId != null and userId !='' ">
  794. AND usr.user_id=#{userId}
  795. </if>
  796. ORDER BY
  797. usr.create_time ASC
  798. LIMIT 1
  799. ) AS study_start_time,
  800. (
  801. SELECT
  802. usr.update_time
  803. FROM
  804. user_study_record usr
  805. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id and ccs.chapter_id = usr.chapter_id
  806. WHERE
  807. ccs.chapter_id = cc.chapter_id
  808. AND usr.current_status = 1
  809. <if test="courseId != null and courseId !='' ">
  810. AND usr.course_id=#{courseId}
  811. </if>
  812. <if test="moduleId != null and moduleId !='' ">
  813. AND usr.module_id=#{moduleId}
  814. </if>
  815. <if test="goodsId != null and goodsId !='' ">
  816. AND usr.goods_id=#{goodsId}
  817. </if>
  818. <if test="gradeId != null and gradeId !='' ">
  819. AND usr.grade_id=#{gradeId}
  820. </if>
  821. <if test="userId != null and userId !='' ">
  822. AND usr.user_id=#{userId}
  823. </if>
  824. ORDER BY
  825. usr.create_time DESC
  826. LIMIT 1
  827. ) AS study_end_time,
  828. (
  829. SELECT
  830. ubr.performance
  831. FROM
  832. user_bank_record ubr
  833. LEFT JOIN course_menu_exam cme ON cme.exam_id = ubr.exam_id and cme.chapter_id = ubr.chapter_id
  834. WHERE 1=1
  835. AND ubr.current_status = 1
  836. <if test="moduleId != null and moduleId !='' ">
  837. AND ubr.module_id=#{moduleId}
  838. </if>
  839. <if test="goodsId != null and goodsId !='' ">
  840. AND ubr.goods_id=#{goodsId}
  841. </if>
  842. <if test="moduleId != null and moduleId !='' ">
  843. AND cme.module_id=#{moduleId}
  844. </if>
  845. <if test="courseId != null and courseId !='' ">
  846. AND cme.course_id =#{courseId}
  847. </if>
  848. <if test="userId != null and userId !='' ">
  849. AND ubr.user_id=#{userId}
  850. </if>
  851. AND cme.chapter_id = cmc.chapter_id
  852. LIMIT 1 ) AS performance
  853. FROM
  854. course_menu cm
  855. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  856. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  857. WHERE
  858. 1 = 1
  859. <if test="moduleId != null and moduleId !='' ">
  860. AND cmc.module_id=#{moduleId}
  861. </if>
  862. <if test="courseId != null and courseId !='' ">
  863. AND cm.course_id =#{courseId}
  864. </if>
  865. </select>
  866. <select id="listperiodExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  867. SELECT
  868. cme.exam_id as id,
  869. cme.course_id,
  870. (SELECT u.realname FROM `user` u where 1=1
  871. <if test="userId != null and userId !='' ">
  872. and u.user_id = #{userId}
  873. </if>
  874. ) as realname,
  875. (SELECT u.user_id FROM `user` u where 1=1
  876. <if test="userId != null and userId !='' ">
  877. and u.user_id = #{userId}
  878. </if>
  879. ) as user_id,
  880. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  881. null as class_hours,
  882. 4 as type
  883. FROM
  884. course_menu_exam cme
  885. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  886. WHERE 1=1
  887. <if test="courseId != null and courseId !='' ">
  888. AND cme.course_id=#{courseId}
  889. </if>
  890. <if test="chapterId != null and chapterId !='' ">
  891. AND cme.chapter_id =#{chapterId}
  892. </if>
  893. <if test="moduleId != null and moduleId !='' ">
  894. AND cme.module_id =#{moduleId}
  895. </if>
  896. </select>
  897. <select id="listPeriodSection" parameterType="map" resultMap="ClassPeriodSectionVo">
  898. SELECT
  899. ccs.sort,
  900. cs.section_id AS id,
  901. #{courseId} AS course_id,
  902. ( SELECT u.realname FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  903. and u.user_id = #{userId}
  904. </if> ) AS realname,
  905. ( SELECT u.user_id FROM `user` u WHERE 1 = 1 <if test="userId != null and userId !='' ">
  906. and u.user_id = #{userId}
  907. </if> ) AS user_id,
  908. cs.NAME AS type_name,
  909. cs.duration_time,
  910. NULL AS class_hours,
  911. 3 AS type
  912. FROM
  913. course_chapter_section ccs
  914. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  915. WHERE
  916. 1 = 1
  917. <if test="chapterId != null and chapterId !='' ">
  918. AND ccs.chapter_id = #{chapterId}
  919. </if>
  920. </select>
  921. <select id="listPeriodSectionExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  922. SELECT
  923. cme.exam_id as id,
  924. cme.course_id,
  925. (SELECT u.realname FROM `user` u where 1=1
  926. <if test="userId != null and userId !='' ">
  927. and u.user_id = #{userId}
  928. </if>
  929. ) as realname,
  930. (SELECT u.user_id FROM `user` u where 1=1
  931. <if test="userId != null and userId !='' ">
  932. and u.user_id = #{userId}
  933. </if>
  934. ) as user_id,
  935. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  936. null as class_hours,
  937. 4 as type
  938. FROM
  939. course_menu_exam cme
  940. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  941. WHERE 1=1
  942. and cme.module_id =0
  943. <if test="courseId != null and courseId !='' ">
  944. AND cme.course_id=#{courseId}
  945. </if>
  946. <if test="chapterId != null and chapterId !='' ">
  947. AND cme.chapter_id = #{chapterId}
  948. </if>
  949. </select>
  950. <select id="selectStart" parameterType="map" resultType="long">
  951. SELECT
  952. usr.create_time
  953. FROM
  954. user_study_record usr
  955. WHERE
  956. usr.goods_id = #{goodsId}
  957. AND usr.grade_id = #{gradeId}
  958. AND usr.user_id = #{userId} UNION
  959. SELECT
  960. ubr.create_time
  961. FROM
  962. user_bank_record ubr
  963. WHERE
  964. ubr.goods_id =#{goodsId}
  965. AND ubr.grade_id = #{gradeId}
  966. AND ubr.user_id = #{userId}
  967. ORDER BY create_time ASC
  968. </select>
  969. <select id="sendClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  970. SELECT
  971. cgu.user_id,
  972. cg.class_start_time,
  973. cg.class_end_time,
  974. cgg.goods_id,
  975. cg.grade_id
  976. FROM
  977. class_grade_user cgu
  978. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  979. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  980. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  981. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  982. where 1=1
  983. and irb.remind_id =5
  984. and cgu.status = 1
  985. AND unix_timestamp(now()) BETWEEN cg.class_end_time-1728000 and cg.class_end_time-1641600
  986. AND (SELECT COUNT(1) FROM inform_user iu where 1=1 and iu.remind_id = 5 and cgu.user_id = iu.user_id and cgu.grade_id = iu.grade_id and iu.system_status=3) &lt; 1
  987. </select>
  988. <select id="sendTenClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  989. SELECT
  990. cgu.user_id,
  991. cg.class_start_time,
  992. cg.class_end_time,
  993. cgg.goods_id,
  994. cg.grade_id
  995. FROM
  996. class_grade_user cgu
  997. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  998. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  999. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  1000. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  1001. where 1=1
  1002. and irb.remind_id =6
  1003. and cgu.status = 1
  1004. AND unix_timestamp(now()) BETWEEN cg.class_end_time-864000 and cg.class_end_time-777600
  1005. AND (SELECT COUNT(1) FROM inform_user iu where 1=1 and iu.remind_id = 6 and cgu.user_id = iu.user_id and cgu.grade_id = iu.grade_id and iu.system_status=3) &lt; 1
  1006. </select>
  1007. <select id="sendFiveClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  1008. SELECT
  1009. cgu.user_id,
  1010. cg.class_start_time,
  1011. cg.class_end_time,
  1012. cgg.goods_id,
  1013. cg.grade_id
  1014. FROM
  1015. class_grade_user cgu
  1016. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  1017. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  1018. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  1019. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  1020. where 1=1
  1021. and irb.remind_id =7
  1022. and cgu.status = 1
  1023. AND unix_timestamp(now()) BETWEEN cg.class_end_time-432000 and cg.class_end_time-345600
  1024. AND (SELECT COUNT(1) FROM inform_user iu where 1=1 and iu.remind_id = 7 and cgu.user_id = iu.user_id and cgu.grade_id = iu.grade_id and iu.system_status=3) &lt; 1
  1025. </select>
  1026. <select id="selectUserCount" parameterType="com.zhongzheng.modules.user.domain.User" resultType="long">
  1027. SELECT
  1028. COUNT( 1 )
  1029. FROM
  1030. `user`
  1031. WHERE
  1032. id_card = #{idCard} and user_id != #{userId} and `status` = 1
  1033. </select>
  1034. <select id="selectUserCertificate" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  1035. resultMap="ClassGradeUserVoResult">
  1036. </select>
  1037. <select id="findChapterList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="CourseChapterResultVo">
  1038. SELECT
  1039. cc.chapter_id,
  1040. cc.`name`
  1041. FROM
  1042. course_module_chapter p
  1043. LEFT JOIN course_chapter cc ON p.chapter_id = cc.chapter_id
  1044. LEFT JOIN course_menu m ON m.menu_id = p.module_id
  1045. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  1046. WHERE
  1047. gc.goods_id = #{goodsId}
  1048. AND m.type IN ( 1 ) UNION
  1049. SELECT
  1050. cc.chapter_id,
  1051. cc.`name`
  1052. FROM
  1053. course_menu m
  1054. LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
  1055. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  1056. WHERE
  1057. gc.goods_id = #{goodsId}
  1058. AND m.type IN ( 2 )
  1059. </select>
  1060. <select id="selectOfficialInfoCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="long">
  1061. SELECT
  1062. count(*)
  1063. FROM
  1064. class_grade_user cgu
  1065. WHERE
  1066. cgu.grade_id = #{gradeId}
  1067. AND cgu.official_status = 1
  1068. </select>
  1069. <select id="selectLearnStatusCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="long">
  1070. SELECT
  1071. count(*)
  1072. FROM
  1073. class_grade_user cgu
  1074. WHERE
  1075. cgu.grade_id = #{gradeId}
  1076. AND cgu.learn_status = 1
  1077. </select>
  1078. <select id="selectOfficialPeriodCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="long">
  1079. SELECT
  1080. count(*)
  1081. FROM
  1082. class_grade_user cgu
  1083. WHERE
  1084. cgu.grade_id = #{gradeId}
  1085. AND cgu.period_plush = 1
  1086. </select>
  1087. <select id="selectOfficialNotPush" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="ClassGradeUserGoodsVoResult">
  1088. SELECT
  1089. gu.*
  1090. FROM
  1091. class_grade g
  1092. LEFT JOIN class_grade_user gu ON g.grade_id = gu.grade_id
  1093. WHERE
  1094. g.interface_push_id > 0
  1095. AND g.`status` = 1
  1096. AND gu.`status` = 1
  1097. AND gu.change_grade = 0
  1098. AND IFNULL(gu.official_status,0) != 1
  1099. </select>
  1100. <select id="selectPeriodNotPush" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="ClassGradeUserGoodsVoResult">
  1101. SELECT
  1102. gu.*
  1103. FROM
  1104. class_grade g
  1105. LEFT JOIN class_grade_user gu ON g.grade_id = gu.grade_id
  1106. WHERE
  1107. g.interface_period_id > 0
  1108. AND g.`status` = 1
  1109. AND gu.`status` = 1
  1110. AND gu.change_grade = 0
  1111. AND IFNULL(gu.period_plush,0) != 1
  1112. AND gu.period_status = 1
  1113. </select>
  1114. </mapper>