ClassGradeUserMapper.xml 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.ClassGradeUser" id="ClassGradeUserResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="gradeId" column="grade_id"/>
  10. <result property="status" column="status"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="fromType" column="from_type"/>
  15. <result property="periodStatus" column="period_status"/>
  16. <result property="orderGoodsId" column="order_goods_id"/>
  17. <result property="finishStatus" column="finish_status"/>
  18. <result property="officialStatus" column="official_status"/>
  19. <result property="learnStatus" column="learn_status"/>
  20. <result property="periodPlush" column="period_plush"/>
  21. <result property="periodTime" column="period_time"/>
  22. <result property="periodWaitTime" column="period_wait_time"/>
  23. <result property="changeGrade" column="change_grade"/>
  24. <result property="officialStatusMsg" column="official_status_msg"/>
  25. <result property="periodPlushMsg" column="period_plush_msg"/>
  26. <result property="officialStatusTime" column="official_status_time"/>
  27. <result property="periodPlushTime" column="period_plush_time"/>
  28. <result property="officialStatusNum" column="official_status_num"/>
  29. <result property="periodStatusNum" column="period_status_num"/>
  30. <result property="periodIngTime" column="period_ing_time"/>
  31. <result property="auditUserName" column="audit_user_name"/>
  32. <result property="toOldStatus" column="to_old_status"/>
  33. <result property="toOldResult" column="to_old_result"/>
  34. <result property="toOldTime" column="to_old_time"/>
  35. </resultMap>
  36. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserVo" id="ClassGradeUserVoResult">
  37. <result property="id" column="id"/>
  38. <result property="userId" column="user_id"/>
  39. <result property="gradeId" column="grade_id"/>
  40. <result property="className" column="class_name"/>
  41. <result property="status" column="status"/>
  42. <result property="code" column="user_account"/>
  43. <result property="realName" column="realname"/>
  44. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  45. <result property="createBy" column="create_by"/>
  46. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  47. <result property="changeGrade" column="change_grade"/>
  48. <result property="interfacePushId" column="interface_push_id"/>
  49. <result property="classStatus" column="class_status"/>
  50. <result property="officialName" column="official_name"/>
  51. <result property="classStartTime" column="class_start_time"/>
  52. <result property="classEndTime" column="class_end_time"/>
  53. <result property="officialStatusNum" column="official_status_num"/>
  54. <result property="periodTime" column="period_time"/>
  55. <result property="periodWaitTime" column="period_wait_time"/>
  56. <result property="periodStatus" column="period_status"/>
  57. <result property="periodStatusNum" column="period_status_num"/>
  58. <result property="periodIngTime" column="period_ing_time"/>
  59. <result property="finishStatus" column="finish_status"/>
  60. <result property="learnStatus" column="learn_status"/>
  61. <result property="reason" column="reason"/>
  62. <result property="interfaceAccountId" column="interface_account_id"/>
  63. <result property="noInterfaceAccountId" column="no_interface_account_id"/>
  64. <result property="toOldStatus" column="to_old_status"/>
  65. <result property="toOldResult" column="to_old_result"/>
  66. <result property="toOldTime" column="to_old_time"/>
  67. <result property="orderGoodsId" column="order_goods_id"/>
  68. </resultMap>
  69. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserGoodsVo" id="ClassGradeUserGoodsVoResult">
  70. <result property="id" column="id"/>
  71. <result property="userId" column="user_id"/>
  72. <result property="gradeId" column="grade_id"/>
  73. <result property="status" column="status"/>
  74. <result property="goodsCode" column="goods_code"/>
  75. <result property="goodsName" column="goods_name"/>
  76. <result property="gradeStatus" column="grade_status"/>
  77. <result property="gradeCode" column="grade_code"/>
  78. <result property="gradeName" column="grade_name"/>
  79. <result property="year" column="year"/>
  80. <result property="educationName" column="education_name"/>
  81. <result property="projectName" column="project_name"/>
  82. <result property="businessName" column="business_name"/>
  83. <result property="schoolName" column="school_name"/>
  84. <result property="createTime" column="create_time"/>
  85. <result property="createBy" column="create_by"/>
  86. <result property="goodsId" column="goods_id"/>
  87. <result property="classStartTime" column="class_start_time"/>
  88. <result property="classEndTime" column="class_end_time"/>
  89. <result property="orderGoodsId" column="order_goods_id"/>
  90. </resultMap>
  91. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodStudentVo" id="ClassPeriodStudentVo">
  92. <result property="userId" column="user_id"/>
  93. <result property="gradeId" column="grade_id"/>
  94. <result property="studentCode" column="user_account"/>
  95. <result property="realName" column="realname"/>
  96. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  97. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  98. <result property="status" column="status"/>
  99. <result property="classHours" column="class_hours"/>
  100. <result property="periodStatus" column="period_status"/>
  101. <result property="secAllNum" column="sec_all_num"/>
  102. <result property="examNum" column="exam_num"/>
  103. <result property="recordNum" column="record_num"/>
  104. <result property="periodPlush" column="period_plush"/>
  105. <result property="startTime" column="start_time"/>
  106. <result property="endTime" column="end_time"/>
  107. <result property="studyStartTime" column="study_start_time"/>
  108. <result property="studyEndTime" column="study_end_time"/>
  109. <result property="rebuildNum" column="rebuild_num"/>
  110. <result property="profileStatus" column="profile_status"/>
  111. <result property="className" column="class_name"/>
  112. <result property="goodsName" column="goods_name"/>
  113. <result property="standPrice" column="stand_price"/>
  114. <result property="goodsCode" column="goods_code"/>
  115. <result property="keyValue" column="key_value"/>
  116. <result property="classStartTime" column="class_start_time"/>
  117. <result property="classEndTime" column="class_end_time"/>
  118. <result property="periodStatusNum" column="period_status_num"/>
  119. <result property="serviceStartTime" column="service_start_time"/>
  120. <result property="serviceEndTime" column="service_end_time"/>
  121. <result property="oneInchPhotos" column="one_inch_photos"/>
  122. <result property="periodTime" column="period_time"/>
  123. <result property="sectionName" column="section_name"/>
  124. <result property="companyName" column="company_name"/>
  125. <result property="durationTime" column="duration_time"/>
  126. <result property="recordStartTime" column="record_start_time"/>
  127. <result property="recordEndTime" column="record_end_time"/>
  128. <result property="onLineTime" column="on_line_time"/>
  129. <result property="orderGoodsId" column="order_goods_id"/>
  130. </resultMap>
  131. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodUserVo" id="ClassPeriodUserVo">
  132. <result property="userId" column="user_id"/>
  133. <result property="studentCode" column="user_account"/>
  134. <result property="realName" column="realname"/>
  135. <result property="oneInchPhotos" column="one_inch_photos"/>
  136. <result property="idCardImg1" column="id_card_img1"/>
  137. <result property="idCardImg2" column="id_card_img2"/>
  138. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  139. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  140. <result property="secAllNum" column="sec_all_num"/>
  141. <result property="examNum" column="exam_num"/>
  142. <result property="recordNum" column="record_num"/>
  143. <result property="pass" column="pass"/>
  144. <result property="cheat" column="cheat"/>
  145. <result property="pending" column="pending"/>
  146. <result property="examPass" column="exam_pass"/>
  147. <result property="examPending" column="exam_pending"/>
  148. <result property="examCheat" column="exam_cheat"/>
  149. <result property="keyValue" column="key_value"/>
  150. <result property="periodStatus" column="period_status"/>
  151. <result property="studyStartTime" column="study_start_time"/>
  152. <result property="studyEndTime" column="study_end_time"/>
  153. <result property="goodsName" column="goods_name"/>
  154. <result property="className" column="class_name"/>
  155. <result property="classHours" column="class_hours"/>
  156. <result property="orderGoodsId" column="order_goods_id"/>
  157. <result property="classStartTime" column="class_start_time"/>
  158. <result property="classEndTime" column="class_end_time"/>
  159. <result property="officialName" column="official_name"/>
  160. </resultMap>
  161. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodVo" id="ClassPeriodVo">
  162. <result property="userId" column="user_id"/>
  163. <result property="id" column="id"/>
  164. <result property="typeName" column="type_name"/>
  165. <result property="realName" column="realname"/>
  166. <result property="classHours" column="class_hours"/>
  167. <result property="studyStartTime" column="study_start_time"/>
  168. <result property="status" column="status"/>
  169. <result property="auditTime" column="audit_time"/>
  170. <result property="type" column="type"/>
  171. <result property="sort" column="sort"/>
  172. <result property="courseId" column="course_id"/>
  173. <result property="studyEndTime" column="study_end_time"/>
  174. <result property="durationTime" column="duration_time"/>
  175. <result property="courseSort" column="course_sort"/>
  176. <result property="sectionType" column="section_type"/>
  177. <result property="realLiveStartTime" column="real_live_start_time"/>
  178. <result property="realLiveEndTime" column="real_live_end_time"/>
  179. <result property="realDuration" column="real_duration"/>
  180. <result property="commonSign" column="common_sign"/>
  181. </resultMap>
  182. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodChapterVo" id="ClassPeriodChapterVo">
  183. <result property="userId" column="user_id"/>
  184. <result property="id" column="id"/>
  185. <result property="courseId" column="course_id"/>
  186. <result property="typeName" column="type_name"/>
  187. <result property="realName" column="realname"/>
  188. <result property="classHours" column="class_hours"/>
  189. <result property="studyStartTime" column="study_start_time"/>
  190. <result property="status" column="status"/>
  191. <result property="auditTime" column="audit_time"/>
  192. <result property="type" column="type"/>
  193. <result property="studyEndTime" column="study_end_time"/>
  194. <result property="performance" column="performance"/>
  195. <result property="sort" column="sort"/>
  196. <result property="doType" column="do_type"/>
  197. <result property="moduleId" column="module_id"/>
  198. <result property="commonSign" column="common_sign"/>
  199. </resultMap>
  200. <resultMap type="com.zhongzheng.modules.grade.vo.ClassPeriodSectionVo" id="ClassPeriodSectionVo">
  201. <result property="userId" column="user_id"/>
  202. <result property="id" column="id"/>
  203. <result property="typeName" column="type_name"/>
  204. <result property="realName" column="realname"/>
  205. <result property="classHours" column="class_hours"/>
  206. <result property="durationTime" column="duration_time"/>
  207. <result property="studyStartTime" column="study_start_time"/>
  208. <result property="status" column="status"/>
  209. <result property="auditTime" column="audit_time"/>
  210. <result property="type" column="type"/>
  211. <result property="studyEndTime" column="study_end_time"/>
  212. <result property="auditNum" column="audit_num"/>
  213. <result property="sort" column="sort"/>
  214. <result property="sectionType" column="section_type"/>
  215. <result property="realLiveStartTime" column="real_live_start_time"/>
  216. <result property="realLiveEndTime" column="real_live_end_time"/>
  217. <result property="realDuration" column="real_duration"/>
  218. <result property="recordingUrl" column="recording_url"/>
  219. <result property="doType" column="do_type"/>
  220. <result property="chapterId" column="chapter_id"/>
  221. <result property="moduleId" column="module_id"/>
  222. </resultMap>
  223. <resultMap type="com.zhongzheng.modules.course.vo.CourseChapterVo" id="CourseChapterResultVo">
  224. <result property="chapterId" column="chapter_id"/>
  225. <result property="name" column="name"/>
  226. </resultMap>
  227. <select id="selectUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  228. resultMap="ClassGradeUserVoResult">
  229. SELECT
  230. g.*,
  231. u.user_account,
  232. u.realname,
  233. u.id_card,
  234. u.telphone,
  235. cg.class_name,
  236. cg.official_name,
  237. cg.class_status,
  238. cg.interface_push_id,
  239. cg.class_start_time,
  240. cg.class_end_time,
  241. g.official_status_num,
  242. g.period_time,
  243. g.period_wait_time,
  244. g.period_status
  245. FROM
  246. class_grade_user g
  247. LEFT JOIN `user` u ON g.user_id = u.user_id
  248. LEFT JOIN class_grade cg ON cg.grade_id = g.grade_id
  249. WHERE
  250. 1 = 1
  251. AND g.change_grade = 0
  252. AND g.grade_id = #{gradeId}
  253. AND g.user_id = #{userId}
  254. AND g.order_goods_id = #{orderGoodsId}
  255. </select>
  256. <select id="select" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  257. resultMap="ClassGradeUserVoResult">
  258. SELECT
  259. g.*,
  260. u.user_account,
  261. u.realname,
  262. u.id_card,
  263. u.telphone
  264. FROM
  265. class_grade_user g
  266. LEFT JOIN `user` u ON g.user_id = u.user_id
  267. WHERE
  268. 1 = 1
  269. <if test="status != null and status.size()!=0 ">
  270. AND g.status in
  271. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  272. #{item}
  273. </foreach>
  274. </if>
  275. <if test="gradeId != null and gradeId != ''">
  276. AND g.grade_id = #{gradeId}
  277. </if>
  278. <if test="userId != null and userId != ''">
  279. AND g.user_id = #{userId}
  280. </if>
  281. <if test="classStartTime != null or classEndTime != null ">
  282. AND #{classStartTime} BETWEEN g.class_start_time
  283. </if>
  284. order by g.update_time desc
  285. </select>
  286. <select id="listUser" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  287. resultMap="ClassGradeUserGoodsVoResult">
  288. SELECT
  289. * ,
  290. (select `code` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  291. u.grade_id) as goods_code,
  292. (select `year` FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  293. u.grade_id) as year,
  294. (select goods_name FROM goods g LEFT JOIN class_grade_goods c on g.goods_id = c.goods_id where c.grade_id =
  295. u.grade_id) as goods_name,
  296. (select b.business_name FROM course_business b LEFT JOIN goods g on b.id = g.business_id LEFT JOIN
  297. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as business_name,
  298. (select b.project_name FROM course_project_type b LEFT JOIN goods g on b.id = g.project_id LEFT JOIN
  299. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as project_name,
  300. (select b.school_name FROM school b LEFT JOIN goods g on b.id = g.school_id LEFT JOIN class_grade_goods c on
  301. g.goods_id = c.goods_id where c.grade_id = u.grade_id) as school_name,
  302. (select b.education_name FROM course_education_type b LEFT JOIN goods g on b.id = g.education_type_id LEFT JOIN
  303. class_grade_goods c on g.goods_id = c.goods_id where c.grade_id = u.grade_id) as education_name,
  304. (SELECT g.grade_code FROM class_grade g where u.grade_id = g.grade_id) as grade_code,
  305. (SELECT g.class_name FROM class_grade g where u.grade_id = g.grade_id) as grade_name,
  306. (SELECT g.status FROM class_grade g where u.grade_id = g.grade_id) as grade_status
  307. FROM
  308. class_grade_user u
  309. where 1=1
  310. <if test="status != null and status.size()!=0 ">
  311. AND u.status in
  312. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  313. #{item}
  314. </foreach>
  315. </if>
  316. <if test="userId != null and userId != ''">
  317. and u.user_id= #{userId}
  318. </if>
  319. order by u.create_time desc
  320. </select>
  321. <select id="listUserVideoRecord" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  322. resultMap="ClassPeriodStudentVo">
  323. SELECT
  324. up.* ,cg.class_name,cs.duration_time,u.id_card,u.realname,u.one_inch_photos,u.company_name,cs.`name` as section_name,ups.record_start_time,ups.record_end_time,ups.update_time as on_line_time
  325. FROM
  326. user_period up
  327. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  328. LEFT JOIN class_grade cg on up.grade_id = cg.grade_id
  329. LEFT JOIN goods g ON up.goods_id = g.goods_id
  330. LEFT JOIN course_section cs ON up.section_id = cs.section_id
  331. LEFT JOIN `user` u ON up.user_id = u.user_id
  332. WHERE
  333. up.grade_id > 0 and up.type = 1
  334. <if test="businessId != null and businessId != ''">
  335. AND g.business_id = #{businessId}
  336. </if>
  337. <if test="educationTypeId != null and educationTypeId != ''">
  338. AND g.education_type_id = #{educationTypeId}
  339. </if>
  340. <if test="projectId != null and projectId != ''">
  341. AND g.project_id = #{projectId}
  342. </if>
  343. <if test="realname != null and realname != ''">
  344. AND u.realname like concat('%', #{realname}, '%')
  345. </if>
  346. <if test="telphone != null and telphone != ''">
  347. AND u.telphone = #{telphone`,typeHandler=com.zhongzheng.common.type.EncryptHandler`}
  348. </if>
  349. <if test="idCard != null and idCard != ''">
  350. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  351. </if>
  352. <if test="companyName != null and companyName != ''">
  353. AND u.company_name like concat('%', #{companyName}, '%')
  354. </if>
  355. order by up.create_time desc
  356. </select>
  357. <select id="listUserPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  358. resultMap="ClassPeriodStudentVo">
  359. SELECT
  360. u.user_account,
  361. u.user_id,
  362. cgu.`status`,
  363. u.realname,
  364. cgg.goods_id,
  365. u.id_card,
  366. cgu.grade_id,
  367. u.telphone,
  368. u.one_inch_photos,
  369. up.`status` as profile_status,
  370. g.class_hours as class_hours,
  371. g.study_start_time as study_start_time,
  372. g.study_end_time as study_end_time,
  373. g.goods_name,
  374. g.code as goods_code,
  375. g.stand_price,
  376. cgu.period_status,
  377. cg.class_start_time,
  378. cg.class_end_time,
  379. cg.class_name,
  380. cgu.period_plush,
  381. cgu.period_status_num,
  382. cgu.period_time,
  383. cgu.order_goods_id,
  384. IFNULL(ge.exam_num,0) as exam_num,
  385. <if test="userPhoto != null and userPhoto == 1">
  386. up.key_value,
  387. </if>
  388. cgu.period_wait_time as end_time,
  389. (SELECT og.service_start_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_start_time,
  390. (SELECT og.service_end_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_end_time,
  391. (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
  392. <if test="userPhoto == null">
  393. ,(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
  394. 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
  395. </if>
  396. FROM
  397. class_grade_user cgu
  398. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  399. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  400. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  401. 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
  402. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  403. LEFT JOIN course_business cb ON g.business_id = cb.id
  404. LEFT JOIN (SELECT
  405. COUNT( m.id ) AS exam_num,
  406. c.goods_id
  407. FROM
  408. course_menu_exam m
  409. LEFT JOIN goods_course c ON m.course_id = c.course_id
  410. where
  411. m.type in (1,3)
  412. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  413. where 1=1
  414. and cgu.`status` =1
  415. <if test="periodPlush != null and periodPlush != ''">
  416. AND cgu.period_plush = #{periodPlush}
  417. </if>
  418. <if test="officialStatus != null and officialStatus != ''">
  419. AND cgu.official_status = #{officialStatus}
  420. </if>
  421. <if test="changeGrade != null and changeGrade != ''">
  422. AND cgu.change_grade = #{changeGrade}
  423. </if>
  424. <if test="profileStatus != null and profileStatus != ''">
  425. AND up.status = #{profileStatus}
  426. </if>
  427. <if test="gradeId != null and gradeId !='' ">
  428. and cgu.grade_id = #{gradeId}
  429. </if>
  430. <if test="businessId != null and businessId != ''">
  431. AND g.business_id = #{businessId}
  432. </if>
  433. <if test="projectId != null and projectId != ''">
  434. AND g.project_id = #{projectId}
  435. </if>
  436. <if test="educationTypeId != null and educationTypeId != ''">
  437. AND g.education_type_id = #{educationTypeId}
  438. </if>
  439. <if test="schoolId != null and schoolId != ''">
  440. AND g.school_id = #{schoolId}
  441. </if>
  442. <if test="majorId != null and majorId != ''">
  443. AND g.major_id = #{majorId}
  444. </if>
  445. <if test="periodStatus != null ">
  446. and cgu.period_status = #{periodStatus}
  447. </if>
  448. <if test="classStartTime != null and classStartTime != '' ">
  449. AND cg.class_start_time >= #{classStartTime}
  450. </if>
  451. <if test="classEndTime != null and classEndTime != '' ">
  452. AND #{classEndTime} >= cg.class_end_time
  453. </if>
  454. <if test="studyStatus != null and studyStatus == 1 ">
  455. and cgu.period_status = -1
  456. </if>
  457. <if test="studyStatus != null and studyStatus == 2 ">
  458. and cgu.period_status != -1
  459. </if>
  460. <if test="className != null and className !='' ">
  461. and cg.class_name like concat('%', #{className}, '%')
  462. </if>
  463. <if test="searchKey != null and searchKey != '' ">
  464. and (u.realname like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or cg.class_name like concat('%', #{searchKey}, '%'))
  465. </if>
  466. <if test="idCard != null and idCard !='' ">
  467. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  468. </if>
  469. <if test="telphone != null and telphone !='' ">
  470. AND u.telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  471. </if>
  472. <if test="searchStartTime != null and searchStartTime !='' ">
  473. AND cgu.create_time >=#{searchStartTime}
  474. </if>
  475. <if test="searchEndTime != null and searchEndTime !='' ">
  476. AND #{searchEndTime} >= cgu.create_time
  477. </if>
  478. <if test="periodStartTime != null and periodStartTime !='' ">
  479. AND cgu.period_time >=#{periodStartTime}
  480. </if>
  481. <if test="periodEndTime != null and periodEndTime !='' ">
  482. AND #{periodEndTime} >= cgu.period_time
  483. </if>
  484. <!-- 数据范围过滤 -->
  485. ${params.dataScope}
  486. <if test="periodStatus != 2 and periodStatus != 3">
  487. order by cgu.update_time desc
  488. </if>
  489. <if test="periodStatus == 2 ">
  490. order by cgu.period_wait_time,cgu.create_time
  491. </if>
  492. <if test="periodStatus == 3 ">
  493. order by cgu.period_ing_time,cgu.create_time
  494. </if>
  495. </select>
  496. <select id="listUserWeekStudyTime" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  497. resultType="Long">
  498. SELECT
  499. IFNULL( SUM( cs.duration_time ), 0 )
  500. FROM
  501. (
  502. SELECT
  503. section_id
  504. FROM
  505. user_study_record
  506. WHERE
  507. user_id = #{userId}
  508. AND grade_id = #{gradeId}
  509. AND current_status = 1
  510. AND `status` = 1
  511. <if test="searchWeekStartTime != null and searchWeekStartTime != '' ">
  512. AND update_time >= #{searchWeekStartTime}
  513. </if>
  514. <if test="searchWeekEndTime != null and searchWeekEndTime != '' ">
  515. AND #{searchWeekEndTime} >= update_time
  516. </if>
  517. GROUP BY
  518. course_id,
  519. module_id,
  520. chapter_id,
  521. section_id
  522. ) usr
  523. LEFT JOIN course_section cs ON usr.section_id = cs.section_id
  524. </select>
  525. <select id="listUserWeekPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  526. resultMap="ClassPeriodStudentVo">
  527. SELECT
  528. u.user_account,
  529. u.user_id,
  530. cgu.`status`,
  531. u.realname,
  532. cgg.goods_id,
  533. u.id_card,
  534. cgu.grade_id,
  535. u.telphone,
  536. u.one_inch_photos,
  537. up.`status` as profile_status,
  538. g.class_hours as class_hours,
  539. g.study_start_time as study_start_time,
  540. g.study_end_time as study_end_time,
  541. g.goods_name,
  542. g.code as goods_code,
  543. g.stand_price,
  544. cgu.period_status,
  545. cg.class_start_time,
  546. cg.class_end_time,
  547. cg.class_name,
  548. cgu.period_plush,
  549. cgu.period_status_num,
  550. cgu.period_time,
  551. cgu.order_goods_id,
  552. <if test="userPhoto != null and userPhoto == 1">
  553. up.key_value,
  554. </if>
  555. cgu.period_wait_time as end_time
  556. <if test="userPhoto == null">
  557. ,(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
  558. 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
  559. </if>
  560. FROM
  561. class_grade_user cgu
  562. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  563. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  564. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  565. 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
  566. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  567. LEFT JOIN course_business cb ON g.business_id = cb.id
  568. where 1=1
  569. and cgu.`status` =1
  570. <if test="searchWeekStartTime != null and searchWeekEndTime != '' ">
  571. AND (SELECT count(*) from user_study_record usr where usr.user_id = cgu.user_id AND usr.grade_id = cgu.grade_id AND usr.current_status = 1 AND #{searchWeekEndTime} >= usr.update_time AND usr.update_time >=#{searchWeekStartTime}) >0
  572. </if>
  573. <if test="periodPlush != null and periodPlush != ''">
  574. AND cgu.period_plush = #{periodPlush}
  575. </if>
  576. <if test="officialStatus != null and officialStatus != ''">
  577. AND cgu.official_status = #{officialStatus}
  578. </if>
  579. <if test="changeGrade != null and changeGrade != ''">
  580. AND cgu.change_grade = #{changeGrade}
  581. </if>
  582. <if test="profileStatus != null and profileStatus != ''">
  583. AND up.status = #{profileStatus}
  584. </if>
  585. <if test="gradeId != null and gradeId !='' ">
  586. and cgu.grade_id = #{gradeId}
  587. </if>
  588. <if test="businessId != null and businessId != ''">
  589. AND g.business_id = #{businessId}
  590. </if>
  591. <if test="educationTypeId != null and educationTypeId != ''">
  592. AND g.education_type_id = #{educationTypeId}
  593. </if>
  594. <if test="schoolId != null and schoolId != ''">
  595. AND g.school_id = #{schoolId}
  596. </if>
  597. <if test="majorId != null and majorId != ''">
  598. AND g.major_id = #{majorId}
  599. </if>
  600. <if test="periodStatus != null ">
  601. and cgu.period_status = #{periodStatus}
  602. </if>
  603. <if test="classStartTime != null and classStartTime != '' ">
  604. AND cg.class_start_time >= #{classStartTime}
  605. </if>
  606. <if test="classEndTime != null and classEndTime != '' ">
  607. AND #{classEndTime} >= cg.class_end_time
  608. </if>
  609. <if test="studyStatus != null and studyStatus == 1 ">
  610. and cgu.period_status = -1
  611. </if>
  612. <if test="studyStatus != null and studyStatus == 2 ">
  613. and cgu.period_status != -1
  614. </if>
  615. <if test="className != null and className !='' ">
  616. and cg.class_name like concat('%', #{className}, '%')
  617. </if>
  618. <if test="searchKey != null and searchKey != '' ">
  619. and (u.realname like concat('%', #{searchKey}, '%') or g.goods_name like concat('%', #{searchKey}, '%') or cg.class_name like concat('%', #{searchKey}, '%'))
  620. </if>
  621. <if test="idCard != null and idCard !='' ">
  622. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  623. </if>
  624. <if test="telphone != null and telphone !='' ">
  625. AND u.telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  626. </if>
  627. <if test="searchStartTime != null and searchStartTime !='' ">
  628. AND cgu.create_time >=#{searchStartTime}
  629. </if>
  630. <if test="searchEndTime != null and searchEndTime !='' ">
  631. AND #{searchEndTime} >= cgu.create_time
  632. </if>
  633. <if test="periodStartTime != null and periodStartTime !='' ">
  634. AND cgu.period_time >=#{periodStartTime}
  635. </if>
  636. <if test="periodEndTime != null and periodEndTime !='' ">
  637. AND #{periodEndTime} >= cgu.period_time
  638. </if>
  639. <!-- 数据范围过滤 -->
  640. ${params.dataScope}
  641. <if test="periodStatus != 2 and periodStatus != 3">
  642. order by cgu.update_time desc
  643. </if>
  644. <if test="periodStatus == 2 ">
  645. order by cgu.period_wait_time,cgu.create_time
  646. </if>
  647. <if test="periodStatus == 3 ">
  648. order by cgu.period_ing_time,cgu.create_time
  649. </if>
  650. </select>
  651. <select id="listUserPeriodExport" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  652. resultMap="ClassPeriodStudentVo">
  653. SELECT
  654. u.user_account,
  655. u.user_id,
  656. cgu.`status`,
  657. u.realname,
  658. cgg.goods_id,
  659. u.id_card,
  660. cgu.grade_id,
  661. u.telphone,
  662. g.class_hours as class_hours,
  663. g.study_start_time as study_start_time,
  664. g.study_end_time as study_end_time,
  665. g.goods_name,
  666. g.code as goods_code,
  667. g.stand_price,
  668. cgu.period_status,
  669. cg.class_start_time,
  670. cg.class_end_time,
  671. cg.class_name,
  672. cgu.period_plush,
  673. cgu.period_status_num,
  674. cgu.order_goods_id,
  675. (SELECT og.service_start_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_start_time,
  676. (SELECT og.service_end_time FROM order_goods og where og.order_goods_id = cgu.order_goods_id ) as service_end_time,
  677. <if test="userPhoto != null and userPhoto == 1">
  678. up.key_value,
  679. </if>
  680. cgu.period_time as end_time
  681. FROM
  682. class_grade_user cgu
  683. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  684. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  685. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  686. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  687. LEFT JOIN course_business cb ON g.business_id = cb.id
  688. 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
  689. where 1=1
  690. <if test="searchWeekStartTime != null and searchWeekEndTime != '' ">
  691. AND (SELECT count(*) from user_study_record usr where usr.user_id = cgu.user_id AND usr.grade_id = cgu.grade_id AND usr.current_status = 1 AND #{searchWeekEndTime} >= usr.update_time AND usr.update_time >=#{searchWeekStartTime}) >0
  692. </if>
  693. and cgu.`status` =1
  694. <if test="periodPlush != null and periodPlush != ''">
  695. AND cgu.period_plush = #{periodPlush}
  696. </if>
  697. <if test="officialStatus != null and officialStatus != ''">
  698. AND cgu.official_status = #{officialStatus}
  699. </if>
  700. <if test="changeGrade != null and changeGrade != ''">
  701. AND cgu.change_grade = #{changeGrade}
  702. </if>
  703. <if test="profileStatus != null and profileStatus != ''">
  704. AND up.status = #{profileStatus}
  705. </if>
  706. <if test="gradeId != null and gradeId !='' ">
  707. and cgu.grade_id = #{gradeId}
  708. </if>
  709. <if test="businessId != null and businessId != ''">
  710. AND g.business_id = #{businessId}
  711. </if>
  712. <if test="educationTypeId != null and educationTypeId != ''">
  713. AND g.education_type_id = #{educationTypeId}
  714. </if>
  715. <if test="schoolId != null and schoolId != ''">
  716. AND g.school_id = #{schoolId}
  717. </if>
  718. <if test="majorId != null and majorId != ''">
  719. AND g.major_id = #{majorId}
  720. </if>
  721. <if test="periodStatus != null ">
  722. and cgu.period_status = #{periodStatus}
  723. </if>
  724. <if test="classStartTime != null and classStartTime != '' ">
  725. AND cg.class_start_time >= #{classStartTime}
  726. </if>
  727. <if test="classEndTime != null and classEndTime != '' ">
  728. AND #{classEndTime} >= cg.class_end_time
  729. </if>
  730. <if test="studyStatus != null and studyStatus == 1 ">
  731. and cgu.period_status = -1
  732. </if>
  733. <if test="studyStatus != null and studyStatus == 2 ">
  734. and cgu.period_status != -1
  735. </if>
  736. <if test="searchKey != null and searchKey != '' ">
  737. 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}, '%'))
  738. </if>
  739. <if test="searchStartTime != null and searchStartTime !='' ">
  740. AND cgu.create_time >=#{searchStartTime}
  741. </if>
  742. <if test="searchEndTime != null and searchEndTime !='' ">
  743. AND #{searchEndTime} >= cgu.create_time
  744. </if>
  745. <!-- 数据范围过滤 -->
  746. ${params.dataScope}
  747. <if test="periodStatus != 2 and periodStatus != 3">
  748. order by cgu.update_time desc
  749. </if>
  750. <if test="periodStatus == 2 ">
  751. order by cgu.period_wait_time,cgu.create_time
  752. </if>
  753. <if test="periodStatus == 3 ">
  754. order by cgu.period_ing_time,cgu.create_time
  755. </if>
  756. </select>
  757. <select id="userPeriodStatus" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  758. resultMap="ClassPeriodStudentVo">
  759. SELECT
  760. IFNULL(ge.exam_num,0) as exam_num,
  761. cg.class_start_time,
  762. cg.class_end_time,
  763. g.study_start_time,
  764. g.study_end_time,
  765. (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
  766. = 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.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  767. cgu.user_id,
  768. cgg.goods_id
  769. FROM
  770. class_grade_user cgu
  771. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  772. LEFT JOIN class_grade_goods cgg on cg.grade_id=cgg.grade_id
  773. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  774. LEFT JOIN (SELECT
  775. COUNT( m.id ) AS exam_num,
  776. c.goods_id
  777. FROM
  778. course_menu_exam m
  779. LEFT JOIN goods_course c ON m.course_id = c.course_id
  780. where
  781. m.type in (1,3)
  782. GROUP BY c.goods_id ) ge on cgg.goods_id = ge.goods_id
  783. where 1=1
  784. and cgu.`status` =1
  785. <if test="gradeId != null and gradeId !='' ">
  786. and cgu.grade_id = #{gradeId}
  787. </if>
  788. <if test="userId != null ">
  789. and cgu.user_id = #{userId}
  790. </if>
  791. <if test="orderGoodsId != null ">
  792. and cgu.order_goods_id = #{orderGoodsId}
  793. </if>
  794. LIMIT 1
  795. </select>
  796. <select id="listPeriod" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  797. resultMap="ClassPeriodUserVo">
  798. SELECT
  799. u.user_account,
  800. u.realname,
  801. u.id_card,
  802. u.user_id,
  803. u.telphone,
  804. g.goods_id,
  805. g.goods_name,
  806. cg.class_name,
  807. cg.official_name,
  808. cg.class_start_time,
  809. cg.class_end_time,
  810. cg.official_name,
  811. g.class_hours,
  812. u.one_inch_photos,
  813. u.id_card_img1,
  814. u.id_card_img2,
  815. cgu.period_status,
  816. cgu.order_goods_id,
  817. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN
  818. 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,
  819. (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.order_goods_id=cgu.order_goods_id and ubr.current_status=1) as record_num,
  820. (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
  821. 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.order_goods_id=cgu.order_goods_id and up.`type` = 1) as pass,
  822. (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
  823. 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.order_goods_id=cgu.order_goods_id and up.user_id = #{userId} and up.`type` = 1) as pending,
  824. (SELECT
  825. 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`
  826. =0 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.order_goods_id=cgu.order_goods_id and up.user_id = #{userId} and up.`type` = 1) as cheat,
  827. (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
  828. ups.`status` =1 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.user_id = #{userId} and up.order_goods_id=cgu.order_goods_id and up.grade_id = cg.grade_id and up.`type` in (2,3)) as exam_pass,
  829. (SELECT
  830. 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`
  831. =0 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.order_goods_id=cgu.order_goods_id and up.user_id = #{userId} and up.`type` in (2,3)) as exam_cheat,
  832. (SELECT
  833. 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`
  834. =2 and ups.period_status = 1 and up.goods_id=#{goodsId} and up.grade_id = cg.grade_id and up.order_goods_id=cgu.order_goods_id and up.user_id = #{userId} and up.`type` in (2,3)) as exam_pending,
  835. (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
  836. <if test="userId != null and userId !='' ">
  837. ,(SELECT MIN(first_start_time) from user_study_record where user_id = #{userId} and grade_id = #{gradeId} and order_goods_id=#{orderGoodsId}) as study_start_time,
  838. (SELECT MAX(end_time) from user_study_record where user_id = #{userId} and grade_id = #{gradeId} and order_goods_id=#{orderGoodsId}) as study_end_time
  839. </if>
  840. FROM
  841. class_grade_user cgu
  842. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  843. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  844. LEFT JOIN class_grade_goods cgg ON cg.grade_id=cgg.grade_id
  845. LEFT JOIN goods g ON g.goods_id = cgg.goods_id
  846. where 1=1
  847. <if test="userId != null and userId !='' ">
  848. and u.user_id = #{userId}
  849. </if>
  850. <if test="gradeId != null and gradeId !='' ">
  851. and cgu.grade_id = #{gradeId}
  852. </if>
  853. <if test="periodStatus != null and periodStatus !='' ">
  854. and cgu.period_status = #{periodStatus}
  855. </if>
  856. <if test="orderGoodsId != null and orderGoodsId !='' ">
  857. and cgu.order_goods_id = #{orderGoodsId}
  858. </if>
  859. LIMIT 1
  860. </select>
  861. <select id="listPeriodAudit" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  862. resultMap="ClassPeriodVo">
  863. SELECT
  864. gc.sort as course_sort,
  865. cm.sort,
  866. cm.menu_id as id,
  867. cm.course_id,
  868. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  869. and u.user_id = #{userId}
  870. </if>) as realname,
  871. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  872. and u.user_id = #{userId}
  873. </if>) as user_id,
  874. (SELECT cm.module_name FROM course_module cm where cm.menu_id = cm.module_id) as type_name,
  875. 0 as common_sign,
  876. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs LEFT JOIN course_module_chapter cmc on
  877. cmc.chapter_id=ccs.chapter_id where cmc.module_id=cm.menu_id) as class_hours,
  878. 1 as type,
  879. NULL as study_start_time,
  880. NULL as study_end_time
  881. FROM
  882. course_menu cm
  883. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  884. where 1=1
  885. <if test="goodsId != null and goodsId !='' ">
  886. and gc.goods_id=#{goodsId}
  887. </if>
  888. <if test="courseId != null and courseId !='' ">
  889. and gc.course_id=#{courseId}
  890. </if>
  891. AND cm.type=1
  892. UNION
  893. SELECT
  894. gc.sort as course_sort,
  895. cm.sort,
  896. cm.menu_id as id,
  897. cm.course_id,
  898. (SELECT u.realname FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  899. and u.user_id = #{userId}
  900. </if>) as realname,
  901. (SELECT u.user_id FROM `user` u where 1=1 <if test="userId != null and userId !='' ">
  902. and u.user_id = #{userId}
  903. </if>) as user_id,
  904. (SELECT cc.`name` FROM course_chapter cc where cm.menu_id = cc.chapter_id) as type_name,
  905. (SELECT cc.common_sign FROM course_chapter cc where cm.menu_id = cc.chapter_id) as common_sign,
  906. (SELECT COUNT(ccs.section_id) FROM course_chapter_section ccs where ccs.chapter_id=cm.menu_id) as class_hours,
  907. 2 as type,
  908. (SELECT usr.create_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  909. 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} and usr.order_goods_id = #{orderGoodsId} ORDER BY usr.create_time ASC
  910. limit 1) as study_start_time,
  911. (SELECT usr.update_time FROM user_study_record usr LEFT JOIN course_chapter_section ccs on usr.section_id =
  912. 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} and usr.order_goods_id = #{orderGoodsId} ORDER BY usr.create_time DESC
  913. limit 1) as study_end_time
  914. FROM
  915. course_menu cm
  916. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  917. where 1=1
  918. <if test="goodsId != null and goodsId !='' ">
  919. and gc.goods_id=#{goodsId}
  920. </if>
  921. <if test="courseId != null and courseId !='' ">
  922. and gc.course_id=#{courseId}
  923. </if>
  924. AND cm.type=2
  925. </select>
  926. <select id="listPeriodAuditSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  927. resultMap="ClassPeriodVo">
  928. SELECT
  929. gc.sort as course_sort,
  930. cm.sort,
  931. cm.menu_id as id,
  932. cm.course_id,
  933. (SELECT u.realname FROM `user` u where 1=1
  934. <if test="userId != null and userId !='' ">
  935. and u.user_id = #{userId}
  936. </if>
  937. ) as realname,
  938. (SELECT u.user_id FROM `user` u where 1=1
  939. <if test="userId != null and userId !='' ">
  940. and u.user_id = #{userId}
  941. </if>
  942. ) as user_id,
  943. cs.`name` as type_name,
  944. cs.duration_time,
  945. cs.real_live_start_time,
  946. cs.real_live_end_time,
  947. cs.real_duration,
  948. cs.section_type,
  949. null as class_hours,
  950. 3 as type
  951. FROM
  952. course_menu cm
  953. LEFT JOIN course_section cs on cm.menu_id = cs.section_id
  954. LEFT JOIN goods_course gc on gc.course_id = cm.course_id
  955. where 1=1
  956. <if test="goodsId != null and goodsId !='' ">
  957. and gc.goods_id = #{goodsId}
  958. </if>
  959. <if test="courseId != null ">
  960. and gc.course_id=#{courseId}
  961. </if>
  962. AND cm.type=3
  963. </select>
  964. <select id="listPeriodAuditExam" 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. 4 as type,
  981. (
  982. SELECT
  983. ups.record_start_time
  984. FROM
  985. user_period_status ups
  986. LEFT JOIN user_period up ON up.id = ups.period_id
  987. WHERE
  988. period_status = 1
  989. AND up.course_id = gc.course_id
  990. <if test="goodsId != null and goodsId !='' ">
  991. AND up.goods_id = #{goodsId}
  992. </if>
  993. and cme.section_id =up.section_id
  994. AND up.exam_id = cme.exam_id
  995. ) AS study_start_time,
  996. (
  997. SELECT
  998. ups.record_end_time
  999. FROM
  1000. user_period_status ups
  1001. LEFT JOIN user_period up ON up.id = ups.period_id
  1002. WHERE
  1003. period_status = 1
  1004. AND up.course_id = gc.course_id
  1005. <if test="goodsId != null and goodsId !='' ">
  1006. AND up.goods_id = #{goodsId}
  1007. </if>
  1008. AND up.exam_id = cme.exam_id
  1009. ) AS study_end_time,
  1010. (
  1011. SELECT
  1012. ups.`status`
  1013. FROM
  1014. user_period_status ups
  1015. LEFT JOIN user_period up ON up.id = ups.period_id
  1016. WHERE
  1017. period_status = 1
  1018. AND up.course_id = gc.course_id
  1019. <if test="goodsId != null and goodsId !='' ">
  1020. AND up.goods_id = #{goodsId}
  1021. </if>
  1022. and cme.section_id =up.section_id
  1023. AND up.exam_id = cme.exam_id
  1024. ) AS STATUS,
  1025. (
  1026. SELECT
  1027. ups.create_time
  1028. FROM
  1029. user_period_status ups
  1030. LEFT JOIN user_period up ON up.id = ups.period_id
  1031. WHERE
  1032. period_status = 1
  1033. AND up.course_id = gc.course_id
  1034. <if test="goodsId != null and goodsId !='' ">
  1035. AND up.goods_id = #{goodsId}
  1036. </if>
  1037. and cme.section_id =up.section_id
  1038. AND up.exam_id = cme.exam_id
  1039. ) AS audit_time,
  1040. (
  1041. SELECT
  1042. COUNT( ups.id )
  1043. FROM
  1044. user_period_status ups
  1045. LEFT JOIN user_period up ON up.id = ups.period_id
  1046. WHERE
  1047. period_status = 1
  1048. AND up.course_id = gc.course_id
  1049. <if test="goodsId != null and goodsId !='' ">
  1050. AND up.goods_id = #{goodsId}
  1051. </if>
  1052. and cme.section_id =up.section_id
  1053. AND up.exam_id = cme.exam_id
  1054. ) AS audit_num
  1055. FROM
  1056. course_menu_exam cme
  1057. LEFT JOIN goods_course gc on gc.course_id = cme.course_id
  1058. LEFT JOIN course_menu cm on cme.section_id = cm.menu_id
  1059. where 1=1
  1060. <if test="goodsId != null and goodsId !='' ">
  1061. and gc.goods_id= #{goodsId}
  1062. </if>
  1063. AND cm.type=3 and cme.chapter_id=0 and cme.module_id=0 and cme.type=1 and cm.type=3
  1064. </select>
  1065. <select id="listperiodChapter" parameterType="map" resultMap="ClassPeriodChapterVo">
  1066. SELECT
  1067. cmc.sort,
  1068. cc.chapter_id as id,
  1069. cc.common_sign,
  1070. cm.course_id,
  1071. ( SELECT u.realname FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  1072. and u.user_id = #{userId}
  1073. </if> LIMIT 1) AS realname,
  1074. ( SELECT u.user_id FROM `user` u WHERE 1=1 <if test="userId != null and userId !='' ">
  1075. and u.user_id = #{userId}
  1076. </if> LIMIT 1) AS user_id,
  1077. cc.`name` as type_name,
  1078. ( SELECT COUNT( ccs.section_id ) FROM course_chapter_section ccs WHERE ccs.chapter_id = cc.chapter_id ) AS
  1079. class_hours,
  1080. 2 AS type,
  1081. (
  1082. SELECT
  1083. usr.create_time
  1084. FROM
  1085. user_study_record usr
  1086. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id and ccs.chapter_id = usr.chapter_id
  1087. WHERE
  1088. ccs.chapter_id = cc.chapter_id
  1089. AND usr.current_status = 1
  1090. <if test="courseId != null ">
  1091. AND usr.course_id=#{courseId}
  1092. </if>
  1093. <if test="moduleId != null">
  1094. AND usr.module_id=#{moduleId}
  1095. </if>
  1096. <if test="goodsId != null and goodsId !='' ">
  1097. AND usr.goods_id=#{goodsId}
  1098. </if>
  1099. <if test="gradeId != null and gradeId !='' ">
  1100. AND usr.grade_id=#{gradeId}
  1101. </if>
  1102. <if test="userId != null and userId !='' ">
  1103. AND usr.user_id=#{userId}
  1104. </if>
  1105. <if test="orderGoodsId != null and orderGoodsId !='' ">
  1106. AND usr.order_goods_id=#{orderGoodsId}
  1107. </if>
  1108. ORDER BY
  1109. usr.create_time ASC
  1110. LIMIT 1
  1111. ) AS study_start_time,
  1112. (
  1113. SELECT
  1114. usr.update_time
  1115. FROM
  1116. user_study_record usr
  1117. LEFT JOIN course_chapter_section ccs ON usr.section_id = ccs.section_id and ccs.chapter_id = usr.chapter_id
  1118. WHERE
  1119. ccs.chapter_id = cc.chapter_id
  1120. AND usr.current_status = 1
  1121. <if test="courseId != null ">
  1122. AND usr.course_id=#{courseId}
  1123. </if>
  1124. <if test="moduleId != null">
  1125. AND usr.module_id=#{moduleId}
  1126. </if>
  1127. <if test="goodsId != null and goodsId !='' ">
  1128. AND usr.goods_id=#{goodsId}
  1129. </if>
  1130. <if test="gradeId != null and gradeId !='' ">
  1131. AND usr.grade_id=#{gradeId}
  1132. </if>
  1133. <if test="userId != null and userId !='' ">
  1134. AND usr.user_id=#{userId}
  1135. </if>
  1136. <if test="orderGoodsId != null and orderGoodsId !='' ">
  1137. AND usr.order_goods_id=#{orderGoodsId}
  1138. </if>
  1139. ORDER BY
  1140. usr.create_time DESC
  1141. LIMIT 1
  1142. ) AS study_end_time,
  1143. (
  1144. SELECT
  1145. ubr.performance
  1146. FROM
  1147. user_bank_record ubr
  1148. LEFT JOIN course_menu_exam cme ON cme.exam_id = ubr.exam_id and cme.chapter_id = ubr.chapter_id
  1149. WHERE 1=1
  1150. AND ubr.current_status = 1
  1151. AND ubr.report_status = 1
  1152. <if test="moduleId != null ">
  1153. AND ubr.module_id=#{moduleId}
  1154. </if>
  1155. <if test="goodsId != null">
  1156. AND ubr.goods_id=#{goodsId}
  1157. </if>
  1158. <if test="moduleId != null ">
  1159. AND cme.module_id=#{moduleId}
  1160. </if>
  1161. <if test="courseId != null">
  1162. AND cme.course_id =#{courseId}
  1163. </if>
  1164. <if test="userId != null and userId !='' ">
  1165. AND ubr.user_id=#{userId}
  1166. </if>
  1167. <if test="orderGoodsId != null and orderGoodsId !='' ">
  1168. AND ubr.order_goods_id=#{orderGoodsId}
  1169. </if>
  1170. AND cme.chapter_id = cmc.chapter_id
  1171. LIMIT 1 ) AS performance
  1172. FROM
  1173. course_menu cm
  1174. LEFT JOIN course_module_chapter cmc ON cm.menu_id = cmc.module_id
  1175. LEFT JOIN course_chapter cc ON cmc.chapter_id = cc.chapter_id
  1176. WHERE
  1177. 1 = 1
  1178. <if test="moduleId != null ">
  1179. AND cmc.module_id=#{moduleId}
  1180. </if>
  1181. <if test="courseId != null">
  1182. AND cm.course_id =#{courseId}
  1183. </if>
  1184. </select>
  1185. <select id="listperiodExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  1186. SELECT
  1187. cme.exam_id as id,
  1188. cme.course_id,
  1189. e.do_type,
  1190. <if test="userId != null and userId !='' ">
  1191. (SELECT u.realname FROM `user` u where 1=1
  1192. and u.user_id = #{userId}
  1193. ) as realname,
  1194. </if>
  1195. <if test="userId != null and userId !='' ">
  1196. #{userId} as user_id,
  1197. </if>
  1198. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  1199. null as class_hours,
  1200. 4 as type,
  1201. cme.chapter_id,
  1202. cme.module_id
  1203. FROM
  1204. course_menu_exam cme
  1205. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  1206. WHERE 1=1
  1207. AND cme.type=1
  1208. <if test="courseId != null">
  1209. AND cme.course_id=#{courseId}
  1210. </if>
  1211. <if test="chapterId != null">
  1212. AND cme.chapter_id =#{chapterId}
  1213. </if>
  1214. <if test="moduleId != null">
  1215. AND cme.module_id =#{moduleId}
  1216. </if>
  1217. </select>
  1218. <select id="listperiodModuleExam" parameterType="map" resultMap="ClassPeriodChapterVo">
  1219. SELECT
  1220. cme.exam_id as id,
  1221. cme.course_id,
  1222. e.do_type,
  1223. <if test="userId != null and userId !='' ">
  1224. (SELECT u.realname FROM `user` u where 1=1
  1225. and u.user_id = #{userId}
  1226. ) as realname,
  1227. </if>
  1228. <if test="userId != null and userId !='' ">
  1229. #{userId} as user_id,
  1230. </if>
  1231. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  1232. null as class_hours,
  1233. 5 as type,
  1234. cme.module_id
  1235. FROM
  1236. course_menu_exam cme
  1237. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  1238. WHERE 1=1
  1239. AND cme.type=3
  1240. <if test="courseId != null">
  1241. AND cme.course_id=#{courseId}
  1242. </if>
  1243. <if test="moduleId != null">
  1244. AND cme.module_id =#{moduleId}
  1245. </if>
  1246. </select>
  1247. <select id="listPeriodSection" parameterType="map" resultMap="ClassPeriodSectionVo">
  1248. SELECT
  1249. ccs.sort,
  1250. cs.section_id AS id,
  1251. #{courseId} AS course_id,
  1252. <if test="userId != null and userId !='' ">
  1253. (SELECT u.realname FROM `user` u where 1=1
  1254. and u.user_id = #{userId}
  1255. ) as realname,
  1256. </if>
  1257. <if test="userId != null and userId !='' ">
  1258. #{userId} as user_id,
  1259. </if>
  1260. cs.NAME AS type_name,
  1261. cs.duration_time,
  1262. cs.section_type,
  1263. cs.real_live_start_time,
  1264. cs.real_live_end_time,
  1265. cs.real_duration,
  1266. NULL AS class_hours,
  1267. cs.recording_url,
  1268. 3 AS type
  1269. FROM
  1270. course_chapter_section ccs
  1271. LEFT JOIN course_section cs ON ccs.section_id = cs.section_id
  1272. WHERE
  1273. 1 = 1
  1274. <if test="chapterId != null">
  1275. AND ccs.chapter_id = #{chapterId}
  1276. </if>
  1277. ORDER BY
  1278. ccs.sort
  1279. </select>
  1280. <select id="listPeriodSectionExam" parameterType="map" resultMap="ClassPeriodSectionVo">
  1281. SELECT
  1282. cme.exam_id as id,
  1283. cme.course_id,
  1284. (SELECT u.realname FROM `user` u where 1=1
  1285. <if test="userId != null and userId !='' ">
  1286. and u.user_id = #{userId}
  1287. </if>
  1288. ) as realname,
  1289. (SELECT u.user_id FROM `user` u where 1=1
  1290. <if test="userId != null and userId !='' ">
  1291. and u.user_id = #{userId}
  1292. </if>
  1293. ) as user_id,
  1294. (SELECT e.exam_name FROM exam e where cme.exam_id = e.exam_id) as type_name,
  1295. null as class_hours,
  1296. 4 as type
  1297. FROM
  1298. course_menu_exam cme
  1299. LEFT JOIN exam e ON cme.exam_id = e.exam_id
  1300. WHERE 1=1
  1301. and cme.module_id =0
  1302. and cme.type =1
  1303. <if test="courseId != null">
  1304. AND cme.course_id=#{courseId}
  1305. </if>
  1306. <if test="chapterId != null ">
  1307. AND cme.chapter_id = #{chapterId}
  1308. </if>
  1309. </select>
  1310. <select id="selectStart" parameterType="map" resultType="long">
  1311. SELECT
  1312. usr.create_time
  1313. FROM
  1314. user_study_record usr
  1315. WHERE
  1316. usr.goods_id = #{goodsId}
  1317. AND usr.grade_id = #{gradeId}
  1318. AND usr.user_id = #{userId} UNION
  1319. SELECT
  1320. ubr.create_time
  1321. FROM
  1322. user_bank_record ubr
  1323. WHERE
  1324. ubr.goods_id =#{goodsId}
  1325. AND ubr.grade_id = #{gradeId}
  1326. AND ubr.user_id = #{userId}
  1327. ORDER BY create_time ASC
  1328. </select>
  1329. <select id="selectEnd" parameterType="map" resultType="long">
  1330. SELECT
  1331. usr.end_time
  1332. FROM
  1333. user_study_record usr
  1334. WHERE
  1335. usr.goods_id = #{goodsId}
  1336. AND usr.grade_id = #{gradeId}
  1337. AND usr.user_id = #{userId} UNION
  1338. SELECT
  1339. ubr.update_time as end_time
  1340. FROM
  1341. user_bank_record ubr
  1342. WHERE
  1343. ubr.goods_id =#{goodsId}
  1344. AND ubr.grade_id = #{gradeId}
  1345. AND ubr.user_id = #{userId}
  1346. ORDER BY end_time DESC
  1347. </select>
  1348. <select id="sendClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  1349. SELECT
  1350. cgu.user_id,
  1351. cgu.order_goods_id,
  1352. cg.class_start_time,
  1353. cg.class_end_time,
  1354. cgg.goods_id,
  1355. cg.grade_id
  1356. FROM
  1357. class_grade_user cgu
  1358. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  1359. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  1360. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  1361. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  1362. where 1=1
  1363. and irb.remind_id =5
  1364. and cgu.status = 1
  1365. AND unix_timestamp(now()) BETWEEN cg.class_end_time-1728000 and cg.class_end_time-1641600
  1366. </select>
  1367. <select id="checkSendClassGradeUser" parameterType="map" resultType="long">
  1368. 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
  1369. </select>
  1370. <select id="sendTenClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  1371. SELECT
  1372. cgu.user_id,
  1373. cgu.order_goods_id,
  1374. cg.class_start_time,
  1375. cg.class_end_time,
  1376. cgg.goods_id,
  1377. cg.grade_id
  1378. FROM
  1379. class_grade_user cgu
  1380. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  1381. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  1382. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  1383. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  1384. where 1=1
  1385. and irb.remind_id =6
  1386. and cgu.status = 1
  1387. AND unix_timestamp(now()) BETWEEN cg.class_end_time-864000 and cg.class_end_time-777600
  1388. </select>
  1389. <select id="sendFiveClassGradeUser" resultMap="ClassGradeUserGoodsVoResult">
  1390. SELECT
  1391. cgu.user_id,
  1392. cgu.order_goods_id,
  1393. cg.class_start_time,
  1394. cg.class_end_time,
  1395. cgg.goods_id,
  1396. cg.grade_id
  1397. FROM
  1398. class_grade_user cgu
  1399. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  1400. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  1401. LEFT JOIN goods g on cgg.goods_id = g.goods_id
  1402. LEFT JOIN inform_remind_business irb on irb.business_id = g.business_id
  1403. where 1=1
  1404. and irb.remind_id =7
  1405. and cgu.status = 1
  1406. AND unix_timestamp(now()) BETWEEN cg.class_end_time-432000 and cg.class_end_time-345600
  1407. </select>
  1408. <select id="selectUserCount" parameterType="com.zhongzheng.modules.user.domain.User" resultType="long">
  1409. SELECT
  1410. COUNT( 1 )
  1411. FROM
  1412. `user`
  1413. WHERE
  1414. id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler} and user_id != #{userId} and `status` = 1
  1415. </select>
  1416. <select id="selectUserCertificate" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo"
  1417. resultMap="ClassGradeUserVoResult">
  1418. </select>
  1419. <select id="findChapterList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="CourseChapterResultVo">
  1420. SELECT
  1421. cc.chapter_id,
  1422. cc.`name`
  1423. FROM
  1424. course_module_chapter p
  1425. LEFT JOIN course_chapter cc ON p.chapter_id = cc.chapter_id
  1426. LEFT JOIN course_menu m ON m.menu_id = p.module_id
  1427. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  1428. WHERE
  1429. gc.goods_id = #{goodsId}
  1430. AND m.type = 1 UNION
  1431. SELECT
  1432. cc.chapter_id,
  1433. cc.`name`
  1434. FROM
  1435. course_menu m
  1436. LEFT JOIN course_chapter cc ON m.menu_id = cc.chapter_id
  1437. LEFT JOIN goods_course gc ON gc.course_id = m.course_id
  1438. WHERE
  1439. gc.goods_id = #{goodsId}
  1440. AND m.type = 2
  1441. </select>
  1442. <select id="selectOfficialInfoCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="long">
  1443. SELECT
  1444. count(*)
  1445. FROM
  1446. class_grade_user cgu
  1447. WHERE
  1448. cgu.grade_id = #{gradeId}
  1449. AND cgu.official_status = 1
  1450. </select>
  1451. <select id="selectLearnStatusCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="long">
  1452. SELECT
  1453. count(*)
  1454. FROM
  1455. class_grade_user cgu
  1456. WHERE
  1457. cgu.grade_id = #{gradeId}
  1458. AND cgu.learn_status = 1
  1459. </select>
  1460. <select id="selectOfficialPeriodCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="long">
  1461. SELECT
  1462. count(*)
  1463. FROM
  1464. class_grade_user cgu
  1465. WHERE
  1466. cgu.grade_id = #{gradeId}
  1467. AND cgu.period_plush = 1
  1468. </select>
  1469. <select id="selectOfficialNotPush" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="ClassGradeUserGoodsVoResult">
  1470. SELECT
  1471. gu.*
  1472. FROM
  1473. class_grade g
  1474. LEFT JOIN class_grade_user gu ON g.grade_id = gu.grade_id
  1475. WHERE
  1476. g.interface_push_id > 0
  1477. AND g.official_name IS NOT NULL
  1478. AND g.`status` = 1
  1479. AND gu.`status` = 1
  1480. AND gu.change_grade = 0
  1481. AND IFNULL(gu.official_status,0) != 1
  1482. </select>
  1483. <select id="selectPeriodNotPush" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="ClassGradeUserGoodsVoResult">
  1484. SELECT
  1485. gu.*
  1486. FROM
  1487. class_grade g
  1488. LEFT JOIN class_grade_user gu ON g.grade_id = gu.grade_id
  1489. WHERE
  1490. g.interface_period_id > 0
  1491. AND g.`status` = 1
  1492. AND gu.`status` = 1
  1493. AND gu.change_grade = 0
  1494. AND IFNULL(gu.period_plush,0) != 1
  1495. AND gu.period_status = 1
  1496. </select>
  1497. <select id="selectGoodsGradeList" parameterType="Long" resultMap="ClassGradeUserGoodsVoResult">
  1498. SELECT
  1499. cgg.goods_id,
  1500. cgg.grade_id,
  1501. cgu.user_id,
  1502. cgu.order_goods_id
  1503. FROM
  1504. class_grade_goods cgg
  1505. LEFT JOIN class_grade_user cgu ON cgg.grade_id = cgu.grade_id
  1506. WHERE
  1507. cgg.goods_id = #{goodsId}
  1508. AND cgu.user_id IS NOT NULL
  1509. </select>
  1510. <select id="queryCountList" parameterType="java.lang.Integer" resultMap="ClassGradeUserVoResult">
  1511. SELECT
  1512. cgu.*,
  1513. cg.interface_account_id,
  1514. cg.no_interface_account_id
  1515. FROM
  1516. class_grade_user cgu
  1517. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1518. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  1519. LEFT JOIN goods g on og.goods_id = g.goods_id
  1520. WHERE
  1521. cgu.`status` = 1
  1522. and g.project_id = #{projectId}
  1523. and g.business_id = #{businessId}
  1524. <if test="all != null and all == 0">
  1525. and (cg.interface_account_id is not null or cg.no_interface_account_id is not null)
  1526. </if>
  1527. </select>
  1528. <select id="checkFinishRequiredCourse" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="java.lang.Long">
  1529. SELECT
  1530. IFNULL(count(*),0)
  1531. FROM
  1532. class_grade_user cgu
  1533. LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  1534. LEFT JOIN goods g on og.goods_id = g.goods_id
  1535. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  1536. WHERE
  1537. cgu.user_id = #{userId}
  1538. AND cgu.period_status = -1
  1539. AND (unix_timestamp(now()) BETWEEN cg.class_start_time and cg.class_end_time)
  1540. and g.business_id = #{businessId}
  1541. and g.goods_id != #{goodsId}
  1542. AND (
  1543. SELECT
  1544. IFNULL( count(*), 0 )
  1545. FROM
  1546. user_period up
  1547. WHERE
  1548. 1 = 1
  1549. AND up.user_id = cgu.user_id
  1550. AND up.grade_id = cgu.grade_id
  1551. )>0
  1552. </select>
  1553. <select id="getPeriodStartTime" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="java.lang.Long">
  1554. SELECT
  1555. p.create_time
  1556. FROM
  1557. user_study_record usr
  1558. LEFT JOIN user_study_record_photo p ON usr.record_id = p.record_id
  1559. WHERE
  1560. usr.current_status = 1
  1561. AND usr.user_id = #{userId}
  1562. AND usr.grade_id = #{gradeId}
  1563. <if test="orderGoodsId != null and orderGoodsId !='' ">
  1564. AND usr.order_goods_id = #{orderGoodsId}
  1565. </if>
  1566. AND P.create_time IS NOT NULL
  1567. ORDER BY
  1568. P.create_time
  1569. LIMIT 1
  1570. </select>
  1571. <select id="getPeriodEndTime" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultType="java.lang.Long">
  1572. SELECT
  1573. ups.record_end_time
  1574. FROM
  1575. user_period_status ups
  1576. LEFT JOIN user_period up ON up.id = ups.period_id
  1577. WHERE
  1578. 1 = 1
  1579. AND up.user_id = #{userId}
  1580. AND up.grade_id = #{gradeId}
  1581. <if test="orderGoodsId != null and orderGoodsId !='' ">
  1582. AND up.order_goods_id = #{orderGoodsId}
  1583. </if>
  1584. AND ups.period_status = 1
  1585. ORDER BY
  1586. ups.record_end_time DESC
  1587. LIMIT 1
  1588. </select>
  1589. <select id="getClassInfoByUser" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.grade.domain.ClassGradeUser">
  1590. SELECT
  1591. cgu.*
  1592. FROM
  1593. class_grade_user cgu
  1594. LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  1595. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1596. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1597. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1598. LEFT JOIN course_business cb ON g.business_id = cb.id
  1599. WHERE
  1600. cgu.`status` = 1
  1601. AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), "继续教育" ) > 0
  1602. AND INSTR( CONCAT( cet.education_name, cb.business_name, cpt.project_name ), "施工现场专业人员" ) > 0
  1603. AND og.`status` = 1
  1604. AND og.refund_status != 2
  1605. AND og.pay_status IN ( 2, 3, 4 )
  1606. AND cgu.period_status != 1
  1607. AND cgu.finish_status = 0
  1608. AND (
  1609. SELECT
  1610. COUNT( usr.record_id )
  1611. FROM
  1612. user_study_record usr
  1613. WHERE
  1614. usr.order_goods_id = cgu.order_goods_id
  1615. AND usr.user_id = cgu.user_id
  1616. AND usr.current_status = 1
  1617. ) > 0
  1618. AND cgu.user_id = #{userId}
  1619. </select>
  1620. </mapper>