ClassGradeMapper.xml 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.grade.mapper.ClassGradeMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.ClassGrade" id="ClassGradeResult">
  7. <result property="gradeId" column="grade_id"/>
  8. <result property="classStatus" column="class_status"/>
  9. <result property="officialName" column="official_name"/>
  10. <result property="className" column="class_name"/>
  11. <result property="studentUpper" column="student_upper"/>
  12. <result property="learningTimeStart" column="learning_time_start"/>
  13. <result property="learningStatus" column="learning_status"/>
  14. <result property="status" column="status"/>
  15. <result property="classStartTime" column="class_start_time"/>
  16. <result property="classEndTime" column="class_end_time"/>
  17. <result property="examineId" column="examine_id"/>
  18. <result property="areasId" column="areas_id"/>
  19. <result property="createTime" column="create_time"/>
  20. <result property="updateTime" column="update_time"/>
  21. <result property="sysUserId" column="sys_user_id"/>
  22. <result property="interfacePushId" column="interface_push_id"/>
  23. <result property="remark" column="remark"/>
  24. <result property="interfaceAccountId" column="interface_account_id"/>
  25. <result property="interfacePeriodId" column="interface_period_id"/>
  26. <result property="officialLearningUrl" column="official_learning_url"/>
  27. </resultMap>
  28. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  29. <result property="gradeId" column="grade_id"/>
  30. <result property="classStatus" column="class_status"/>
  31. <result property="officialName" column="official_name"/>
  32. <result property="className" column="class_name"/>
  33. <result property="studentUpper" column="student_upper"/>
  34. <result property="learningTimeStart" column="learning_time_start"/>
  35. <result property="learningStatus" column="learning_status"/>
  36. <result property="status" column="status"/>
  37. <result property="classStartTime" column="class_start_time"/>
  38. <result property="classEndTime" column="class_end_time"/>
  39. <result property="examineId" column="examine_id"/>
  40. <result property="areasId" column="areas_id"/>
  41. <result property="sysUserId" column="sys_user_id"/>
  42. <result property="interfacePushId" column="interface_push_id"/>
  43. <result property="remark" column="remark"/>
  44. <result property="interfaceAccountId" column="interface_account_id"/>
  45. <result property="interfacePeriodId" column="interface_period_id"/>
  46. <result property="interfaceAccountName" column="interface_account_name"/>
  47. <result property="interfacePeriodName" column="interface_period_name"/>
  48. <result property="interfacePushName" column="interface_push_name"/>
  49. <result property="studentNum" column="student_num"/>
  50. <result property="officialLearningUrl" column="official_learning_url"/>
  51. <result property="officialStatusNum" column="official_status_num"/>
  52. <result property="periodStatusNum" column="period_status_num"/>
  53. <result property="periodPlushNum" column="period_plush_num"/>
  54. <result property="periodPlushNum" column="period_plush_num"/>
  55. <result property="subjectNames" column="subject_names"/>
  56. <result property="subjectIds" column="subject_ids"/>
  57. <result property="businessId" column="business_id"/>
  58. <result property="projectId" column="project_id"/>
  59. <result property="goodsId" column="goods_id"/>
  60. </resultMap>
  61. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserListVo" id="ClassGradeUserListVo">
  62. <result property="gradeId" column="grade_id"/>
  63. <result property="classStatus" column="class_status"/>
  64. <result property="officialName" column="official_name"/>
  65. <result property="className" column="class_name"/>
  66. <result property="studentUpper" column="student_upper"/>
  67. <result property="learningTimeStart" column="learning_time_start"/>
  68. <result property="learningStatus" column="learning_status"/>
  69. <result property="status" column="status"/>
  70. <result property="classStartTime" column="class_start_time"/>
  71. <result property="classEndTime" column="class_end_time"/>
  72. <result property="examineId" column="examine_id"/>
  73. <result property="areasId" column="areas_id"/>
  74. <result property="sysUserId" column="sys_user_id"/>
  75. <result property="interfacePushId" column="interface_push_id"/>
  76. <result property="remark" column="remark"/>
  77. <result property="interfaceAccountId" column="interface_account_id"/>
  78. <result property="interfacePeriodId" column="interface_period_id"/>
  79. <result property="interfaceAccountName" column="interface_account_name"/>
  80. <result property="interfacePeriodName" column="interface_period_name"/>
  81. <result property="interfacePushName" column="interface_push_name"/>
  82. <result property="studentNum" column="student_num"/>
  83. </resultMap>
  84. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  85. <result property="goodsId" column="goods_id"/>
  86. <result property="year" column="year"/>
  87. <result property="supplyId" column="supply_id"/>
  88. <result property="goodsType" column="goods_type"/>
  89. <result property="educationTypeId" column="education_type_id"/>
  90. <result property="businessId" column="business_id"/>
  91. <result property="schoolId" column="school_id"/>
  92. <result property="majorId" column="major_id"/>
  93. <result property="goodsName" column="goods_name"/>
  94. <result property="standPrice" column="stand_price"/>
  95. <result property="lowestPrice" column="lowest_price"/>
  96. <result property="createTime" column="create_time"/>
  97. <result property="updateTime" column="update_time"/>
  98. <result property="status" column="status"/>
  99. <result property="validityStartTime" column="validity_start_time"/>
  100. <result property="validityEndTime" column="validity_end_time"/>
  101. <result property="studyStartTime" column="study_start_time"/>
  102. <result property="studyEndTime" column="study_end_time"/>
  103. <result property="certificateIds" column="certificate_ids"/>
  104. <result property="introduce" column="introduce"/>
  105. <result property="suitableObject" column="suitable_object"/>
  106. <result property="buyNote" column="buy_note"/>
  107. <result property="pcDetailHtml" column="pc_detail_html"/>
  108. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  109. <result property="goodsStatus" column="goods_status"/>
  110. <result property="coverUrl" column="cover_url"/>
  111. <result property="classHours" column="class_hours"/>
  112. <result property="standPriceJson" column="stand_price_json"/>
  113. <result property="code" column="code"/>
  114. <result property="projectId" column="project_id"/>
  115. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  116. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  117. <result property="goodsPlayConfig" column="goods_play_config"/>
  118. <result property="goodsExamConfig" column="goods_exam_config"/>
  119. <result property="supplyName" column="supply_name"/>
  120. <result property="educationName" column="education_name"/>
  121. <result property="projectName" column="project_name"/>
  122. <result property="businessName" column="business_name"/>
  123. <result property="schoolName" column="school_name"/>
  124. <result property="categoryName" column="category_name"/>
  125. <result property="handoutsId" column="handouts_id"/>
  126. <result property="templateType" column="template_type"/>
  127. </resultMap>
  128. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeStudentVo" id="ClassGradeStudentVo">
  129. <result property="userId" column="user_id"/>
  130. <result property="id" column="id"/>
  131. <result property="gradeId" column="grade_id"/>
  132. <result property="studentCode" column="user_account"/>
  133. <result property="realname" column="realname"/>
  134. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  135. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  136. <result property="userStatus" column="user_status"/>
  137. <result property="status" column="status"/>
  138. <result property="classHours" column="class_hours"/>
  139. <result property="periodStatus" column="period_status"/>
  140. <result property="finishStatus" column="finish_status"/>
  141. <result property="officialStatus" column="official_status"/>
  142. <result property="learnStatus" column="learn_status"/>
  143. <result property="secAllNum" column="sec_all_num"/>
  144. <result property="examNum" column="exam_num"/>
  145. <result property="recordNum" column="record_num"/>
  146. <result property="classStartTime" column="class_start_time"/>
  147. <result property="classEndTime" column="class_end_time"/>
  148. <result property="studyStartTime" column="study_start_time"/>
  149. <result property="studyEndTime" column="study_end_time"/>
  150. <result property="studyCount" column="study_count"/>
  151. <result property="orderGoodsId" column="order_goods_id"/>
  152. <result property="officialStatusNum" column="official_status_num"/>
  153. <result property="officialStatusTime" column="official_status_time"/>
  154. <result property="interfacePushId" column="interface_push_id"/>
  155. <result property="periodPlush" column="period_plush"/>
  156. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  157. <result property="serviceStartTime" column="service_start_time"/>
  158. <result property="serviceEndTime" column="service_end_time"/>
  159. <result property="goodsName" column="goods_name"/>
  160. <result property="orderSn" column="order_sn"/>
  161. <result property="categoryName" column="category_name"/>
  162. <result property="reason" column="reason"/>
  163. <result property="projectName" column="project_name"/>
  164. <result property="businessName" column="business_name"/>
  165. <result property="userBindWx" column="user_bind_wx"/>
  166. <result property="userFollowWx" column="user_follow_wx"/>
  167. <result property="useStudyCount" column="use_study_count"/>
  168. <result property="examNumber" column="exam_number"/>
  169. <result property="doNumber" column="do_number"/>
  170. <result property="expendNumber" column="expend_number"/>
  171. <result property="expendBefore" column="expend_before"/>
  172. </resultMap>
  173. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeGoodsVo" id="ClassGradeGoodsVoResult">
  174. <result property="goodsId" column="goods_id"/>
  175. <collection property="gradeList" column="goods_id" select="findGradeList"/>
  176. </resultMap>
  177. <resultMap type="com.zhongzheng.modules.grade.vo.ClassNpUserInfoVo" id="ClassNpUserInfoVoResult">
  178. <result property="gradeId" column="grade_id"/>
  179. <result property="tenantId" column="tenantId"/>
  180. <result property="classNo" column="classNo"/>
  181. <result property="platformName" column="platformName"/>
  182. <result property="categoryName" column="categoryName"/>
  183. <result property="name" column="name"/>
  184. <result property="idNum" column="idNum" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  185. <result property="mobile" column="mobile" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  186. <result property="companyName" column="companyName"/>
  187. <result property="orderTimeLong" column="orderTimeLong"/>
  188. <result property="createTimeLong" column="createTimeLong"/>
  189. <result property="doTimeLong" column="doTimeLong"/>
  190. <result property="reportStatu" column="reportStatu"/>
  191. <result property="studyQueueStatus" column="studyQueueStatus"/>
  192. <result property="applyTimeLong" column="applyTimeLong"/>
  193. <result property="userId" column="user_id"/>
  194. <result property="subjectIds" column="subject_ids"/>
  195. </resultMap>
  196. <select id="findGradeList" resultMap="ClassGradeVoResult">
  197. SELECT
  198. g.*,
  199. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  200. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  201. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  202. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  203. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  204. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  205. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  206. (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,
  207. (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,
  208. (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
  209. FROM
  210. class_grade_goods cgg LEFT JOIN
  211. class_grade g on cgg.grade_id = g.grade_id
  212. where cgg.goods_id = #{goods_id} and g.`status` = 1
  213. </select>
  214. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  215. SELECT
  216. g.*,
  217. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  218. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  219. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  220. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  221. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  222. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  223. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  224. (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,
  225. (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,
  226. (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,
  227. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,d.subject_ids)) subject_names
  228. FROM
  229. class_grade g
  230. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  231. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  232. LEFT JOIN course_business cb ON d.business_id = cb.id
  233. <if test="userId != null and userId !=0 ">
  234. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  235. </if>
  236. where g.status !=-1
  237. <if test="status != null and status.size()!=0 ">
  238. AND g.status in
  239. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  240. #{item}
  241. </foreach>
  242. </if>
  243. <if test="userId != null and userId !=0 ">
  244. AND gu.user_id = #{userId}
  245. </if>
  246. <if test="gradeId != null and gradeId !=0 ">
  247. AND g.grade_id = #{gradeId}
  248. </if>
  249. <if test="searchKey != null and searchKey !='' ">
  250. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  251. SELECT
  252. COUNT(*)
  253. FROM
  254. class_grade_user cgu
  255. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  256. WHERE
  257. g.grade_id = cgu.grade_id
  258. AND u.realname like concat('%', #{searchKey}, '%')
  259. ) >0 or (
  260. SELECT
  261. COUNT(*)
  262. FROM
  263. class_grade_goods s
  264. LEFT JOIN goods d ON s.goods_id = d.goods_id
  265. WHERE
  266. g.grade_id = s.grade_id
  267. AND d.goods_name like concat('%', #{searchKey}, '%')
  268. ) >0)
  269. </if>
  270. <if test="classStatus != null ">
  271. AND g.class_status = #{classStatus}
  272. </if>
  273. <if test="className != null and className !='' ">
  274. AND g.class_name like concat('%', #{className}, '%')
  275. </if>
  276. <if test="atFull != null and atFull !='' ">
  277. 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
  278. </if>
  279. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  280. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  281. </if>
  282. <if test="pastDue != null or pastDue != null ">
  283. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  284. </if>
  285. <if test="educationTypeId != null and educationTypeId !='' ">
  286. AND (
  287. SELECT
  288. COUNT(*)
  289. FROM
  290. class_grade_goods s
  291. LEFT JOIN goods d ON s.goods_id = d.goods_id
  292. WHERE
  293. 1 = 1
  294. AND g.grade_id = s.grade_id
  295. AND d.education_type_id =#{educationTypeId}
  296. ) >0
  297. </if>
  298. <if test="businessId != null and businessId !='' ">
  299. AND cb.id = #{businessId}
  300. </if>
  301. <if test="schoolId != null and schoolId !='' ">
  302. AND (
  303. SELECT
  304. COUNT(*)
  305. FROM
  306. class_grade_goods s
  307. LEFT JOIN goods d ON s.goods_id = d.goods_id
  308. WHERE
  309. 1 = 1
  310. AND g.grade_id = s.grade_id
  311. AND d.school_id =#{schoolId}
  312. ) >0
  313. </if>
  314. <if test="majorId != null and majorId !='' ">
  315. AND (
  316. SELECT
  317. COUNT(*)
  318. FROM
  319. class_grade_goods s
  320. LEFT JOIN goods d ON s.goods_id = d.goods_id
  321. WHERE
  322. 1 = 1
  323. AND g.grade_id = s.grade_id
  324. AND d.major_id =#{majorId}
  325. ) >0
  326. </if>
  327. <if test="goodsId != null and goodsId !='' ">
  328. AND (
  329. SELECT
  330. COUNT(*)
  331. FROM
  332. class_grade_goods s
  333. WHERE
  334. 1 = 1
  335. AND g.grade_id = s.grade_id
  336. AND s.goods_id =#{goodsId}
  337. ) >0
  338. </if>
  339. <if test="hasInterface != null and hasInterface == 0">
  340. AND g.interface_account_id is null AND g.no_interface_account_id is null
  341. </if>
  342. <if test="hasInterface != null and hasInterface == 1">
  343. AND g.interface_account_id is not null
  344. </if>
  345. <if test="hasInterface != null and hasInterface == 2">
  346. AND g.no_interface_account_id is not null
  347. </if>
  348. <!-- 数据范围过滤 -->
  349. ${params.dataScope}
  350. order by g.create_time desc
  351. </select>
  352. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  353. SELECT
  354. g.*,
  355. ps.supply_name,
  356. cet.education_name,
  357. cpt.project_name,
  358. cb.business_name,
  359. s.school_name,
  360. m.category_name,
  361. ot.type AS template_type
  362. FROM
  363. goods g
  364. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  365. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  366. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  367. LEFT JOIN course_business cb ON g.business_id = cb.id
  368. LEFT JOIN school s ON s.id = g.school_id
  369. LEFT JOIN major m ON g.major_id = m.id
  370. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  371. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  372. WHERE
  373. 1 = 1
  374. AND o.grade_id =#{gradeId}
  375. </select>
  376. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  377. SELECT
  378. cgu.id,
  379. cgu.official_status_time,
  380. cgu.official_status_num,
  381. u.user_account,
  382. u.user_id,
  383. cgu.`status`,
  384. u.realname,
  385. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  386. u.id_card,
  387. cgu.grade_id,
  388. u.telphone,
  389. (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,
  390. (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,
  391. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  392. (SELECT g.class_hours FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as class_hours,
  393. cgu.period_status,
  394. cgu.finish_status,
  395. cgu.period_plush,
  396. (SELECT g.study_start_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_start_time,
  397. (SELECT g.study_end_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_end_time,
  398. cg.class_start_time,
  399. cg.class_end_time,
  400. cg.interface_push_id,
  401. cgu.official_status,
  402. cgu.learn_status,
  403. (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type in (1,3) ) as exam_num,
  404. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id = ubr.goods_id where ubr.`status`=1 and ubr.type in (1,3) and ubr.user_id = u.user_id and ubr.grade_id = cgu.grade_id and ubr.report_status=1 and ubr.current_status = 1) as record_num,
  405. (og.study_count) as study_count,
  406. og.order_goods_id,
  407. og.rebuy_order_goods_id,
  408. og.service_start_time,
  409. og.service_end_time,
  410. g.goods_name,
  411. og.order_sn,
  412. m.category_name,
  413. g.major_id,
  414. u.province,
  415. cgu.reason,
  416. cb.business_name,
  417. cpt.project_name,
  418. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,
  419. (case WHEN uwf.gzh_open_id is null then 0 ELSE 1 end) as user_follow_wx,
  420. (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,
  421. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  422. ueg.exam_number,
  423. ueg.do_number,
  424. ueg.expend_number,
  425. ueg.expend_before
  426. FROM
  427. class_grade_user cgu
  428. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  429. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  430. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  431. LEFT JOIN goods g on og.goods_id = g.goods_id
  432. LEFT JOIN major m ON g.major_id = m.id
  433. LEFT JOIN course_business cb ON g.business_id = cb.id
  434. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  435. LEFT JOIN user_wx_follow uwf ON u.union_id = uwf.union_id
  436. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  437. where 1=1
  438. <if test="gradeId != null and gradeId !='' ">
  439. and cgu.grade_id = #{gradeId}
  440. </if>
  441. <if test="choice != null and choice == 1 ">
  442. and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and (SELECT cgg.goods_id FROM class_grade_goods cgg where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null) and cge.`status`=1 and cgur.`status` =1)= 0 and cgu.period_status=0
  443. 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
  444. </if>
  445. <if test="choice != null and choice == 2 ">
  446. and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and (SELECT cgg.goods_id FROM class_grade_goods cgg
  447. where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) AND (unix_timestamp(now()) &lt; cge.class_end_time or cge.class_start_time is null)
  448. and cge.`status`=1 and cgur.`status` =1)> 0
  449. 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
  450. </if>
  451. <if test="studyCountMore != null and studyCountMore == 2 ">
  452. AND og.study_count > 0 AND cgu.change_grade = 0
  453. </if>
  454. <if test="studyCountMore != null and studyCountMore == 1 ">
  455. AND og.study_count > 0 AND cgu.change_grade = 1
  456. </if>
  457. <if test="studyCountMore != null and studyCountMore == 0 ">
  458. AND og.study_count = 0
  459. </if>
  460. <if test="realname != null and realname != ''">
  461. AND u.realname like concat('%', #{realname}, '%')
  462. </if>
  463. <if test="telphone != null and telphone != ''">
  464. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  465. </if>
  466. <if test="companyName != null and companyName != ''">
  467. AND u.company_name like concat('%', #{companyName}, '%')
  468. </if>
  469. <if test="idCard != null and idCard != ''">
  470. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  471. </if>
  472. <if test="idCards != null and idCards.size() != 0">
  473. AND u.id_card IN
  474. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  475. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  476. </foreach>
  477. </if>
  478. <if test="orderSn != null and orderSn != ''">
  479. AND og.order_sn = #{orderSn}
  480. </if>
  481. <if test="goodsName != null and goodsName != ''">
  482. AND g.goods_name like concat('%', #{goodsName}, '%')
  483. </if>
  484. <if test="searchStartTime != null and searchStartTime != ''">
  485. AND cgu.create_time &gt; #{searchStartTime}
  486. </if>
  487. <if test="searchEndTime != null and searchEndTime != ''">
  488. AND cgu.create_time &lt; #{searchEndTime}
  489. </if>
  490. <if test="finishStatus != null">
  491. AND cgu.finish_status = #{finishStatus}
  492. </if>
  493. <if test="learnStatus != null">
  494. AND cgu.learn_status = #{learnStatus}
  495. </if>
  496. <if test="projectId != null and projectId != ''">
  497. AND g.project_id = #{projectId}
  498. </if>
  499. <if test="businessId != null and businessId != ''">
  500. AND g.business_id = #{businessId}
  501. </if>
  502. <if test="educationTypeId != null and educationTypeId != ''">
  503. AND g.education_type_id = #{educationTypeId}
  504. </if>
  505. <if test="majorId != null and majorId != ''">
  506. AND m.id = #{majorId}
  507. </if>
  508. <if test="hasInterface != null and hasInterface == 0">
  509. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  510. </if>
  511. <if test="hasInterface != null and hasInterface == 1">
  512. AND cg.interface_account_id is not null
  513. </if>
  514. <if test="hasInterface != null and hasInterface == 2">
  515. AND cg.no_interface_account_id is not null
  516. </if>
  517. <if test="hasBindWx != null and hasBindWx == 1 ">
  518. AND u.union_id is not null
  519. </if>
  520. <if test="hasBindWx != null and hasBindWx == 0 ">
  521. AND u.union_id is null
  522. </if>
  523. <if test="hasFollowWx != null and hasFollowWx == 1 ">
  524. AND uwf.gzh_open_id is not null
  525. </if>
  526. <if test="hasFollowWx != null and hasFollowWx == 0 ">
  527. AND uwf.gzh_open_id is null
  528. </if>
  529. order by user_info_status desc ,user_status desc ,cgu.id desc
  530. </select>
  531. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  532. SELECT
  533. g.*,
  534. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  535. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  536. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  537. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  538. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  539. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  540. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  541. FROM
  542. class_grade g
  543. where g.status !=-1
  544. <if test="status != null and status.size()!=0 ">
  545. AND g.status in
  546. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  547. #{item}
  548. </foreach>
  549. </if>
  550. <if test="gradeId != null and gradeId !=0 ">
  551. AND g.grade_id = #{gradeId}
  552. </if>
  553. <if test="className != null and className !='' ">
  554. AND g.class_name like concat('%', #{className}, '%')
  555. </if>
  556. <if test="classStartTime != null and classStartTime !=0 ">
  557. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  558. </if>
  559. <if test="educationTypeId != null and educationTypeId !='' ">
  560. AND (
  561. SELECT
  562. COUNT(*)
  563. FROM
  564. class_grade_goods s
  565. LEFT JOIN goods d ON s.goods_id = d.goods_id
  566. WHERE
  567. 1 = 1
  568. AND g.grade_id = s.grade_id
  569. AND d.education_type_id =#{educationTypeId}
  570. ) >0
  571. </if>
  572. <if test="businessId != null and businessId !='' ">
  573. AND (
  574. SELECT
  575. COUNT(*)
  576. FROM
  577. class_grade_goods s
  578. LEFT JOIN goods d ON s.goods_id = d.goods_id
  579. WHERE
  580. 1 = 1
  581. AND g.grade_id = s.grade_id
  582. AND d.business_id =#{businessId}
  583. ) >0
  584. </if>
  585. <if test="schoolId != null and schoolId !='' ">
  586. AND (
  587. SELECT
  588. COUNT(*)
  589. FROM
  590. class_grade_goods s
  591. LEFT JOIN goods d ON s.goods_id = d.goods_id
  592. WHERE
  593. 1 = 1
  594. AND g.grade_id = s.grade_id
  595. AND d.school_id =#{schoolId}
  596. ) >0
  597. </if>
  598. <if test="majorId != null and majorId !='' ">
  599. AND (
  600. SELECT
  601. COUNT(*)
  602. FROM
  603. class_grade_goods s
  604. LEFT JOIN goods d ON s.goods_id = d.goods_id
  605. WHERE
  606. 1 = 1
  607. AND g.grade_id = s.grade_id
  608. AND d.major_id =#{majorId}
  609. ) >0
  610. </if>
  611. <if test="goodsId != null and goodsId !='' ">
  612. AND (
  613. SELECT
  614. COUNT(*)
  615. FROM
  616. class_grade_goods s
  617. WHERE
  618. 1 = 1
  619. AND g.grade_id = s.grade_id
  620. AND s.goods_id =#{goodsId}
  621. ) >0
  622. </if>
  623. order by g.update_time desc
  624. </select>
  625. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  626. SELECT
  627. u.user_account,
  628. u.user_id,
  629. u.realname,
  630. u.id_card
  631. FROM
  632. `user` u
  633. WHERE
  634. 1 = 1
  635. and u.realname is NOT NULL
  636. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  637. <if test="status != null and status.size()!=0 ">
  638. AND u.status in
  639. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  640. #{item}
  641. </foreach>
  642. </if>
  643. </select>
  644. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  645. SELECT
  646. DISTINCT u.*
  647. FROM
  648. `user` u
  649. LEFT JOIN `order` o ON u.user_id = o.user_id
  650. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  651. LEFT JOIN goods g on g.goods_id=og.goods_id
  652. WHERE
  653. 1 = 1
  654. AND og.status=1
  655. and u.status=1
  656. and og.refund_status in(0,3)
  657. and og.pay_status in (2,3,4)
  658. and g.business_id =#{businessId}
  659. </select>
  660. <select id="querClassSMS" parameterType="map" resultType="Long">
  661. SELECT
  662. COUNT(1)
  663. FROM
  664. class_grade_goods cgg
  665. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  666. where 1=1
  667. and cgg.grade_id=#{gradeId}
  668. and g.business_id=#{businessId}
  669. </select>
  670. <select id="queryUser" parameterType="Long" resultType="Long">
  671. SELECT
  672. user_id
  673. FROM
  674. class_grade_user
  675. WHERE
  676. grade_id = #{gradeId}
  677. and `status` = 1
  678. </select>
  679. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  680. SELECT
  681. cg.grade_id,cg.class_status
  682. FROM
  683. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  684. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  685. WHERE
  686. 1 = 1
  687. and cg.`status` != -1
  688. <if test="businessId != null">
  689. AND g.business_id = #{businessId}
  690. </if>
  691. <if test="startTime != null">
  692. AND cg.create_time >= #{startTime}
  693. </if>
  694. <if test="endTime != null">
  695. AND #{endTime} >= cg.create_time
  696. </if>
  697. </select>
  698. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  699. SELECT
  700. count(cgu.id)
  701. FROM
  702. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  703. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  704. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  705. WHERE
  706. cgu.`status` = 1
  707. AND (cg.interface_account_id is not null or cg.no_interface_account_id is not null)
  708. <if test="learnStatus != null">
  709. AND cgu.learn_status = #{learnStatus}
  710. </if>
  711. <if test="finishStatus != null">
  712. AND cgu.finish_status = #{finishStatus}
  713. </if>
  714. <if test="projectId != null">
  715. AND g.project_id = #{projectId}
  716. </if>
  717. <if test="startTime != null">
  718. AND cgu.create_time >= #{startTime}
  719. </if>
  720. <if test="endTime != null">
  721. AND #{endTime} >= cgu.create_time
  722. </if>
  723. </select>
  724. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  725. SELECT
  726. count(cg.grade_id)
  727. FROM
  728. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  729. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  730. WHERE
  731. cg.status !=-1
  732. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  733. AND cg.interface_account_id > 0
  734. </if>
  735. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  736. AND cg.interface_account_id is NULL
  737. </if>
  738. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  739. AND cg.no_interface_account_id > 0
  740. </if>
  741. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  742. AND cg.no_interface_account_id is NULL
  743. </if>
  744. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  745. AND cg.interface_period_id > 0
  746. </if>
  747. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  748. AND cg.interface_period_id is NULL
  749. </if>
  750. <if test="interfacePushId != null and interfacePushId== 1">
  751. AND cg.interface_push_id > 0
  752. </if>
  753. <if test="interfacePushId != null and interfacePushId== 0">
  754. AND cg.interface_push_id is NULL
  755. </if>
  756. <if test="businessId != null">
  757. AND g.business_id = #{businessId}
  758. </if>
  759. <if test="startTime != null">
  760. AND cg.create_time >= #{startTime}
  761. </if>
  762. <if test="endTime != null">
  763. AND #{endTime} >= cg.create_time
  764. </if>
  765. </select>
  766. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  767. SELECT
  768. count(cgu.id)
  769. FROM
  770. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  771. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  772. WHERE
  773. 1 = 1
  774. <if test="periodStatus != null">
  775. AND cgu.period_status = #{periodStatus}
  776. </if>
  777. <if test="businessId != null">
  778. AND g.business_id = #{businessId}
  779. </if>
  780. <if test="startTime != null">
  781. AND cgu.period_ing_time >= #{startTime}
  782. </if>
  783. <if test="endTime != null">
  784. AND #{endTime} >= cgu.period_ing_time
  785. </if>
  786. <if test="waitStartTime != null">
  787. AND cgu.period_wait_time >= #{waitStartTime}
  788. </if>
  789. <if test="waitEndTime != null">
  790. AND #{waitEndTime} >= cgu.period_wait_time
  791. </if>
  792. </select>
  793. <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  794. SELECT
  795. count(cgu.id)
  796. FROM
  797. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  798. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  799. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  800. WHERE
  801. 1 = 1
  802. <if test="periodStatus != null">
  803. AND cgu.period_status = 1
  804. </if>
  805. <if test="interfacePushId != null">
  806. AND cg.interface_push_id > 0
  807. </if>
  808. <if test="officialStatus != null">
  809. AND cgu.official_status = 1
  810. </if>
  811. <if test="periodPlush != null">
  812. AND cgu.period_plush = 1
  813. </if>
  814. <if test="businessId != null">
  815. AND g.business_id = #{businessId}
  816. </if>
  817. </select>
  818. <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">
  819. SELECT
  820. g.goods_id
  821. FROM
  822. goods g
  823. WHERE
  824. 1=1
  825. <if test="goodsIds != null and goodsIds.size()!=0 ">
  826. AND g.goods_id in
  827. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  828. #{item}
  829. </foreach>
  830. </if>
  831. </select>
  832. <select id="listGradeSubjects" resultMap="ClassGradeVoResult">
  833. SELECT
  834. cg.*,
  835. g.subject_ids,
  836. g.business_id,
  837. g.project_id
  838. FROM
  839. class_grade cg
  840. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  841. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  842. </select>
  843. <select id="queryCountList" parameterType="java.lang.Long" resultMap="ClassGradeVoResult">
  844. SELECT
  845. cg.*
  846. FROM
  847. class_grade cg
  848. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  849. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  850. WHERE
  851. cg.`status` != -1
  852. and cg.`status` in (0,1)
  853. and g.business_id = #{businessId}
  854. </select>
  855. <select id="queryOfficialGradeCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="Integer">
  856. SELECT
  857. ((
  858. SELECT
  859. count(*)
  860. FROM
  861. class_grade_user_temp cgu
  862. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  863. WHERE
  864. cg.official_name = #{officialName}
  865. AND cgu.`status` = 1
  866. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = 1) > 0
  867. ) + (
  868. SELECT
  869. count(*)
  870. FROM
  871. class_grade_user cgu
  872. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  873. WHERE
  874. cg.official_name = #{officialName}
  875. AND cgu.`status` = 1
  876. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = 1) > 0
  877. ))
  878. </select>
  879. <select id="queryGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  880. SELECT
  881. cg.*,cgg.goods_id
  882. FROM
  883. class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  884. cg.class_end_time > #{startTime}
  885. AND #{endTime} >= cg.class_end_time
  886. </select>
  887. <select id="getClassUserNumByTenant" parameterType="java.lang.Long" resultType="java.lang.Long">
  888. SELECT
  889. sum( a.num )
  890. FROM
  891. ( 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
  892. </select>
  893. <select id="getGradeDetailByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassNpUserInfoBo" resultMap="ClassNpUserInfoVoResult" >
  894. SELECT
  895. CONCAT('',cg.tenant_id) as tenantId,
  896. cg.official_name as classNo,
  897. cb.alias_name as platformName,
  898. cg.class_name as categoryName,
  899. u.realname as `name`,
  900. u.id_card as idNum,
  901. u.telphone as mobile,
  902. u.company_name as companyName,
  903. (SELECT og.create_time FROM order_goods og LEFT JOIN `order` o ON og.order_sn = o.order_sn WHERE og.goods_id = g.goods_id AND o.user_id = u.user_id) AS orderTimeLong,
  904. cg.class_start_time as createTimeLong,
  905. cgu.official_status_time as doTimeLong,
  906. cgu.official_status as reportStatu,
  907. cgu.period_plush as studyQueueStatus,
  908. cgu.period_wait_time as applyTimeLong,
  909. u.user_id,
  910. cg.grade_id,
  911. g.subject_ids
  912. FROM class_grade cg
  913. INNER JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
  914. <if test="tenantId != null">
  915. AND cgu.tenant_id = #{tenantId}
  916. </if>
  917. INNER JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  918. <if test="tenantId != null">
  919. AND cgg.tenant_id = #{tenantId}
  920. </if>
  921. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  922. <if test="tenantId != null">
  923. AND u.tenant_id = #{tenantId}
  924. </if>
  925. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  926. <if test="tenantId != null">
  927. AND g.tenant_id = #{tenantId}
  928. </if>
  929. LEFT JOIN course_business cb ON g.business_id = cb.id
  930. <if test="tenantId != null">
  931. AND cb.tenant_id = #{tenantId}
  932. </if>
  933. WHERE 1 = 1
  934. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  935. <if test="officialName != null and officialName !=''">
  936. AND cg.official_name = #{officialName}
  937. </if>
  938. <if test="tenantId != null">
  939. AND cg.tenant_id = #{tenantId}
  940. </if>
  941. <if test="name != null and name !=''">
  942. AND u.realname like concat('%', #{name}, '%')
  943. </if>
  944. <if test="idNum != null and idNum !=''">
  945. AND u.id_card like concat('%', #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  946. </if>
  947. <if test="mobile != null and mobile !=''">
  948. AND u.telphone like concat('%', #{mobile,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  949. </if>
  950. </select>
  951. <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  952. SELECT
  953. cg.*
  954. FROM
  955. class_grade cg
  956. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  957. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  958. LEFT JOIN course_business cb ON g.business_id = cb.id
  959. WHERE
  960. 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
  961. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  962. <if test="subIds != null and subIds.size()!=0 ">
  963. AND (
  964. <foreach collection="subIds" item="id" index="index">
  965. <if test="index != subIds.size()-1">
  966. FIND_IN_SET(#{id},g.subject_ids) OR
  967. </if>
  968. <if test="index == subIds.size()-1">
  969. FIND_IN_SET(#{id},g.subject_ids)
  970. </if>
  971. </foreach>
  972. )
  973. </if>
  974. </select>
  975. <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">
  976. SELECT
  977. g.goods_id
  978. FROM
  979. goods g
  980. LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
  981. WHERE
  982. cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId}
  983. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
  984. <if test="subIds != null and subIds.size()!=0 ">
  985. AND (
  986. <foreach collection="subIds" item="id" index="index">
  987. <if test="index != subIds.size()-1">
  988. FIND_IN_SET(#{id},g.subject_ids) OR
  989. </if>
  990. <if test="index == subIds.size()-1">
  991. FIND_IN_SET(#{id},g.subject_ids)
  992. </if>
  993. </foreach>
  994. )
  995. </if>
  996. </select>
  997. <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  998. SELECT
  999. *
  1000. FROM
  1001. class_grade
  1002. where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}
  1003. </select>
  1004. <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1005. SELECT
  1006. cg.*
  1007. FROM
  1008. class_grade cg
  1009. where cg.official_name = #{registerCode}
  1010. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1011. </select>
  1012. <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1013. update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},
  1014. class_start_time = #{classStartTime},class_end_time = #{classEndTime},learning_status = #{learningStatus},learning_time_start = #{learningTimeStart}
  1015. where 1 = 1
  1016. <if test="gradeIds != null and gradeIds.size()!=0 ">
  1017. AND grade_id in
  1018. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1019. #{item}
  1020. </foreach>
  1021. </if>
  1022. </update>
  1023. <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >
  1024. update class_grade set register_code = official_name where 1 = 1
  1025. <if test="ids != null and ids.size()!=0 ">
  1026. AND grade_id in
  1027. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1028. #{item}
  1029. </foreach>
  1030. </if>
  1031. </update>
  1032. <update id="UpGradeInterfaceByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1033. update class_grade set interface_push_id = #{interfacePushId} where grade_id = #{gradeId}
  1034. </update>
  1035. </mapper>