ClassGradeMapper.xml 71 KB

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