ClassGradeMapper.xml 34 KB

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