ClassGradeMapper.xml 36 KB

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