ClassGradeMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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. </resultMap>
  58. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserListVo" id="ClassGradeUserListVo">
  59. <result property="gradeId" column="grade_id"/>
  60. <result property="classStatus" column="class_status"/>
  61. <result property="officialName" column="official_name"/>
  62. <result property="className" column="class_name"/>
  63. <result property="studentUpper" column="student_upper"/>
  64. <result property="learningTimeStart" column="learning_time_start"/>
  65. <result property="learningStatus" column="learning_status"/>
  66. <result property="status" column="status"/>
  67. <result property="classStartTime" column="class_start_time"/>
  68. <result property="classEndTime" column="class_end_time"/>
  69. <result property="examineId" column="examine_id"/>
  70. <result property="areasId" column="areas_id"/>
  71. <result property="sysUserId" column="sys_user_id"/>
  72. <result property="interfacePushId" column="interface_push_id"/>
  73. <result property="remark" column="remark"/>
  74. <result property="interfaceAccountId" column="interface_account_id"/>
  75. <result property="interfacePeriodId" column="interface_period_id"/>
  76. <result property="interfaceAccountName" column="interface_account_name"/>
  77. <result property="interfacePeriodName" column="interface_period_name"/>
  78. <result property="interfacePushName" column="interface_push_name"/>
  79. <result property="studentNum" column="student_num"/>
  80. </resultMap>
  81. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  82. <result property="goodsId" column="goods_id"/>
  83. <result property="year" column="year"/>
  84. <result property="supplyId" column="supply_id"/>
  85. <result property="goodsType" column="goods_type"/>
  86. <result property="educationTypeId" column="education_type_id"/>
  87. <result property="businessId" column="business_id"/>
  88. <result property="schoolId" column="school_id"/>
  89. <result property="majorId" column="major_id"/>
  90. <result property="goodsName" column="goods_name"/>
  91. <result property="standPrice" column="stand_price"/>
  92. <result property="lowestPrice" column="lowest_price"/>
  93. <result property="createTime" column="create_time"/>
  94. <result property="updateTime" column="update_time"/>
  95. <result property="status" column="status"/>
  96. <result property="validityStartTime" column="validity_start_time"/>
  97. <result property="validityEndTime" column="validity_end_time"/>
  98. <result property="studyStartTime" column="study_start_time"/>
  99. <result property="studyEndTime" column="study_end_time"/>
  100. <result property="certificateIds" column="certificate_ids"/>
  101. <result property="introduce" column="introduce"/>
  102. <result property="suitableObject" column="suitable_object"/>
  103. <result property="buyNote" column="buy_note"/>
  104. <result property="pcDetailHtml" column="pc_detail_html"/>
  105. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  106. <result property="goodsStatus" column="goods_status"/>
  107. <result property="coverUrl" column="cover_url"/>
  108. <result property="classHours" column="class_hours"/>
  109. <result property="standPriceJson" column="stand_price_json"/>
  110. <result property="code" column="code"/>
  111. <result property="projectId" column="project_id"/>
  112. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  113. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  114. <result property="goodsPlayConfig" column="goods_play_config"/>
  115. <result property="goodsExamConfig" column="goods_exam_config"/>
  116. <result property="supplyName" column="supply_name"/>
  117. <result property="educationName" column="education_name"/>
  118. <result property="projectName" column="project_name"/>
  119. <result property="businessName" column="business_name"/>
  120. <result property="schoolName" column="school_name"/>
  121. <result property="categoryName" column="category_name"/>
  122. <result property="handoutsId" column="handouts_id"/>
  123. <result property="templateType" column="template_type"/>
  124. </resultMap>
  125. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeStudentVo" id="ClassGradeStudentVo">
  126. <result property="userId" column="user_id"/>
  127. <result property="id" column="id"/>
  128. <result property="gradeId" column="grade_id"/>
  129. <result property="studentCode" column="user_account"/>
  130. <result property="realname" column="realname"/>
  131. <result property="idCard" column="id_card"/>
  132. <result property="telPhone" column="telphone"/>
  133. <result property="userStatus" column="user_status"/>
  134. <result property="status" column="status"/>
  135. <result property="classHours" column="class_hours"/>
  136. <result property="periodStatus" column="period_status"/>
  137. <result property="finishStatus" column="finish_status"/>
  138. <result property="officialStatus" column="official_status"/>
  139. <result property="learnStatus" column="learn_status"/>
  140. <result property="secAllNum" column="sec_all_num"/>
  141. <result property="examNum" column="exam_num"/>
  142. <result property="recordNum" column="record_num"/>
  143. <result property="classStartTime" column="class_start_time"/>
  144. <result property="classEndTime" column="class_end_time"/>
  145. <result property="studyStartTime" column="study_start_time"/>
  146. <result property="studyEndTime" column="study_end_time"/>
  147. <result property="studyCount" column="study_count"/>
  148. <result property="orderGoodsId" column="order_goods_id"/>
  149. <result property="officialStatusNum" column="official_status_num"/>
  150. <result property="officialStatusTime" column="official_status_time"/>
  151. <result property="interfacePushId" column="interface_push_id"/>
  152. <result property="periodPlush" column="period_plush"/>
  153. <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>
  154. <result property="serviceStartTime" column="service_start_time"/>
  155. <result property="serviceEndTime" column="service_end_time"/>
  156. <result property="goodsName" column="goods_name"/>
  157. <result property="orderSn" column="order_sn"/>
  158. <result property="categoryName" column="category_name"/>
  159. <result property="reason" column="reason"/>
  160. <result property="projectName" column="project_name"/>
  161. <result property="businessName" column="business_name"/>
  162. </resultMap>
  163. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeGoodsVo" id="ClassGradeGoodsVoResult">
  164. <result property="goodsId" column="goods_id"/>
  165. <collection property="gradeList" column="goods_id" select="findGradeList"/>
  166. </resultMap>
  167. <select id="findGradeList" resultMap="ClassGradeVoResult">
  168. SELECT
  169. g.*,
  170. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  171. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  172. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  173. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  174. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  175. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  176. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  177. (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,
  178. (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,
  179. (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
  180. FROM
  181. class_grade_goods cgg LEFT JOIN
  182. class_grade g on cgg.grade_id = g.grade_id
  183. where cgg.goods_id = #{goods_id} and g.`status` = 1
  184. </select>
  185. <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">
  186. SELECT
  187. g.*,
  188. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  189. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  190. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  191. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  192. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  193. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  194. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,
  195. (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,
  196. (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,
  197. (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,
  198. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,d.subject_ids)) subject_names
  199. FROM
  200. class_grade g
  201. LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id
  202. LEFT JOIN goods d ON cgg.goods_id = d.goods_id
  203. LEFT JOIN course_business cb ON d.business_id = cb.id
  204. <if test="userId != null and userId !=0 ">
  205. LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1
  206. </if>
  207. where g.status !=-1
  208. <if test="status != null and status.size()!=0 ">
  209. AND g.status in
  210. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  211. #{item}
  212. </foreach>
  213. </if>
  214. <if test="userId != null and userId !=0 ">
  215. AND gu.user_id = #{userId}
  216. </if>
  217. <if test="gradeId != null and gradeId !=0 ">
  218. AND g.grade_id = #{gradeId}
  219. </if>
  220. <if test="searchKey != null and searchKey !='' ">
  221. AND ((g.class_name like concat('%', #{searchKey}, '%')) or (
  222. SELECT
  223. COUNT(*)
  224. FROM
  225. class_grade_user cgu
  226. LEFT JOIN `user` u ON cgu.user_id = u.user_id
  227. WHERE
  228. g.grade_id = cgu.grade_id
  229. AND u.realname like concat('%', #{searchKey}, '%')
  230. ) >0 or (
  231. SELECT
  232. COUNT(*)
  233. FROM
  234. class_grade_goods s
  235. LEFT JOIN goods d ON s.goods_id = d.goods_id
  236. WHERE
  237. g.grade_id = s.grade_id
  238. AND d.goods_name like concat('%', #{searchKey}, '%')
  239. ) >0)
  240. </if>
  241. <if test="classStatus != null ">
  242. AND g.class_status = #{classStatus}
  243. </if>
  244. <if test="className != null and className !='' ">
  245. AND g.class_name like concat('%', #{className}, '%')
  246. </if>
  247. <if test="atFull != null and atFull !='' ">
  248. 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
  249. </if>
  250. <if test="classStartTime != null and classStartTime != '' and classEndTime != null and classEndTime != ''">
  251. AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)
  252. </if>
  253. <if test="pastDue != null or pastDue != null ">
  254. AND (unix_timestamp(now()) &lt; g.class_end_time or g.class_start_time is null)
  255. </if>
  256. <if test="educationTypeId != null and educationTypeId !='' ">
  257. AND (
  258. SELECT
  259. COUNT(*)
  260. FROM
  261. class_grade_goods s
  262. LEFT JOIN goods d ON s.goods_id = d.goods_id
  263. WHERE
  264. 1 = 1
  265. AND g.grade_id = s.grade_id
  266. AND d.education_type_id =#{educationTypeId}
  267. ) >0
  268. </if>
  269. <if test="businessId != null and businessId !='' ">
  270. AND cb.id = #{businessId}
  271. </if>
  272. <if test="schoolId != null and schoolId !='' ">
  273. AND (
  274. SELECT
  275. COUNT(*)
  276. FROM
  277. class_grade_goods s
  278. LEFT JOIN goods d ON s.goods_id = d.goods_id
  279. WHERE
  280. 1 = 1
  281. AND g.grade_id = s.grade_id
  282. AND d.school_id =#{schoolId}
  283. ) >0
  284. </if>
  285. <if test="majorId != null and majorId !='' ">
  286. AND (
  287. SELECT
  288. COUNT(*)
  289. FROM
  290. class_grade_goods s
  291. LEFT JOIN goods d ON s.goods_id = d.goods_id
  292. WHERE
  293. 1 = 1
  294. AND g.grade_id = s.grade_id
  295. AND d.major_id =#{majorId}
  296. ) >0
  297. </if>
  298. <if test="goodsId != null and goodsId !='' ">
  299. AND (
  300. SELECT
  301. COUNT(*)
  302. FROM
  303. class_grade_goods s
  304. WHERE
  305. 1 = 1
  306. AND g.grade_id = s.grade_id
  307. AND s.goods_id =#{goodsId}
  308. ) >0
  309. </if>
  310. <if test="hasInterface != null and hasInterface == 0">
  311. AND g.interface_account_id is null AND g.no_interface_account_id is null
  312. </if>
  313. <if test="hasInterface != null and hasInterface == 1">
  314. AND g.interface_account_id is not null
  315. </if>
  316. <if test="hasInterface != null and hasInterface == 2">
  317. AND g.no_interface_account_id is not null
  318. </if>
  319. <!-- 数据范围过滤 -->
  320. ${params.dataScope}
  321. order by g.create_time desc
  322. </select>
  323. <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">
  324. SELECT
  325. g.*,
  326. ps.supply_name,
  327. cet.education_name,
  328. cpt.project_name,
  329. cb.business_name,
  330. s.school_name,
  331. m.category_name,
  332. ot.type AS template_type
  333. FROM
  334. goods g
  335. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  336. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  337. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  338. LEFT JOIN course_business cb ON g.business_id = cb.id
  339. LEFT JOIN school s ON s.id = g.school_id
  340. LEFT JOIN major m ON g.major_id = m.id
  341. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  342. LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id
  343. WHERE
  344. 1 = 1
  345. AND o.grade_id =#{gradeId}
  346. </select>
  347. <select id="listGrade" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  348. SELECT
  349. cgu.id,
  350. cgu.official_status_time,
  351. cgu.official_status_num,
  352. u.user_account,
  353. u.user_id,
  354. cgu.`status`,
  355. u.realname,
  356. (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,
  357. u.id_card,
  358. cgu.grade_id,
  359. u.telphone,
  360. (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,
  361. (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,
  362. (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,
  363. (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,
  364. cgu.period_status,
  365. cgu.finish_status,
  366. cgu.period_plush,
  367. (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,
  368. (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,
  369. cg.class_start_time,
  370. cg.class_end_time,
  371. cg.interface_push_id,
  372. cgu.official_status,
  373. cgu.learn_status,
  374. (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,
  375. (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,
  376. (og.study_count) as study_count,
  377. og.order_goods_id,
  378. og.rebuy_order_goods_id,
  379. og.service_start_time,
  380. og.service_end_time,
  381. g.goods_name,
  382. og.order_sn,
  383. m.category_name,
  384. g.major_id,
  385. u.province,
  386. cgu.reason,
  387. cb.business_name,
  388. cpt.project_name
  389. FROM
  390. class_grade_user cgu
  391. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  392. LEFT JOIN `user` u ON u.user_id = cgu.user_id
  393. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  394. LEFT JOIN goods g on og.goods_id = g.goods_id
  395. LEFT JOIN major m ON g.major_id = m.id
  396. LEFT JOIN course_business cb ON g.business_id = cb.id
  397. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  398. where 1=1
  399. and cgu.`status` =1
  400. <if test="gradeId != null and gradeId !='' ">
  401. and cgu.grade_id = #{gradeId}
  402. </if>
  403. <if test="choice != null and choice == 1 ">
  404. 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
  405. 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
  406. </if>
  407. <if test="choice != null and choice == 2 ">
  408. 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
  409. 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)
  410. and cge.`status`=1 and cgur.`status` =1)> 0
  411. 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
  412. </if>
  413. <if test="studyCountMore != null and studyCountMore == 2 ">
  414. AND og.study_count > 0 AND cgu.change_grade = 0
  415. </if>
  416. <if test="studyCountMore != null and studyCountMore == 1 ">
  417. AND og.study_count > 0 AND cgu.change_grade = 1
  418. </if>
  419. <if test="studyCountMore != null and studyCountMore == 0 ">
  420. AND og.study_count = 0
  421. </if>
  422. <if test="realname != null and realname != ''">
  423. AND u.realname like concat('%', #{realname}, '%')
  424. </if>
  425. <if test="idCard != null and idCard != ''">
  426. AND u.id_card = #{idCard}
  427. </if>
  428. <if test="idCards != null and idCards.size() != 0">
  429. AND u.id_card IN
  430. <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
  431. #{item}
  432. </foreach>
  433. </if>
  434. <if test="orderSn != null and orderSn != ''">
  435. AND og.order_sn = #{orderSn}
  436. </if>
  437. <if test="goodsName != null and goodsName != ''">
  438. AND g.goods_name like concat('%', #{goodsName}, '%')
  439. </if>
  440. <if test="searchStartTime != null and searchStartTime != ''">
  441. AND cgu.create_time &gt; #{searchStartTime}
  442. </if>
  443. <if test="searchEndTime != null and searchEndTime != ''">
  444. AND cgu.create_time &lt; #{searchEndTime}
  445. </if>
  446. <if test="finishStatus != null">
  447. AND cgu.finish_status = #{finishStatus}
  448. </if>
  449. <if test="learnStatus != null">
  450. AND cgu.learn_status = #{learnStatus}
  451. </if>
  452. <if test="businessId != null and businessId != ''">
  453. AND g.business_id = #{businessId}
  454. </if>
  455. <if test="educationTypeId != null and educationTypeId != ''">
  456. AND g.education_type_id = #{educationTypeId}
  457. </if>
  458. <if test="majorId != null and majorId != ''">
  459. AND m.id = #{majorId}
  460. </if>
  461. <if test="hasInterface != null and hasInterface == 0">
  462. AND cg.interface_account_id is null AND cg.no_interface_account_id is null
  463. </if>
  464. <if test="hasInterface != null and hasInterface == 1">
  465. AND cg.interface_account_id is not null
  466. </if>
  467. <if test="hasInterface != null and hasInterface == 2">
  468. AND cg.no_interface_account_id is not null
  469. </if>
  470. order by user_info_status desc ,user_status desc ,cgu.id desc
  471. </select>
  472. <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">
  473. SELECT
  474. g.*,
  475. (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,
  476. (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,
  477. (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,
  478. (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,
  479. (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,
  480. (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,
  481. (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num
  482. FROM
  483. class_grade g
  484. where g.status !=-1
  485. <if test="status != null and status.size()!=0 ">
  486. AND g.status in
  487. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  488. #{item}
  489. </foreach>
  490. </if>
  491. <if test="gradeId != null and gradeId !=0 ">
  492. AND g.grade_id = #{gradeId}
  493. </if>
  494. <if test="className != null and className !='' ">
  495. AND g.class_name like concat('%', #{className}, '%')
  496. </if>
  497. <if test="classStartTime != null and classStartTime !=0 ">
  498. AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time
  499. </if>
  500. <if test="educationTypeId != null and educationTypeId !='' ">
  501. AND (
  502. SELECT
  503. COUNT(*)
  504. FROM
  505. class_grade_goods s
  506. LEFT JOIN goods d ON s.goods_id = d.goods_id
  507. WHERE
  508. 1 = 1
  509. AND g.grade_id = s.grade_id
  510. AND d.education_type_id =#{educationTypeId}
  511. ) >0
  512. </if>
  513. <if test="businessId != null and businessId !='' ">
  514. AND (
  515. SELECT
  516. COUNT(*)
  517. FROM
  518. class_grade_goods s
  519. LEFT JOIN goods d ON s.goods_id = d.goods_id
  520. WHERE
  521. 1 = 1
  522. AND g.grade_id = s.grade_id
  523. AND d.business_id =#{businessId}
  524. ) >0
  525. </if>
  526. <if test="schoolId != null and schoolId !='' ">
  527. AND (
  528. SELECT
  529. COUNT(*)
  530. FROM
  531. class_grade_goods s
  532. LEFT JOIN goods d ON s.goods_id = d.goods_id
  533. WHERE
  534. 1 = 1
  535. AND g.grade_id = s.grade_id
  536. AND d.school_id =#{schoolId}
  537. ) >0
  538. </if>
  539. <if test="majorId != null and majorId !='' ">
  540. AND (
  541. SELECT
  542. COUNT(*)
  543. FROM
  544. class_grade_goods s
  545. LEFT JOIN goods d ON s.goods_id = d.goods_id
  546. WHERE
  547. 1 = 1
  548. AND g.grade_id = s.grade_id
  549. AND d.major_id =#{majorId}
  550. ) >0
  551. </if>
  552. <if test="goodsId != null and goodsId !='' ">
  553. AND (
  554. SELECT
  555. COUNT(*)
  556. FROM
  557. class_grade_goods s
  558. WHERE
  559. 1 = 1
  560. AND g.grade_id = s.grade_id
  561. AND s.goods_id =#{goodsId}
  562. ) >0
  563. </if>
  564. order by g.update_time desc
  565. </select>
  566. <select id="listGradeStudy" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  567. SELECT
  568. u.user_account,
  569. u.user_id,
  570. u.realname,
  571. u.id_card
  572. FROM
  573. `user` u
  574. WHERE
  575. 1 = 1
  576. and u.realname is NOT NULL
  577. and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )
  578. <if test="status != null and status.size()!=0 ">
  579. AND u.status in
  580. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  581. #{item}
  582. </foreach>
  583. </if>
  584. </select>
  585. <select id="listGradeService" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">
  586. SELECT
  587. DISTINCT u.*
  588. FROM
  589. `user` u
  590. LEFT JOIN `order` o ON u.user_id = o.user_id
  591. LEFT JOIN order_goods og ON o.order_sn = og.order_sn
  592. LEFT JOIN goods g on g.goods_id=og.goods_id
  593. WHERE
  594. 1 = 1
  595. AND og.status=1
  596. and u.status=1
  597. and og.refund_status in(0,3)
  598. and og.pay_status in (2,3,4)
  599. and g.business_id =#{businessId}
  600. </select>
  601. <select id="querClassSMS" parameterType="map" resultType="Long">
  602. SELECT
  603. COUNT(1)
  604. FROM
  605. class_grade_goods cgg
  606. LEFT JOIN goods g ON g.business_id = cgg.goods_id
  607. where 1=1
  608. and cgg.grade_id=#{gradeId}
  609. and g.business_id=#{businessId}
  610. </select>
  611. <select id="queryUser" parameterType="Long" resultType="Long">
  612. SELECT
  613. user_id
  614. FROM
  615. class_grade_user
  616. WHERE
  617. grade_id = #{gradeId}
  618. and `status` = 1
  619. </select>
  620. <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">
  621. SELECT
  622. cg.grade_id,cg.class_status
  623. FROM
  624. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  625. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  626. WHERE
  627. 1 = 1
  628. <if test="businessId != null">
  629. AND g.business_id = #{businessId}
  630. </if>
  631. <if test="startTime != null">
  632. AND cg.create_time >= #{startTime}
  633. </if>
  634. <if test="endTime != null">
  635. AND #{endTime} >= cg.create_time
  636. </if>
  637. </select>
  638. <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  639. SELECT
  640. count(cgu.id)
  641. FROM
  642. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  643. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  644. WHERE
  645. 1 = 1
  646. <if test="learnStatus != null">
  647. AND cgu.learn_status = #{learnStatus}
  648. </if>
  649. <if test="finishStatus != null">
  650. AND cgu.finish_status = #{finishStatus}
  651. </if>
  652. <if test="businessId != null">
  653. AND g.business_id = #{businessId}
  654. </if>
  655. <if test="startTime != null">
  656. AND cgu.create_time >= #{startTime}
  657. </if>
  658. <if test="endTime != null">
  659. AND #{endTime} >= cgu.create_time
  660. </if>
  661. </select>
  662. <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  663. SELECT
  664. count(cg.grade_id)
  665. FROM
  666. class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  667. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  668. WHERE
  669. 1 = 1
  670. <if test="interfaceAccountId != null and interfaceAccountId== 1">
  671. AND cg.interface_account_id > 0
  672. </if>
  673. <if test="interfaceAccountId != null and interfaceAccountId== 0">
  674. AND cg.interface_account_id is NULL
  675. </if>
  676. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">
  677. AND cg.no_interface_account_id > 0
  678. </if>
  679. <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">
  680. AND cg.no_interface_account_id is NULL
  681. </if>
  682. <if test="interfacePeriodId != null and interfacePeriodId== 1">
  683. AND cg.interface_period_id > 0
  684. </if>
  685. <if test="interfacePeriodId != null and interfacePeriodId== 0">
  686. AND cg.interface_period_id is NULL
  687. </if>
  688. <if test="interfacePushId != null and interfacePushId== 1">
  689. AND cg.interface_push_id > 0
  690. </if>
  691. <if test="interfacePushId != null and interfacePushId== 0">
  692. AND cg.interface_push_id is NULL
  693. </if>
  694. <if test="businessId != null">
  695. AND g.business_id = #{businessId}
  696. </if>
  697. <if test="startTime != null">
  698. AND cg.create_time >= #{startTime}
  699. </if>
  700. <if test="endTime != null">
  701. AND #{endTime} >= cg.create_time
  702. </if>
  703. </select>
  704. <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  705. SELECT
  706. count(cgu.id)
  707. FROM
  708. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  709. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  710. WHERE
  711. 1 = 1
  712. <if test="periodStatus != null">
  713. AND cgu.period_status = #{periodStatus}
  714. </if>
  715. <if test="businessId != null">
  716. AND g.business_id = #{businessId}
  717. </if>
  718. <if test="startTime != null">
  719. AND cgu.period_ing_time >= #{startTime}
  720. </if>
  721. <if test="endTime != null">
  722. AND #{endTime} >= cgu.period_ing_time
  723. </if>
  724. <if test="waitStartTime != null">
  725. AND cgu.period_wait_time >= #{waitStartTime}
  726. </if>
  727. <if test="waitEndTime != null">
  728. AND #{waitEndTime} >= cgu.period_wait_time
  729. </if>
  730. </select>
  731. <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">
  732. SELECT
  733. count(cgu.id)
  734. FROM
  735. class_grade_user cgu LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  736. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  737. LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id
  738. WHERE
  739. 1 = 1
  740. <if test="periodStatus != null">
  741. AND cgu.period_status = 1
  742. </if>
  743. <if test="interfacePushId != null">
  744. AND cg.interface_push_id > 0
  745. </if>
  746. <if test="officialStatus != null">
  747. AND cgu.official_status = 1
  748. </if>
  749. <if test="periodPlush != null">
  750. AND cgu.period_plush = 1
  751. </if>
  752. <if test="businessId != null">
  753. AND g.business_id = #{businessId}
  754. </if>
  755. </select>
  756. <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">
  757. SELECT
  758. g.goods_id
  759. FROM
  760. goods g
  761. WHERE
  762. 1=1
  763. <if test="goodsIds != null and goodsIds.size()!=0 ">
  764. AND g.goods_id in
  765. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  766. #{item}
  767. </foreach>
  768. </if>
  769. </select>
  770. <select id="listGradeSubjects" resultMap="ClassGradeVoResult">
  771. SELECT
  772. cg.*,
  773. g.subject_ids
  774. FROM
  775. class_grade cg
  776. LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
  777. LEFT JOIN goods g ON cgg.goods_id = g.goods_id
  778. </select>
  779. </mapper>