ClassGradeUserMapper.xml 50 KB

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