ClassGradeUserMapper.xml 50 KB

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