ClassGradeMapper.xml 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566
  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.ClassGradeMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.ClassGrade" id="ClassGradeResult">
  7. <result property="gradeId" column="grade_id"/>
  8. <result property="classStatus" column="class_status"/>
  9. <result property="officialName" column="official_name"/>
  10. <result property="className" column="class_name"/>
  11. <result property="studentUpper" column="student_upper"/>
  12. <result property="learningTimeStart" column="learning_time_start"/>
  13. <result property="learningStatus" column="learning_status"/>
  14. <result property="status" column="status"/>
  15. <result property="classStartTime" column="class_start_time"/>
  16. <result property="classEndTime" column="class_end_time"/>
  17. <result property="examineId" column="examine_id"/>
  18. <result property="areasId" column="areas_id"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateTime" column="update_time"/>
  21. <result property="sysUserId" column="sys_user_id"/>
  22. <result property="interfacePushId" column="interface_push_id"/>
  23. <result property="remark" column="remark"/>
  24. <result property="interfaceAccountId" column="interface_account_id"/>
  25. <result property="interfacePeriodId" column="interface_period_id"/>
  26. <result property="officialLearningUrl" column="official_learning_url"/>
  27. </resultMap>
  28. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  29. <result property="gradeId" column="grade_id"/>
  30. <result property="classStatus" column="class_status"/>
  31. <result property="officialName" column="official_name"/>
  32. <result property="className" column="class_name"/>
  33. <result property="studentUpper" column="student_upper"/>
  34. <result property="learningTimeStart" column="learning_time_start"/>
  35. <result property="learningStatus" column="learning_status"/>
  36. <result property="status" column="status"/>
  37. <result property="classStartTime" column="class_start_time"/>
  38. <result property="classEndTime" column="class_end_time"/>
  39. <result property="examineId" column="examine_id"/>
  40. <result property="areasId" column="areas_id"/>
  41. <result property="sysUserId" column="sys_user_id"/>
  42. <result property="interfacePushId" column="interface_push_id"/>
  43. <result property="remark" column="remark"/>
  44. <result property="interfaceAccountId" column="interface_account_id"/>
  45. <result property="interfacePeriodId" column="interface_period_id"/>
  46. <result property="interfaceAccountName" column="interface_account_name"/>
  47. <result property="interfacePeriodName" column="interface_period_name"/>
  48. <result property="interfacePushName" column="interface_push_name"/>
  49. <result property="studentNum" column="student_num"/>
  50. <result property="officialLearningUrl" column="official_learning_url"/>
  51. <result property="officialStatusNum" column="official_status_num"/>
  52. <result property="periodStatusNum" column="period_status_num"/>
  53. <result property="periodPlushNum" column="period_plush_num"/>
  54. <result property="periodPlushNum" column="period_plush_num"/>
  55. <result property="subjectNames" column="subject_names"/>
  56. <result property="subjectIds" column="subject_ids"/>
  57. <result property="businessId" column="business_id"/>
  58. <result property="projectId" column="project_id"/>
  59. <result property="goodsId" column="goods_id"/>
  60. <result property="sevenCode" column="seven_code"/>
  61. </resultMap>
  62. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserListVo" id="ClassGradeUserListVo">
  63. <result property="gradeId" column="grade_id"/>
  64. <result property="classStatus" column="class_status"/>
  65. <result property="officialName" column="official_name"/>
  66. <result property="className" column="class_name"/>
  67. <result property="studentUpper" column="student_upper"/>
  68. <result property="learningTimeStart" column="learning_time_start"/>
  69. <result property="learningStatus" column="learning_status"/>
  70. <result property="status" column="status"/>
  71. <result property="classStartTime" column="class_start_time"/>
  72. <result property="classEndTime" column="class_end_time"/>
  73. <result property="examineId" column="examine_id"/>
  74. <result property="areasId" column="areas_id"/>
  75. <result property="sysUserId" column="sys_user_id"/>
  76. <result property="interfacePushId" column="interface_push_id"/>
  77. <result property="remark" column="remark"/>
  78. <result property="interfaceAccountId" column="interface_account_id"/>
  79. <result property="interfacePeriodId" column="interface_period_id"/>
  80. <result property="interfaceAccountName" column="interface_account_name"/>
  81. <result property="interfacePeriodName" column="interface_period_name"/>
  82. <result property="interfacePushName" column="interface_push_name"/>
  83. <result property="studentNum" column="student_num"/>
  84. </resultMap>
  85. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  86. <result property="goodsId" column="goods_id"/>
  87. <result property="year" column="year"/>
  88. <result property="supplyId" column="supply_id"/>
  89. <result property="goodsType" column="goods_type"/>
  90. <result property="educationTypeId" column="education_type_id"/>
  91. <result property="businessId" column="business_id"/>
  92. <result property="schoolId" column="school_id"/>
  93. <result property="majorId" column="major_id"/>
  94. <result property="goodsName" column="goods_name"/>
  95. <result property="standPrice" column="stand_price"/>
  96. <result property="lowestPrice" column="lowest_price"/>
  97. <result property="createTime" column="create_time"/>
  98. <result property="updateTime" column="update_time"/>
  99. <result property="status" column="status"/>
  100. <result property="validityStartTime" column="validity_start_time"/>
  101. <result property="validityEndTime" column="validity_end_time"/>
  102. <result property="studyStartTime" column="study_start_time"/>
  103. <result property="studyEndTime" column="study_end_time"/>
  104. <result property="certificateIds" column="certificate_ids"/>
  105. <result property="introduce" column="introduce"/>
  106. <result property="suitableObject" column="suitable_object"/>
  107. <result property="buyNote" column="buy_note"/>
  108. <result property="pcDetailHtml" column="pc_detail_html"/>
  109. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  110. <result property="goodsStatus" column="goods_status"/>
  111. <result property="coverUrl" column="cover_url"/>
  112. <result property="classHours" column="class_hours"/>
  113. <result property="standPriceJson" column="stand_price_json"/>
  114. <result property="code" column="code"/>
  115. <result property="projectId" column="project_id"/>
  116. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  117. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  118. <result property="goodsPlayConfig" column="goods_play_config"/>
  119. <result property="goodsExamConfig" column="goods_exam_config"/>
  120. <result property="supplyName" column="supply_name"/>
  121. <result property="educationName" column="education_name"/>
  122. <result property="projectName" column="project_name"/>
  123. <result property="businessName" column="business_name"/>
  124. <result property="schoolName" column="school_name"/>
  125. <result property="categoryName" column="category_name"/>
  126. <result property="handoutsId" column="handouts_id"/>
  127. <result property="templateType" column="template_type"/>
  128. </resultMap>
  129. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeStudentVo" id="ClassGradeStudentVo">
  130. <result property="userId" column="user_id"/>
  131. <result property="id" column="id"/>
  132. <result property="gradeId" column="grade_id"/>
  133. <result property="studentCode" column="user_account"/>
  134. <result property="realname" column="realname"/>
  135. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  136. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  137. <result property="userStatus" column="user_status"/>
  138. <result property="status" column="status"/>
  139. <result property="classHours" column="class_hours"/>
  140. <result property="periodStatus" column="period_status"/>
  141. <result property="finishStatus" column="finish_status"/>
  142. <result property="officialStatus" column="official_status"/>
  143. <result property="learnStatus" column="learn_status"/>
  144. <result property="secAllNum" column="sec_all_num"/>
  145. <result property="examNum" column="exam_num"/>
  146. <result property="recordNum" column="record_num"/>
  147. <result property="classStartTime" column="class_start_time"/>
  148. <result property="classEndTime" column="class_end_time"/>
  149. <result property="studyStartTime" column="study_start_time"/>
  150. <result property="studyEndTime" column="study_end_time"/>
  151. <result property="studyCount" column="study_count"/>
  152. <result property="orderGoodsId" column="order_goods_id"/>
  153. <result property="officialStatusNum" column="official_status_num"/>
  154. <result property="officialStatusTime" column="official_status_time"/>
  155. <result property="interfacePushId" column="interface_push_id"/>
  156. <result property="periodPlush" column="period_plush"/>
  157. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  158. <result property="serviceStartTime" column="service_start_time"/>
  159. <result property="serviceEndTime" column="service_end_time"/>
  160. <result property="goodsName" column="goods_name"/>
  161. <result property="orderSn" column="order_sn"/>
  162. <result property="categoryName" column="category_name"/>
  163. <result property="reason" column="reason"/>
  164. <result property="projectName" column="project_name"/>
  165. <result property="businessName" column="business_name"/>
  166. <result property="educationName" column="education_name"/>
  167. <result property="sevenYear" column="seven_year"/>
  168. <result property="orgId" column="org_id"/>
  169. <result property="userBindWx" column="user_bind_wx"/>
  170. <result property="userFollowWx" column="user_follow_wx"/>
  171. <result property="useStudyCount" column="use_study_count"/>
  172. <result property="examNumber" column="exam_number"/>
  173. <result property="doNumber" column="do_number"/>
  174. <result property="expendNumber" column="expend_number"/>
  175. <result property="expendBefore" column="expend_before"/>
  176. <result property="periodPlushMsg" column="official_status_msg"/>
  177. <result property="officialStatusMsg" column="period_plush_msg"/>
  178. <result property="companyName" column="company_name"/>
  179. <result property="gradeName" column="class_name"/>
  180. <result property="endTime" column="end_time"/>
  181. <result property="profileStatus" column="profile_status"/>
  182. <result property="classStatus" column="class_status"/>
  183. </resultMap>
  184. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeGoodsVo" id="ClassGradeGoodsVoResult">
  185. <result property="goodsId" column="goods_id"/>
  186. <collection property="gradeList" column="goods_id" select="findGradeList"/>
  187. </resultMap>
  188. <resultMap type="com.zhongzheng.modules.grade.vo.ClassNpUserInfoVo" id="ClassNpUserInfoVoResult">
  189. <result property="gradeId" column="grade_id"/>
  190. <result property="tenantId" column="tenantId"/>
  191. <result property="classNo" column="classNo"/>
  192. <result property="platformName" column="platformName"/>
  193. <result property="categoryName" column="categoryName"/>
  194. <result property="name" column="name"/>
  195. <result property="idNum" column="idNum" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  196. <result property="mobile" column="mobile" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  197. <result property="companyName" column="companyName"/>
  198. <result property="orderTimeLong" column="orderTimeLong"/>
  199. <result property="createTimeLong" column="createTimeLong"/>
  200. <result property="doTimeLong" column="doTimeLong"/>
  201. <result property="reportStatu" column="reportStatu"/>
  202. <result property="finishStatus" column="finishStatus"/>
  203. <result property="studyQueueStatus" column="studyQueueStatus"/>
  204. <result property="finishStatus" column="finishStatus"/>
  205. <result property="applyTimeLong" column="applyTimeLong"/>
  206. <result property="userId" column="user_id"/>
  207. <result property="subjectIds" column="subject_ids"/>
  208. </resultMap>
  209. <select id="findGradeList" resultMap="ClassGradeVoResult">
  210. SELECT
  211. g.*,
  212. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  213. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  214. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  215. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  216. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  217. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  218. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  219. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and official_status =1) as official_status_num,
  220. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_status =1) as period_status_num,
  221. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_plush =1) as period_plush_num
  222. FROM
  223. class_grade_goods cgg LEFT JOIN
  224. class_grade g on cgg.grade_id = g.grade_id
  225. where cgg.goods_id = #{goods_id} and g.`status` = 1
  226. </select>
  227. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  228. SELECT
  229. g.*,
  230. d.goods_id,
  231. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  232. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  233. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  234. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  235. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  236. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  237. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  238. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and official_status =1) as official_status_num,
  239. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_status =1) as period_status_num,
  240. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_plush =1) as period_plush_num,
  241. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,d.subject_ids)) subject_names
  242. FROM
  243. class_grade g
  244. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  245. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  246. LEFT JOIN course_business cb ON d.business_id = cb.id
  247. <if test="userId != null and userId !=0 ">
  248. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  249. </if>
  250. where g.status !=-1
  251. <if test="status != null and status.size()!=0 ">
  252. AND g.status in
  253. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  254. #{item}
  255. </foreach>
  256. </if>
  257. <if test="userId != null and userId !=0 ">
  258. AND gu.user_id = #{userId}
  259. </if>
  260. <if test="gradeId != null and gradeId !=0 ">
  261. AND g.grade_id = #{gradeId}
  262. </if>
  263. <if test="searchKey != null and searchKey !='' ">
  264. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  265. SELECT
  266. COUNT(*)
  267. FROM
  268. class_grade_user cgu
  269. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  270. WHERE
  271. g.grade_id = cgu.grade_id
  272. AND u.realname like concat('%', #{searchKey}, '%')
  273. ) >0 or (
  274. SELECT
  275. COUNT(*)
  276. FROM
  277. class_grade_goods s
  278. LEFT JOIN goods d ON s.goods_id = d.goods_id
  279. WHERE
  280. g.grade_id = s.grade_id
  281. AND d.goods_name like concat('%', #{searchKey}, '%')
  282. ) >0)
  283. </if>
  284. <if test="classStatus != null ">
  285. AND g.class_status = #{classStatus}
  286. </if>
  287. <if test="className != null and className !='' ">
  288. AND g.class_name like concat('%', #{className}, '%')
  289. </if>
  290. <if test="atFull != null and atFull !='' ">
  291. AND (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) &lt; g.student_upper
  292. </if>
  293. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  294. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  295. </if>
  296. <if test="pastDue != null or pastDue != null ">
  297. AND ((unix_timestamp(now())+6*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  298. </if>
  299. <if test="educationTypeId != null and educationTypeId !='' ">
  300. AND (
  301. SELECT
  302. COUNT(*)
  303. FROM
  304. class_grade_goods s
  305. LEFT JOIN goods d ON s.goods_id = d.goods_id
  306. WHERE
  307. 1 = 1
  308. AND g.grade_id = s.grade_id
  309. AND d.education_type_id =#{educationTypeId}
  310. ) >0
  311. </if>
  312. <if test="businessId != null and businessId !='' ">
  313. AND cb.id = #{businessId}
  314. </if>
  315. <if test="schoolId != null and schoolId !='' ">
  316. AND (
  317. SELECT
  318. COUNT(*)
  319. FROM
  320. class_grade_goods s
  321. LEFT JOIN goods d ON s.goods_id = d.goods_id
  322. WHERE
  323. 1 = 1
  324. AND g.grade_id = s.grade_id
  325. AND d.school_id =#{schoolId}
  326. ) >0
  327. </if>
  328. <if test="majorId != null and majorId !='' ">
  329. AND (
  330. SELECT
  331. COUNT(*)
  332. FROM
  333. class_grade_goods s
  334. LEFT JOIN goods d ON s.goods_id = d.goods_id
  335. WHERE
  336. 1 = 1
  337. AND g.grade_id = s.grade_id
  338. AND d.major_id =#{majorId}
  339. ) >0
  340. </if>
  341. <if test="goodsId != null and goodsId !='' ">
  342. AND d.goods_id = #{goodsId}
  343. </if>
  344. <if test="goodsIds != null and goodsIds.size()!=0 ">
  345. AND d.goods_id in
  346. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  347. #{item}
  348. </foreach>
  349. </if>
  350. <if test="hasInterface != null and hasInterface == 0">
  351. AND g.interface_account_id is null AND g.no_interface_account_id is null
  352. </if>
  353. <if test="hasInterface != null and hasInterface == 1">
  354. AND g.interface_account_id is not null
  355. </if>
  356. <if test="hasInterface != null and hasInterface == 2">
  357. AND g.no_interface_account_id is not null
  358. </if>
  359. <!-- 数据范围过滤 -->
  360. ${params.dataScope}
  361. order by g.create_time desc
  362. </select>
  363. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  364. SELECT
  365. g.*,
  366. ps.supply_name,
  367. cet.education_name,
  368. cpt.project_name,
  369. cb.business_name,
  370. s.school_name,
  371. m.category_name,
  372. ot.type AS template_type
  373. FROM
  374. goods g
  375. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  376. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  377. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  378. LEFT JOIN course_business cb ON g.business_id = cb.id
  379. LEFT JOIN school s ON s.id = g.school_id
  380. LEFT JOIN major m ON g.major_id = m.id
  381. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  382. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  383. WHERE
  384. 1 = 1
  385. AND o.grade_id =#{gradeId}
  386. </select>
  387. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  388. SELECT
  389. cgu.id,
  390. cgu.official_status_time,
  391. cgu.official_status_num,
  392. u.user_account,
  393. u.user_id,
  394. cgu.`status`,
  395. u.realname,
  396. og.goods_id,
  397. u.id_card,
  398. cgu.grade_id,
  399. u.telphone,
  400. (case WHEN (select COUNT(uu.id) FROM user_update uu where cgu.user_id = uu.user_id and uu.status = 2) >0 then 1 ELSE 0 end) as user_status,
  401. (case WHEN cgu.official_status_time > (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id) then 0 ELSE 1 end) as user_info_status,
  402. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  403. g.class_hours,
  404. cgu.period_status,
  405. cgu.finish_status,
  406. cgu.period_plush,
  407. g.study_start_time,
  408. g.study_end_time,
  409. cg.class_start_time,
  410. cg.class_end_time,
  411. cg.interface_push_id,
  412. cgu.official_status,
  413. cgu.official_status_msg,
  414. cgu.period_plush_msg,
  415. cgu.learn_status,
  416. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id where c.goods_id=og.goods_id and m.type in (1,3) ) as exam_num,
  417. (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.user_id = u.user_id and ubr.grade_id = cgu.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.report_status=1 and ubr.current_status = 1) as record_num,
  418. (og.study_count) as study_count,
  419. og.order_goods_id,
  420. og.rebuy_order_goods_id,
  421. og.service_start_time,
  422. og.service_end_time,
  423. g.goods_name,
  424. og.order_sn,
  425. og.seven_year,
  426. m.category_name,
  427. g.major_id,
  428. u.province,
  429. cgu.reason,
  430. cgu.tenant_id as org_id,
  431. cb.business_name,
  432. cpt.project_name,
  433. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,
  434. (case WHEN uwf.gzh_open_id is null then 0 ELSE 1 end) as user_follow_wx,
  435. (SELECT IFNULL(SUM(usr.study_duration),0) from user_study_record usr where usr.user_id = cgu.user_id and usr.grade_id = cgu.grade_id) as user_study_duration,
  436. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  437. ueg.exam_number,
  438. ueg.do_number,
  439. ueg.expend_number,
  440. ueg.expend_before
  441. FROM
  442. class_grade_user cgu
  443. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  444. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  445. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  446. LEFT JOIN goods g on og.goods_id = g.goods_id
  447. LEFT JOIN major m ON g.major_id = m.id
  448. LEFT JOIN course_business cb ON g.business_id = cb.id
  449. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  450. LEFT JOIN user_wx_follow uwf ON u.union_id = uwf.union_id
  451. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  452. where 1=1 and cgu.`status` = 1
  453. <if test="sevenCode != null and sevenCode !='' ">
  454. AND cg.seven_code = #{sevenCode}
  455. </if>
  456. <if test="gradeId != null and gradeId !='' and (sevenCode == null or sevenCode =='')">
  457. and cgu.grade_id = #{gradeId}
  458. </if>
  459. <if test="choice != null and choice == 1 ">
  460. and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and cgur.order_goods_id = cgu.order_goods_id AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null) and cge.`status`=1 and cgur.`status` =1)= 0 and cgu.period_status=0
  461. AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) &lt; cgde.class_end_time or cgde.class_start_time is null)) =0
  462. </if>
  463. <if test="choice != null and choice == 2 ">
  464. and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and cgur.order_goods_id = cgu.order_goods_id AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null)
  465. and cge.`status`=1 and cgur.`status` =1)> 0
  466. AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) &lt; cgde.class_end_time or cgde.class_start_time is null)) =0
  467. </if>
  468. <if test="studyCountMore != null and studyCountMore == 2 ">
  469. AND og.study_count > 0 AND cgu.change_grade = 0
  470. </if>
  471. <if test="studyCountMore != null and studyCountMore == 1 ">
  472. AND og.study_count > 0 AND cgu.change_grade = 1
  473. </if>
  474. <if test="studyCountMore != null and studyCountMore == 0 ">
  475. AND og.study_count = 0
  476. </if>
  477. <if test="officialStatus != null and officialStatus == 1 ">
  478. AND cgu.official_status = 1
  479. </if>
  480. <if test="officialStatus != null and officialStatus == 0 ">
  481. AND (cgu.official_status is NULL or cgu.official_status=0)
  482. </if>
  483. <if test="realname != null and realname != ''">
  484. AND u.realname like concat('%', #{realname}, '%')
  485. </if>
  486. <if test="telphone != null and telphone != ''">
  487. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  488. </if>
  489. <if test="companyName != null and companyName != ''">
  490. AND u.company_name like concat('%', #{companyName}, '%')
  491. </if>
  492. <if test="idCard != null and idCard != ''">
  493. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  494. </if>
  495. <if test="idCards != null and idCards.size() != 0">
  496. AND u.id_card IN
  497. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  498. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  499. </foreach>
  500. </if>
  501. <if test="orderSn != null and orderSn != ''">
  502. AND og.order_sn = #{orderSn}
  503. </if>
  504. <if test="goodsName != null and goodsName != ''">
  505. AND g.goods_name like concat('%', #{goodsName}, '%')
  506. </if>
  507. <if test="searchStartTime != null and searchStartTime != ''">
  508. AND cgu.create_time &gt; #{searchStartTime}
  509. </if>
  510. <if test="searchEndTime != null and searchEndTime != ''">
  511. AND cgu.create_time &lt; #{searchEndTime}
  512. </if>
  513. <if test="finishStatus != null">
  514. AND cgu.finish_status = #{finishStatus}
  515. </if>
  516. <if test="learnStatus != null">
  517. AND cgu.learn_status = #{learnStatus}
  518. </if>
  519. <if test="projectId != null and projectId != ''">
  520. AND g.project_id = #{projectId}
  521. </if>
  522. <if test="businessId != null and businessId != ''">
  523. AND g.business_id = #{businessId}
  524. </if>
  525. <if test="educationTypeId != null and educationTypeId != ''">
  526. AND g.education_type_id = #{educationTypeId}
  527. </if>
  528. <if test="majorId != null and majorId != ''">
  529. AND m.id = #{majorId}
  530. </if>
  531. <if test="hasInterface != null and hasInterface == 0">
  532. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  533. </if>
  534. <if test="hasInterface != null and hasInterface == 1">
  535. AND cg.interface_account_id is not null
  536. </if>
  537. <if test="hasInterface != null and hasInterface == 2">
  538. AND cg.no_interface_account_id is not null
  539. </if>
  540. <if test="hasBindWx != null and hasBindWx == 1 ">
  541. AND u.union_id is not null
  542. </if>
  543. <if test="hasBindWx != null and hasBindWx == 0 ">
  544. AND u.union_id is null
  545. </if>
  546. <if test="hasFollowWx != null and hasFollowWx == 1 ">
  547. AND uwf.gzh_open_id is not null
  548. </if>
  549. <if test="hasFollowWx != null and hasFollowWx == 0 ">
  550. AND uwf.gzh_open_id is null
  551. </if>
  552. order by user_info_status desc ,user_status desc ,cgu.id desc
  553. </select>
  554. <select id="listGradeAll" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  555. SELECT
  556. cgu.id,
  557. cgu.official_status_time,
  558. cgu.official_status_num,
  559. u.user_account,
  560. u.user_id,
  561. u.company_name,
  562. cgu.`status`,
  563. u.realname,
  564. og.goods_id,
  565. u.id_card,
  566. cgu.grade_id,
  567. u.telphone,
  568. g.class_hours,
  569. cgu.period_status,
  570. cgu.finish_status,
  571. cgu.period_plush,
  572. g.study_start_time,
  573. g.study_end_time,
  574. cg.class_start_time,
  575. cg.class_end_time,
  576. cg.class_status,
  577. cg.interface_push_id,
  578. cgu.official_status,
  579. cgu.official_status_msg,
  580. cgu.period_plush_msg,
  581. cgu.learn_status,
  582. cgu.period_wait_time as end_time,
  583. (case WHEN (select COUNT(uu.id) FROM user_update uu where cgu.user_id = uu.user_id and uu.status = 2) >0 then 1 ELSE 0 end) as user_status,
  584. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id where c.goods_id=og.goods_id and m.type in (1,3) ) as exam_num,
  585. (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.user_id = u.user_id and ubr.grade_id = cgu.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.report_status=1 and ubr.current_status = 1) as record_num,
  586. (og.study_count) as study_count,
  587. og.order_goods_id,
  588. og.rebuy_order_goods_id,
  589. og.service_start_time,
  590. og.service_end_time,
  591. g.goods_name,
  592. og.order_sn,
  593. og.seven_year,
  594. m.category_name,
  595. g.major_id,
  596. u.province,
  597. cg.class_name,
  598. cgu.reason,
  599. cgu.tenant_id as org_id,
  600. cb.business_name,
  601. cpt.project_name,
  602. (SELECT IFNULL(SUM(usr.study_duration),0) from user_study_record usr where usr.user_id = cgu.user_id and usr.grade_id = cgu.grade_id) as user_study_duration,
  603. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  604. ueg.exam_number,
  605. ueg.do_number,
  606. ueg.expend_number,
  607. ueg.expend_before,
  608. up.`status` as profile_status,
  609. cet.education_name
  610. FROM
  611. class_grade_user cgu
  612. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  613. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  614. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  615. LEFT JOIN goods g on og.goods_id = g.goods_id
  616. LEFT JOIN major m ON g.major_id = m.id
  617. LEFT JOIN course_business cb ON g.business_id = cb.id
  618. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  619. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  620. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  621. LEFT JOIN user_profile up on cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
  622. where 1=1 and cgu.`status` = 1
  623. <if test="sevenCode != null and sevenCode !='' ">
  624. AND cg.seven_code = #{sevenCode}
  625. </if>
  626. <if test="gradeId != null and gradeId !='' and (sevenCode == null or sevenCode =='')">
  627. and cgu.grade_id = #{gradeId}
  628. </if>
  629. <if test="choice != null and choice == 1 ">
  630. and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and cgur.order_goods_id = cgu.order_goods_id AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null) and cge.`status`=1 and cgur.`status` =1)= 0 and cgu.period_status=0
  631. AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) &lt; cgde.class_end_time or cgde.class_start_time is null)) =0
  632. </if>
  633. <if test="choice != null and choice == 2 ">
  634. and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and cgur.order_goods_id = cgu.order_goods_id AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null)
  635. and cge.`status`=1 and cgur.`status` =1)> 0
  636. AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) &lt; cgde.class_end_time or cgde.class_start_time is null)) =0
  637. </if>
  638. <if test="studyCountMore != null and studyCountMore == 2 ">
  639. AND og.study_count > 0 AND cgu.change_grade = 0 AND (cg.status = 0 or unix_timestamp(now()) > cg.class_end_time)
  640. </if>
  641. <if test="studyCountMore != null and studyCountMore == 1 ">
  642. AND og.study_count > 0 AND cgu.change_grade = 1
  643. </if>
  644. <if test="studyCountMore != null and studyCountMore == 0 ">
  645. AND og.study_count = 0
  646. </if>
  647. <if test="officialStatus != null and officialStatus == 1 ">
  648. AND cgu.official_status = 1
  649. </if>
  650. <if test="officialStatus != null and officialStatus == 0 ">
  651. AND (cgu.official_status is NULL or cgu.official_status=0)
  652. </if>
  653. <if test="periodPlush != null and periodPlush == 1 ">
  654. AND cgu.period_plush = 1
  655. </if>
  656. <if test="periodPlush != null and periodPlush == 0 ">
  657. AND (cgu.period_plush is NULL or cgu.period_plush=0)
  658. </if>
  659. <if test="searchKey != null and searchKey != ''">
  660. AND (cg.class_name like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.company_name like concat('%', #{searchKey}, '%'))
  661. </if>
  662. <if test="telphone != null and telphone != ''">
  663. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  664. </if>
  665. <if test="idCard != null and idCard != ''">
  666. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  667. </if>
  668. <if test="idCards != null and idCards.size() != 0">
  669. AND u.id_card IN
  670. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  671. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  672. </foreach>
  673. </if>
  674. <if test="orderSn != null and orderSn != ''">
  675. AND og.order_sn = #{orderSn}
  676. </if>
  677. <if test="goodsName != null and goodsName != ''">
  678. AND g.goods_name like concat('%', #{goodsName}, '%')
  679. </if>
  680. <if test="searchStartTime != null and searchStartTime != ''">
  681. AND cgu.create_time &gt; #{searchStartTime}
  682. </if>
  683. <if test="searchEndTime != null and searchEndTime != ''">
  684. AND cgu.create_time &lt; #{searchEndTime}
  685. </if>
  686. <if test="finishStatus != null">
  687. AND cgu.finish_status = #{finishStatus}
  688. </if>
  689. <if test="learnStatus != null">
  690. AND cgu.learn_status = #{learnStatus}
  691. </if>
  692. <if test="projectId != null and projectId != ''">
  693. AND g.project_id = #{projectId}
  694. </if>
  695. <if test="businessId != null and businessId != ''">
  696. AND g.business_id = #{businessId}
  697. </if>
  698. <if test="educationTypeId != null and educationTypeId != ''">
  699. AND g.education_type_id = #{educationTypeId}
  700. </if>
  701. <if test="majorId != null and majorId != ''">
  702. AND m.id = #{majorId}
  703. </if>
  704. <if test="hasInterface != null and hasInterface == 0">
  705. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  706. </if>
  707. <if test="hasInterface != null and hasInterface == 1">
  708. AND cg.interface_account_id is not null
  709. </if>
  710. <if test="hasInterface != null and hasInterface == 2">
  711. AND cg.no_interface_account_id is not null
  712. </if>
  713. </select>
  714. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  715. SELECT
  716. g.*,
  717. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  718. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  719. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  720. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  721. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  722. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  723. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  724. FROM
  725. class_grade g
  726. where g.status !=-1
  727. <if test="status != null and status.size()!=0 ">
  728. AND g.status in
  729. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  730. #{item}
  731. </foreach>
  732. </if>
  733. <if test="gradeId != null and gradeId !=0 ">
  734. AND g.grade_id = #{gradeId}
  735. </if>
  736. <if test="className != null and className !='' ">
  737. AND g.class_name like concat('%', #{className}, '%')
  738. </if>
  739. <if test="classStartTime != null and classStartTime !=0 ">
  740. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  741. </if>
  742. <if test="educationTypeId != null and educationTypeId !='' ">
  743. AND (
  744. SELECT
  745. COUNT(*)
  746. FROM
  747. class_grade_goods s
  748. LEFT JOIN goods d ON s.goods_id = d.goods_id
  749. WHERE
  750. 1 = 1
  751. AND g.grade_id = s.grade_id
  752. AND d.education_type_id =#{educationTypeId}
  753. ) >0
  754. </if>
  755. <if test="businessId != null and businessId !='' ">
  756. AND (
  757. SELECT
  758. COUNT(*)
  759. FROM
  760. class_grade_goods s
  761. LEFT JOIN goods d ON s.goods_id = d.goods_id
  762. WHERE
  763. 1 = 1
  764. AND g.grade_id = s.grade_id
  765. AND d.business_id =#{businessId}
  766. ) >0
  767. </if>
  768. <if test="schoolId != null and schoolId !='' ">
  769. AND (
  770. SELECT
  771. COUNT(*)
  772. FROM
  773. class_grade_goods s
  774. LEFT JOIN goods d ON s.goods_id = d.goods_id
  775. WHERE
  776. 1 = 1
  777. AND g.grade_id = s.grade_id
  778. AND d.school_id =#{schoolId}
  779. ) >0
  780. </if>
  781. <if test="majorId != null and majorId !='' ">
  782. AND (
  783. SELECT
  784. COUNT(*)
  785. FROM
  786. class_grade_goods s
  787. LEFT JOIN goods d ON s.goods_id = d.goods_id
  788. WHERE
  789. 1 = 1
  790. AND g.grade_id = s.grade_id
  791. AND d.major_id =#{majorId}
  792. ) >0
  793. </if>
  794. <if test="goodsId != null and goodsId !='' ">
  795. AND (
  796. SELECT
  797. COUNT(*)
  798. FROM
  799. class_grade_goods s
  800. WHERE
  801. 1 = 1
  802. AND g.grade_id = s.grade_id
  803. AND s.goods_id =#{goodsId}
  804. ) >0
  805. </if>
  806. order by g.update_time desc
  807. </select>
  808. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  809. SELECT
  810. u.user_account,
  811. u.user_id,
  812. u.realname,
  813. u.id_card
  814. FROM
  815. `user` u
  816. WHERE
  817. 1 = 1
  818. and u.realname is NOT NULL
  819. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  820. <if test="status != null and status.size()!=0 ">
  821. AND u.status in
  822. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  823. #{item}
  824. </foreach>
  825. </if>
  826. </select>
  827. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  828. SELECT
  829. DISTINCT u.*
  830. FROM
  831. `user` u
  832. LEFT JOIN `order` o ON u.user_id = o.user_id
  833. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  834. LEFT JOIN goods g on g.goods_id=og.goods_id
  835. WHERE
  836. 1 = 1
  837. AND og.status=1
  838. and u.status=1
  839. and og.refund_status in(0,3)
  840. and og.pay_status in (2,3,4)
  841. and g.business_id =#{businessId}
  842. </select>
  843. <select id="querClassSMS" parameterType="map" resultType="Long">
  844. SELECT
  845. COUNT(1)
  846. FROM
  847. class_grade_goods cgg
  848. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  849. where 1=1
  850. and cgg.grade_id=#{gradeId}
  851. and g.business_id=#{businessId}
  852. </select>
  853. <select id="queryUser" parameterType="Long" resultType="Long">
  854. SELECT
  855. user_id
  856. FROM
  857. class_grade_user
  858. WHERE
  859. grade_id = #{gradeId}
  860. and `status` = 1
  861. </select>
  862. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  863. SELECT
  864. cg.grade_id,cg.class_status
  865. FROM
  866. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  867. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  868. WHERE
  869. 1 = 1
  870. and cg.`status` != -1
  871. <if test="businessId != null">
  872. AND g.business_id = #{businessId}
  873. </if>
  874. <if test="startTime != null">
  875. AND cg.create_time >= #{startTime}
  876. </if>
  877. <if test="endTime != null">
  878. AND #{endTime} >= cg.create_time
  879. </if>
  880. </select>
  881. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  882. SELECT
  883. count(cgu.id)
  884. FROM
  885. class_grade_user cgu LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  886. LEFT JOIN goods g ON og.goods_id = g.goods_id
  887. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  888. WHERE
  889. cgu.`status` = 1
  890. AND (cg.interface_account_id is not null or cg.no_interface_account_id is not null)
  891. <if test="learnStatus != null">
  892. AND cgu.learn_status = #{learnStatus}
  893. </if>
  894. <if test="finishStatus != null">
  895. AND cgu.finish_status = #{finishStatus}
  896. </if>
  897. <if test="projectId != null">
  898. AND g.project_id = #{projectId}
  899. </if>
  900. <if test="startTime != null">
  901. AND cgu.create_time >= #{startTime}
  902. </if>
  903. <if test="endTime != null">
  904. AND #{endTime} >= cgu.create_time
  905. </if>
  906. </select>
  907. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  908. SELECT
  909. count(cg.grade_id)
  910. FROM
  911. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  912. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  913. WHERE
  914. cg.status !=-1
  915. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  916. AND cg.interface_account_id > 0
  917. </if>
  918. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  919. AND cg.interface_account_id is NULL
  920. </if>
  921. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  922. AND cg.no_interface_account_id > 0
  923. </if>
  924. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  925. AND cg.no_interface_account_id is NULL
  926. </if>
  927. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  928. AND cg.interface_period_id > 0
  929. </if>
  930. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  931. AND cg.interface_period_id is NULL
  932. </if>
  933. <if test="interfacePushId != null and interfacePushId== 1">
  934. AND cg.interface_push_id > 0
  935. </if>
  936. <if test="interfacePushId != null and interfacePushId== 0">
  937. AND cg.interface_push_id is NULL
  938. </if>
  939. <if test="businessId != null">
  940. AND g.business_id = #{businessId}
  941. </if>
  942. <if test="startTime != null">
  943. AND cg.create_time >= #{startTime}
  944. </if>
  945. <if test="endTime != null">
  946. AND #{endTime} >= cg.create_time
  947. </if>
  948. </select>
  949. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  950. SELECT
  951. count(cgu.id)
  952. FROM
  953. class_grade_user cgu LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  954. LEFT JOIN goods g ON og.goods_id = g.goods_id
  955. WHERE
  956. 1 = 1
  957. <if test="periodStatus != null">
  958. AND cgu.period_status = #{periodStatus}
  959. </if>
  960. <if test="businessId != null">
  961. AND g.business_id = #{businessId}
  962. </if>
  963. <if test="startTime != null">
  964. AND cgu.period_ing_time >= #{startTime}
  965. </if>
  966. <if test="endTime != null">
  967. AND #{endTime} >= cgu.period_ing_time
  968. </if>
  969. <if test="waitStartTime != null">
  970. AND cgu.period_wait_time >= #{waitStartTime}
  971. </if>
  972. <if test="waitEndTime != null">
  973. AND #{waitEndTime} >= cgu.period_wait_time
  974. </if>
  975. </select>
  976. <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  977. SELECT
  978. count(cgu.id)
  979. FROM
  980. class_grade_user cgu LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  981. LEFT JOIN goods g ON og.goods_id = g.goods_id
  982. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  983. WHERE
  984. 1 = 1
  985. <if test="periodStatus != null">
  986. AND cgu.period_status = 1
  987. </if>
  988. <if test="interfacePushId != null">
  989. AND cg.interface_push_id > 0
  990. </if>
  991. <if test="officialStatus != null">
  992. AND cgu.official_status = 1
  993. </if>
  994. <if test="periodPlush != null">
  995. AND cgu.period_plush = 1
  996. </if>
  997. <if test="businessId != null">
  998. AND g.business_id = #{businessId}
  999. </if>
  1000. </select>
  1001. <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">
  1002. SELECT
  1003. g.goods_id
  1004. FROM
  1005. goods g
  1006. WHERE
  1007. 1=1
  1008. <if test="goodsIds != null and goodsIds.size()!=0 ">
  1009. AND g.goods_id in
  1010. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  1011. #{item}
  1012. </foreach>
  1013. </if>
  1014. </select>
  1015. <select id="listGradeSubjects" resultMap="ClassGradeVoResult">
  1016. SELECT
  1017. cg.*,
  1018. g.subject_ids,
  1019. g.business_id,
  1020. g.project_id
  1021. FROM
  1022. class_grade cg
  1023. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1024. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1025. </select>
  1026. <select id="queryCountList" parameterType="java.lang.Long" resultMap="ClassGradeVoResult">
  1027. SELECT
  1028. cg.*
  1029. FROM
  1030. class_grade cg
  1031. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1032. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1033. WHERE
  1034. cg.`status` != -1
  1035. and cg.`status` in (0,1)
  1036. and g.business_id = #{businessId}
  1037. </select>
  1038. <select id="queryOfficialGradeCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="Integer">
  1039. SELECT
  1040. ((
  1041. SELECT
  1042. count(*)
  1043. FROM
  1044. class_grade_user_temp cgu
  1045. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1046. WHERE
  1047. cg.official_name = #{officialName}
  1048. AND cgu.`status` = 1
  1049. <if test="classSign != null">
  1050. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
  1051. </if>
  1052. ) + (
  1053. SELECT
  1054. count(*)
  1055. FROM
  1056. class_grade_user cgu
  1057. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1058. WHERE
  1059. cg.official_name = #{officialName}
  1060. AND cgu.`status` = 1
  1061. <if test="classSign != null">
  1062. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
  1063. </if>
  1064. ))
  1065. </select>
  1066. <select id="queryGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  1067. SELECT
  1068. cg.*,cgg.goods_id
  1069. FROM
  1070. class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  1071. cg.class_end_time > #{startTime}
  1072. AND #{endTime} >= cg.class_end_time
  1073. </select>
  1074. <select id="getClassUserNumByTenant" parameterType="java.lang.Long" resultType="java.lang.Long">
  1075. SELECT
  1076. IFNULL(sum( a.num ),0)
  1077. FROM
  1078. ( SELECT COUNT( user_id ) AS num FROM class_grade_user WHERE grade_id = #{gradeId} AND `status` = 1 AND change_grade = 0 GROUP BY user_id ) a
  1079. </select>
  1080. <select id="getGradeDetailByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassNpUserInfoBo" resultMap="ClassNpUserInfoVoResult" >
  1081. SELECT
  1082. CONCAT('',cg.tenant_id) as tenantId,
  1083. cg.official_name as classNo,
  1084. cb.alias_name as platformName,
  1085. cg.class_name as categoryName,
  1086. u.realname as `name`,
  1087. u.id_card as idNum,
  1088. u.telphone as mobile,
  1089. u.company_name as companyName,
  1090. (SELECT og.create_time FROM order_goods og LEFT JOIN `order` o ON og.order_sn = o.order_sn WHERE og.goods_id = g.goods_id AND o.user_id = u.user_id AND og.pay_status in (2, 3, 4)
  1091. AND og.refund_status !=2
  1092. ORDER BY og.create_time DESC LIMIT 1) AS orderTimeLong,
  1093. cg.class_start_time as createTimeLong,
  1094. cgu.official_status_time as doTimeLong,
  1095. cgu.official_status as reportStatu,
  1096. cgu.finish_status as finishStatus,
  1097. cgu.period_plush as studyQueueStatus,
  1098. cgu.period_wait_time as applyTimeLong,
  1099. cgu.finish_status as finishStatus,
  1100. u.user_id,
  1101. cg.grade_id,
  1102. g.subject_ids
  1103. FROM class_grade cg
  1104. INNER JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
  1105. <if test="tenantId != null">
  1106. AND cgu.tenant_id = #{tenantId}
  1107. </if>
  1108. INNER JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  1109. <if test="tenantId != null">
  1110. AND og.tenant_id = #{tenantId}
  1111. </if>
  1112. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  1113. <if test="tenantId != null">
  1114. AND u.tenant_id = #{tenantId}
  1115. </if>
  1116. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1117. <if test="tenantId != null">
  1118. AND g.tenant_id = #{tenantId}
  1119. </if>
  1120. LEFT JOIN course_business cb ON g.business_id = cb.id
  1121. <if test="tenantId != null">
  1122. AND cb.tenant_id = #{tenantId}
  1123. </if>
  1124. WHERE 1 = 1
  1125. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1126. <if test="officialName != null and officialName !=''">
  1127. AND cg.official_name = #{officialName}
  1128. </if>
  1129. <if test="tenantId != null">
  1130. AND cg.tenant_id = #{tenantId}
  1131. </if>
  1132. <if test="name != null and name !=''">
  1133. AND u.realname like concat('%', #{name}, '%')
  1134. </if>
  1135. <if test="idNum != null and idNum !=''">
  1136. AND u.id_card like concat('%', #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  1137. </if>
  1138. <if test="mobile != null and mobile !=''">
  1139. AND u.telphone like concat('%', #{mobile,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  1140. </if>
  1141. </select>
  1142. <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1143. SELECT
  1144. cg.*
  1145. FROM
  1146. class_grade cg
  1147. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1148. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1149. LEFT JOIN course_business cb ON g.business_id = cb.id
  1150. WHERE
  1151. cb.alias_name = #{aliasName} AND cg.class_status = 0 AND cg.`status` = 1 AND g.goods_status = 1 AND cb.`status` = 1 AND g.`status` = 1
  1152. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1153. <if test="subIds != null and subIds.size()!=0 ">
  1154. AND (
  1155. <foreach collection="subIds" item="id" index="index">
  1156. <if test="index != subIds.size()-1">
  1157. FIND_IN_SET(#{id},g.subject_ids) OR
  1158. </if>
  1159. <if test="index == subIds.size()-1">
  1160. FIND_IN_SET(#{id},g.subject_ids)
  1161. </if>
  1162. </foreach>
  1163. )
  1164. </if>
  1165. </select>
  1166. <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">
  1167. SELECT
  1168. g.goods_id
  1169. FROM
  1170. goods g
  1171. LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
  1172. LEFT JOIN course_project_type cpt ON cb.project_id = cpt.id AND cpt.tenant_id = #{tenantId}
  1173. LEFT JOIN course_education_type cet ON cpt.education_id = cet.id AND cet.tenant_id = #{tenantId}
  1174. WHERE
  1175. cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId} AND g.goods_status = 1 AND cet.education_name = #{educationName}
  1176. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
  1177. <if test="subIds != null and subIds.size()!=0 ">
  1178. AND (
  1179. <foreach collection="subIds" item="id" index="index">
  1180. <if test="index != subIds.size()-1">
  1181. FIND_IN_SET(#{id},g.subject_ids) OR
  1182. </if>
  1183. <if test="index == subIds.size()-1">
  1184. FIND_IN_SET(#{id},g.subject_ids)
  1185. </if>
  1186. </foreach>
  1187. )
  1188. </if>
  1189. </select>
  1190. <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1191. SELECT
  1192. *
  1193. FROM
  1194. class_grade
  1195. where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}
  1196. </select>
  1197. <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1198. SELECT
  1199. cg.*
  1200. FROM
  1201. class_grade cg
  1202. where cg.official_name = #{officialName}
  1203. AND (SELECT COUNT(*) FROM sys_tenant s WHERE s.tenant_id = cg.tenant_id AND s.share_class = 1) > 0
  1204. </select>
  1205. <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1206. update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},
  1207. class_start_time = #{classStartTime},class_end_time = #{classEndTime},learning_status = #{learningStatus},learning_time_start = #{learningTimeStart}
  1208. where 1 = 1
  1209. <if test="gradeIds != null and gradeIds.size()!=0 ">
  1210. AND grade_id in
  1211. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1212. #{item}
  1213. </foreach>
  1214. </if>
  1215. </update>
  1216. <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >
  1217. update class_grade set register_code = official_name where 1 = 1
  1218. <if test="ids != null and ids.size()!=0 ">
  1219. AND grade_id in
  1220. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1221. #{item}
  1222. </foreach>
  1223. </if>
  1224. </update>
  1225. <update id="UpGradeInterfaceByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1226. update class_grade set interface_push_id = #{interfacePushId} where grade_id = #{gradeId}
  1227. </update>
  1228. <select id="getSevenGrade" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1229. SELECT *
  1230. FROM class_grade cg
  1231. WHERE cg.`status` = 1 AND (
  1232. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cg.grade_id = cgu.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  1233. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cg.grade_id = cgut.grade_id AND cgut.`status` = 1 )
  1234. ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
  1235. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1236. #{item}
  1237. </foreach>
  1238. LIMIT 1
  1239. </select>
  1240. <select id="getStudeCountByCode" resultType="java.lang.Long" parameterType="java.lang.String">
  1241. SELECT SUM(
  1242. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  1243. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  1244. ) as num FROM class_grade cg
  1245. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  1246. </select>
  1247. <select id="searchGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="com.zhongzheng.modules.grade.vo.ClassGradeVo">
  1248. SELECT
  1249. *
  1250. FROM
  1251. (
  1252. SELECT DISTINCT
  1253. g.grade_id,
  1254. g.class_name,
  1255. g.create_time,
  1256. g.class_status,
  1257. d.goods_name,
  1258. g.official_name,
  1259. g.seven_code,
  1260. g.student_upper,
  1261. g.class_start_time,
  1262. g.class_end_time,
  1263. g.learning_status,
  1264. g.remark,
  1265. g.status,
  1266. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  1267. (
  1268. SELECT
  1269. GROUP_CONCAT( subject_name )
  1270. FROM
  1271. course_subject
  1272. WHERE
  1273. FIND_IN_SET( id, d.subject_ids )) subject_names
  1274. FROM
  1275. class_grade g
  1276. LEFT JOIN (SELECT grade_id,any_value(goods_id) goods_id from class_grade_goods GROUP BY grade_id)cgg ON cgg.grade_id = g.grade_id
  1277. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  1278. LEFT JOIN course_business cb ON d.business_id = cb.id
  1279. WHERE
  1280. g.seven_code IS NULL
  1281. <if test="status != null and status.size()!=0 ">
  1282. AND g.status in
  1283. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  1284. #{item}
  1285. </foreach>
  1286. </if>
  1287. <if test="searchKey != null and searchKey !='' ">
  1288. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  1289. SELECT
  1290. COUNT(*)
  1291. FROM
  1292. class_grade_goods s
  1293. LEFT JOIN goods d ON s.goods_id = d.goods_id
  1294. WHERE
  1295. g.grade_id = s.grade_id
  1296. AND d.goods_name like concat('%', #{searchKey}, '%')
  1297. ) >0)
  1298. </if>
  1299. <if test="userName != null and userName !='' ">
  1300. AND (
  1301. SELECT
  1302. COUNT(*)
  1303. FROM
  1304. class_grade_user cgu
  1305. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  1306. WHERE
  1307. g.grade_id = cgu.grade_id
  1308. AND u.realname like concat('%', #{userName}, '%')
  1309. ) >0
  1310. </if>
  1311. AND g.status != -1
  1312. <if test="classStatus != null and classStatus==0">
  1313. AND (g.class_status = #{classStatus} or g.class_status is null )
  1314. </if>
  1315. <if test="classStatus != null and classStatus==1">
  1316. AND g.class_status = 1 and g.class_end_time >= unix_timestamp(now())
  1317. </if>
  1318. <if test="classStatus != null and classStatus == 2 ">
  1319. AND g.class_status = 1 and unix_timestamp(now()) > g.class_end_time
  1320. </if>
  1321. <if test="atFull != null and atFull !='' ">
  1322. AND (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) &lt; g.student_upper
  1323. </if>
  1324. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  1325. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  1326. </if>
  1327. <if test="pastDue != null or pastDue != null ">
  1328. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  1329. </if>
  1330. <if test="educationTypeId != null and educationTypeId !='' ">
  1331. AND d.education_type_id = #{educationTypeId}
  1332. </if>
  1333. <if test="businessId != null and businessId !='' ">
  1334. AND cb.id = #{businessId}
  1335. </if>
  1336. <if test="majorId != null and majorId !='' ">
  1337. AND d.major_id = #{majorId}
  1338. </if>
  1339. UNION ALL
  1340. SELECT DISTINCT
  1341. g.grade_id,
  1342. g.class_name,
  1343. g.create_time,
  1344. g.class_status,
  1345. d.goods_name,
  1346. g.official_name,
  1347. g.seven_code,
  1348. g.student_upper,
  1349. g.class_start_time,
  1350. g.class_end_time,
  1351. g.learning_status,
  1352. g.remark,
  1353. g.status,
  1354. (SELECT COUNT(c.id) FROM class_grade_user c where a.grade_id = c.grade_id and c.status =1) as student_num,
  1355. (
  1356. SELECT
  1357. GROUP_CONCAT( subject_name )
  1358. FROM
  1359. course_subject
  1360. WHERE
  1361. FIND_IN_SET( id, d.subject_ids )) subject_names
  1362. FROM
  1363. ( SELECT any_value ( g.grade_id ) AS grade_id FROM class_grade g WHERE g.`status` != - 1 AND g.seven_code IS NOT NULL
  1364. <if test="userName != null and userName !='' ">
  1365. AND (
  1366. SELECT
  1367. COUNT(*)
  1368. FROM
  1369. class_grade_user cgu
  1370. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  1371. WHERE
  1372. g.grade_id = cgu.grade_id
  1373. AND u.realname like concat('%', #{userName}, '%')
  1374. ) >0
  1375. </if>
  1376. GROUP BY seven_code ) a
  1377. LEFT JOIN class_grade g ON a.grade_id = g.grade_id
  1378. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  1379. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  1380. LEFT JOIN course_business cb ON d.business_id = cb.id
  1381. WHERE
  1382. 1 = 1
  1383. AND g.status != -1
  1384. <if test="status != null and status.size()!=0 ">
  1385. AND g.status in
  1386. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  1387. #{item}
  1388. </foreach>
  1389. </if>
  1390. <if test="searchKey != null and searchKey !='' ">
  1391. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  1392. SELECT
  1393. COUNT(*)
  1394. FROM
  1395. class_grade_goods s
  1396. LEFT JOIN goods d ON s.goods_id = d.goods_id
  1397. WHERE
  1398. g.grade_id = s.grade_id
  1399. AND d.goods_name like concat('%', #{searchKey}, '%')
  1400. ) >0)
  1401. </if>
  1402. <if test="classStatus != null and classStatus==0">
  1403. AND (g.class_status = #{classStatus} or g.class_status is null )
  1404. </if>
  1405. <if test="classStatus != null and classStatus==1">
  1406. AND g.class_status = 1 and g.class_end_time >= unix_timestamp(now())
  1407. </if>
  1408. <if test="classStatus != null and classStatus == 2 ">
  1409. AND g.class_status = 1 and unix_timestamp(now()) > g.class_end_time
  1410. </if>
  1411. <if test="atFull != null and atFull !='' ">
  1412. AND (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) &lt; g.student_upper
  1413. </if>
  1414. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  1415. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  1416. </if>
  1417. <if test="pastDue != null or pastDue != null ">
  1418. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  1419. </if>
  1420. <if test="educationTypeId != null and educationTypeId !='' ">
  1421. AND d.education_type_id = #{educationTypeId}
  1422. </if>
  1423. <if test="businessId != null and businessId !='' ">
  1424. AND cb.id = #{businessId}
  1425. </if>
  1426. <if test="majorId != null and majorId !='' ">
  1427. AND d.major_id = #{majorId}
  1428. </if>
  1429. ) b
  1430. WHERE
  1431. 1 = 1
  1432. ORDER BY
  1433. b.create_time DESC
  1434. </select>
  1435. <select id="getSevenYearByCode" resultType="java.lang.String" parameterType="java.lang.String">
  1436. SELECT DISTINCT
  1437. g.seven_year
  1438. FROM
  1439. class_grade cg
  1440. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1441. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1442. WHERE
  1443. cg.`status` != - 1
  1444. AND cg.seven_code = #{sevenCode}
  1445. </select>
  1446. <select id="listByIdsNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  1447. SELECT
  1448. cg.*
  1449. FROM
  1450. class_grade cg
  1451. WHERE
  1452. cg.`status` != - 1
  1453. AND cg.grade_id in
  1454. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1455. #{item}
  1456. </foreach>
  1457. </select>
  1458. <select id="getListNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="map">
  1459. SELECT
  1460. *
  1461. FROM
  1462. class_grade
  1463. WHERE
  1464. `status` = 1
  1465. AND seven_code = #{sevenCode}
  1466. AND grade_id != #{gradeId}
  1467. </select>
  1468. <update id="updateByIdNoTenant" parameterType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1469. UPDATE class_grade
  1470. SET class_status = #{classStatus},
  1471. official_name = #{officialName},
  1472. class_name = #{className},
  1473. student_upper = #{studentUpper},
  1474. learning_time_start = #{learningTimeStart},
  1475. learning_status = #{learningStatus},
  1476. `status` = #{status},
  1477. class_start_time = #{classStartTime},
  1478. class_end_time = #{classEndTime},
  1479. examine_id = #{examineId},
  1480. areas_id = #{areasId}
  1481. WHERE
  1482. grade_id = #{gradeId}
  1483. </update>
  1484. <select id="getCodeNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="map">
  1485. SELECT
  1486. *
  1487. FROM
  1488. class_grade
  1489. WHERE
  1490. `status` = 1
  1491. AND official_name = #{officialName}
  1492. AND tenant_id = #{tenantId}
  1493. LIMIT 1
  1494. </select>
  1495. <select id="getGradeCount" resultType="java.lang.Long" parameterType="java.lang.String">
  1496. SELECT
  1497. COUNT( DISTINCT cgu.user_id )
  1498. FROM
  1499. class_grade_user cgu
  1500. WHERE
  1501. cgu.`status` = 1
  1502. AND cgu.grade_id IN ( SELECT grade_id FROM class_grade WHERE seven_code = #{sevenCode} )
  1503. </select>
  1504. <select id="getStudeCountByCodeNoTenant" resultType="java.lang.Integer" parameterType="java.lang.String">
  1505. SELECT SUM(
  1506. (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
  1507. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  1508. ) as num FROM class_grade cg
  1509. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  1510. </select>
  1511. </mapper>