ClassGradeMapper.xml 37 KB

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