ClassGradeUserMapper.xml 54 KB

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