ClassGradeMapper.xml 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081
  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. </resultMap>
  61. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserListVo" id="ClassGradeUserListVo">
  62. <result property="gradeId" column="grade_id"/>
  63. <result property="classStatus" column="class_status"/>
  64. <result property="officialName" column="official_name"/>
  65. <result property="className" column="class_name"/>
  66. <result property="studentUpper" column="student_upper"/>
  67. <result property="learningTimeStart" column="learning_time_start"/>
  68. <result property="learningStatus" column="learning_status"/>
  69. <result property="status" column="status"/>
  70. <result property="classStartTime" column="class_start_time"/>
  71. <result property="classEndTime" column="class_end_time"/>
  72. <result property="examineId" column="examine_id"/>
  73. <result property="areasId" column="areas_id"/>
  74. <result property="sysUserId" column="sys_user_id"/>
  75. <result property="interfacePushId" column="interface_push_id"/>
  76. <result property="remark" column="remark"/>
  77. <result property="interfaceAccountId" column="interface_account_id"/>
  78. <result property="interfacePeriodId" column="interface_period_id"/>
  79. <result property="interfaceAccountName" column="interface_account_name"/>
  80. <result property="interfacePeriodName" column="interface_period_name"/>
  81. <result property="interfacePushName" column="interface_push_name"/>
  82. <result property="studentNum" column="student_num"/>
  83. </resultMap>
  84. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  85. <result property="goodsId" column="goods_id"/>
  86. <result property="year" column="year"/>
  87. <result property="supplyId" column="supply_id"/>
  88. <result property="goodsType" column="goods_type"/>
  89. <result property="educationTypeId" column="education_type_id"/>
  90. <result property="businessId" column="business_id"/>
  91. <result property="schoolId" column="school_id"/>
  92. <result property="majorId" column="major_id"/>
  93. <result property="goodsName" column="goods_name"/>
  94. <result property="standPrice" column="stand_price"/>
  95. <result property="lowestPrice" column="lowest_price"/>
  96. <result property="createTime" column="create_time"/>
  97. <result property="updateTime" column="update_time"/>
  98. <result property="status" column="status"/>
  99. <result property="validityStartTime" column="validity_start_time"/>
  100. <result property="validityEndTime" column="validity_end_time"/>
  101. <result property="studyStartTime" column="study_start_time"/>
  102. <result property="studyEndTime" column="study_end_time"/>
  103. <result property="certificateIds" column="certificate_ids"/>
  104. <result property="introduce" column="introduce"/>
  105. <result property="suitableObject" column="suitable_object"/>
  106. <result property="buyNote" column="buy_note"/>
  107. <result property="pcDetailHtml" column="pc_detail_html"/>
  108. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  109. <result property="goodsStatus" column="goods_status"/>
  110. <result property="coverUrl" column="cover_url"/>
  111. <result property="classHours" column="class_hours"/>
  112. <result property="standPriceJson" column="stand_price_json"/>
  113. <result property="code" column="code"/>
  114. <result property="projectId" column="project_id"/>
  115. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  116. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  117. <result property="goodsPlayConfig" column="goods_play_config"/>
  118. <result property="goodsExamConfig" column="goods_exam_config"/>
  119. <result property="supplyName" column="supply_name"/>
  120. <result property="educationName" column="education_name"/>
  121. <result property="projectName" column="project_name"/>
  122. <result property="businessName" column="business_name"/>
  123. <result property="schoolName" column="school_name"/>
  124. <result property="categoryName" column="category_name"/>
  125. <result property="handoutsId" column="handouts_id"/>
  126. <result property="templateType" column="template_type"/>
  127. </resultMap>
  128. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeStudentVo" id="ClassGradeStudentVo">
  129. <result property="userId" column="user_id"/>
  130. <result property="id" column="id"/>
  131. <result property="gradeId" column="grade_id"/>
  132. <result property="studentCode" column="user_account"/>
  133. <result property="realname" column="realname"/>
  134. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  135. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  136. <result property="userStatus" column="user_status"/>
  137. <result property="status" column="status"/>
  138. <result property="classHours" column="class_hours"/>
  139. <result property="periodStatus" column="period_status"/>
  140. <result property="finishStatus" column="finish_status"/>
  141. <result property="officialStatus" column="official_status"/>
  142. <result property="learnStatus" column="learn_status"/>
  143. <result property="secAllNum" column="sec_all_num"/>
  144. <result property="examNum" column="exam_num"/>
  145. <result property="recordNum" column="record_num"/>
  146. <result property="classStartTime" column="class_start_time"/>
  147. <result property="classEndTime" column="class_end_time"/>
  148. <result property="studyStartTime" column="study_start_time"/>
  149. <result property="studyEndTime" column="study_end_time"/>
  150. <result property="studyCount" column="study_count"/>
  151. <result property="orderGoodsId" column="order_goods_id"/>
  152. <result property="officialStatusNum" column="official_status_num"/>
  153. <result property="officialStatusTime" column="official_status_time"/>
  154. <result property="interfacePushId" column="interface_push_id"/>
  155. <result property="periodPlush" column="period_plush"/>
  156. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  157. <result property="serviceStartTime" column="service_start_time"/>
  158. <result property="serviceEndTime" column="service_end_time"/>
  159. <result property="goodsName" column="goods_name"/>
  160. <result property="orderSn" column="order_sn"/>
  161. <result property="categoryName" column="category_name"/>
  162. <result property="reason" column="reason"/>
  163. <result property="projectName" column="project_name"/>
  164. <result property="businessName" column="business_name"/>
  165. <result property="userBindWx" column="user_bind_wx"/>
  166. <result property="userFollowWx" column="user_follow_wx"/>
  167. <result property="useStudyCount" column="use_study_count"/>
  168. <result property="examNumber" column="exam_number"/>
  169. <result property="doNumber" column="do_number"/>
  170. <result property="expendNumber" column="expend_number"/>
  171. <result property="expendBefore" column="expend_before"/>
  172. </resultMap>
  173. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeGoodsVo" id="ClassGradeGoodsVoResult">
  174. <result property="goodsId" column="goods_id"/>
  175. <collection property="gradeList" column="goods_id" select="findGradeList"/>
  176. </resultMap>
  177. <resultMap type="com.zhongzheng.modules.grade.vo.ClassNpUserInfoVo" id="ClassNpUserInfoVoResult">
  178. <result property="gradeId" column="grade_id"/>
  179. <result property="tenantId" column="tenantId"/>
  180. <result property="classNo" column="classNo"/>
  181. <result property="platformName" column="platformName"/>
  182. <result property="categoryName" column="categoryName"/>
  183. <result property="name" column="name"/>
  184. <result property="idNum" column="idNum" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  185. <result property="mobile" column="mobile" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  186. <result property="companyName" column="companyName"/>
  187. <result property="orderTimeLong" column="orderTimeLong"/>
  188. <result property="createTimeLong" column="createTimeLong"/>
  189. <result property="doTimeLong" column="doTimeLong"/>
  190. <result property="reportStatu" column="reportStatu"/>
  191. <result property="studyQueueStatus" column="studyQueueStatus"/>
  192. <result property="applyTimeLong" column="applyTimeLong"/>
  193. <result property="userId" column="user_id"/>
  194. <result property="subjectIds" column="subject_ids"/>
  195. </resultMap>
  196. <select id="findGradeList" resultMap="ClassGradeVoResult">
  197. SELECT
  198. g.*,
  199. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  200. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  201. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  202. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  203. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  204. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  205. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  206. (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,
  207. (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,
  208. (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
  209. FROM
  210. class_grade_goods cgg LEFT JOIN
  211. class_grade g on cgg.grade_id = g.grade_id
  212. where cgg.goods_id = #{goods_id} and g.`status` = 1
  213. </select>
  214. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  215. SELECT
  216. g.*,
  217. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  218. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  219. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  220. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  221. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  222. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  223. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  224. (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,
  225. (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,
  226. (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,
  227. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,d.subject_ids)) subject_names
  228. FROM
  229. class_grade g
  230. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  231. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  232. LEFT JOIN course_business cb ON d.business_id = cb.id
  233. <if test="userId != null and userId !=0 ">
  234. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  235. </if>
  236. where g.status !=-1
  237. <if test="status != null and status.size()!=0 ">
  238. AND g.status in
  239. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  240. #{item}
  241. </foreach>
  242. </if>
  243. <if test="userId != null and userId !=0 ">
  244. AND gu.user_id = #{userId}
  245. </if>
  246. <if test="gradeId != null and gradeId !=0 ">
  247. AND g.grade_id = #{gradeId}
  248. </if>
  249. <if test="searchKey != null and searchKey !='' ">
  250. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  251. SELECT
  252. COUNT(*)
  253. FROM
  254. class_grade_user cgu
  255. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  256. WHERE
  257. g.grade_id = cgu.grade_id
  258. AND u.realname like concat('%', #{searchKey}, '%')
  259. ) >0 or (
  260. SELECT
  261. COUNT(*)
  262. FROM
  263. class_grade_goods s
  264. LEFT JOIN goods d ON s.goods_id = d.goods_id
  265. WHERE
  266. g.grade_id = s.grade_id
  267. AND d.goods_name like concat('%', #{searchKey}, '%')
  268. ) >0)
  269. </if>
  270. <if test="classStatus != null ">
  271. AND g.class_status = #{classStatus}
  272. </if>
  273. <if test="className != null and className !='' ">
  274. AND g.class_name like concat('%', #{className}, '%')
  275. </if>
  276. <if test="atFull != null and atFull !='' ">
  277. 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
  278. </if>
  279. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  280. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  281. </if>
  282. <if test="pastDue != null or pastDue != null ">
  283. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  284. </if>
  285. <if test="educationTypeId != null and educationTypeId !='' ">
  286. AND (
  287. SELECT
  288. COUNT(*)
  289. FROM
  290. class_grade_goods s
  291. LEFT JOIN goods d ON s.goods_id = d.goods_id
  292. WHERE
  293. 1 = 1
  294. AND g.grade_id = s.grade_id
  295. AND d.education_type_id =#{educationTypeId}
  296. ) >0
  297. </if>
  298. <if test="businessId != null and businessId !='' ">
  299. AND cb.id = #{businessId}
  300. </if>
  301. <if test="schoolId != null and schoolId !='' ">
  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.school_id =#{schoolId}
  312. ) >0
  313. </if>
  314. <if test="majorId != null and majorId !='' ">
  315. AND (
  316. SELECT
  317. COUNT(*)
  318. FROM
  319. class_grade_goods s
  320. LEFT JOIN goods d ON s.goods_id = d.goods_id
  321. WHERE
  322. 1 = 1
  323. AND g.grade_id = s.grade_id
  324. AND d.major_id =#{majorId}
  325. ) >0
  326. </if>
  327. <if test="goodsId != null and goodsId !='' ">
  328. AND (
  329. SELECT
  330. COUNT(*)
  331. FROM
  332. class_grade_goods s
  333. WHERE
  334. 1 = 1
  335. AND g.grade_id = s.grade_id
  336. AND s.goods_id =#{goodsId}
  337. ) >0
  338. </if>
  339. <if test="hasInterface != null and hasInterface == 0">
  340. AND g.interface_account_id is null AND g.no_interface_account_id is null
  341. </if>
  342. <if test="hasInterface != null and hasInterface == 1">
  343. AND g.interface_account_id is not null
  344. </if>
  345. <if test="hasInterface != null and hasInterface == 2">
  346. AND g.no_interface_account_id is not null
  347. </if>
  348. <!-- 数据范围过滤 -->
  349. ${params.dataScope}
  350. order by g.create_time desc
  351. </select>
  352. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  353. SELECT
  354. g.*,
  355. ps.supply_name,
  356. cet.education_name,
  357. cpt.project_name,
  358. cb.business_name,
  359. s.school_name,
  360. m.category_name,
  361. ot.type AS template_type
  362. FROM
  363. goods g
  364. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  365. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  366. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  367. LEFT JOIN course_business cb ON g.business_id = cb.id
  368. LEFT JOIN school s ON s.id = g.school_id
  369. LEFT JOIN major m ON g.major_id = m.id
  370. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  371. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  372. WHERE
  373. 1 = 1
  374. AND o.grade_id =#{gradeId}
  375. </select>
  376. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  377. SELECT
  378. cgu.id,
  379. cgu.official_status_time,
  380. cgu.official_status_num,
  381. u.user_account,
  382. u.user_id,
  383. cgu.`status`,
  384. u.realname,
  385. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  386. u.id_card,
  387. cgu.grade_id,
  388. u.telphone,
  389. (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,
  390. (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,
  391. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  392. (SELECT g.class_hours FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as class_hours,
  393. cgu.period_status,
  394. cgu.finish_status,
  395. cgu.period_plush,
  396. (SELECT g.study_start_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_start_time,
  397. (SELECT g.study_end_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_end_time,
  398. cg.class_start_time,
  399. cg.class_end_time,
  400. cg.interface_push_id,
  401. cgu.official_status,
  402. cgu.learn_status,
  403. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type in (1,3) ) as exam_num,
  404. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id = ubr.goods_id 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.report_status=1 and ubr.current_status = 1) as record_num,
  405. (og.study_count) as study_count,
  406. og.order_goods_id,
  407. og.rebuy_order_goods_id,
  408. og.service_start_time,
  409. og.service_end_time,
  410. g.goods_name,
  411. og.order_sn,
  412. m.category_name,
  413. g.major_id,
  414. u.province,
  415. cgu.reason,
  416. cb.business_name,
  417. cpt.project_name,
  418. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,
  419. (case WHEN uwf.gzh_open_id is null then 0 ELSE 1 end) as user_follow_wx,
  420. (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,
  421. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  422. ueg.exam_number,
  423. ueg.do_number,
  424. ueg.expend_number,
  425. ueg.expend_before
  426. FROM
  427. class_grade_user cgu
  428. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  429. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  430. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  431. LEFT JOIN goods g on og.goods_id = g.goods_id
  432. LEFT JOIN major m ON g.major_id = m.id
  433. LEFT JOIN course_business cb ON g.business_id = cb.id
  434. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  435. LEFT JOIN user_wx_follow uwf ON u.union_id = uwf.union_id
  436. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  437. where 1=1
  438. <if test="gradeId != null and gradeId !='' ">
  439. and cgu.grade_id = #{gradeId}
  440. </if>
  441. <if test="choice != null and choice == 1 ">
  442. 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 (SELECT cgg.goods_id FROM class_grade_goods cgg where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_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
  443. 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
  444. </if>
  445. <if test="choice != null and choice == 2 ">
  446. 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 (SELECT cgg.goods_id FROM class_grade_goods cgg
  447. where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null)
  448. and cge.`status`=1 and cgur.`status` =1)> 0
  449. 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
  450. </if>
  451. <if test="studyCountMore != null and studyCountMore == 2 ">
  452. AND og.study_count > 0 AND cgu.change_grade = 0
  453. </if>
  454. <if test="studyCountMore != null and studyCountMore == 1 ">
  455. AND og.study_count > 0 AND cgu.change_grade = 1
  456. </if>
  457. <if test="studyCountMore != null and studyCountMore == 0 ">
  458. AND og.study_count = 0
  459. </if>
  460. <if test="realname != null and realname != ''">
  461. AND u.realname like concat('%', #{realname}, '%')
  462. </if>
  463. <if test="telphone != null and telphone != ''">
  464. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  465. </if>
  466. <if test="companyName != null and companyName != ''">
  467. AND u.company_name like concat('%', #{companyName}, '%')
  468. </if>
  469. <if test="idCard != null and idCard != ''">
  470. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  471. </if>
  472. <if test="idCards != null and idCards.size() != 0">
  473. AND u.id_card IN
  474. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  475. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  476. </foreach>
  477. </if>
  478. <if test="orderSn != null and orderSn != ''">
  479. AND og.order_sn = #{orderSn}
  480. </if>
  481. <if test="goodsName != null and goodsName != ''">
  482. AND g.goods_name like concat('%', #{goodsName}, '%')
  483. </if>
  484. <if test="searchStartTime != null and searchStartTime != ''">
  485. AND cgu.create_time &gt; #{searchStartTime}
  486. </if>
  487. <if test="searchEndTime != null and searchEndTime != ''">
  488. AND cgu.create_time &lt; #{searchEndTime}
  489. </if>
  490. <if test="finishStatus != null">
  491. AND cgu.finish_status = #{finishStatus}
  492. </if>
  493. <if test="learnStatus != null">
  494. AND cgu.learn_status = #{learnStatus}
  495. </if>
  496. <if test="projectId != null and projectId != ''">
  497. AND g.project_id = #{projectId}
  498. </if>
  499. <if test="businessId != null and businessId != ''">
  500. AND g.business_id = #{businessId}
  501. </if>
  502. <if test="educationTypeId != null and educationTypeId != ''">
  503. AND g.education_type_id = #{educationTypeId}
  504. </if>
  505. <if test="majorId != null and majorId != ''">
  506. AND m.id = #{majorId}
  507. </if>
  508. <if test="hasInterface != null and hasInterface == 0">
  509. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  510. </if>
  511. <if test="hasInterface != null and hasInterface == 1">
  512. AND cg.interface_account_id is not null
  513. </if>
  514. <if test="hasInterface != null and hasInterface == 2">
  515. AND cg.no_interface_account_id is not null
  516. </if>
  517. <if test="hasBindWx != null and hasBindWx == 1 ">
  518. AND u.union_id is not null
  519. </if>
  520. <if test="hasBindWx != null and hasBindWx == 0 ">
  521. AND u.union_id is null
  522. </if>
  523. <if test="hasFollowWx != null and hasFollowWx == 1 ">
  524. AND uwf.gzh_open_id is not null
  525. </if>
  526. <if test="hasFollowWx != null and hasFollowWx == 0 ">
  527. AND uwf.gzh_open_id is null
  528. </if>
  529. order by user_info_status desc ,user_status desc ,cgu.id desc
  530. </select>
  531. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  532. SELECT
  533. g.*,
  534. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  535. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  536. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  537. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  538. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  539. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  540. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  541. FROM
  542. class_grade g
  543. where g.status !=-1
  544. <if test="status != null and status.size()!=0 ">
  545. AND g.status in
  546. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  547. #{item}
  548. </foreach>
  549. </if>
  550. <if test="gradeId != null and gradeId !=0 ">
  551. AND g.grade_id = #{gradeId}
  552. </if>
  553. <if test="className != null and className !='' ">
  554. AND g.class_name like concat('%', #{className}, '%')
  555. </if>
  556. <if test="classStartTime != null and classStartTime !=0 ">
  557. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  558. </if>
  559. <if test="educationTypeId != null and educationTypeId !='' ">
  560. AND (
  561. SELECT
  562. COUNT(*)
  563. FROM
  564. class_grade_goods s
  565. LEFT JOIN goods d ON s.goods_id = d.goods_id
  566. WHERE
  567. 1 = 1
  568. AND g.grade_id = s.grade_id
  569. AND d.education_type_id =#{educationTypeId}
  570. ) >0
  571. </if>
  572. <if test="businessId != null and businessId !='' ">
  573. AND (
  574. SELECT
  575. COUNT(*)
  576. FROM
  577. class_grade_goods s
  578. LEFT JOIN goods d ON s.goods_id = d.goods_id
  579. WHERE
  580. 1 = 1
  581. AND g.grade_id = s.grade_id
  582. AND d.business_id =#{businessId}
  583. ) >0
  584. </if>
  585. <if test="schoolId != null and schoolId !='' ">
  586. AND (
  587. SELECT
  588. COUNT(*)
  589. FROM
  590. class_grade_goods s
  591. LEFT JOIN goods d ON s.goods_id = d.goods_id
  592. WHERE
  593. 1 = 1
  594. AND g.grade_id = s.grade_id
  595. AND d.school_id =#{schoolId}
  596. ) >0
  597. </if>
  598. <if test="majorId != null and majorId !='' ">
  599. AND (
  600. SELECT
  601. COUNT(*)
  602. FROM
  603. class_grade_goods s
  604. LEFT JOIN goods d ON s.goods_id = d.goods_id
  605. WHERE
  606. 1 = 1
  607. AND g.grade_id = s.grade_id
  608. AND d.major_id =#{majorId}
  609. ) >0
  610. </if>
  611. <if test="goodsId != null and goodsId !='' ">
  612. AND (
  613. SELECT
  614. COUNT(*)
  615. FROM
  616. class_grade_goods s
  617. WHERE
  618. 1 = 1
  619. AND g.grade_id = s.grade_id
  620. AND s.goods_id =#{goodsId}
  621. ) >0
  622. </if>
  623. order by g.update_time desc
  624. </select>
  625. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  626. SELECT
  627. u.user_account,
  628. u.user_id,
  629. u.realname,
  630. u.id_card
  631. FROM
  632. `user` u
  633. WHERE
  634. 1 = 1
  635. and u.realname is NOT NULL
  636. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  637. <if test="status != null and status.size()!=0 ">
  638. AND u.status in
  639. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  640. #{item}
  641. </foreach>
  642. </if>
  643. </select>
  644. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  645. SELECT
  646. DISTINCT u.*
  647. FROM
  648. `user` u
  649. LEFT JOIN `order` o ON u.user_id = o.user_id
  650. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  651. LEFT JOIN goods g on g.goods_id=og.goods_id
  652. WHERE
  653. 1 = 1
  654. AND og.status=1
  655. and u.status=1
  656. and og.refund_status in(0,3)
  657. and og.pay_status in (2,3,4)
  658. and g.business_id =#{businessId}
  659. </select>
  660. <select id="querClassSMS" parameterType="map" resultType="Long">
  661. SELECT
  662. COUNT(1)
  663. FROM
  664. class_grade_goods cgg
  665. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  666. where 1=1
  667. and cgg.grade_id=#{gradeId}
  668. and g.business_id=#{businessId}
  669. </select>
  670. <select id="queryUser" parameterType="Long" resultType="Long">
  671. SELECT
  672. user_id
  673. FROM
  674. class_grade_user
  675. WHERE
  676. grade_id = #{gradeId}
  677. and `status` = 1
  678. </select>
  679. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  680. SELECT
  681. cg.grade_id,cg.class_status
  682. FROM
  683. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  684. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  685. WHERE
  686. 1 = 1
  687. and cg.`status` != -1
  688. <if test="businessId != null">
  689. AND g.business_id = #{businessId}
  690. </if>
  691. <if test="startTime != null">
  692. AND cg.create_time >= #{startTime}
  693. </if>
  694. <if test="endTime != null">
  695. AND #{endTime} >= cg.create_time
  696. </if>
  697. </select>
  698. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  699. SELECT
  700. count(cgu.id)
  701. FROM
  702. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  703. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  704. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  705. WHERE
  706. cgu.`status` = 1
  707. AND (cg.interface_account_id is not null or cg.no_interface_account_id is not null)
  708. <if test="learnStatus != null">
  709. AND cgu.learn_status = #{learnStatus}
  710. </if>
  711. <if test="finishStatus != null">
  712. AND cgu.finish_status = #{finishStatus}
  713. </if>
  714. <if test="projectId != null">
  715. AND g.project_id = #{projectId}
  716. </if>
  717. <if test="startTime != null">
  718. AND cgu.create_time >= #{startTime}
  719. </if>
  720. <if test="endTime != null">
  721. AND #{endTime} >= cgu.create_time
  722. </if>
  723. </select>
  724. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  725. SELECT
  726. count(cg.grade_id)
  727. FROM
  728. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  729. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  730. WHERE
  731. cg.status !=-1
  732. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  733. AND cg.interface_account_id > 0
  734. </if>
  735. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  736. AND cg.interface_account_id is NULL
  737. </if>
  738. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  739. AND cg.no_interface_account_id > 0
  740. </if>
  741. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  742. AND cg.no_interface_account_id is NULL
  743. </if>
  744. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  745. AND cg.interface_period_id > 0
  746. </if>
  747. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  748. AND cg.interface_period_id is NULL
  749. </if>
  750. <if test="interfacePushId != null and interfacePushId== 1">
  751. AND cg.interface_push_id > 0
  752. </if>
  753. <if test="interfacePushId != null and interfacePushId== 0">
  754. AND cg.interface_push_id is NULL
  755. </if>
  756. <if test="businessId != null">
  757. AND g.business_id = #{businessId}
  758. </if>
  759. <if test="startTime != null">
  760. AND cg.create_time >= #{startTime}
  761. </if>
  762. <if test="endTime != null">
  763. AND #{endTime} >= cg.create_time
  764. </if>
  765. </select>
  766. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  767. SELECT
  768. count(cgu.id)
  769. FROM
  770. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  771. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  772. WHERE
  773. 1 = 1
  774. <if test="periodStatus != null">
  775. AND cgu.period_status = #{periodStatus}
  776. </if>
  777. <if test="businessId != null">
  778. AND g.business_id = #{businessId}
  779. </if>
  780. <if test="startTime != null">
  781. AND cgu.period_ing_time >= #{startTime}
  782. </if>
  783. <if test="endTime != null">
  784. AND #{endTime} >= cgu.period_ing_time
  785. </if>
  786. <if test="waitStartTime != null">
  787. AND cgu.period_wait_time >= #{waitStartTime}
  788. </if>
  789. <if test="waitEndTime != null">
  790. AND #{waitEndTime} >= cgu.period_wait_time
  791. </if>
  792. </select>
  793. <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  794. SELECT
  795. count(cgu.id)
  796. FROM
  797. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  798. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  799. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  800. WHERE
  801. 1 = 1
  802. <if test="periodStatus != null">
  803. AND cgu.period_status = 1
  804. </if>
  805. <if test="interfacePushId != null">
  806. AND cg.interface_push_id > 0
  807. </if>
  808. <if test="officialStatus != null">
  809. AND cgu.official_status = 1
  810. </if>
  811. <if test="periodPlush != null">
  812. AND cgu.period_plush = 1
  813. </if>
  814. <if test="businessId != null">
  815. AND g.business_id = #{businessId}
  816. </if>
  817. </select>
  818. <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">
  819. SELECT
  820. g.goods_id
  821. FROM
  822. goods g
  823. WHERE
  824. 1=1
  825. <if test="goodsIds != null and goodsIds.size()!=0 ">
  826. AND g.goods_id in
  827. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  828. #{item}
  829. </foreach>
  830. </if>
  831. </select>
  832. <select id="listGradeSubjects" resultMap="ClassGradeVoResult">
  833. SELECT
  834. cg.*,
  835. g.subject_ids,
  836. g.business_id,
  837. g.project_id
  838. FROM
  839. class_grade cg
  840. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  841. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  842. </select>
  843. <select id="queryCountList" parameterType="java.lang.Long" resultMap="ClassGradeVoResult">
  844. SELECT
  845. cg.*
  846. FROM
  847. class_grade cg
  848. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  849. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  850. WHERE
  851. cg.`status` != -1
  852. and cg.`status` in (0,1)
  853. and g.business_id = #{businessId}
  854. </select>
  855. <select id="queryOfficialGradeCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="Integer">
  856. SELECT
  857. ((
  858. SELECT
  859. count(*)
  860. FROM
  861. class_grade_user_temp cgu
  862. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  863. WHERE
  864. cg.official_name = #{officialName}
  865. AND cgu.`status` = 1
  866. -- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = 1) > 0
  867. ) + (
  868. SELECT
  869. count(*)
  870. FROM
  871. class_grade_user cgu
  872. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  873. WHERE
  874. cg.official_name = #{officialName}
  875. AND cgu.`status` = 1
  876. -- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = 1) > 0
  877. ))
  878. </select>
  879. <select id="queryGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  880. SELECT
  881. cg.*,cgg.goods_id
  882. FROM
  883. class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  884. cg.class_end_time > #{startTime}
  885. AND #{endTime} >= cg.class_end_time
  886. </select>
  887. <select id="getClassUserNumByTenant" parameterType="java.lang.Long" resultType="java.lang.Long">
  888. SELECT
  889. sum( a.num )
  890. FROM
  891. ( 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
  892. </select>
  893. <select id="getGradeDetailByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassNpUserInfoBo" resultMap="ClassNpUserInfoVoResult" >
  894. SELECT
  895. CONCAT('',cg.tenant_id) as tenantId,
  896. cg.official_name as classNo,
  897. cb.alias_name as platformName,
  898. cg.class_name as categoryName,
  899. u.realname as `name`,
  900. u.id_card as idNum,
  901. u.telphone as mobile,
  902. u.company_name as companyName,
  903. (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)
  904. AND og.refund_status !=2
  905. ORDER BY og.create_time DESC LIMIT 1) AS orderTimeLong,
  906. cg.class_start_time as createTimeLong,
  907. cgu.official_status_time as doTimeLong,
  908. cgu.official_status as reportStatu,
  909. cgu.period_plush as studyQueueStatus,
  910. cgu.period_wait_time as applyTimeLong,
  911. u.user_id,
  912. cg.grade_id,
  913. g.subject_ids
  914. FROM class_grade cg
  915. INNER JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
  916. <if test="tenantId != null">
  917. AND cgu.tenant_id = #{tenantId}
  918. </if>
  919. INNER JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  920. <if test="tenantId != null">
  921. AND cgg.tenant_id = #{tenantId}
  922. </if>
  923. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  924. <if test="tenantId != null">
  925. AND u.tenant_id = #{tenantId}
  926. </if>
  927. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  928. <if test="tenantId != null">
  929. AND g.tenant_id = #{tenantId}
  930. </if>
  931. LEFT JOIN course_business cb ON g.business_id = cb.id
  932. <if test="tenantId != null">
  933. AND cb.tenant_id = #{tenantId}
  934. </if>
  935. WHERE 1 = 1
  936. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  937. <if test="officialName != null and officialName !=''">
  938. AND cg.official_name = #{officialName}
  939. </if>
  940. <if test="tenantId != null">
  941. AND cg.tenant_id = #{tenantId}
  942. </if>
  943. <if test="name != null and name !=''">
  944. AND u.realname like concat('%', #{name}, '%')
  945. </if>
  946. <if test="idNum != null and idNum !=''">
  947. AND u.id_card like concat('%', #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  948. </if>
  949. <if test="mobile != null and mobile !=''">
  950. AND u.telphone like concat('%', #{mobile,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  951. </if>
  952. </select>
  953. <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  954. SELECT
  955. cg.*
  956. FROM
  957. class_grade cg
  958. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  959. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  960. LEFT JOIN course_business cb ON g.business_id = cb.id
  961. WHERE
  962. 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
  963. -- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  964. <if test="subIds != null and subIds.size()!=0 ">
  965. AND (
  966. <foreach collection="subIds" item="id" index="index">
  967. <if test="index != subIds.size()-1">
  968. FIND_IN_SET(#{id},g.subject_ids) OR
  969. </if>
  970. <if test="index == subIds.size()-1">
  971. FIND_IN_SET(#{id},g.subject_ids)
  972. </if>
  973. </foreach>
  974. )
  975. </if>
  976. </select>
  977. <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">
  978. SELECT
  979. g.goods_id
  980. FROM
  981. goods g
  982. LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
  983. LEFT JOIN course_project_type cpt ON cb.project_id = cpt.id AND cpt.tenant_id = #{tenantId}
  984. LEFT JOIN course_education_type cet ON cpt.education_id = cet.id AND cet.tenant_id = #{tenantId}
  985. WHERE
  986. cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId} AND g.goods_status = 1 AND cet.education_name = #{educationName}
  987. -- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
  988. <if test="subIds != null and subIds.size()!=0 ">
  989. AND (
  990. <foreach collection="subIds" item="id" index="index">
  991. <if test="index != subIds.size()-1">
  992. FIND_IN_SET(#{id},g.subject_ids) OR
  993. </if>
  994. <if test="index == subIds.size()-1">
  995. FIND_IN_SET(#{id},g.subject_ids)
  996. </if>
  997. </foreach>
  998. )
  999. </if>
  1000. </select>
  1001. <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1002. SELECT
  1003. *
  1004. FROM
  1005. class_grade
  1006. where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}
  1007. </select>
  1008. <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1009. SELECT
  1010. cg.*
  1011. FROM
  1012. class_grade cg
  1013. where cg.official_name = #{registerCode}
  1014. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1015. </select>
  1016. <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1017. update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},
  1018. class_start_time = #{classStartTime},class_end_time = #{classEndTime},learning_status = #{learningStatus},learning_time_start = #{learningTimeStart}
  1019. where 1 = 1
  1020. <if test="gradeIds != null and gradeIds.size()!=0 ">
  1021. AND grade_id in
  1022. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1023. #{item}
  1024. </foreach>
  1025. </if>
  1026. </update>
  1027. <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >
  1028. update class_grade set register_code = official_name where 1 = 1
  1029. <if test="ids != null and ids.size()!=0 ">
  1030. AND grade_id in
  1031. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1032. #{item}
  1033. </foreach>
  1034. </if>
  1035. </update>
  1036. <update id="UpGradeInterfaceByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1037. update class_grade set interface_push_id = #{interfacePushId} where grade_id = #{gradeId}
  1038. </update>
  1039. </mapper>