ClassGradeMapper.xml 70 KB

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