ClassGradeMapper.xml 69 KB

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