ClassGradeUserMapper.xml 50 KB

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