ClassGradeUserMapper.xml 70 KB

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