ClassGradeUserMapper.xml 53 KB

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