ClassGradeUserMapper.xml 73 KB

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