ClassGradeUserMapper.xml 67 KB

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