ClassGradeUserMapper.xml 55 KB

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