CourseMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  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.course.mapper.CourseMapper">
  6. <resultMap type="com.zhongzheng.modules.course.domain.Course" id="CourseResult">
  7. <result property="courseId" column="course_id"/>
  8. <result property="prefixName" column="prefix_name"/>
  9. <result property="coverUrl" column="cover_url"/>
  10. <result property="introduction" column="introduction"/>
  11. <result property="createTime" column="create_time"/>
  12. <result property="updateTime" column="update_time"/>
  13. <result property="status" column="status"/>
  14. <result property="educationTypeId" column="education_type_id"/>
  15. <result property="businessId" column="business_id"/>
  16. <result property="schoolId" column="school_id"/>
  17. <result property="courseName" column="course_name"/>
  18. <result property="publishStatus" column="publish_status"/>
  19. <result property="sort" column="sort"/>
  20. <result property="suitableObject" column="suitable_object"/>
  21. <result property="pcDetailHtml" column="pc_detail_html"/>
  22. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  23. <result property="majorId" column="major_id"/>
  24. <result property="code" column="code"/>
  25. <result property="subjectId" column="subject_id"/>
  26. <result property="projectId" column="project_id"/>
  27. <result property="courseShow" column="course_show"/>
  28. </resultMap>
  29. <resultMap type="com.zhongzheng.modules.course.vo.CourseVo" id="CourseResultVo">
  30. <result property="courseId" column="course_id"/>
  31. <result property="prefixName" column="prefix_name"/>
  32. <result property="coverUrl" column="cover_url"/>
  33. <result property="introduction" column="introduction"/>
  34. <result property="status" column="status"/>
  35. <result property="educationTypeId" column="education_type_id"/>
  36. <result property="businessId" column="business_id"/>
  37. <result property="schoolId" column="school_id"/>
  38. <result property="courseName" column="course_name"/>
  39. <result property="publishStatus" column="publish_status"/>
  40. <result property="sort" column="sort"/>
  41. <result property="suitableObject" column="suitable_object"/>
  42. <result property="pcDetailHtml" column="pc_detail_html"/>
  43. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  44. <result property="majorId" column="major_id"/>
  45. <result property="code" column="code"/>
  46. <result property="subjectId" column="subject_id"/>
  47. <result property="projectId" column="project_id"/>
  48. <result property="createTime" column="create_time"/>
  49. <result property="updateTime" column="update_time"/>
  50. <result property="educationName" column="education_name"/>
  51. <result property="projectName" column="project_name"/>
  52. <result property="businessName" column="business_name"/>
  53. <result property="schoolName" column="school_name"/>
  54. <result property="categoryName" column="category_name"/>
  55. <result property="subjectName" column="subject_name"/>
  56. <result property="courseShow" column="course_show"/>
  57. <collection property="goodsList" column="course_id" select="findGoodsList"/>
  58. </resultMap>
  59. <resultMap type="com.zhongzheng.modules.course.vo.CourseUserVo" id="CourseUserVo">
  60. <result property="courseId" column="course_id"/>
  61. <result property="prefixName" column="prefix_name"/>
  62. <result property="coverUrl" column="cover_url"/>
  63. <result property="gradeId" column="grade_id"/>
  64. <result property="introduction" column="introduction"/>
  65. <result property="status" column="status"/>
  66. <result property="educationTypeId" column="education_type_id"/>
  67. <result property="businessId" column="business_id"/>
  68. <result property="schoolId" column="school_id"/>
  69. <result property="courseName" column="course_name"/>
  70. <result property="publishStatus" column="publish_status"/>
  71. <result property="sort" column="sort"/>
  72. <result property="suitableObject" column="suitable_object"/>
  73. <result property="pcDetailHtml" column="pc_detail_html"/>
  74. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  75. <result property="majorId" column="major_id"/>
  76. <result property="code" column="code"/>
  77. <result property="subjectId" column="subject_id"/>
  78. <result property="projectId" column="project_id"/>
  79. <result property="createTime" column="create_time"/>
  80. <result property="updateTime" column="update_time"/>
  81. <result property="educationName" column="education_name"/>
  82. <result property="projectName" column="project_name"/>
  83. <result property="businessName" column="business_name"/>
  84. <result property="schoolName" column="school_name"/>
  85. <result property="categoryName" column="category_name"/>
  86. <result property="subjectName" column="subject_name"/>
  87. <result property="examNum" column="exam_num"/>
  88. <result property="recordNum" column="record_num"/>
  89. </resultMap>
  90. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsPeriodVo" id="GoodsPeriodVo">
  91. <result property="goodsId" column="goods_id"/>
  92. <result property="year" column="year"/>
  93. <result property="goodsName" column="goods_name"/>
  94. <result property="periodStatus" column="period_status"/>
  95. <result property="rebuild" column="rebuild"/>
  96. <result property="gradeId" column="grade_id"/>
  97. <result property="examNum" column="exam_num"/>
  98. <result property="recordNum" column="record_num"/>
  99. <result property="applyStatus" column="apply_status"/>
  100. <result property="beforeStatus" column="before_status"/>
  101. <result property="applyName" column="apply_name"/>
  102. <result property="beforeName" column="before_name"/>
  103. <result property="rebuildNum" column="rebuildNum"/>
  104. <result property="rebuildStatus" column="rebuild_status"/>
  105. <result property="orderGoodsId" column="order_goods_id"/>
  106. <result property="serviceStartTime" column="service_start_time"/>
  107. <result property="serviceEndTime" column="service_end_time"/>
  108. <result property="classStartTime" column="class_start_time"/>
  109. <result property="classEndTime" column="class_end_time"/>
  110. <result property="learningStatus" column="learning_status"/>
  111. <result property="classStatus" column="class_status"/>
  112. <result property="learningTimeStart" column="learning_time_start"/>
  113. <result property="interfacePushId" column="interface_push_id"/>
  114. <result property="officialStatus" column="official_status"/>
  115. <result property="businessId" column="business_id"/>
  116. <result property="educationName" column="education_name"/>
  117. <result property="projectName" column="project_name"/>
  118. <result property="businessName" column="business_name"/>
  119. <result property="officialName" column="official_name"/>
  120. </resultMap>
  121. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo" id="GoodsPeriodStatusVo">
  122. <result property="id" column="id"/>
  123. <result property="type" column="type"/>
  124. <result property="name" column="name"/>
  125. <result property="periodId" column="period_id"/>
  126. <result property="sectionType" column="section_type"/>
  127. <result property="auditReason" column="audit_reason"/>
  128. </resultMap>
  129. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsUserVo" id="GoodsUserVo">
  130. <result property="goodsId" column="goods_id"/>
  131. <result property="year" column="year"/>
  132. <result property="supplyId" column="supply_id"/>
  133. <result property="userId" column="user_id"/>
  134. <result property="goodsType" column="goods_type"/>
  135. <result property="educationTypeId" column="education_type_id"/>
  136. <result property="businessId" column="business_id"/>
  137. <result property="schoolId" column="school_id"/>
  138. <result property="majorId" column="major_id"/>
  139. <result property="goodsName" column="goods_name"/>
  140. <result property="standPrice" column="stand_price"/>
  141. <result property="lowestPrice" column="lowest_price"/>
  142. <result property="createTime" column="create_time"/>
  143. <result property="updateTime" column="update_time"/>
  144. <result property="status" column="status"/>
  145. <result property="validityStartTime" column="validity_start_time"/>
  146. <result property="validityEndTime" column="validity_end_time"/>
  147. <result property="studyStartTime" column="study_start_time"/>
  148. <result property="studyEndTime" column="study_end_time"/>
  149. <result property="certificateIds" column="certificate_ids"/>
  150. <result property="introduce" column="introduce"/>
  151. <result property="suitableObject" column="suitable_object"/>
  152. <result property="buyNote" column="buy_note"/>
  153. <result property="pcDetailHtml" column="pc_detail_html"/>
  154. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  155. <result property="goodsStatus" column="goods_status"/>
  156. <result property="coverUrl" column="cover_url"/>
  157. <result property="classHours" column="class_hours"/>
  158. <result property="standPriceJson" column="stand_price_json"/>
  159. <result property="code" column="code"/>
  160. <result property="projectId" column="project_id"/>
  161. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  162. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  163. <result property="goodsPlayConfig" column="goods_play_config"/>
  164. <result property="goodsExamConfig" column="goods_exam_config"/>
  165. <result property="gradeId" column="grade_id"/>
  166. <result property="rebuildStatus" column="rebuild_status"/>
  167. <result property="sectionMaxNum" column="section_max_num"/>
  168. <result property="supplyName" column="supply_name"/>
  169. <result property="educationName" column="education_name"/>
  170. <result property="projectName" column="project_name"/>
  171. <result property="businessName" column="business_name"/>
  172. <result property="schoolName" column="school_name"/>
  173. <result property="categoryName" column="category_name"/>
  174. <result property="handoutsId" column="handouts_id"/>
  175. <result property="templateType" column="template_type"/>
  176. <result property="period" column="period"/>
  177. <result property="makeStartTime" column="make_start_time"/>
  178. <result property="makeEndTime" column="make_end_time"/>
  179. <result property="studyCount" column="order_study_count"/>
  180. <result property="makeGoodsName" column="make_goods_name"/>
  181. <result property="makeGoodsCode" column="make_goods_code"/>
  182. <result property="applyStatus" column="apply_status"/>
  183. <result property="beforeStatus" column="before_status"/>
  184. <result property="applyName" column="apply_name"/>
  185. <result property="beforeName" column="before_name"/>
  186. <result property="courseNum" column="course_num"/>
  187. <result property="orderGoodsId" column="order_goods_id"/>
  188. <result property="profileStatus" column="profile_status"/>
  189. <result property="profileTpStatus" column="profile_tp_status"/>
  190. <result property="subExamStatus" column="sub_exam_status"/>
  191. <result property="subPerformance" column="sub_performance"/>
  192. <result property="subResult" column="sub_result"/>
  193. <result property="subApplySiteStartTime" column="sub_apply_site_start_time"/>
  194. <result property="subApplySiteEndTime" column="sub_apply_site_end_time"/>
  195. <result property="subApplySiteExamTime" column="sub_apply_site_exam_time"/>
  196. <result property="gradeId" column="grade_id"/>
  197. <result property="subscribeId" column="subscribe_id"/>
  198. <result property="serviceStartTime" column="service_start_time"/>
  199. <result property="serviceEndTime" column="service_end_time"/>
  200. <result property="subjectNames" column="subject_names"/>
  201. <result property="sectionNum" column="section_num"/>
  202. </resultMap>
  203. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  204. <result property="gradeId" column="grade_id"/>
  205. <result property="classStatus" column="class_status"/>
  206. <result property="officialName" column="official_name"/>
  207. <result property="className" column="class_name"/>
  208. <result property="studentUpper" column="student_upper"/>
  209. <result property="learningTimeStart" column="learning_time_start"/>
  210. <result property="learningStatus" column="learning_status"/>
  211. <result property="status" column="status"/>
  212. <result property="classStartTime" column="class_start_time"/>
  213. <result property="classEndTime" column="class_end_time"/>
  214. <result property="examineId" column="examine_id"/>
  215. <result property="areasId" column="areas_id"/>
  216. <result property="sysUserId" column="sys_user_id"/>
  217. <result property="interfacePushId" column="interface_push_id"/>
  218. <result property="remark" column="remark"/>
  219. <result property="interfaceAccountId" column="interface_account_id"/>
  220. <result property="interfacePeriodId" column="interface_period_id"/>
  221. <result property="interfaceAccountName" column="interface_account_name"/>
  222. <result property="interfacePeriodName" column="interface_period_name"/>
  223. <result property="interfacePushName" column="interface_push_name"/>
  224. <result property="studentNum" column="student_num"/>
  225. <result property="periodStatus" column="period_status"/>
  226. <result property="examNum" column="exam_num"/>
  227. <result property="recordNum" column="record_num"/>
  228. <result property="interfacePushId" column="interface_push_id"/>
  229. <result property="interfaceAccountId" column="interface_account_id"/>
  230. <result property="officialLearningUrl" column="official_learning_url"/>
  231. <result property="learnStatus" column="learn_status"/>
  232. <result property="officialStatus" column="official_status"/>
  233. <result property="periodPlush" column="period_plush"/>
  234. <result property="orderGoodsId" column="order_goods_id"/>
  235. <result property="officialName" column="official_name"/>
  236. </resultMap>
  237. <select id="findGoodsList" resultMap="CourseGoodsListResult">
  238. SELECT
  239. g.goods_name,
  240. g.goods_id
  241. FROM
  242. goods_course gc
  243. LEFT JOIN goods g ON gc.goods_id = g.goods_id
  244. WHERE
  245. gc.course_id =#{course_id}
  246. </select>
  247. <resultMap type="com.zhongzheng.modules.course.vo.CourseGoodsVo" id="CourseGoodsListResult">
  248. <result property="goodsName" column="goods_name"/>
  249. <result property="goodsId" column="goods_id"/>
  250. </resultMap>
  251. <select id="selectCourseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseResultVo">
  252. SELECT
  253. c.*,
  254. cet.education_name,
  255. cpt.project_name,
  256. cb.business_name,
  257. s.school_name,
  258. m.category_name,
  259. cs.subject_name
  260. FROM
  261. course c
  262. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id AND cet.status =1
  263. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id AND cpt.status =1
  264. LEFT JOIN course_business cb ON c.business_id = cb.id AND cb.status =1
  265. LEFT JOIN school s ON s.id = c.school_id AND s.status =1
  266. LEFT JOIN major m ON c.major_id = m.id AND m.status =1
  267. LEFT JOIN course_subject cs ON cs.id = c.subject_id AND cs.status =1
  268. WHERE
  269. 1 = 1 AND c.status !=-1 AND c.course_show =1
  270. <if test="subjectIds != null and subjectIds.size()!=0 ">
  271. AND c.subject_id in
  272. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  273. #{item}
  274. </foreach>
  275. </if>
  276. <if test="status != null and status.size()!=0 ">
  277. AND c.status in
  278. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  279. #{item}
  280. </foreach>
  281. </if>
  282. <if test="educationTypeId != null and educationTypeId != ''">
  283. AND c.education_type_id = #{educationTypeId}
  284. </if>
  285. <if test="subjectId != null and subjectId != ''">
  286. AND c.subject_id = #{subjectId}
  287. </if>
  288. <if test="businessId != null and businessId != ''">
  289. AND c.business_id = #{businessId}
  290. </if>
  291. <if test="prefixName != null and prefixName != ''">
  292. AND c.prefix_name like concat('%', #{prefixName}, '%')
  293. </if>
  294. <if test="courseName != null and courseName != ''">
  295. AND c.course_name like concat('%', #{courseName}, '%')
  296. </if>
  297. <if test="publishStatus != null ">
  298. AND c.publish_status = #{publishStatus}
  299. </if>
  300. <if test="schoolId != null and schoolId != ''">
  301. AND c.school_id = #{schoolId}
  302. </if>
  303. <if test="majorId != null and majorId != ''">
  304. AND c.major_id = #{majorId}
  305. </if>
  306. <if test="key != null and key != ''">
  307. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  308. </if>
  309. GROUP BY
  310. c.course_id
  311. ORDER BY c.create_time DESC
  312. </select>
  313. <select id="selectCourseList_COUNT" resultType="Long">
  314. SELECT
  315. count(distinct c.course_id )
  316. FROM
  317. course c
  318. WHERE
  319. 1 = 1 AND c.status !=-1 AND c.course_show =1
  320. <if test="subjectIds != null and subjectIds.size()!=0 ">
  321. AND c.subject_id in
  322. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  323. #{item}
  324. </foreach>
  325. </if>
  326. <if test="status != null and status.size()!=0 ">
  327. AND c.status in
  328. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  329. #{item}
  330. </foreach>
  331. </if>
  332. <if test="educationTypeId != null and educationTypeId != ''">
  333. AND c.education_type_id = #{educationTypeId}
  334. </if>
  335. <if test="subjectId != null and subjectId != ''">
  336. AND c.subject_id = #{subjectId}
  337. </if>
  338. <if test="businessId != null and businessId != ''">
  339. AND c.business_id = #{businessId}
  340. </if>
  341. <if test="prefixName != null and prefixName != ''">
  342. AND c.prefix_name like concat('%', #{prefixName}, '%')
  343. </if>
  344. <if test="courseName != null and courseName != ''">
  345. AND c.course_name like concat('%', #{courseName}, '%')
  346. </if>
  347. <if test="publishStatus != null ">
  348. AND c.publish_status = #{publishStatus}
  349. </if>
  350. <if test="schoolId != null and schoolId != ''">
  351. AND c.school_id = #{schoolId}
  352. </if>
  353. <if test="majorId != null and majorId != ''">
  354. AND c.major_id = #{majorId}
  355. </if>
  356. <if test="key != null and key != ''">
  357. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  358. </if>
  359. </select>
  360. <select id="selectDetailById" parameterType="Long" resultMap="CourseResultVo">
  361. SELECT
  362. c.*,
  363. cet.education_name,
  364. cpt.project_name,
  365. cb.business_name,
  366. s.school_name,
  367. m.category_name,
  368. cs.subject_name
  369. FROM
  370. course c
  371. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  372. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  373. LEFT JOIN course_business cb ON c.business_id = cb.id
  374. LEFT JOIN school s ON s.id = c.school_id
  375. LEFT JOIN major m ON c.major_id = m.id
  376. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  377. WHERE
  378. course_id = #{id}
  379. </select>
  380. <select id="getCourseUserVoInfo" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserVo">
  381. SELECT
  382. c.*,
  383. cet.education_name,
  384. cpt.project_name,
  385. cb.business_name,
  386. s.school_name,
  387. m.category_name,
  388. cs.subject_name
  389. FROM
  390. course c
  391. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  392. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  393. LEFT JOIN course_business cb ON c.business_id = cb.id
  394. LEFT JOIN school s ON s.id = c.school_id
  395. LEFT JOIN major m ON c.major_id = m.id
  396. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  397. WHERE
  398. course_id = #{id}
  399. </select>
  400. <select id="listGoodsPeriodVo" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo" resultMap="GoodsPeriodVo">
  401. SELECT
  402. g.goods_id,
  403. g.goods_name,
  404. g.`year`,
  405. cgu.period_status,
  406. (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where ups.period_status =1 and (ups.`status` =3 or ups.`status` =0) and up.grade_id = cgu.grade_id and up.user_id = cgu.user_id) as rebuild,
  407. (case WHEN (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where up.grade_id = cgu.grade_id AND ups.period_status =1 and ups.`status` =3 and up.user_id = cgu.user_id ) >0 then 1 ELSE 0 end) as rebuild_status,
  408. cgu.grade_id,
  409. (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id where eag.goods_id = cgg.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
  410. (case WHEN (SELECT COUNT(1) FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) >0 then 1 ELSE 0 end) as before_status,
  411. (SELECT eb.before_name FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = cgg.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) as before_name,
  412. cgu.order_goods_id,
  413. og.service_start_time,
  414. og.service_end_time,
  415. cg.class_start_time,
  416. cg.class_end_time,
  417. cg.learning_status,
  418. cgu.official_status,
  419. cg.learning_time_start,
  420. cg.class_status,
  421. cg.interface_push_id,
  422. cb.business_name,
  423. g.business_id,
  424. cet.education_name,
  425. cpt.project_name,
  426. cb.business_name,
  427. cg.official_name
  428. FROM
  429. class_grade_user cgu
  430. LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  431. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  432. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  433. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  434. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  435. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  436. LEFT JOIN course_business cb ON g.business_id = cb.id
  437. WHERE
  438. cgu.user_id =#{userId}
  439. AND cg.status=1 AND cgu.`status`=1 AND cgu.change_grade=0
  440. <if test="educationTypeId != null and educationTypeId != ''">
  441. AND g.education_type_id = #{educationTypeId}
  442. </if>
  443. <if test="businessId != null and businessId != ''">
  444. AND g.business_id = #{businessId}
  445. </if>
  446. ORDER BY cgu.create_time DESC
  447. </select>
  448. <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="GoodsPeriodStatusVo">
  449. SELECT
  450. ups.id,
  451. ups.period_id,
  452. cs.`name`,
  453. 1 as type,
  454. cs.section_type as section_type,
  455. ups.audit_reason
  456. FROM
  457. user_period up
  458. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  459. LEFT JOIN course_section cs ON cs.section_id = up.section_id
  460. WHERE
  461. 1 = 1
  462. AND user_id = #{userId}
  463. AND ups.period_status = 1
  464. AND ups.`status` = 0
  465. AND up.exam_id = 0
  466. and up.grade_id = #{gradeId}
  467. UNION
  468. SELECT
  469. ups.id,
  470. ups.period_id,
  471. exam_name as name,
  472. 2 as type,
  473. 0 as section_type,
  474. ups.audit_reason
  475. FROM
  476. user_period up
  477. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  478. LEFT JOIN exam e ON e.exam_id = up.exam_id
  479. WHERE
  480. 1 = 1
  481. AND user_id = #{userId}
  482. AND ups.period_status = 1
  483. AND ups.`status` = 0
  484. AND up.section_id = 0
  485. and up.grade_id = #{gradeId}
  486. </select>
  487. <select id="goodsRebuildStatus" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="Long">
  488. SELECT case WHEN COUNT(1) >0 then 0 ELSE 1 end FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where up.goods_id = #{goodsId} AND ups.period_status =1 and up.user_id = #{userId} and up.grade_id = #{gradeId} and ups.`status` =0
  489. </select>
  490. <select id="goodsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  491. SELECT
  492. g.*,
  493. o.user_id,
  494. og.study_count as order_study_count,
  495. og.order_goods_id,
  496. og.grade_id,
  497. og.service_start_time,
  498. og.service_end_time,
  499. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  500. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  501. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  502. (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  503. (case WHEN (SELECT COUNT(1) FROM user_period up LEFT JOIN user_period_status ups on up.id = ups.period_id where up.goods_id = g.goods_id AND ups.period_status =1 and ups.`status` =0) >0 then 0 ELSE 1 end) as rebuild_status,
  504. (case WHEN (SELECT COUNT(1) FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id LEFT JOIN exam_apply_user eau on eau.apply_id = ea.apply_id where eag.goods_id = g.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time) >0 then 1 ELSE 0 end) as apply_status,
  505. (case WHEN (SELECT COUNT(1) FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = g.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) >0 then 1 ELSE 0 end) as before_status,
  506. (SELECT ea.apply_name FROM exam_apply_goods eag LEFT JOIN exam_apply ea on eag.apply_id = ea.apply_id where eag.goods_id = g.goods_id and ea.`status` = 1 and unix_timestamp(now()) BETWEEN ea.apply_start_time and ea.apply_end_time limit 1) as apply_name,
  507. (SELECT eb.before_name FROM exam_before_goods ebg LEFT JOIN exam_before eb on ebg.before_id = eb.before_id where ebg.goods_id = g.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) as before_name,
  508. (SELECT `status` from user_profile where user_id = o.user_id and goods_id = g.goods_id and current_status = 1 and type_status = 1 and order_goods_id = og.order_goods_id limit 1 ) as profile_status,
  509. (case WHEN(SELECT COUNT(1) from profile_tp where `status`=1 and FIND_IN_SET(g.goods_id,goods_ids) ) >0 then 1 ELSE 0 end) as profile_tp_status,
  510. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  511. <if test="userId != null and userId != ''">
  512. ,
  513. us.exam_status as sub_exam_status,
  514. us.performance as sub_performance,
  515. us.`result` as sub_result,
  516. us.subscribe_id,
  517. us.apply_site_start_time as sub_apply_site_start_time,
  518. us.apply_site_end_time as sub_apply_site_end_time,
  519. us.apply_site_exam_time as sub_apply_site_exam_time
  520. </if>
  521. FROM
  522. `order` o
  523. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  524. LEFT JOIN goods g on og.goods_id = g.goods_id
  525. <if test="userId != null and userId != ''">
  526. LEFT JOIN (SELECT * from user_subscribe where subscribe_id in (SELECT MAX(subscribe_id) from user_subscribe where user_id = #{userId} and subscribe_status = 1 GROUP BY order_goods_id)) us on us.order_goods_id = og.order_goods_id
  527. </if>
  528. where 1=1
  529. AND og.`status` = 1
  530. AND og.refund_status in (0,1,3)
  531. AND og.pay_status in (2,3,4)
  532. AND g.goods_type =1
  533. <if test="pageNum == null">
  534. and (SELECT count(*) from class_grade cg where (cg.class_end_time > unix_timestamp(now()) or ISNULL(cg.class_end_time)) and cg.grade_id = og.grade_id ) >0
  535. </if>
  536. <if test="userId != null and userId != ''">
  537. and o.user_id = #{userId}
  538. </if>
  539. <if test="educationTypeId != null and educationTypeId != ''">
  540. AND g.education_type_id = #{educationTypeId}
  541. </if>
  542. <if test="businessId != null and businessId != ''">
  543. AND g.business_id = #{businessId}
  544. </if>
  545. <if test="orderGoodsId != null and orderGoodsId != ''">
  546. AND og.order_goods_id = #{orderGoodsId}
  547. </if>
  548. order by o.create_time desc
  549. </select>
  550. <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  551. SELECT
  552. c.*,
  553. #{gradeId} as grade_id,
  554. cs.subject_name,
  555. <if test="userId != null ">
  556. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`= 1 and ubr.`type` in (1) and ubr.course_id= gc.course_id and ubr.report_status=1 and ubr.grade_id = #{gradeId} and ubr.user_id = #{userId} and ubr.current_status = 1) as record_num,
  557. </if>
  558. IFNULL(ge.exam_num,0) as exam_num
  559. FROM
  560. course c
  561. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  562. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  563. LEFT JOIN (SELECT
  564. COUNT( m.id ) AS exam_num,
  565. m.course_id
  566. FROM
  567. course_menu_exam m
  568. where
  569. m.type in (1,3) GROUP BY m.course_id
  570. ) ge on gc.course_id = ge.course_id
  571. where 1=1
  572. and gc.goods_id =#{goodsId}
  573. order by gc.sort asc
  574. </select>
  575. <select id="courseExamNum" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  576. SELECT
  577. c.*,
  578. #{gradeId} as grade_id
  579. FROM
  580. course c
  581. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  582. where 1=1
  583. and gc.goods_id =#{goodsId}
  584. order by gc.sort asc
  585. </select>
  586. <select id="rebuildNext" parameterType="Long" resultType="Long">
  587. SELECT
  588. COUNT( 1 )
  589. FROM
  590. user_period up
  591. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  592. WHERE
  593. up.goods_id = #{goodsId}
  594. AND up.grade_id = #{gradeId}
  595. AND ups.`status` = 0
  596. AND ups.period_status = 1
  597. </select>
  598. <select id="gradeIdSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  599. SELECT
  600. (SELECT
  601. COUNT( m.id )
  602. FROM
  603. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  604. where
  605. m.type in (1,3)
  606. and c.goods_id = #{goodsId}) as exam_num,
  607. (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
  608. = ubr.goods_id where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  609. cgu.grade_id,
  610. cg.class_start_time,
  611. cg.class_end_time,
  612. cg.class_status,
  613. cg.status,
  614. cg.learning_status,
  615. cgu.period_status,
  616. cg.learning_time_start,
  617. cgu.learn_status,
  618. cg.interface_account_id,
  619. cg.official_learning_url,
  620. cg.interface_push_id,
  621. cgu.official_status,
  622. cgu.period_plush,
  623. cgu.order_goods_id,
  624. cg.official_name
  625. FROM
  626. class_grade_user cgu
  627. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  628. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  629. WHERE
  630. 1=1
  631. <if test="gradeId != null and gradeId != ''">
  632. and cg.grade_id = #{gradeId}
  633. </if>
  634. and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  635. order by cg.create_time desc LIMIT 1
  636. </select>
  637. <select id="checkCourseHaveStudy" parameterType="Long" resultType="Long">
  638. SELECT
  639. count(*)
  640. FROM
  641. user_period up
  642. LEFT JOIN goods_course gc ON gc.goods_id = up.goods_id
  643. WHERE
  644. gc.course_id = #{courseId}
  645. </select>
  646. </mapper>