ClassGradeUserMapper.xml 40 KB

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