ClassGradeUserMapper.xml 53 KB

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