ClassGradeMapper.xml 47 KB

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