ClassGradeMapper.xml 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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="finishStatus" column="finishStatus"/>
  192. <result property="studyQueueStatus" column="studyQueueStatus"/>
  193. <result property="finishStatus" column="finishStatus"/>
  194. <result property="applyTimeLong" column="applyTimeLong"/>
  195. <result property="userId" column="user_id"/>
  196. <result property="subjectIds" column="subject_ids"/>
  197. </resultMap>
  198. <select id="findGradeList" resultMap="ClassGradeVoResult">
  199. SELECT
  200. g.*,
  201. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  202. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  203. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  204. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  205. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  206. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  207. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  208. (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,
  209. (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,
  210. (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
  211. FROM
  212. class_grade_goods cgg LEFT JOIN
  213. class_grade g on cgg.grade_id = g.grade_id
  214. where cgg.goods_id = #{goods_id} and g.`status` = 1
  215. </select>
  216. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  217. SELECT
  218. g.*,
  219. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  220. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  221. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  222. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  223. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  224. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  225. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  226. (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,
  227. (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,
  228. (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,
  229. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,d.subject_ids)) subject_names
  230. FROM
  231. class_grade g
  232. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  233. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  234. LEFT JOIN course_business cb ON d.business_id = cb.id
  235. <if test="userId != null and userId !=0 ">
  236. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  237. </if>
  238. where g.status !=-1
  239. <if test="status != null and status.size()!=0 ">
  240. AND g.status in
  241. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  242. #{item}
  243. </foreach>
  244. </if>
  245. <if test="userId != null and userId !=0 ">
  246. AND gu.user_id = #{userId}
  247. </if>
  248. <if test="gradeId != null and gradeId !=0 ">
  249. AND g.grade_id = #{gradeId}
  250. </if>
  251. <if test="searchKey != null and searchKey !='' ">
  252. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  253. SELECT
  254. COUNT(*)
  255. FROM
  256. class_grade_user cgu
  257. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  258. WHERE
  259. g.grade_id = cgu.grade_id
  260. AND u.realname like concat('%', #{searchKey}, '%')
  261. ) >0 or (
  262. SELECT
  263. COUNT(*)
  264. FROM
  265. class_grade_goods s
  266. LEFT JOIN goods d ON s.goods_id = d.goods_id
  267. WHERE
  268. g.grade_id = s.grade_id
  269. AND d.goods_name like concat('%', #{searchKey}, '%')
  270. ) >0)
  271. </if>
  272. <if test="classStatus != null ">
  273. AND g.class_status = #{classStatus}
  274. </if>
  275. <if test="className != null and className !='' ">
  276. AND g.class_name like concat('%', #{className}, '%')
  277. </if>
  278. <if test="atFull != null and atFull !='' ">
  279. 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
  280. </if>
  281. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  282. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  283. </if>
  284. <if test="pastDue != null or pastDue != null ">
  285. AND ((unix_timestamp(now())+10*24*3600) &lt; g.class_end_time or g.class_start_time is null)
  286. </if>
  287. <if test="educationTypeId != null and educationTypeId !='' ">
  288. AND (
  289. SELECT
  290. COUNT(*)
  291. FROM
  292. class_grade_goods s
  293. LEFT JOIN goods d ON s.goods_id = d.goods_id
  294. WHERE
  295. 1 = 1
  296. AND g.grade_id = s.grade_id
  297. AND d.education_type_id =#{educationTypeId}
  298. ) >0
  299. </if>
  300. <if test="businessId != null and businessId !='' ">
  301. AND cb.id = #{businessId}
  302. </if>
  303. <if test="schoolId != null and schoolId !='' ">
  304. AND (
  305. SELECT
  306. COUNT(*)
  307. FROM
  308. class_grade_goods s
  309. LEFT JOIN goods d ON s.goods_id = d.goods_id
  310. WHERE
  311. 1 = 1
  312. AND g.grade_id = s.grade_id
  313. AND d.school_id =#{schoolId}
  314. ) >0
  315. </if>
  316. <if test="majorId != null and majorId !='' ">
  317. AND (
  318. SELECT
  319. COUNT(*)
  320. FROM
  321. class_grade_goods s
  322. LEFT JOIN goods d ON s.goods_id = d.goods_id
  323. WHERE
  324. 1 = 1
  325. AND g.grade_id = s.grade_id
  326. AND d.major_id =#{majorId}
  327. ) >0
  328. </if>
  329. <if test="goodsId != null and goodsId !='' ">
  330. AND (
  331. SELECT
  332. COUNT(*)
  333. FROM
  334. class_grade_goods s
  335. WHERE
  336. 1 = 1
  337. AND g.grade_id = s.grade_id
  338. AND s.goods_id =#{goodsId}
  339. ) >0
  340. </if>
  341. <if test="hasInterface != null and hasInterface == 0">
  342. AND g.interface_account_id is null AND g.no_interface_account_id is null
  343. </if>
  344. <if test="hasInterface != null and hasInterface == 1">
  345. AND g.interface_account_id is not null
  346. </if>
  347. <if test="hasInterface != null and hasInterface == 2">
  348. AND g.no_interface_account_id is not null
  349. </if>
  350. <!-- 数据范围过滤 -->
  351. ${params.dataScope}
  352. order by g.create_time desc
  353. </select>
  354. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  355. SELECT
  356. g.*,
  357. ps.supply_name,
  358. cet.education_name,
  359. cpt.project_name,
  360. cb.business_name,
  361. s.school_name,
  362. m.category_name,
  363. ot.type AS template_type
  364. FROM
  365. goods g
  366. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  367. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  368. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  369. LEFT JOIN course_business cb ON g.business_id = cb.id
  370. LEFT JOIN school s ON s.id = g.school_id
  371. LEFT JOIN major m ON g.major_id = m.id
  372. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  373. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  374. WHERE
  375. 1 = 1
  376. AND o.grade_id =#{gradeId}
  377. </select>
  378. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  379. SELECT
  380. cgu.id,
  381. cgu.official_status_time,
  382. cgu.official_status_num,
  383. u.user_account,
  384. u.user_id,
  385. cgu.`status`,
  386. u.realname,
  387. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  388. u.id_card,
  389. cgu.grade_id,
  390. u.telphone,
  391. (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,
  392. (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,
  393. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  394. (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,
  395. cgu.period_status,
  396. cgu.finish_status,
  397. cgu.period_plush,
  398. (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,
  399. (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,
  400. cg.class_start_time,
  401. cg.class_end_time,
  402. cg.interface_push_id,
  403. cgu.official_status,
  404. cgu.learn_status,
  405. (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,
  406. (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,
  407. (og.study_count) as study_count,
  408. og.order_goods_id,
  409. og.rebuy_order_goods_id,
  410. og.service_start_time,
  411. og.service_end_time,
  412. g.goods_name,
  413. og.order_sn,
  414. m.category_name,
  415. g.major_id,
  416. u.province,
  417. cgu.reason,
  418. cb.business_name,
  419. cpt.project_name,
  420. (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,
  421. (case WHEN uwf.gzh_open_id is null then 0 ELSE 1 end) as user_follow_wx,
  422. (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,
  423. (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,
  424. ueg.exam_number,
  425. ueg.do_number,
  426. ueg.expend_number,
  427. ueg.expend_before
  428. FROM
  429. class_grade_user cgu
  430. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  431. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  432. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  433. LEFT JOIN goods g on og.goods_id = g.goods_id
  434. LEFT JOIN major m ON g.major_id = m.id
  435. LEFT JOIN course_business cb ON g.business_id = cb.id
  436. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  437. LEFT JOIN user_wx_follow uwf ON u.union_id = uwf.union_id
  438. LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
  439. where 1=1
  440. <if test="gradeId != null and gradeId !='' ">
  441. and cgu.grade_id = #{gradeId}
  442. </if>
  443. <if test="choice != null and choice == 1 ">
  444. 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
  445. 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
  446. </if>
  447. <if test="choice != null and choice == 2 ">
  448. 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
  449. 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)
  450. and cge.`status`=1 and cgur.`status` =1)> 0
  451. 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
  452. </if>
  453. <if test="studyCountMore != null and studyCountMore == 2 ">
  454. AND og.study_count > 0 AND cgu.change_grade = 0
  455. </if>
  456. <if test="studyCountMore != null and studyCountMore == 1 ">
  457. AND og.study_count > 0 AND cgu.change_grade = 1
  458. </if>
  459. <if test="studyCountMore != null and studyCountMore == 0 ">
  460. AND og.study_count = 0
  461. </if>
  462. <if test="realname != null and realname != ''">
  463. AND u.realname like concat('%', #{realname}, '%')
  464. </if>
  465. <if test="telphone != null and telphone != ''">
  466. AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
  467. </if>
  468. <if test="companyName != null and companyName != ''">
  469. AND u.company_name like concat('%', #{companyName}, '%')
  470. </if>
  471. <if test="idCard != null and idCard != ''">
  472. AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  473. </if>
  474. <if test="idCards != null and idCards.size() != 0">
  475. AND u.id_card IN
  476. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  477. #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  478. </foreach>
  479. </if>
  480. <if test="orderSn != null and orderSn != ''">
  481. AND og.order_sn = #{orderSn}
  482. </if>
  483. <if test="goodsName != null and goodsName != ''">
  484. AND g.goods_name like concat('%', #{goodsName}, '%')
  485. </if>
  486. <if test="searchStartTime != null and searchStartTime != ''">
  487. AND cgu.create_time &gt; #{searchStartTime}
  488. </if>
  489. <if test="searchEndTime != null and searchEndTime != ''">
  490. AND cgu.create_time &lt; #{searchEndTime}
  491. </if>
  492. <if test="finishStatus != null">
  493. AND cgu.finish_status = #{finishStatus}
  494. </if>
  495. <if test="learnStatus != null">
  496. AND cgu.learn_status = #{learnStatus}
  497. </if>
  498. <if test="projectId != null and projectId != ''">
  499. AND g.project_id = #{projectId}
  500. </if>
  501. <if test="businessId != null and businessId != ''">
  502. AND g.business_id = #{businessId}
  503. </if>
  504. <if test="educationTypeId != null and educationTypeId != ''">
  505. AND g.education_type_id = #{educationTypeId}
  506. </if>
  507. <if test="majorId != null and majorId != ''">
  508. AND m.id = #{majorId}
  509. </if>
  510. <if test="hasInterface != null and hasInterface == 0">
  511. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  512. </if>
  513. <if test="hasInterface != null and hasInterface == 1">
  514. AND cg.interface_account_id is not null
  515. </if>
  516. <if test="hasInterface != null and hasInterface == 2">
  517. AND cg.no_interface_account_id is not null
  518. </if>
  519. <if test="hasBindWx != null and hasBindWx == 1 ">
  520. AND u.union_id is not null
  521. </if>
  522. <if test="hasBindWx != null and hasBindWx == 0 ">
  523. AND u.union_id is null
  524. </if>
  525. <if test="hasFollowWx != null and hasFollowWx == 1 ">
  526. AND uwf.gzh_open_id is not null
  527. </if>
  528. <if test="hasFollowWx != null and hasFollowWx == 0 ">
  529. AND uwf.gzh_open_id is null
  530. </if>
  531. order by user_info_status desc ,user_status desc ,cgu.id desc
  532. </select>
  533. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  534. SELECT
  535. g.*,
  536. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  537. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  538. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  539. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  540. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  541. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  542. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  543. FROM
  544. class_grade g
  545. where g.status !=-1
  546. <if test="status != null and status.size()!=0 ">
  547. AND g.status in
  548. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  549. #{item}
  550. </foreach>
  551. </if>
  552. <if test="gradeId != null and gradeId !=0 ">
  553. AND g.grade_id = #{gradeId}
  554. </if>
  555. <if test="className != null and className !='' ">
  556. AND g.class_name like concat('%', #{className}, '%')
  557. </if>
  558. <if test="classStartTime != null and classStartTime !=0 ">
  559. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  560. </if>
  561. <if test="educationTypeId != null and educationTypeId !='' ">
  562. AND (
  563. SELECT
  564. COUNT(*)
  565. FROM
  566. class_grade_goods s
  567. LEFT JOIN goods d ON s.goods_id = d.goods_id
  568. WHERE
  569. 1 = 1
  570. AND g.grade_id = s.grade_id
  571. AND d.education_type_id =#{educationTypeId}
  572. ) >0
  573. </if>
  574. <if test="businessId != null and businessId !='' ">
  575. AND (
  576. SELECT
  577. COUNT(*)
  578. FROM
  579. class_grade_goods s
  580. LEFT JOIN goods d ON s.goods_id = d.goods_id
  581. WHERE
  582. 1 = 1
  583. AND g.grade_id = s.grade_id
  584. AND d.business_id =#{businessId}
  585. ) >0
  586. </if>
  587. <if test="schoolId != null and schoolId !='' ">
  588. AND (
  589. SELECT
  590. COUNT(*)
  591. FROM
  592. class_grade_goods s
  593. LEFT JOIN goods d ON s.goods_id = d.goods_id
  594. WHERE
  595. 1 = 1
  596. AND g.grade_id = s.grade_id
  597. AND d.school_id =#{schoolId}
  598. ) >0
  599. </if>
  600. <if test="majorId != null and majorId !='' ">
  601. AND (
  602. SELECT
  603. COUNT(*)
  604. FROM
  605. class_grade_goods s
  606. LEFT JOIN goods d ON s.goods_id = d.goods_id
  607. WHERE
  608. 1 = 1
  609. AND g.grade_id = s.grade_id
  610. AND d.major_id =#{majorId}
  611. ) >0
  612. </if>
  613. <if test="goodsId != null and goodsId !='' ">
  614. AND (
  615. SELECT
  616. COUNT(*)
  617. FROM
  618. class_grade_goods s
  619. WHERE
  620. 1 = 1
  621. AND g.grade_id = s.grade_id
  622. AND s.goods_id =#{goodsId}
  623. ) >0
  624. </if>
  625. order by g.update_time desc
  626. </select>
  627. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  628. SELECT
  629. u.user_account,
  630. u.user_id,
  631. u.realname,
  632. u.id_card
  633. FROM
  634. `user` u
  635. WHERE
  636. 1 = 1
  637. and u.realname is NOT NULL
  638. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  639. <if test="status != null and status.size()!=0 ">
  640. AND u.status in
  641. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  642. #{item}
  643. </foreach>
  644. </if>
  645. </select>
  646. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  647. SELECT
  648. DISTINCT u.*
  649. FROM
  650. `user` u
  651. LEFT JOIN `order` o ON u.user_id = o.user_id
  652. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  653. LEFT JOIN goods g on g.goods_id=og.goods_id
  654. WHERE
  655. 1 = 1
  656. AND og.status=1
  657. and u.status=1
  658. and og.refund_status in(0,3)
  659. and og.pay_status in (2,3,4)
  660. and g.business_id =#{businessId}
  661. </select>
  662. <select id="querClassSMS" parameterType="map" resultType="Long">
  663. SELECT
  664. COUNT(1)
  665. FROM
  666. class_grade_goods cgg
  667. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  668. where 1=1
  669. and cgg.grade_id=#{gradeId}
  670. and g.business_id=#{businessId}
  671. </select>
  672. <select id="queryUser" parameterType="Long" resultType="Long">
  673. SELECT
  674. user_id
  675. FROM
  676. class_grade_user
  677. WHERE
  678. grade_id = #{gradeId}
  679. and `status` = 1
  680. </select>
  681. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  682. SELECT
  683. cg.grade_id,cg.class_status
  684. FROM
  685. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  686. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  687. WHERE
  688. 1 = 1
  689. and cg.`status` != -1
  690. <if test="businessId != null">
  691. AND g.business_id = #{businessId}
  692. </if>
  693. <if test="startTime != null">
  694. AND cg.create_time >= #{startTime}
  695. </if>
  696. <if test="endTime != null">
  697. AND #{endTime} >= cg.create_time
  698. </if>
  699. </select>
  700. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  701. SELECT
  702. count(cgu.id)
  703. FROM
  704. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  705. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  706. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  707. WHERE
  708. cgu.`status` = 1
  709. AND (cg.interface_account_id is not null or cg.no_interface_account_id is not null)
  710. <if test="learnStatus != null">
  711. AND cgu.learn_status = #{learnStatus}
  712. </if>
  713. <if test="finishStatus != null">
  714. AND cgu.finish_status = #{finishStatus}
  715. </if>
  716. <if test="projectId != null">
  717. AND g.project_id = #{projectId}
  718. </if>
  719. <if test="startTime != null">
  720. AND cgu.create_time >= #{startTime}
  721. </if>
  722. <if test="endTime != null">
  723. AND #{endTime} >= cgu.create_time
  724. </if>
  725. </select>
  726. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  727. SELECT
  728. count(cg.grade_id)
  729. FROM
  730. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  731. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  732. WHERE
  733. cg.status !=-1
  734. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  735. AND cg.interface_account_id > 0
  736. </if>
  737. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  738. AND cg.interface_account_id is NULL
  739. </if>
  740. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  741. AND cg.no_interface_account_id > 0
  742. </if>
  743. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  744. AND cg.no_interface_account_id is NULL
  745. </if>
  746. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  747. AND cg.interface_period_id > 0
  748. </if>
  749. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  750. AND cg.interface_period_id is NULL
  751. </if>
  752. <if test="interfacePushId != null and interfacePushId== 1">
  753. AND cg.interface_push_id > 0
  754. </if>
  755. <if test="interfacePushId != null and interfacePushId== 0">
  756. AND cg.interface_push_id is NULL
  757. </if>
  758. <if test="businessId != null">
  759. AND g.business_id = #{businessId}
  760. </if>
  761. <if test="startTime != null">
  762. AND cg.create_time >= #{startTime}
  763. </if>
  764. <if test="endTime != null">
  765. AND #{endTime} >= cg.create_time
  766. </if>
  767. </select>
  768. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  769. SELECT
  770. count(cgu.id)
  771. FROM
  772. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  773. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  774. WHERE
  775. 1 = 1
  776. <if test="periodStatus != null">
  777. AND cgu.period_status = #{periodStatus}
  778. </if>
  779. <if test="businessId != null">
  780. AND g.business_id = #{businessId}
  781. </if>
  782. <if test="startTime != null">
  783. AND cgu.period_ing_time >= #{startTime}
  784. </if>
  785. <if test="endTime != null">
  786. AND #{endTime} >= cgu.period_ing_time
  787. </if>
  788. <if test="waitStartTime != null">
  789. AND cgu.period_wait_time >= #{waitStartTime}
  790. </if>
  791. <if test="waitEndTime != null">
  792. AND #{waitEndTime} >= cgu.period_wait_time
  793. </if>
  794. </select>
  795. <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  796. SELECT
  797. count(cgu.id)
  798. FROM
  799. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  800. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  801. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  802. WHERE
  803. 1 = 1
  804. <if test="periodStatus != null">
  805. AND cgu.period_status = 1
  806. </if>
  807. <if test="interfacePushId != null">
  808. AND cg.interface_push_id > 0
  809. </if>
  810. <if test="officialStatus != null">
  811. AND cgu.official_status = 1
  812. </if>
  813. <if test="periodPlush != null">
  814. AND cgu.period_plush = 1
  815. </if>
  816. <if test="businessId != null">
  817. AND g.business_id = #{businessId}
  818. </if>
  819. </select>
  820. <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">
  821. SELECT
  822. g.goods_id
  823. FROM
  824. goods g
  825. WHERE
  826. 1=1
  827. <if test="goodsIds != null and goodsIds.size()!=0 ">
  828. AND g.goods_id in
  829. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  830. #{item}
  831. </foreach>
  832. </if>
  833. </select>
  834. <select id="listGradeSubjects" resultMap="ClassGradeVoResult">
  835. SELECT
  836. cg.*,
  837. g.subject_ids,
  838. g.business_id,
  839. g.project_id
  840. FROM
  841. class_grade cg
  842. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  843. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  844. </select>
  845. <select id="queryCountList" parameterType="java.lang.Long" resultMap="ClassGradeVoResult">
  846. SELECT
  847. cg.*
  848. FROM
  849. class_grade cg
  850. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  851. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  852. WHERE
  853. cg.`status` != -1
  854. and cg.`status` in (0,1)
  855. and g.business_id = #{businessId}
  856. </select>
  857. <select id="queryOfficialGradeCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="Integer">
  858. SELECT
  859. ((
  860. SELECT
  861. count(*)
  862. FROM
  863. class_grade_user_temp cgu
  864. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  865. WHERE
  866. cg.official_name = #{officialName}
  867. AND cgu.`status` = 1
  868. <if test="classSign != null">
  869. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
  870. </if>
  871. ) + (
  872. SELECT
  873. count(*)
  874. FROM
  875. class_grade_user cgu
  876. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  877. WHERE
  878. cg.official_name = #{officialName}
  879. AND cgu.`status` = 1
  880. <if test="classSign != null">
  881. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
  882. </if>
  883. ))
  884. </select>
  885. <select id="queryGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  886. SELECT
  887. cg.*,cgg.goods_id
  888. FROM
  889. class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where
  890. cg.class_end_time > #{startTime}
  891. AND #{endTime} >= cg.class_end_time
  892. </select>
  893. <select id="getClassUserNumByTenant" parameterType="java.lang.Long" resultType="java.lang.Long">
  894. SELECT
  895. sum( a.num )
  896. FROM
  897. ( 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
  898. </select>
  899. <select id="getGradeDetailByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassNpUserInfoBo" resultMap="ClassNpUserInfoVoResult" >
  900. SELECT
  901. CONCAT('',cg.tenant_id) as tenantId,
  902. cg.official_name as classNo,
  903. cb.alias_name as platformName,
  904. cg.class_name as categoryName,
  905. u.realname as `name`,
  906. u.id_card as idNum,
  907. u.telphone as mobile,
  908. u.company_name as companyName,
  909. (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)
  910. AND og.refund_status !=2
  911. ORDER BY og.create_time DESC LIMIT 1) AS orderTimeLong,
  912. cg.class_start_time as createTimeLong,
  913. cgu.official_status_time as doTimeLong,
  914. cgu.official_status as reportStatu,
  915. cgu.finish_status as finishStatus,
  916. cgu.period_plush as studyQueueStatus,
  917. cgu.period_wait_time as applyTimeLong,
  918. cgu.finish_status as finishStatus,
  919. u.user_id,
  920. cg.grade_id,
  921. g.subject_ids
  922. FROM class_grade cg
  923. INNER JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
  924. <if test="tenantId != null">
  925. AND cgu.tenant_id = #{tenantId}
  926. </if>
  927. INNER JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  928. <if test="tenantId != null">
  929. AND cgg.tenant_id = #{tenantId}
  930. </if>
  931. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  932. <if test="tenantId != null">
  933. AND u.tenant_id = #{tenantId}
  934. </if>
  935. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  936. <if test="tenantId != null">
  937. AND g.tenant_id = #{tenantId}
  938. </if>
  939. LEFT JOIN course_business cb ON g.business_id = cb.id
  940. <if test="tenantId != null">
  941. AND cb.tenant_id = #{tenantId}
  942. </if>
  943. WHERE 1 = 1
  944. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  945. <if test="officialName != null and officialName !=''">
  946. AND cg.official_name = #{officialName}
  947. </if>
  948. <if test="tenantId != null">
  949. AND cg.tenant_id = #{tenantId}
  950. </if>
  951. <if test="name != null and name !=''">
  952. AND u.realname like concat('%', #{name}, '%')
  953. </if>
  954. <if test="idNum != null and idNum !=''">
  955. AND u.id_card like concat('%', #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  956. </if>
  957. <if test="mobile != null and mobile !=''">
  958. AND u.telphone like concat('%', #{mobile,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
  959. </if>
  960. </select>
  961. <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  962. SELECT
  963. cg.*
  964. FROM
  965. class_grade cg
  966. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  967. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  968. LEFT JOIN course_business cb ON g.business_id = cb.id
  969. WHERE
  970. 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
  971. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  972. <if test="subIds != null and subIds.size()!=0 ">
  973. AND (
  974. <foreach collection="subIds" item="id" index="index">
  975. <if test="index != subIds.size()-1">
  976. FIND_IN_SET(#{id},g.subject_ids) OR
  977. </if>
  978. <if test="index == subIds.size()-1">
  979. FIND_IN_SET(#{id},g.subject_ids)
  980. </if>
  981. </foreach>
  982. )
  983. </if>
  984. </select>
  985. <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">
  986. SELECT
  987. g.goods_id
  988. FROM
  989. goods g
  990. LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}
  991. LEFT JOIN course_project_type cpt ON cb.project_id = cpt.id AND cpt.tenant_id = #{tenantId}
  992. LEFT JOIN course_education_type cet ON cpt.education_id = cet.id AND cet.tenant_id = #{tenantId}
  993. WHERE
  994. cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId} AND g.goods_status = 1 AND cet.education_name = #{educationName}
  995. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
  996. <if test="subIds != null and subIds.size()!=0 ">
  997. AND (
  998. <foreach collection="subIds" item="id" index="index">
  999. <if test="index != subIds.size()-1">
  1000. FIND_IN_SET(#{id},g.subject_ids) OR
  1001. </if>
  1002. <if test="index == subIds.size()-1">
  1003. FIND_IN_SET(#{id},g.subject_ids)
  1004. </if>
  1005. </foreach>
  1006. )
  1007. </if>
  1008. </select>
  1009. <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1010. SELECT
  1011. *
  1012. FROM
  1013. class_grade
  1014. where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}
  1015. </select>
  1016. <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
  1017. SELECT
  1018. cg.*
  1019. FROM
  1020. class_grade cg
  1021. where cg.official_name = #{registerCode}
  1022. AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
  1023. </select>
  1024. <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1025. update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},
  1026. class_start_time = #{classStartTime},class_end_time = #{classEndTime},learning_status = #{learningStatus},learning_time_start = #{learningTimeStart}
  1027. where 1 = 1
  1028. <if test="gradeIds != null and gradeIds.size()!=0 ">
  1029. AND grade_id in
  1030. <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
  1031. #{item}
  1032. </foreach>
  1033. </if>
  1034. </update>
  1035. <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >
  1036. update class_grade set register_code = official_name where 1 = 1
  1037. <if test="ids != null and ids.size()!=0 ">
  1038. AND grade_id in
  1039. <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
  1040. #{item}
  1041. </foreach>
  1042. </if>
  1043. </update>
  1044. <update id="UpGradeInterfaceByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
  1045. update class_grade set interface_push_id = #{interfacePushId} where grade_id = #{gradeId}
  1046. </update>
  1047. </mapper>