ClassGradeMapper.xml 71 KB

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