ClassGradeMapper.xml 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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. <result property="reason" column="reason"/>
  154. </resultMap>
  155. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  156. SELECT
  157. g.*,
  158. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  159. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  160. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  161. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  162. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  163. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  164. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  165. FROM
  166. class_grade g
  167. <if test="userId != null and userId !=0 ">
  168. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  169. </if>
  170. where g.status !=-1
  171. <if test="status != null and status.size()!=0 ">
  172. AND g.status in
  173. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  174. #{item}
  175. </foreach>
  176. </if>
  177. <if test="userId != null and userId !=0 ">
  178. AND gu.user_id = #{userId}
  179. </if>
  180. <if test="gradeId != null and gradeId !=0 ">
  181. AND g.grade_id = #{gradeId}
  182. </if>
  183. <if test="searchKey != null and searchKey !='' ">
  184. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  185. SELECT
  186. COUNT(*)
  187. FROM
  188. class_grade_user cgu
  189. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  190. WHERE
  191. g.grade_id = cgu.grade_id
  192. AND u.realname like concat('%', #{searchKey}, '%')
  193. ) >0 or (
  194. SELECT
  195. COUNT(*)
  196. FROM
  197. class_grade_goods s
  198. LEFT JOIN goods d ON s.goods_id = d.goods_id
  199. WHERE
  200. g.grade_id = s.grade_id
  201. AND d.goods_name like concat('%', #{searchKey}, '%')
  202. ) >0)
  203. </if>
  204. <if test="classStatus != null and classStatus !='' ">
  205. AND g.class_status = #{classStatus}
  206. </if>
  207. <if test="className != null and className !='' ">
  208. AND g.class_name like concat('%', #{className}, '%')
  209. </if>
  210. <if test="atFull != null and atFull !='' ">
  211. 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
  212. </if>
  213. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  214. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  215. </if>
  216. <if test="pastDue != null or pastDue != null ">
  217. AND (unix_timestamp(now()) &lt; g.class_end_time or g.class_start_time is null)
  218. </if>
  219. <if test="educationTypeId != null and educationTypeId !='' ">
  220. AND (
  221. SELECT
  222. COUNT(*)
  223. FROM
  224. class_grade_goods s
  225. LEFT JOIN goods d ON s.goods_id = d.goods_id
  226. WHERE
  227. 1 = 1
  228. AND g.grade_id = s.grade_id
  229. AND d.education_type_id =#{educationTypeId}
  230. ) >0
  231. </if>
  232. <if test="businessId != null and businessId !='' ">
  233. AND (
  234. SELECT
  235. COUNT(*)
  236. FROM
  237. class_grade_goods s
  238. LEFT JOIN goods d ON s.goods_id = d.goods_id
  239. WHERE
  240. 1 = 1
  241. AND g.grade_id = s.grade_id
  242. AND d.business_id =#{businessId}
  243. ) >0
  244. </if>
  245. <if test="schoolId != null and schoolId !='' ">
  246. AND (
  247. SELECT
  248. COUNT(*)
  249. FROM
  250. class_grade_goods s
  251. LEFT JOIN goods d ON s.goods_id = d.goods_id
  252. WHERE
  253. 1 = 1
  254. AND g.grade_id = s.grade_id
  255. AND d.school_id =#{schoolId}
  256. ) >0
  257. </if>
  258. <if test="majorId != null and majorId !='' ">
  259. AND (
  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. 1 = 1
  267. AND g.grade_id = s.grade_id
  268. AND d.major_id =#{majorId}
  269. ) >0
  270. </if>
  271. <if test="goodsId != null and goodsId !='' ">
  272. AND (
  273. SELECT
  274. COUNT(*)
  275. FROM
  276. class_grade_goods s
  277. WHERE
  278. 1 = 1
  279. AND g.grade_id = s.grade_id
  280. AND s.goods_id =#{goodsId}
  281. ) >0
  282. </if>
  283. order by g.create_time desc
  284. </select>
  285. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  286. SELECT
  287. g.*,
  288. ps.supply_name,
  289. cet.education_name,
  290. cpt.project_name,
  291. cb.business_name,
  292. s.school_name,
  293. m.category_name,
  294. ot.type AS template_type
  295. FROM
  296. goods g
  297. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  298. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  299. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  300. LEFT JOIN course_business cb ON g.business_id = cb.id
  301. LEFT JOIN school s ON s.id = g.school_id
  302. LEFT JOIN major m ON g.major_id = m.id
  303. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  304. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  305. WHERE
  306. 1 = 1
  307. AND o.grade_id =#{gradeId}
  308. </select>
  309. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  310. SELECT
  311. cgu.id,
  312. cgu.official_status_time,
  313. cgu.official_status_num,
  314. u.user_account,
  315. u.user_id,
  316. cgu.`status`,
  317. u.realname,
  318. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  319. u.id_card,
  320. cgu.grade_id,
  321. u.telphone,
  322. (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,
  323. (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,
  324. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  325. (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,
  326. cgu.period_status,
  327. cgu.finish_status,
  328. cgu.period_plush,
  329. (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,
  330. (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,
  331. cg.class_start_time,
  332. cg.class_end_time,
  333. cg.interface_push_id,
  334. cgu.official_status,
  335. cgu.learn_status,
  336. (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,
  337. (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,
  338. (og.study_count) as study_count,
  339. og.order_goods_id,
  340. og.rebuy_order_goods_id,
  341. og.service_start_time,
  342. og.service_end_time,
  343. g.goods_name,
  344. og.order_sn,
  345. m.category_name,
  346. g.major_id,
  347. u.province,
  348. cgu.reason
  349. FROM
  350. class_grade_user cgu
  351. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  352. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  353. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  354. LEFT JOIN goods g on og.goods_id = g.goods_id
  355. LEFT JOIN major m ON g.major_id = m.id
  356. where 1=1
  357. and cgu.`status` =1
  358. <if test="gradeId != null and gradeId !='' ">
  359. and cgu.grade_id = #{gradeId}
  360. </if>
  361. <if test="choice != null and choice == 1 ">
  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 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
  363. 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
  364. </if>
  365. <if test="choice != null and choice == 2 ">
  366. 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
  367. 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)
  368. and cge.`status`=1 and cgur.`status` =1)> 0
  369. 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
  370. </if>
  371. <if test="studyCountMore != null and studyCountMore == 2 ">
  372. AND og.study_count > 0 AND cgu.change_grade = 0
  373. </if>
  374. <if test="studyCountMore != null and studyCountMore == 1 ">
  375. AND og.study_count > 0 AND cgu.change_grade = 1
  376. </if>
  377. <if test="studyCountMore != null and studyCountMore == 0 ">
  378. AND og.study_count = 0
  379. </if>
  380. <if test="realname != null and realname != ''">
  381. AND u.realname like concat('%', #{realname}, '%')
  382. </if>
  383. <if test="idCard != null and idCard != ''">
  384. AND u.id_card = #{idCard}
  385. </if>
  386. <if test="idCards != null and idCards.size() != 0">
  387. AND u.id_card IN
  388. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  389. #{item}
  390. </foreach>
  391. </if>
  392. <if test="orderSn != null and orderSn != ''">
  393. AND og.order_sn = #{orderSn}
  394. </if>
  395. <if test="goodsName != null and goodsName != ''">
  396. AND g.goods_name like concat('%', #{goodsName}, '%')
  397. </if>
  398. <if test="searchStartTime != null and searchStartTime != ''">
  399. AND cgu.create_time &gt; #{searchStartTime}
  400. </if>
  401. <if test="searchEndTime != null and searchEndTime != ''">
  402. AND cgu.create_time &lt; #{searchEndTime}
  403. </if>
  404. <if test="finishStatus != null">
  405. AND cgu.finish_status = #{finishStatus}
  406. </if>
  407. <if test="learnStatus != null">
  408. AND cgu.learn_status = #{learnStatus}
  409. </if>
  410. <if test="businessId != null and businessId != ''">
  411. AND g.business_id = #{businessId}
  412. </if>
  413. <if test="educationTypeId != null and educationTypeId != ''">
  414. AND g.education_type_id = #{educationTypeId}
  415. </if>
  416. <if test="majorId != null and majorId != ''">
  417. AND m.id = #{majorId}
  418. </if>
  419. <if test="hasInterface != null and noInterfaceAccountId == 0">
  420. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  421. </if>
  422. <if test="hasInterface != null and noInterfaceAccountId == 1">
  423. AND cg.interface_account_id is not null
  424. </if>
  425. <if test="hasInterface != null and noInterfaceAccountId == 2">
  426. AND cg.no_interface_account_id is not null
  427. </if>
  428. order by user_info_status desc ,user_status desc ,cgu.id desc
  429. </select>
  430. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  431. SELECT
  432. g.*,
  433. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  434. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  435. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  436. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  437. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  438. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  439. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  440. FROM
  441. class_grade g
  442. where g.status !=-1
  443. <if test="status != null and status.size()!=0 ">
  444. AND g.status in
  445. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  446. #{item}
  447. </foreach>
  448. </if>
  449. <if test="gradeId != null and gradeId !=0 ">
  450. AND g.grade_id = #{gradeId}
  451. </if>
  452. <if test="className != null and className !='' ">
  453. AND g.class_name like concat('%', #{className}, '%')
  454. </if>
  455. <if test="classStartTime != null and classStartTime !=0 ">
  456. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  457. </if>
  458. <if test="educationTypeId != null and educationTypeId !='' ">
  459. AND (
  460. SELECT
  461. COUNT(*)
  462. FROM
  463. class_grade_goods s
  464. LEFT JOIN goods d ON s.goods_id = d.goods_id
  465. WHERE
  466. 1 = 1
  467. AND g.grade_id = s.grade_id
  468. AND d.education_type_id =#{educationTypeId}
  469. ) >0
  470. </if>
  471. <if test="businessId != null and businessId !='' ">
  472. AND (
  473. SELECT
  474. COUNT(*)
  475. FROM
  476. class_grade_goods s
  477. LEFT JOIN goods d ON s.goods_id = d.goods_id
  478. WHERE
  479. 1 = 1
  480. AND g.grade_id = s.grade_id
  481. AND d.business_id =#{businessId}
  482. ) >0
  483. </if>
  484. <if test="schoolId != null and schoolId !='' ">
  485. AND (
  486. SELECT
  487. COUNT(*)
  488. FROM
  489. class_grade_goods s
  490. LEFT JOIN goods d ON s.goods_id = d.goods_id
  491. WHERE
  492. 1 = 1
  493. AND g.grade_id = s.grade_id
  494. AND d.school_id =#{schoolId}
  495. ) >0
  496. </if>
  497. <if test="majorId != null and majorId !='' ">
  498. AND (
  499. SELECT
  500. COUNT(*)
  501. FROM
  502. class_grade_goods s
  503. LEFT JOIN goods d ON s.goods_id = d.goods_id
  504. WHERE
  505. 1 = 1
  506. AND g.grade_id = s.grade_id
  507. AND d.major_id =#{majorId}
  508. ) >0
  509. </if>
  510. <if test="goodsId != null and goodsId !='' ">
  511. AND (
  512. SELECT
  513. COUNT(*)
  514. FROM
  515. class_grade_goods s
  516. WHERE
  517. 1 = 1
  518. AND g.grade_id = s.grade_id
  519. AND s.goods_id =#{goodsId}
  520. ) >0
  521. </if>
  522. order by g.update_time desc
  523. </select>
  524. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  525. SELECT
  526. u.user_account,
  527. u.user_id,
  528. u.realname,
  529. u.id_card
  530. FROM
  531. `user` u
  532. WHERE
  533. 1 = 1
  534. and u.realname is NOT NULL
  535. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  536. <if test="status != null and status.size()!=0 ">
  537. AND u.status in
  538. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  539. #{item}
  540. </foreach>
  541. </if>
  542. </select>
  543. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  544. SELECT
  545. DISTINCT u.*
  546. FROM
  547. `user` u
  548. LEFT JOIN `order` o ON u.user_id = o.user_id
  549. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  550. LEFT JOIN goods g on g.goods_id=og.goods_id
  551. WHERE
  552. 1 = 1
  553. AND og.status=1
  554. and u.status=1
  555. and og.refund_status in(0,3)
  556. and og.pay_status in (2,3,4)
  557. and g.business_id =#{businessId}
  558. </select>
  559. <select id="querClassSMS" parameterType="map" resultType="Long">
  560. SELECT
  561. COUNT(1)
  562. FROM
  563. class_grade_goods cgg
  564. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  565. where 1=1
  566. and cgg.grade_id=#{gradeId}
  567. and g.business_id=#{businessId}
  568. </select>
  569. <select id="queryUser" parameterType="Long" resultType="Long">
  570. SELECT
  571. user_id
  572. FROM
  573. class_grade_user
  574. WHERE
  575. grade_id = #{gradeId}
  576. and `status` = 1
  577. </select>
  578. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  579. SELECT
  580. cg.grade_id,cg.class_status
  581. FROM
  582. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  583. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  584. WHERE
  585. 1 = 1
  586. <if test="businessId != null">
  587. AND g.business_id = #{businessId}
  588. </if>
  589. <if test="startTime != null">
  590. AND cg.create_time >= #{startTime}
  591. </if>
  592. <if test="endTime != null">
  593. AND #{endTime} >= cg.create_time
  594. </if>
  595. </select>
  596. <select id="selectByBusinessId" resultType="com.zhongzheng.modules.grade.vo.ClassGradeVo">
  597. SELECT
  598. cg.*
  599. FROM class_grade cg
  600. LEFT JOIN class_grade_goods cgu ON cg.grade_id = cgu.grade_id
  601. LEFT JOIN goods g ON cgu.goods_id = g.goods_id
  602. WHERE g.`status` = 1
  603. <if test="businessId != null and businessId !=''">
  604. AND g.business_id = #{businessId}
  605. </if>
  606. </select>
  607. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  608. SELECT
  609. count(cgu.id)
  610. FROM
  611. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  612. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  613. WHERE
  614. 1 = 1
  615. <if test="learnStatus != null">
  616. AND cgu.learn_status = #{learnStatus}
  617. </if>
  618. <if test="finishStatus != null">
  619. AND cgu.finish_status = #{finishStatus}
  620. </if>
  621. <if test="businessId != null">
  622. AND g.business_id = #{businessId}
  623. </if>
  624. <if test="startTime != null">
  625. AND cgu.create_time >= #{startTime}
  626. </if>
  627. <if test="endTime != null">
  628. AND #{endTime} >= cgu.create_time
  629. </if>
  630. </select>
  631. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  632. SELECT
  633. count(cg.grade_id)
  634. FROM
  635. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  636. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  637. WHERE
  638. 1 = 1
  639. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  640. AND cg.interface_account_id > 0
  641. </if>
  642. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  643. AND cg.interface_account_id is NULL
  644. </if>
  645. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  646. AND cg.no_interface_account_id > 0
  647. </if>
  648. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  649. AND cg.no_interface_account_id is NULL
  650. </if>
  651. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  652. AND cg.interface_period_id > 0
  653. </if>
  654. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  655. AND cg.interface_period_id is NULL
  656. </if>
  657. <if test="interfacePushId != null and interfacePushId== 1">
  658. AND cg.interface_push_id > 0
  659. </if>
  660. <if test="interfacePushId != null and interfacePushId== 0">
  661. AND cg.interface_push_id is NULL
  662. </if>
  663. <if test="businessId != null">
  664. AND g.business_id = #{businessId}
  665. </if>
  666. <if test="startTime != null">
  667. AND cg.create_time >= #{startTime}
  668. </if>
  669. <if test="endTime != null">
  670. AND #{endTime} >= cg.create_time
  671. </if>
  672. </select>
  673. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  674. SELECT
  675. count(cgu.id)
  676. FROM
  677. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  678. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  679. WHERE
  680. 1 = 1
  681. <if test="periodStatus != null">
  682. AND cgu.period_status = #{periodStatus}
  683. </if>
  684. <if test="businessId != null">
  685. AND g.business_id = #{businessId}
  686. </if>
  687. <if test="startTime != null">
  688. AND cgu.period_ing_time >= #{startTime}
  689. </if>
  690. <if test="endTime != null">
  691. AND #{endTime} >= cgu.period_ing_time
  692. </if>
  693. <if test="waitStartTime != null">
  694. AND cgu.period_wait_time >= #{waitStartTime}
  695. </if>
  696. <if test="waitEndTime != null">
  697. AND #{waitEndTime} >= cgu.period_wait_time
  698. </if>
  699. </select>
  700. <select id="getConsoleGradeUserPeriodNum" 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. 1 = 1
  709. <if test="periodStatus != null">
  710. AND cgu.period_status = 1
  711. </if>
  712. <if test="interfacePushId != null">
  713. AND cg.interface_push_id > 0
  714. </if>
  715. <if test="officialStatus != null">
  716. AND cgu.official_status = 1
  717. </if>
  718. <if test="periodPlush != null">
  719. AND cgu.period_plush = 1
  720. </if>
  721. <if test="businessId != null">
  722. AND g.business_id = #{businessId}
  723. </if>
  724. </select>
  725. </mapper>