ClassGradeMapper.xml 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  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. u.company_name,
  395. cgu.`status`,
  396. u.realname,
  397. og.goods_id,
  398. u.id_card,
  399. cgu.grade_id,
  400. u.telphone,
  401. (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,
  402. (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,
  403. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  404. g.class_hours,
  405. cgu.period_status,
  406. cgu.finish_status,
  407. cgu.period_plush,
  408. g.study_start_time,
  409. g.study_end_time,
  410. cg.class_start_time,
  411. cg.class_end_time,
  412. cg.interface_push_id,
  413. cgu.official_status,
  414. cgu.official_status_msg,
  415. cgu.period_plush_msg,
  416. cgu.learn_status,
  417. (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,
  418. (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,
  419. (og.study_count) as study_count,
  420. og.order_goods_id,
  421. og.rebuy_order_goods_id,
  422. og.service_start_time,
  423. og.service_end_time,
  424. g.goods_name,
  425. og.order_sn,
  426. og.seven_year,
  427. m.category_name,
  428. g.major_id,
  429. u.province,
  430. cgu.reason,
  431. cgu.tenant_id as org_id,
  432. cb.business_name,
  433. cpt.project_name,
  434. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,
  435. (case WHEN uwf.gzh_open_id is null then 0 ELSE 1 end) as user_follow_wx,
  436. (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,
  437. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  438. ueg.exam_number,
  439. ueg.do_number,
  440. ueg.expend_number,
  441. ueg.expend_before,
  442. up.`status` as profile_status,
  443. cet.education_name
  444. FROM
  445. class_grade_user cgu
  446. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  447. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  448. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  449. LEFT JOIN goods g on og.goods_id = g.goods_id
  450. LEFT JOIN major m ON g.major_id = m.id
  451. LEFT JOIN course_business cb ON g.business_id = cb.id
  452. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  453. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  454. LEFT JOIN user_wx_follow uwf ON u.union_id = uwf.union_id
  455. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  456. LEFT JOIN user_profile up on cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
  457. where 1=1 and cgu.`status` = 1
  458. <if test="sevenCode != null and sevenCode !='' ">
  459. AND cg.seven_code = #{sevenCode}
  460. </if>
  461. <if test="gradeId != null and gradeId !='' and (sevenCode == null or sevenCode =='')">
  462. and cgu.grade_id = #{gradeId}
  463. </if>
  464. <if test="choice != null and choice == 1 ">
  465. 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
  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="choice != null and choice == 2 ">
  469. 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)
  470. and cge.`status`=1 and cgur.`status` =1)> 0
  471. 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
  472. </if>
  473. <if test="studyCountMore != null and studyCountMore == 2 ">
  474. AND og.study_count > 0 AND cgu.change_grade = 0
  475. </if>
  476. <if test="studyCountMore != null and studyCountMore == 1 ">
  477. AND og.study_count > 0 AND cgu.change_grade = 1
  478. </if>
  479. <if test="studyCountMore != null and studyCountMore == 0 ">
  480. AND og.study_count = 0
  481. </if>
  482. <if test="periodStatus != null ">
  483. AND cgu.period_status = #{periodStatus}
  484. </if>
  485. <if test="officialStatus != null and officialStatus == 1 ">
  486. AND cgu.official_status = 1
  487. </if>
  488. <if test="officialStatus != null and officialStatus == 0 ">
  489. AND (cgu.official_status is NULL or cgu.official_status=0)
  490. </if>
  491. <if test="periodPlush != null and periodPlush == 1 ">
  492. AND cgu.period_plush = 1
  493. </if>
  494. <if test="periodPlush != null and periodPlush == 0 ">
  495. AND (cgu.period_plush is NULL or cgu.period_plush=0)
  496. </if>
  497. <if test="realname != null and realname != ''">
  498. AND u.realname like concat('%', #{realname}, '%')
  499. </if>
  500. <if test="telphone != null and telphone != ''">
  501. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  502. </if>
  503. <if test="companyName != null and companyName != ''">
  504. AND u.company_name like concat('%', #{companyName}, '%')
  505. </if>
  506. <if test="idCard != null and idCard != ''">
  507. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  508. </if>
  509. <if test="idCards != null and idCards.size() != 0">
  510. AND u.id_card IN
  511. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  512. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  513. </foreach>
  514. </if>
  515. <if test="searchKey != null and searchKey != ''">
  516. AND (cg.class_name like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.company_name like concat('%', #{searchKey}, '%'))
  517. </if>
  518. <if test="orderSn != null and orderSn != ''">
  519. AND og.order_sn = #{orderSn}
  520. </if>
  521. <if test="goodsName != null and goodsName != ''">
  522. AND g.goods_name like concat('%', #{goodsName}, '%')
  523. </if>
  524. <if test="searchStartTime != null and searchStartTime != ''">
  525. AND cgu.create_time &gt; #{searchStartTime}
  526. </if>
  527. <if test="searchEndTime != null and searchEndTime != ''">
  528. AND cgu.create_time &lt; #{searchEndTime}
  529. </if>
  530. <if test="finishStatus != null">
  531. AND cgu.finish_status = #{finishStatus}
  532. </if>
  533. <if test="learnStatus != null">
  534. AND cgu.learn_status = #{learnStatus}
  535. </if>
  536. <if test="projectId != null and projectId != ''">
  537. AND g.project_id = #{projectId}
  538. </if>
  539. <if test="businessId != null and businessId != ''">
  540. AND g.business_id = #{businessId}
  541. </if>
  542. <if test="educationTypeId != null and educationTypeId != ''">
  543. AND g.education_type_id = #{educationTypeId}
  544. </if>
  545. <if test="majorId != null and majorId != ''">
  546. AND m.id = #{majorId}
  547. </if>
  548. <if test="hasInterface != null and hasInterface == 0">
  549. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  550. </if>
  551. <if test="hasInterface != null and hasInterface == 1">
  552. AND cg.interface_account_id is not null
  553. </if>
  554. <if test="hasInterface != null and hasInterface == 2">
  555. AND cg.no_interface_account_id is not null
  556. </if>
  557. <if test="hasBindWx != null and hasBindWx == 1 ">
  558. AND u.union_id is not null
  559. </if>
  560. <if test="hasBindWx != null and hasBindWx == 0 ">
  561. AND u.union_id is null
  562. </if>
  563. <if test="hasFollowWx != null and hasFollowWx == 1 ">
  564. AND uwf.gzh_open_id is not null
  565. </if>
  566. <if test="hasFollowWx != null and hasFollowWx == 0 ">
  567. AND uwf.gzh_open_id is null
  568. </if>
  569. order by user_info_status desc ,user_status desc ,cgu.id desc
  570. </select>
  571. <select id="listGradeAll" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  572. SELECT
  573. cgu.id,
  574. cgu.official_status_time,
  575. cgu.official_status_num,
  576. u.user_account,
  577. u.user_id,
  578. u.company_name,
  579. cgu.`status`,
  580. u.realname,
  581. og.goods_id,
  582. u.id_card,
  583. cgu.grade_id,
  584. u.telphone,
  585. g.class_hours,
  586. cgu.period_status,
  587. cgu.finish_status,
  588. cgu.period_plush,
  589. g.study_start_time,
  590. g.study_end_time,
  591. cg.class_start_time,
  592. cg.class_end_time,
  593. cg.class_status,
  594. cg.interface_push_id,
  595. cgu.official_status,
  596. cgu.official_status_msg,
  597. cgu.period_plush_msg,
  598. cgu.learn_status,
  599. cgu.period_wait_time as end_time,
  600. (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,
  601. (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,
  602. (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,
  603. (og.study_count) as study_count,
  604. og.order_goods_id,
  605. og.rebuy_order_goods_id,
  606. og.service_start_time,
  607. og.service_end_time,
  608. g.goods_name,
  609. og.order_sn,
  610. og.seven_year,
  611. m.category_name,
  612. g.major_id,
  613. u.province,
  614. cg.class_name,
  615. cgu.reason,
  616. cgu.tenant_id as org_id,
  617. cb.business_name,
  618. cpt.project_name,
  619. (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,
  620. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  621. ueg.exam_number,
  622. ueg.do_number,
  623. ueg.expend_number,
  624. ueg.expend_before,
  625. up.`status` as profile_status,
  626. cet.education_name
  627. FROM
  628. class_grade_user cgu
  629. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  630. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  631. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  632. LEFT JOIN goods g on og.goods_id = g.goods_id
  633. LEFT JOIN major m ON g.major_id = m.id
  634. LEFT JOIN course_business cb ON g.business_id = cb.id
  635. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  636. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  637. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  638. LEFT JOIN user_profile up on cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
  639. where 1=1 and cgu.`status` = 1
  640. <if test="sevenCode != null and sevenCode !='' ">
  641. AND cg.seven_code = #{sevenCode}
  642. </if>
  643. <if test="gradeId != null and gradeId !='' and (sevenCode == null or sevenCode =='')">
  644. and cgu.grade_id = #{gradeId}
  645. </if>
  646. <if test="choice != null and choice == 1 ">
  647. 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
  648. 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
  649. </if>
  650. <if test="choice != null and choice == 2 ">
  651. 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)
  652. and cge.`status`=1 and cgur.`status` =1)> 0
  653. 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
  654. </if>
  655. <if test="studyCountMore != null and studyCountMore == 2 ">
  656. AND og.study_count > 0 AND cgu.change_grade = 0 AND (cg.status = 0 or unix_timestamp(now()) > cg.class_end_time)
  657. </if>
  658. <if test="studyCountMore != null and studyCountMore == 1 ">
  659. AND og.study_count > 0 AND cgu.change_grade = 1
  660. </if>
  661. <if test="studyCountMore != null and studyCountMore == 0 ">
  662. AND og.study_count = 0
  663. </if>
  664. <if test="periodStatus != null ">
  665. AND cgu.period_status = #{periodStatus}
  666. </if>
  667. <if test="officialStatus != null and officialStatus == 1 ">
  668. AND cgu.official_status = 1
  669. </if>
  670. <if test="officialStatus != null and officialStatus == 0 ">
  671. AND (cgu.official_status is NULL or cgu.official_status=0)
  672. </if>
  673. <if test="periodPlush != null and periodPlush == 1 ">
  674. AND cgu.period_plush = 1
  675. </if>
  676. <if test="periodPlush != null and periodPlush == 0 ">
  677. AND (cgu.period_plush is NULL or cgu.period_plush=0)
  678. </if>
  679. <if test="searchKey != null and searchKey != ''">
  680. AND (cg.class_name like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.company_name like concat('%', #{searchKey}, '%'))
  681. </if>
  682. <if test="telphone != null and telphone != ''">
  683. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  684. </if>
  685. <if test="idCard != null and idCard != ''">
  686. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  687. </if>
  688. <if test="idCards != null and idCards.size() != 0">
  689. AND u.id_card IN
  690. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  691. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  692. </foreach>
  693. </if>
  694. <if test="orderSn != null and orderSn != ''">
  695. AND og.order_sn = #{orderSn}
  696. </if>
  697. <if test="goodsName != null and goodsName != ''">
  698. AND g.goods_name like concat('%', #{goodsName}, '%')
  699. </if>
  700. <if test="searchStartTime != null and searchStartTime != ''">
  701. AND cgu.create_time &gt; #{searchStartTime}
  702. </if>
  703. <if test="searchEndTime != null and searchEndTime != ''">
  704. AND cgu.create_time &lt; #{searchEndTime}
  705. </if>
  706. <if test="finishStatus != null">
  707. AND cgu.finish_status = #{finishStatus}
  708. </if>
  709. <if test="learnStatus != null">
  710. AND cgu.learn_status = #{learnStatus}
  711. </if>
  712. <if test="projectId != null and projectId != ''">
  713. AND g.project_id = #{projectId}
  714. </if>
  715. <if test="businessId != null and businessId != ''">
  716. AND g.business_id = #{businessId}
  717. </if>
  718. <if test="educationTypeId != null and educationTypeId != ''">
  719. AND g.education_type_id = #{educationTypeId}
  720. </if>
  721. <if test="majorId != null and majorId != ''">
  722. AND m.id = #{majorId}
  723. </if>
  724. <if test="hasInterface != null and hasInterface == 0">
  725. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  726. </if>
  727. <if test="hasInterface != null and hasInterface == 1">
  728. AND cg.interface_account_id is not null
  729. </if>
  730. <if test="hasInterface != null and hasInterface == 2">
  731. AND cg.no_interface_account_id is not null
  732. </if>
  733. order by cgu.id desc
  734. </select>
  735. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  736. SELECT
  737. g.*,
  738. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  739. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  740. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  741. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  742. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  743. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  744. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  745. FROM
  746. class_grade g
  747. where g.status !=-1
  748. <if test="status != null and status.size()!=0 ">
  749. AND g.status in
  750. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  751. #{item}
  752. </foreach>
  753. </if>
  754. <if test="gradeId != null and gradeId !=0 ">
  755. AND g.grade_id = #{gradeId}
  756. </if>
  757. <if test="className != null and className !='' ">
  758. AND g.class_name like concat('%', #{className}, '%')
  759. </if>
  760. <if test="classStartTime != null and classStartTime !=0 ">
  761. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  762. </if>
  763. <if test="educationTypeId != null and educationTypeId !='' ">
  764. AND (
  765. SELECT
  766. COUNT(*)
  767. FROM
  768. class_grade_goods s
  769. LEFT JOIN goods d ON s.goods_id = d.goods_id
  770. WHERE
  771. 1 = 1
  772. AND g.grade_id = s.grade_id
  773. AND d.education_type_id =#{educationTypeId}
  774. ) >0
  775. </if>
  776. <if test="businessId != null and businessId !='' ">
  777. AND (
  778. SELECT
  779. COUNT(*)
  780. FROM
  781. class_grade_goods s
  782. LEFT JOIN goods d ON s.goods_id = d.goods_id
  783. WHERE
  784. 1 = 1
  785. AND g.grade_id = s.grade_id
  786. AND d.business_id =#{businessId}
  787. ) >0
  788. </if>
  789. <if test="schoolId != null and schoolId !='' ">
  790. AND (
  791. SELECT
  792. COUNT(*)
  793. FROM
  794. class_grade_goods s
  795. LEFT JOIN goods d ON s.goods_id = d.goods_id
  796. WHERE
  797. 1 = 1
  798. AND g.grade_id = s.grade_id
  799. AND d.school_id =#{schoolId}
  800. ) >0
  801. </if>
  802. <if test="majorId != null and majorId !='' ">
  803. AND (
  804. SELECT
  805. COUNT(*)
  806. FROM
  807. class_grade_goods s
  808. LEFT JOIN goods d ON s.goods_id = d.goods_id
  809. WHERE
  810. 1 = 1
  811. AND g.grade_id = s.grade_id
  812. AND d.major_id =#{majorId}
  813. ) >0
  814. </if>
  815. <if test="goodsId != null and goodsId !='' ">
  816. AND (
  817. SELECT
  818. COUNT(*)
  819. FROM
  820. class_grade_goods s
  821. WHERE
  822. 1 = 1
  823. AND g.grade_id = s.grade_id
  824. AND s.goods_id =#{goodsId}
  825. ) >0
  826. </if>
  827. order by g.update_time desc
  828. </select>
  829. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  830. SELECT
  831. u.user_account,
  832. u.user_id,
  833. u.realname,
  834. u.id_card
  835. FROM
  836. `user` u
  837. WHERE
  838. 1 = 1
  839. and u.realname is NOT NULL
  840. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  841. <if test="status != null and status.size()!=0 ">
  842. AND u.status in
  843. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  844. #{item}
  845. </foreach>
  846. </if>
  847. </select>
  848. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  849. SELECT
  850. DISTINCT u.*
  851. FROM
  852. `user` u
  853. LEFT JOIN `order` o ON u.user_id = o.user_id
  854. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  855. LEFT JOIN goods g on g.goods_id=og.goods_id
  856. WHERE
  857. 1 = 1
  858. AND og.status=1
  859. and u.status=1
  860. and og.refund_status in(0,3)
  861. and og.pay_status in (2,3,4)
  862. and g.business_id =#{businessId}
  863. </select>
  864. <select id="querClassSMS" parameterType="map" resultType="Long">
  865. SELECT
  866. COUNT(1)
  867. FROM
  868. class_grade_goods cgg
  869. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  870. where 1=1
  871. and cgg.grade_id=#{gradeId}
  872. and g.business_id=#{businessId}
  873. </select>
  874. <select id="queryUser" parameterType="Long" resultType="Long">
  875. SELECT
  876. user_id
  877. FROM
  878. class_grade_user
  879. WHERE
  880. grade_id = #{gradeId}
  881. and `status` = 1
  882. </select>
  883. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  884. SELECT
  885. cg.grade_id,cg.class_status
  886. FROM
  887. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  888. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  889. WHERE
  890. 1 = 1
  891. and cg.`status` != -1
  892. <if test="businessId != null">
  893. AND g.business_id = #{businessId}
  894. </if>
  895. <if test="startTime != null">
  896. AND cg.create_time >= #{startTime}
  897. </if>
  898. <if test="endTime != null">
  899. AND #{endTime} >= cg.create_time
  900. </if>
  901. </select>
  902. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  903. SELECT
  904. count(cgu.id)
  905. FROM
  906. class_grade_user cgu LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  907. LEFT JOIN goods g ON og.goods_id = g.goods_id
  908. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  909. WHERE
  910. cgu.`status` = 1
  911. AND (cg.interface_account_id is not null or cg.no_interface_account_id is not null)
  912. <if test="learnStatus != null">
  913. AND cgu.learn_status = #{learnStatus}
  914. </if>
  915. <if test="finishStatus != null">
  916. AND cgu.finish_status = #{finishStatus}
  917. </if>
  918. <if test="projectId != null">
  919. AND g.project_id = #{projectId}
  920. </if>
  921. <if test="startTime != null">
  922. AND cgu.create_time >= #{startTime}
  923. </if>
  924. <if test="endTime != null">
  925. AND #{endTime} >= cgu.create_time
  926. </if>
  927. </select>
  928. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  929. SELECT
  930. count(cg.grade_id)
  931. FROM
  932. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  933. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  934. WHERE
  935. cg.status !=-1
  936. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  937. AND cg.interface_account_id > 0
  938. </if>
  939. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  940. AND cg.interface_account_id is NULL
  941. </if>
  942. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  943. AND cg.no_interface_account_id > 0
  944. </if>
  945. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  946. AND cg.no_interface_account_id is NULL
  947. </if>
  948. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  949. AND cg.interface_period_id > 0
  950. </if>
  951. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  952. AND cg.interface_period_id is NULL
  953. </if>
  954. <if test="interfacePushId != null and interfacePushId== 1">
  955. AND cg.interface_push_id > 0
  956. </if>
  957. <if test="interfacePushId != null and interfacePushId== 0">
  958. AND cg.interface_push_id is NULL
  959. </if>
  960. <if test="businessId != null">
  961. AND g.business_id = #{businessId}
  962. </if>
  963. <if test="startTime != null">
  964. AND cg.create_time >= #{startTime}
  965. </if>
  966. <if test="endTime != null">
  967. AND #{endTime} >= cg.create_time
  968. </if>
  969. </select>
  970. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  971. SELECT
  972. count(cgu.id)
  973. FROM
  974. class_grade_user cgu LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  975. LEFT JOIN goods g ON og.goods_id = g.goods_id
  976. WHERE
  977. 1 = 1
  978. <if test="periodStatus != null">
  979. AND cgu.period_status = #{periodStatus}
  980. </if>
  981. <if test="businessId != null">
  982. AND g.business_id = #{businessId}
  983. </if>
  984. <if test="startTime != null">
  985. AND cgu.period_ing_time >= #{startTime}
  986. </if>
  987. <if test="endTime != null">
  988. AND #{endTime} >= cgu.period_ing_time
  989. </if>
  990. <if test="waitStartTime != null">
  991. AND cgu.period_wait_time >= #{waitStartTime}
  992. </if>
  993. <if test="waitEndTime != null">
  994. AND #{waitEndTime} >= cgu.period_wait_time
  995. </if>
  996. </select>
  997. <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  998. SELECT
  999. count(cgu.id)
  1000. FROM
  1001. class_grade_user cgu LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  1002. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1003. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1004. WHERE
  1005. 1 = 1
  1006. <if test="periodStatus != null">
  1007. AND cgu.period_status = 1
  1008. </if>
  1009. <if test="interfacePushId != null">
  1010. AND cg.interface_push_id > 0
  1011. </if>
  1012. <if test="officialStatus != null">
  1013. AND cgu.official_status = 1
  1014. </if>
  1015. <if test="periodPlush != null">
  1016. AND cgu.period_plush = 1
  1017. </if>
  1018. <if test="businessId != null">
  1019. AND g.business_id = #{businessId}
  1020. </if>
  1021. </select>
  1022. <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">
  1023. SELECT
  1024. g.goods_id
  1025. FROM
  1026. goods g
  1027. WHERE
  1028. 1=1
  1029. <if test="goodsIds != null and goodsIds.size()!=0 ">
  1030. AND g.goods_id in
  1031. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  1032. #{item}
  1033. </foreach>
  1034. </if>
  1035. </select>
  1036. <select id="listGradeSubjects" resultMap="ClassGradeVoResult">
  1037. SELECT
  1038. cg.*,
  1039. g.subject_ids,
  1040. g.business_id,
  1041. g.project_id
  1042. FROM
  1043. class_grade cg
  1044. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1045. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1046. </select>
  1047. <select id="queryCountList" parameterType="java.lang.Long" resultMap="ClassGradeVoResult">
  1048. SELECT
  1049. cg.*
  1050. FROM
  1051. class_grade cg
  1052. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1053. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1054. WHERE
  1055. cg.`status` != -1
  1056. and cg.`status` in (0,1)
  1057. and g.business_id = #{businessId}
  1058. </select>
  1059. <select id="queryOfficialGradeCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="Integer">
  1060. SELECT
  1061. ((
  1062. SELECT
  1063. count(*)
  1064. FROM
  1065. class_grade_user_temp cgu
  1066. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1067. WHERE
  1068. cg.official_name = #{officialName}
  1069. AND cgu.`status` = 1
  1070. <if test="classSign != null">
  1071. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
  1072. </if>
  1073. ) + (
  1074. SELECT
  1075. count(*)
  1076. FROM
  1077. class_grade_user cgu
  1078. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  1079. WHERE
  1080. cg.official_name = #{officialName}
  1081. AND cgu.`status` = 1
  1082. <if test="classSign != null">
  1083. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
  1084. </if>
  1085. ))
  1086. </select>
  1087. <select id="queryGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  1088. SELECT
  1089. cg.*,cgg.goods_id
  1090. FROM
  1091. class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  1092. cg.class_end_time > #{startTime}
  1093. AND #{endTime} >= cg.class_end_time
  1094. </select>
  1095. <select id="getClassUserNumByTenant" parameterType="java.lang.Long" resultType="java.lang.Long">
  1096. SELECT
  1097. IFNULL(sum( a.num ),0)
  1098. FROM
  1099. ( 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
  1100. </select>
  1101. <select id="getGradeDetailByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassNpUserInfoBo" resultMap="ClassNpUserInfoVoResult" >
  1102. SELECT
  1103. CONCAT('',cg.tenant_id) as tenantId,
  1104. cg.official_name as classNo,
  1105. cb.alias_name as platformName,
  1106. cg.class_name as categoryName,
  1107. u.realname as `name`,
  1108. u.id_card as idNum,
  1109. u.telphone as mobile,
  1110. u.company_name as companyName,
  1111. (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)
  1112. AND og.refund_status !=2
  1113. ORDER BY og.create_time DESC LIMIT 1) AS orderTimeLong,
  1114. cg.class_start_time as createTimeLong,
  1115. cgu.official_status_time as doTimeLong,
  1116. cgu.official_status as reportStatu,
  1117. cgu.finish_status as finishStatus,
  1118. cgu.period_plush as studyQueueStatus,
  1119. cgu.period_wait_time as applyTimeLong,
  1120. cgu.finish_status as finishStatus,
  1121. u.user_id,
  1122. cg.grade_id,
  1123. g.subject_ids
  1124. FROM class_grade cg
  1125. INNER JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
  1126. <if test="tenantId != null">
  1127. AND cgu.tenant_id = #{tenantId}
  1128. </if>
  1129. INNER JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  1130. <if test="tenantId != null">
  1131. AND og.tenant_id = #{tenantId}
  1132. </if>
  1133. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  1134. <if test="tenantId != null">
  1135. AND u.tenant_id = #{tenantId}
  1136. </if>
  1137. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1138. <if test="tenantId != null">
  1139. AND g.tenant_id = #{tenantId}
  1140. </if>
  1141. LEFT JOIN course_business cb ON g.business_id = cb.id
  1142. <if test="tenantId != null">
  1143. AND cb.tenant_id = #{tenantId}
  1144. </if>
  1145. WHERE 1 = 1
  1146. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1147. <if test="officialName != null and officialName !=''">
  1148. AND cg.official_name = #{officialName}
  1149. </if>
  1150. <if test="tenantId != null">
  1151. AND cg.tenant_id = #{tenantId}
  1152. </if>
  1153. <if test="name != null and name !=''">
  1154. AND u.realname like concat('%', #{name}, '%')
  1155. </if>
  1156. <if test="idNum != null and idNum !=''">
  1157. AND u.id_card like concat('%', #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  1158. </if>
  1159. <if test="mobile != null and mobile !=''">
  1160. AND u.telphone like concat('%', #{mobile,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  1161. </if>
  1162. </select>
  1163. <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1164. SELECT
  1165. cg.*
  1166. FROM
  1167. class_grade cg
  1168. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1169. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1170. LEFT JOIN course_business cb ON g.business_id = cb.id
  1171. WHERE
  1172. 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
  1173. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1174. <if test="subIds != null and subIds.size()!=0 ">
  1175. AND (
  1176. <foreach collection="subIds" item="id" index="index">
  1177. <if test="index != subIds.size()-1">
  1178. FIND_IN_SET(#{id},g.subject_ids) OR
  1179. </if>
  1180. <if test="index == subIds.size()-1">
  1181. FIND_IN_SET(#{id},g.subject_ids)
  1182. </if>
  1183. </foreach>
  1184. )
  1185. </if>
  1186. </select>
  1187. <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">
  1188. SELECT
  1189. g.goods_id
  1190. FROM
  1191. goods g
  1192. LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
  1193. LEFT JOIN course_project_type cpt ON cb.project_id = cpt.id AND cpt.tenant_id = #{tenantId}
  1194. LEFT JOIN course_education_type cet ON cpt.education_id = cet.id AND cet.tenant_id = #{tenantId}
  1195. WHERE
  1196. cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId} AND g.goods_status = 1 AND cet.education_name = #{educationName}
  1197. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
  1198. <if test="subIds != null and subIds.size()!=0 ">
  1199. AND (
  1200. <foreach collection="subIds" item="id" index="index">
  1201. <if test="index != subIds.size()-1">
  1202. FIND_IN_SET(#{id},g.subject_ids) OR
  1203. </if>
  1204. <if test="index == subIds.size()-1">
  1205. FIND_IN_SET(#{id},g.subject_ids)
  1206. </if>
  1207. </foreach>
  1208. )
  1209. </if>
  1210. </select>
  1211. <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1212. SELECT
  1213. *
  1214. FROM
  1215. class_grade
  1216. where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}
  1217. </select>
  1218. <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1219. SELECT
  1220. cg.*
  1221. FROM
  1222. class_grade cg
  1223. where cg.official_name = #{officialName}
  1224. AND (SELECT COUNT(*) FROM sys_tenant s WHERE s.tenant_id = cg.tenant_id AND s.share_class = 1) > 0
  1225. </select>
  1226. <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1227. update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},
  1228. class_start_time = #{classStartTime},class_end_time = #{classEndTime},learning_status = #{learningStatus},learning_time_start = #{learningTimeStart}
  1229. where 1 = 1
  1230. <if test="gradeIds != null and gradeIds.size()!=0 ">
  1231. AND grade_id in
  1232. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1233. #{item}
  1234. </foreach>
  1235. </if>
  1236. </update>
  1237. <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >
  1238. update class_grade set register_code = official_name where 1 = 1
  1239. <if test="ids != null and ids.size()!=0 ">
  1240. AND grade_id in
  1241. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1242. #{item}
  1243. </foreach>
  1244. </if>
  1245. </update>
  1246. <update id="UpGradeInterfaceByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1247. update class_grade set interface_push_id = #{interfacePushId} where grade_id = #{gradeId}
  1248. </update>
  1249. <select id="getSevenGrade" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1250. SELECT *
  1251. FROM class_grade cg
  1252. WHERE cg.`status` = 1 AND (
  1253. (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) +
  1254. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cg.grade_id = cgut.grade_id AND cgut.`status` = 1 )
  1255. ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
  1256. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1257. #{item}
  1258. </foreach>
  1259. LIMIT 1
  1260. </select>
  1261. <select id="getStudeCountByCode" resultType="java.lang.Long" parameterType="java.lang.String">
  1262. SELECT SUM(
  1263. (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) +
  1264. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  1265. ) as num FROM class_grade cg
  1266. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  1267. </select>
  1268. <select id="searchGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="com.zhongzheng.modules.grade.vo.ClassGradeVo">
  1269. SELECT
  1270. *
  1271. FROM
  1272. (
  1273. SELECT DISTINCT
  1274. g.grade_id,
  1275. g.class_name,
  1276. g.create_time,
  1277. g.class_status,
  1278. d.goods_name,
  1279. g.official_name,
  1280. g.seven_code,
  1281. g.student_upper,
  1282. g.class_start_time,
  1283. g.class_end_time,
  1284. g.learning_status,
  1285. g.remark,
  1286. g.status,
  1287. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  1288. (
  1289. SELECT
  1290. GROUP_CONCAT( subject_name )
  1291. FROM
  1292. course_subject
  1293. WHERE
  1294. FIND_IN_SET( id, d.subject_ids )) subject_names
  1295. FROM
  1296. class_grade g
  1297. 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
  1298. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  1299. LEFT JOIN course_business cb ON d.business_id = cb.id
  1300. WHERE
  1301. g.seven_code IS NULL
  1302. <if test="status != null and status.size()!=0 ">
  1303. AND g.status in
  1304. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  1305. #{item}
  1306. </foreach>
  1307. </if>
  1308. <if test="searchKey != null and searchKey !='' ">
  1309. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  1310. SELECT
  1311. COUNT(*)
  1312. FROM
  1313. class_grade_goods s
  1314. LEFT JOIN goods d ON s.goods_id = d.goods_id
  1315. WHERE
  1316. g.grade_id = s.grade_id
  1317. AND d.goods_name like concat('%', #{searchKey}, '%')
  1318. ) >0)
  1319. </if>
  1320. <if test="userName != null and userName !='' ">
  1321. AND (
  1322. SELECT
  1323. COUNT(*)
  1324. FROM
  1325. class_grade_user cgu
  1326. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  1327. WHERE
  1328. g.grade_id = cgu.grade_id
  1329. AND u.realname like concat('%', #{userName}, '%')
  1330. ) >0
  1331. </if>
  1332. AND g.status != -1
  1333. <if test="classStatus != null and classStatus==0">
  1334. AND (g.class_status = #{classStatus} or g.class_status is null )
  1335. </if>
  1336. <if test="classStatus != null and classStatus==1">
  1337. AND g.class_status = 1 and g.class_end_time >= unix_timestamp(now())
  1338. </if>
  1339. <if test="classStatus != null and classStatus == 2 ">
  1340. AND g.class_status = 1 and unix_timestamp(now()) > g.class_end_time
  1341. </if>
  1342. <if test="atFull != null and atFull !='' ">
  1343. 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
  1344. </if>
  1345. <if test="classStartTime != null and classStartTime != '' ">
  1346. AND g.class_start_time >=#{classStartTime}
  1347. </if>
  1348. <if test="classEndTime != null and classEndTime != '' ">
  1349. AND #{classEndTime} >= g.class_end_time
  1350. </if>
  1351. <if test="pastDue != null or pastDue != null ">
  1352. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  1353. </if>
  1354. <if test="educationTypeId != null and educationTypeId !='' ">
  1355. AND d.education_type_id = #{educationTypeId}
  1356. </if>
  1357. <if test="businessId != null and businessId !='' ">
  1358. AND cb.id = #{businessId}
  1359. </if>
  1360. <if test="majorId != null and majorId !='' ">
  1361. AND d.major_id = #{majorId}
  1362. </if>
  1363. UNION ALL
  1364. SELECT DISTINCT
  1365. g.grade_id,
  1366. g.class_name,
  1367. g.create_time,
  1368. g.class_status,
  1369. d.goods_name,
  1370. g.official_name,
  1371. g.seven_code,
  1372. g.student_upper,
  1373. g.class_start_time,
  1374. g.class_end_time,
  1375. g.learning_status,
  1376. g.remark,
  1377. g.status,
  1378. (SELECT COUNT(c.id) FROM class_grade_user c where a.grade_id = c.grade_id and c.status =1) as student_num,
  1379. (
  1380. SELECT
  1381. GROUP_CONCAT( subject_name )
  1382. FROM
  1383. course_subject
  1384. WHERE
  1385. FIND_IN_SET( id, d.subject_ids )) subject_names
  1386. FROM
  1387. ( SELECT any_value ( g.grade_id ) AS grade_id FROM class_grade g WHERE g.`status` != - 1 AND g.seven_code IS NOT NULL
  1388. <if test="userName != null and userName !='' ">
  1389. AND (
  1390. SELECT
  1391. COUNT(*)
  1392. FROM
  1393. class_grade_user cgu
  1394. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  1395. WHERE
  1396. g.grade_id = cgu.grade_id
  1397. AND u.realname like concat('%', #{userName}, '%')
  1398. ) >0
  1399. </if>
  1400. GROUP BY seven_code ) a
  1401. LEFT JOIN class_grade g ON a.grade_id = g.grade_id
  1402. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  1403. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  1404. LEFT JOIN course_business cb ON d.business_id = cb.id
  1405. WHERE
  1406. 1 = 1
  1407. AND g.status != -1
  1408. <if test="status != null and status.size()!=0 ">
  1409. AND g.status in
  1410. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  1411. #{item}
  1412. </foreach>
  1413. </if>
  1414. <if test="searchKey != null and searchKey !='' ">
  1415. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  1416. SELECT
  1417. COUNT(*)
  1418. FROM
  1419. class_grade_goods s
  1420. LEFT JOIN goods d ON s.goods_id = d.goods_id
  1421. WHERE
  1422. g.grade_id = s.grade_id
  1423. AND d.goods_name like concat('%', #{searchKey}, '%')
  1424. ) >0)
  1425. </if>
  1426. <if test="classStatus != null and classStatus==0">
  1427. AND (g.class_status = #{classStatus} or g.class_status is null )
  1428. </if>
  1429. <if test="classStatus != null and classStatus==1">
  1430. AND g.class_status = 1 and g.class_end_time >= unix_timestamp(now())
  1431. </if>
  1432. <if test="classStatus != null and classStatus == 2 ">
  1433. AND g.class_status = 1 and unix_timestamp(now()) > g.class_end_time
  1434. </if>
  1435. <if test="atFull != null and atFull !='' ">
  1436. 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
  1437. </if>
  1438. <if test="classStartTime != null and classStartTime != '' ">
  1439. AND g.class_start_time >=#{classStartTime}
  1440. </if>
  1441. <if test="classEndTime != null and classEndTime != '' ">
  1442. AND #{classEndTime} >= g.class_end_time
  1443. </if>
  1444. <if test="pastDue != null or pastDue != null ">
  1445. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  1446. </if>
  1447. <if test="educationTypeId != null and educationTypeId !='' ">
  1448. AND d.education_type_id = #{educationTypeId}
  1449. </if>
  1450. <if test="businessId != null and businessId !='' ">
  1451. AND cb.id = #{businessId}
  1452. </if>
  1453. <if test="majorId != null and majorId !='' ">
  1454. AND d.major_id = #{majorId}
  1455. </if>
  1456. ) b
  1457. WHERE
  1458. 1 = 1
  1459. ORDER BY
  1460. b.create_time DESC
  1461. </select>
  1462. <select id="getSevenYearByCode" resultType="java.lang.String" parameterType="java.lang.String">
  1463. SELECT DISTINCT
  1464. g.seven_year
  1465. FROM
  1466. class_grade cg
  1467. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  1468. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  1469. WHERE
  1470. cg.`status` != - 1
  1471. AND cg.seven_code = #{sevenCode}
  1472. </select>
  1473. <select id="listByIdsNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
  1474. SELECT
  1475. cg.*
  1476. FROM
  1477. class_grade cg
  1478. WHERE
  1479. cg.`status` != - 1
  1480. AND cg.grade_id in
  1481. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1482. #{item}
  1483. </foreach>
  1484. </select>
  1485. <select id="getListNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="map">
  1486. SELECT
  1487. *
  1488. FROM
  1489. class_grade
  1490. WHERE
  1491. `status` = 1
  1492. AND seven_code = #{sevenCode}
  1493. AND grade_id != #{gradeId}
  1494. </select>
  1495. <update id="updateByIdNoTenant" parameterType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1496. UPDATE class_grade
  1497. SET class_status = #{classStatus},
  1498. official_name = #{officialName},
  1499. class_name = #{className},
  1500. student_upper = #{studentUpper},
  1501. learning_time_start = #{learningTimeStart},
  1502. learning_status = #{learningStatus},
  1503. `status` = #{status},
  1504. class_start_time = #{classStartTime},
  1505. class_end_time = #{classEndTime},
  1506. examine_id = #{examineId},
  1507. areas_id = #{areasId}
  1508. WHERE
  1509. grade_id = #{gradeId}
  1510. </update>
  1511. <select id="getCodeNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="map">
  1512. SELECT
  1513. *
  1514. FROM
  1515. class_grade
  1516. WHERE
  1517. `status` = 1
  1518. AND official_name = #{officialName}
  1519. AND tenant_id = #{tenantId}
  1520. LIMIT 1
  1521. </select>
  1522. <select id="getGradeCount" resultType="java.lang.Long" parameterType="java.lang.String">
  1523. SELECT
  1524. COUNT( DISTINCT cgu.user_id )
  1525. FROM
  1526. class_grade_user cgu
  1527. WHERE
  1528. cgu.`status` = 1
  1529. AND cgu.grade_id IN ( SELECT grade_id FROM class_grade WHERE seven_code = #{sevenCode} )
  1530. </select>
  1531. <select id="getStudeCountByCodeNoTenant" resultType="java.lang.Integer" parameterType="java.lang.String">
  1532. SELECT SUM(
  1533. (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) +
  1534. (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
  1535. ) as num FROM class_grade cg
  1536. WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
  1537. </select>
  1538. </mapper>