ClassGradeUserMapper.xml 71 KB

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