ClassGradeUserMapper.xml 58 KB

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