ClassGradeMapper.xml 71 KB

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