ClassGradeMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. </resultMap>
  52. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserListVo" id="ClassGradeUserListVo">
  53. <result property="gradeId" column="grade_id"/>
  54. <result property="classStatus" column="class_status"/>
  55. <result property="officialName" column="official_name"/>
  56. <result property="className" column="class_name"/>
  57. <result property="studentUpper" column="student_upper"/>
  58. <result property="learningTimeStart" column="learning_time_start"/>
  59. <result property="learningStatus" column="learning_status"/>
  60. <result property="status" column="status"/>
  61. <result property="classStartTime" column="class_start_time"/>
  62. <result property="classEndTime" column="class_end_time"/>
  63. <result property="examineId" column="examine_id"/>
  64. <result property="areasId" column="areas_id"/>
  65. <result property="sysUserId" column="sys_user_id"/>
  66. <result property="interfacePushId" column="interface_push_id"/>
  67. <result property="remark" column="remark"/>
  68. <result property="interfaceAccountId" column="interface_account_id"/>
  69. <result property="interfacePeriodId" column="interface_period_id"/>
  70. <result property="interfaceAccountName" column="interface_account_name"/>
  71. <result property="interfacePeriodName" column="interface_period_name"/>
  72. <result property="interfacePushName" column="interface_push_name"/>
  73. <result property="studentNum" column="student_num"/>
  74. </resultMap>
  75. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  76. <result property="goodsId" column="goods_id"/>
  77. <result property="year" column="year"/>
  78. <result property="supplyId" column="supply_id"/>
  79. <result property="goodsType" column="goods_type"/>
  80. <result property="educationTypeId" column="education_type_id"/>
  81. <result property="businessId" column="business_id"/>
  82. <result property="schoolId" column="school_id"/>
  83. <result property="majorId" column="major_id"/>
  84. <result property="goodsName" column="goods_name"/>
  85. <result property="standPrice" column="stand_price"/>
  86. <result property="lowestPrice" column="lowest_price"/>
  87. <result property="createTime" column="create_time"/>
  88. <result property="updateTime" column="update_time"/>
  89. <result property="status" column="status"/>
  90. <result property="validityStartTime" column="validity_start_time"/>
  91. <result property="validityEndTime" column="validity_end_time"/>
  92. <result property="studyStartTime" column="study_start_time"/>
  93. <result property="studyEndTime" column="study_end_time"/>
  94. <result property="certificateIds" column="certificate_ids"/>
  95. <result property="introduce" column="introduce"/>
  96. <result property="suitableObject" column="suitable_object"/>
  97. <result property="buyNote" column="buy_note"/>
  98. <result property="pcDetailHtml" column="pc_detail_html"/>
  99. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  100. <result property="goodsStatus" column="goods_status"/>
  101. <result property="coverUrl" column="cover_url"/>
  102. <result property="classHours" column="class_hours"/>
  103. <result property="standPriceJson" column="stand_price_json"/>
  104. <result property="code" column="code"/>
  105. <result property="projectId" column="project_id"/>
  106. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  107. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  108. <result property="goodsPlayConfig" column="goods_play_config"/>
  109. <result property="goodsExamConfig" column="goods_exam_config"/>
  110. <result property="supplyName" column="supply_name"/>
  111. <result property="educationName" column="education_name"/>
  112. <result property="projectName" column="project_name"/>
  113. <result property="businessName" column="business_name"/>
  114. <result property="schoolName" column="school_name"/>
  115. <result property="categoryName" column="category_name"/>
  116. <result property="handoutsId" column="handouts_id"/>
  117. <result property="templateType" column="template_type"/>
  118. </resultMap>
  119. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeStudentVo" id="ClassGradeStudentVo">
  120. <result property="userId" column="user_id"/>
  121. <result property="id" column="id"/>
  122. <result property="gradeId" column="grade_id"/>
  123. <result property="studentCode" column="user_account"/>
  124. <result property="realName" column="realname"/>
  125. <result property="idCard" column="id_card"/>
  126. <result property="telPhone" column="telphone"/>
  127. <result property="userStatus" column="user_status"/>
  128. <result property="status" column="status"/>
  129. <result property="classHours" column="class_hours"/>
  130. <result property="periodStatus" column="period_status"/>
  131. <result property="finishStatus" column="finish_status"/>
  132. <result property="officialStatus" column="official_status"/>
  133. <result property="learnStatus" column="learn_status"/>
  134. <result property="secAllNum" column="sec_all_num"/>
  135. <result property="examNum" column="exam_num"/>
  136. <result property="recordNum" column="record_num"/>
  137. <result property="classStartTime" column="class_start_time"/>
  138. <result property="classEndTime" column="class_end_time"/>
  139. <result property="studyStartTime" column="study_start_time"/>
  140. <result property="studyEndTime" column="study_end_time"/>
  141. <result property="studyCount" column="study_count"/>
  142. <result property="orderGoodsId" column="order_goods_id"/>
  143. <result property="officialStatusNum" column="official_status_num"/>
  144. <result property="officialStatusTime" column="official_status_time"/>
  145. <result property="interfacePushId" column="interface_push_id"/>
  146. <result property="periodPlush" column="period_plush"/>
  147. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  148. <result property="serviceStartTime" column="service_start_time"/>
  149. <result property="serviceEndTime" column="service_end_time"/>
  150. <result property="goodsName" column="goods_name"/>
  151. <result property="orderSn" column="order_sn"/>
  152. <result property="categoryName" column="category_name"/>
  153. </resultMap>
  154. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  155. SELECT
  156. g.*,
  157. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  158. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  159. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  160. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  161. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  162. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  163. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  164. FROM
  165. class_grade g
  166. <if test="userId != null and userId !=0 ">
  167. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  168. </if>
  169. where g.status !=-1
  170. <if test="status != null and status.size()!=0 ">
  171. AND g.status in
  172. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  173. #{item}
  174. </foreach>
  175. </if>
  176. <if test="userId != null and userId !=0 ">
  177. AND gu.user_id = #{userId}
  178. </if>
  179. <if test="gradeId != null and gradeId !=0 ">
  180. AND g.grade_id = #{gradeId}
  181. </if>
  182. <if test="searchKey != null and searchKey !='' ">
  183. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  184. SELECT
  185. COUNT(*)
  186. FROM
  187. class_grade_user cgu
  188. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  189. WHERE
  190. g.grade_id = cgu.grade_id
  191. AND u.realname like concat('%', #{searchKey}, '%')
  192. ) >0 or (
  193. SELECT
  194. COUNT(*)
  195. FROM
  196. class_grade_goods s
  197. LEFT JOIN goods d ON s.goods_id = d.goods_id
  198. WHERE
  199. g.grade_id = s.grade_id
  200. AND d.goods_name like concat('%', #{searchKey}, '%')
  201. ) >0)
  202. </if>
  203. <if test="classStatus != null and classStatus !='' ">
  204. AND g.class_status = #{classStatus}
  205. </if>
  206. <if test="className != null and className !='' ">
  207. AND g.class_name like concat('%', #{className}, '%')
  208. </if>
  209. <if test="atFull != null and atFull !='' ">
  210. 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
  211. </if>
  212. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  213. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  214. </if>
  215. <if test="pastDue != null or pastDue != null ">
  216. AND (unix_timestamp(now()) &lt; g.class_end_time or g.class_start_time is null)
  217. </if>
  218. <if test="educationTypeId != null and educationTypeId !='' ">
  219. AND (
  220. SELECT
  221. COUNT(*)
  222. FROM
  223. class_grade_goods s
  224. LEFT JOIN goods d ON s.goods_id = d.goods_id
  225. WHERE
  226. 1 = 1
  227. AND g.grade_id = s.grade_id
  228. AND d.education_type_id =#{educationTypeId}
  229. ) >0
  230. </if>
  231. <if test="businessId != null and businessId !='' ">
  232. AND (
  233. SELECT
  234. COUNT(*)
  235. FROM
  236. class_grade_goods s
  237. LEFT JOIN goods d ON s.goods_id = d.goods_id
  238. WHERE
  239. 1 = 1
  240. AND g.grade_id = s.grade_id
  241. AND d.business_id =#{businessId}
  242. ) >0
  243. </if>
  244. <if test="schoolId != null and schoolId !='' ">
  245. AND (
  246. SELECT
  247. COUNT(*)
  248. FROM
  249. class_grade_goods s
  250. LEFT JOIN goods d ON s.goods_id = d.goods_id
  251. WHERE
  252. 1 = 1
  253. AND g.grade_id = s.grade_id
  254. AND d.school_id =#{schoolId}
  255. ) >0
  256. </if>
  257. <if test="majorId != null and majorId !='' ">
  258. AND (
  259. SELECT
  260. COUNT(*)
  261. FROM
  262. class_grade_goods s
  263. LEFT JOIN goods d ON s.goods_id = d.goods_id
  264. WHERE
  265. 1 = 1
  266. AND g.grade_id = s.grade_id
  267. AND d.major_id =#{majorId}
  268. ) >0
  269. </if>
  270. <if test="goodsId != null and goodsId !='' ">
  271. AND (
  272. SELECT
  273. COUNT(*)
  274. FROM
  275. class_grade_goods s
  276. WHERE
  277. 1 = 1
  278. AND g.grade_id = s.grade_id
  279. AND s.goods_id =#{goodsId}
  280. ) >0
  281. </if>
  282. order by g.create_time desc
  283. </select>
  284. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  285. SELECT
  286. g.*,
  287. ps.supply_name,
  288. cet.education_name,
  289. cpt.project_name,
  290. cb.business_name,
  291. s.school_name,
  292. m.category_name,
  293. ot.type AS template_type
  294. FROM
  295. goods g
  296. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  297. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  298. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  299. LEFT JOIN course_business cb ON g.business_id = cb.id
  300. LEFT JOIN school s ON s.id = g.school_id
  301. LEFT JOIN major m ON g.major_id = m.id
  302. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  303. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  304. WHERE
  305. 1 = 1
  306. AND o.grade_id =#{gradeId}
  307. </select>
  308. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  309. SELECT
  310. cgu.id,
  311. cgu.official_status_time,
  312. cgu.official_status_num,
  313. u.user_account,
  314. u.user_id,
  315. cgu.`status`,
  316. u.realname,
  317. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  318. u.id_card,
  319. cgu.grade_id,
  320. u.telphone,
  321. (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,
  322. (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,
  323. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  324. (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,
  325. cgu.period_status,
  326. cgu.finish_status,
  327. cgu.period_plush,
  328. (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,
  329. (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,
  330. cg.class_start_time,
  331. cg.class_end_time,
  332. cg.interface_push_id,
  333. cgu.official_status,
  334. cgu.learn_status,
  335. (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 = 1 ) as exam_num,
  336. (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.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,
  337. (og.study_count) as study_count,
  338. og.order_goods_id,
  339. og.rebuy_order_goods_id,
  340. og.service_start_time,
  341. og.service_end_time,
  342. g.goods_name,
  343. og.order_sn,
  344. m.category_name
  345. FROM
  346. class_grade_user cgu
  347. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  348. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  349. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  350. LEFT JOIN goods g on og.goods_id = g.goods_id
  351. LEFT JOIN major m ON g.major_id = m.id
  352. where 1=1
  353. and cgu.`status` =1
  354. <if test="gradeId != null and gradeId !='' ">
  355. and cgu.grade_id = #{gradeId}
  356. </if>
  357. <if test="choice != null and choice == 1 ">
  358. 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
  359. 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
  360. </if>
  361. <if test="choice != null and choice == 2 ">
  362. 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
  363. 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)
  364. and cge.`status`=1 and cgur.`status` =1)> 0
  365. 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
  366. </if>
  367. <if test="studyCountMore != null and studyCountMore == 2 ">
  368. AND og.study_count > 0 AND cgu.change_grade = 0
  369. </if>
  370. <if test="studyCountMore != null and studyCountMore == 1 ">
  371. AND og.study_count > 0 AND cgu.change_grade = 1
  372. </if>
  373. <if test="studyCountMore != null and studyCountMore == 0 ">
  374. AND og.study_count = 0
  375. </if>
  376. <if test="realname != null and realname != ''">
  377. AND cgu.realname like concat('%', #{realname}, '%')
  378. </if>
  379. <if test="idCard != null and idCard != ''">
  380. AND u.id_card = #{idCard}
  381. </if>
  382. <if test="orderSn != null and orderSn != ''">
  383. AND og.order_sn = #{orderSn}
  384. </if>
  385. <if test="goodsName != null and goodsName != ''">
  386. AND g.goods_name like concat('%', #{goodsName}, '%')
  387. </if>
  388. <if test="searchStartTime != null and searchStartTime != ''">
  389. AND cgu.create_time &gt; #{searchStartTime}
  390. </if>
  391. <if test="searchEndTime != null and searchEndTime != ''">
  392. AND cgu.create_time &lt; #{searchEndTime}
  393. </if>
  394. <if test="finishStatus != null and finishStatus != ''">
  395. AND cgu.finish_status = #{finishStatus}
  396. </if>
  397. <if test="learnStatus != null and learnStatus != ''">
  398. AND cgu.learn_status = #{learnStatus}
  399. </if>
  400. <if test="businessId != null and businessId != ''">
  401. AND g.business_id = #{businessId}
  402. </if>
  403. <if test="educationTypeId != null and educationTypeId != ''">
  404. AND g.education_type_id = #{educationTypeId}
  405. </if>
  406. <if test="interfaceAccountId != null and interfaceAccountId != ''">
  407. AND cg.interface_account_id is not null
  408. </if>
  409. <if test="noInterfaceAccountId != null and noInterfaceAccountId != ''">
  410. AND cg.no_interface_account_id is not null
  411. </if>
  412. order by user_info_status desc ,user_status desc ,cgu.id desc
  413. </select>
  414. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  415. SELECT
  416. g.*,
  417. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  418. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  419. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  420. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  421. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  422. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  423. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  424. FROM
  425. class_grade g
  426. where g.status !=-1
  427. <if test="status != null and status.size()!=0 ">
  428. AND g.status in
  429. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  430. #{item}
  431. </foreach>
  432. </if>
  433. <if test="gradeId != null and gradeId !=0 ">
  434. AND g.grade_id = #{gradeId}
  435. </if>
  436. <if test="className != null and className !='' ">
  437. AND g.class_name like concat('%', #{className}, '%')
  438. </if>
  439. <if test="classStartTime != null and classStartTime !=0 ">
  440. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  441. </if>
  442. <if test="educationTypeId != null and educationTypeId !='' ">
  443. AND (
  444. SELECT
  445. COUNT(*)
  446. FROM
  447. class_grade_goods s
  448. LEFT JOIN goods d ON s.goods_id = d.goods_id
  449. WHERE
  450. 1 = 1
  451. AND g.grade_id = s.grade_id
  452. AND d.education_type_id =#{educationTypeId}
  453. ) >0
  454. </if>
  455. <if test="businessId != null and businessId !='' ">
  456. AND (
  457. SELECT
  458. COUNT(*)
  459. FROM
  460. class_grade_goods s
  461. LEFT JOIN goods d ON s.goods_id = d.goods_id
  462. WHERE
  463. 1 = 1
  464. AND g.grade_id = s.grade_id
  465. AND d.business_id =#{businessId}
  466. ) >0
  467. </if>
  468. <if test="schoolId != null and schoolId !='' ">
  469. AND (
  470. SELECT
  471. COUNT(*)
  472. FROM
  473. class_grade_goods s
  474. LEFT JOIN goods d ON s.goods_id = d.goods_id
  475. WHERE
  476. 1 = 1
  477. AND g.grade_id = s.grade_id
  478. AND d.school_id =#{schoolId}
  479. ) >0
  480. </if>
  481. <if test="majorId != null and majorId !='' ">
  482. AND (
  483. SELECT
  484. COUNT(*)
  485. FROM
  486. class_grade_goods s
  487. LEFT JOIN goods d ON s.goods_id = d.goods_id
  488. WHERE
  489. 1 = 1
  490. AND g.grade_id = s.grade_id
  491. AND d.major_id =#{majorId}
  492. ) >0
  493. </if>
  494. <if test="goodsId != null and goodsId !='' ">
  495. AND (
  496. SELECT
  497. COUNT(*)
  498. FROM
  499. class_grade_goods s
  500. WHERE
  501. 1 = 1
  502. AND g.grade_id = s.grade_id
  503. AND s.goods_id =#{goodsId}
  504. ) >0
  505. </if>
  506. order by g.update_time desc
  507. </select>
  508. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  509. SELECT
  510. u.user_account,
  511. u.user_id,
  512. u.realname,
  513. u.id_card
  514. FROM
  515. `user` u
  516. WHERE
  517. 1 = 1
  518. and u.realname is NOT NULL
  519. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  520. <if test="status != null and status.size()!=0 ">
  521. AND u.status in
  522. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  523. #{item}
  524. </foreach>
  525. </if>
  526. </select>
  527. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  528. SELECT
  529. DISTINCT u.*
  530. FROM
  531. `user` u
  532. LEFT JOIN `order` o ON u.user_id = o.user_id
  533. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  534. LEFT JOIN goods g on g.goods_id=og.goods_id
  535. WHERE
  536. 1 = 1
  537. AND og.status=1
  538. and u.status=1
  539. and og.refund_status in(0,3)
  540. and pay_status in (2,3)
  541. and g.business_id =#{businessId}
  542. </select>
  543. <select id="querClassSMS" parameterType="map" resultType="Long">
  544. SELECT
  545. COUNT(1)
  546. FROM
  547. class_grade_goods cgg
  548. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  549. where 1=1
  550. and cgg.grade_id=#{gradeId}
  551. and g.business_id=#{businessId}
  552. </select>
  553. <select id="queryUser" parameterType="Long" resultType="Long">
  554. SELECT
  555. user_id
  556. FROM
  557. class_grade_user
  558. WHERE
  559. grade_id = #{gradeId}
  560. and `status` = 1
  561. </select>
  562. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  563. SELECT
  564. cg.grade_id,cg.class_status
  565. FROM
  566. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  567. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  568. WHERE
  569. 1 = 1
  570. <if test="businessId != null">
  571. AND g.business_id = #{businessId}
  572. </if>
  573. <if test="startTime != null">
  574. AND cg.create_time >= #{startTime}
  575. </if>
  576. <if test="endTime != null">
  577. AND #{endTime} >= cg.create_time
  578. </if>
  579. </select>
  580. <select id="selectByBusinessId" resultType="com.zhongzheng.modules.grade.vo.ClassGradeVo">
  581. SELECT
  582. cg.*
  583. FROM class_grade cg
  584. LEFT JOIN class_grade_goods cgu ON cg.grade_id = cgu.grade_id
  585. LEFT JOIN goods g ON cgu.goods_id = g.goods_id
  586. WHERE g.`status` = 1
  587. <if test="businessId != null and businessId !=''">
  588. AND g.business_id = #{businessId}
  589. </if>
  590. </select>
  591. </mapper>