ClassGradeUserMapper.xml 71 KB

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