ClassGradeMapper.xml 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  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. <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. (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) 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. cgu.period_wait_time as applyTimeLong,
  888. u.user_id,
  889. cg.grade_id,
  890. g.subject_ids
  891. FROM class_grade cg
  892. LEFT JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
  893. <if test="tenantId != null">
  894. AND cgu.tenant_id = #{tenantId}
  895. </if>
  896. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  897. <if test="tenantId != null">
  898. AND cgg.tenant_id = #{tenantId}
  899. </if>
  900. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  901. <if test="tenantId != null">
  902. AND u.tenant_id = #{tenantId}
  903. </if>
  904. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  905. <if test="tenantId != null">
  906. AND g.tenant_id = #{tenantId}
  907. </if>
  908. LEFT JOIN course_business cb ON g.business_id = cb.id
  909. <if test="tenantId != null">
  910. AND cb.tenant_id = #{tenantId}
  911. </if>
  912. WHERE 1 = 1
  913. <if test="officialName != null and officialName !=''">
  914. AND cg.official_name = #{officialName}
  915. </if>
  916. <if test="tenantId != null">
  917. AND cg.tenant_id = #{tenantId}
  918. </if>
  919. <if test="name != null and name !=''">
  920. AND u.realname like concat('%', #{name}, '%')
  921. </if>
  922. <if test="idNum != null and idNum !=''">
  923. AND u.id_card like concat('%', #{idNum}, '%')
  924. </if>
  925. <if test="mobile != null and mobile !=''">
  926. AND u.telphone like concat('%', #{mobile}, '%')
  927. </if>
  928. </select>
  929. <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  930. SELECT
  931. cg.*
  932. FROM
  933. class_grade cg
  934. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  935. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  936. LEFT JOIN course_business cb ON g.business_id = cb.id
  937. WHERE
  938. cb.alias_name = #{aliasName} AND cg.class_status = 0 AND cg.`status` = 1
  939. <if test="subIds != null and subIds.size()!=0 ">
  940. AND (
  941. <foreach collection="subIds" item="id" index="index">
  942. <if test="index != subIds.size()-1">
  943. FIND_IN_SET(g.subject_ids,#{id}) OR
  944. </if>
  945. <if test="index == subIds.size()-1">
  946. FIND_IN_SET(g.subject_ids,#{id})
  947. </if>
  948. </foreach>
  949. )
  950. </if>
  951. </select>
  952. <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">
  953. SELECT
  954. g.goods_id
  955. FROM
  956. goods g
  957. LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
  958. WHERE
  959. cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId}
  960. <if test="subIds != null and subIds.size()!=0 ">
  961. AND (
  962. <foreach collection="subIds" item="id" index="index">
  963. <if test="index != subIds.size()-1">
  964. FIND_IN_SET(g.subject_ids,#{id}) OR
  965. </if>
  966. <if test="index == subIds.size()-1">
  967. FIND_IN_SET(g.subject_ids,#{id})
  968. </if>
  969. </foreach>
  970. )
  971. </if>
  972. </select>
  973. <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  974. SELECT
  975. *
  976. FROM
  977. class_grade
  978. where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}
  979. </select>
  980. <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  981. SELECT
  982. *
  983. FROM
  984. class_grade
  985. where register_code = #{registerCode}
  986. </select>
  987. <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  988. update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},class_start_time = #{classStartTime},class_end_time = #{classEndTime}
  989. where 1 = 1
  990. <if test="gradeIds != null and gradeIds.size()!=0 ">
  991. AND grade_id in
  992. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  993. #{item}
  994. </foreach>
  995. </if>
  996. </update>
  997. <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >
  998. update class_grade set register_code = official_name where 1 = 1
  999. <if test="gradeIds != null and gradeIds.size()!=0 ">
  1000. AND grade_id in
  1001. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1002. #{item}
  1003. </foreach>
  1004. </if>
  1005. </update>
  1006. </mapper>