CourseMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. <result property="goodsLearningOrder" column="goods_learning_order"/>
  203. </resultMap>
  204. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  205. <result property="gradeId" column="grade_id"/>
  206. <result property="classStatus" column="class_status"/>
  207. <result property="officialName" column="official_name"/>
  208. <result property="className" column="class_name"/>
  209. <result property="studentUpper" column="student_upper"/>
  210. <result property="learningTimeStart" column="learning_time_start"/>
  211. <result property="learningStatus" column="learning_status"/>
  212. <result property="status" column="status"/>
  213. <result property="classStartTime" column="class_start_time"/>
  214. <result property="classEndTime" column="class_end_time"/>
  215. <result property="examineId" column="examine_id"/>
  216. <result property="areasId" column="areas_id"/>
  217. <result property="sysUserId" column="sys_user_id"/>
  218. <result property="interfacePushId" column="interface_push_id"/>
  219. <result property="remark" column="remark"/>
  220. <result property="interfaceAccountId" column="interface_account_id"/>
  221. <result property="interfacePeriodId" column="interface_period_id"/>
  222. <result property="interfaceAccountName" column="interface_account_name"/>
  223. <result property="interfacePeriodName" column="interface_period_name"/>
  224. <result property="interfacePushName" column="interface_push_name"/>
  225. <result property="studentNum" column="student_num"/>
  226. <result property="periodStatus" column="period_status"/>
  227. <result property="examNum" column="exam_num"/>
  228. <result property="recordNum" column="record_num"/>
  229. <result property="interfacePushId" column="interface_push_id"/>
  230. <result property="interfaceAccountId" column="interface_account_id"/>
  231. <result property="officialLearningUrl" column="official_learning_url"/>
  232. <result property="learnStatus" column="learn_status"/>
  233. <result property="officialStatus" column="official_status"/>
  234. <result property="periodPlush" column="period_plush"/>
  235. <result property="orderGoodsId" column="order_goods_id"/>
  236. <result property="officialName" column="official_name"/>
  237. </resultMap>
  238. <select id="findGoodsList" resultMap="CourseGoodsListResult">
  239. SELECT
  240. g.goods_name,
  241. g.goods_id
  242. FROM
  243. goods_course gc
  244. LEFT JOIN goods g ON gc.goods_id = g.goods_id
  245. WHERE
  246. gc.course_id =#{course_id}
  247. </select>
  248. <resultMap type="com.zhongzheng.modules.course.vo.CourseGoodsVo" id="CourseGoodsListResult">
  249. <result property="goodsName" column="goods_name"/>
  250. <result property="goodsId" column="goods_id"/>
  251. </resultMap>
  252. <select id="selectCourseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseResultVo">
  253. SELECT
  254. c.*,
  255. cet.education_name,
  256. cpt.project_name,
  257. cb.business_name,
  258. s.school_name,
  259. m.category_name,
  260. cs.subject_name
  261. FROM
  262. course c
  263. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id AND cet.status =1
  264. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id AND cpt.status =1
  265. LEFT JOIN course_business cb ON c.business_id = cb.id AND cb.status =1
  266. LEFT JOIN school s ON s.id = c.school_id AND s.status =1
  267. LEFT JOIN major m ON c.major_id = m.id AND m.status =1
  268. LEFT JOIN course_subject cs ON cs.id = c.subject_id AND cs.status =1
  269. WHERE
  270. 1 = 1 AND c.status !=-1 AND c.course_show =1
  271. <if test="subjectIds != null and subjectIds.size()!=0 ">
  272. AND c.subject_id in
  273. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  274. #{item}
  275. </foreach>
  276. </if>
  277. <if test="status != null and status.size()!=0 ">
  278. AND c.status in
  279. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  280. #{item}
  281. </foreach>
  282. </if>
  283. <if test="educationTypeId != null and educationTypeId != ''">
  284. AND c.education_type_id = #{educationTypeId}
  285. </if>
  286. <if test="subjectId != null and subjectId != ''">
  287. AND c.subject_id = #{subjectId}
  288. </if>
  289. <if test="businessId != null and businessId != ''">
  290. AND c.business_id = #{businessId}
  291. </if>
  292. <if test="prefixName != null and prefixName != ''">
  293. AND c.prefix_name like concat('%', #{prefixName}, '%')
  294. </if>
  295. <if test="courseName != null and courseName != ''">
  296. AND c.course_name like concat('%', #{courseName}, '%')
  297. </if>
  298. <if test="publishStatus != null ">
  299. AND c.publish_status = #{publishStatus}
  300. </if>
  301. <if test="schoolId != null and schoolId != ''">
  302. AND c.school_id = #{schoolId}
  303. </if>
  304. <if test="majorId != null and majorId != ''">
  305. AND c.major_id = #{majorId}
  306. </if>
  307. <if test="key != null and key != ''">
  308. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  309. </if>
  310. GROUP BY
  311. c.course_id
  312. ORDER BY c.create_time DESC
  313. </select>
  314. <select id="selectCourseList_COUNT" resultType="Long">
  315. SELECT
  316. count(distinct c.course_id )
  317. FROM
  318. course c
  319. WHERE
  320. 1 = 1 AND c.status !=-1 AND c.course_show =1
  321. <if test="subjectIds != null and subjectIds.size()!=0 ">
  322. AND c.subject_id in
  323. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  324. #{item}
  325. </foreach>
  326. </if>
  327. <if test="status != null and status.size()!=0 ">
  328. AND c.status in
  329. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  330. #{item}
  331. </foreach>
  332. </if>
  333. <if test="educationTypeId != null and educationTypeId != ''">
  334. AND c.education_type_id = #{educationTypeId}
  335. </if>
  336. <if test="subjectId != null and subjectId != ''">
  337. AND c.subject_id = #{subjectId}
  338. </if>
  339. <if test="businessId != null and businessId != ''">
  340. AND c.business_id = #{businessId}
  341. </if>
  342. <if test="prefixName != null and prefixName != ''">
  343. AND c.prefix_name like concat('%', #{prefixName}, '%')
  344. </if>
  345. <if test="courseName != null and courseName != ''">
  346. AND c.course_name like concat('%', #{courseName}, '%')
  347. </if>
  348. <if test="publishStatus != null ">
  349. AND c.publish_status = #{publishStatus}
  350. </if>
  351. <if test="schoolId != null and schoolId != ''">
  352. AND c.school_id = #{schoolId}
  353. </if>
  354. <if test="majorId != null and majorId != ''">
  355. AND c.major_id = #{majorId}
  356. </if>
  357. <if test="key != null and key != ''">
  358. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  359. </if>
  360. </select>
  361. <select id="selectDetailById" parameterType="Long" resultMap="CourseResultVo">
  362. SELECT
  363. c.*,
  364. cet.education_name,
  365. cpt.project_name,
  366. cb.business_name,
  367. s.school_name,
  368. m.category_name,
  369. cs.subject_name
  370. FROM
  371. course c
  372. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  373. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  374. LEFT JOIN course_business cb ON c.business_id = cb.id
  375. LEFT JOIN school s ON s.id = c.school_id
  376. LEFT JOIN major m ON c.major_id = m.id
  377. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  378. WHERE
  379. course_id = #{id}
  380. </select>
  381. <select id="getCourseUserVoInfo" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserVo">
  382. SELECT
  383. c.*,
  384. cet.education_name,
  385. cpt.project_name,
  386. cb.business_name,
  387. s.school_name,
  388. m.category_name,
  389. cs.subject_name
  390. FROM
  391. course c
  392. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  393. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  394. LEFT JOIN course_business cb ON c.business_id = cb.id
  395. LEFT JOIN school s ON s.id = c.school_id
  396. LEFT JOIN major m ON c.major_id = m.id
  397. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  398. WHERE
  399. course_id = #{id}
  400. </select>
  401. <select id="listGoodsPeriodVo" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo" resultMap="GoodsPeriodVo">
  402. SELECT
  403. g.goods_id,
  404. g.goods_name,
  405. g.`year`,
  406. cgu.period_status,
  407. (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,
  408. (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,
  409. cgu.grade_id,
  410. (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,
  411. (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,
  412. (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,
  413. cgu.order_goods_id,
  414. og.service_start_time,
  415. og.service_end_time,
  416. cg.class_start_time,
  417. cg.class_end_time,
  418. cg.learning_status,
  419. cgu.official_status,
  420. cg.learning_time_start,
  421. cg.class_status,
  422. cg.interface_push_id,
  423. cb.business_name,
  424. g.business_id,
  425. cet.education_name,
  426. cpt.project_name,
  427. cb.business_name,
  428. cg.official_name
  429. FROM
  430. class_grade_user cgu
  431. LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  432. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  433. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  434. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  435. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  436. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  437. LEFT JOIN course_business cb ON g.business_id = cb.id
  438. WHERE
  439. cgu.user_id =#{userId}
  440. AND cg.status=1 AND cgu.`status`=1 AND cgu.change_grade=0
  441. <if test="educationTypeId != null and educationTypeId != ''">
  442. AND g.education_type_id = #{educationTypeId}
  443. </if>
  444. <if test="businessId != null and businessId != ''">
  445. AND g.business_id = #{businessId}
  446. </if>
  447. ORDER BY cgu.create_time DESC
  448. </select>
  449. <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="GoodsPeriodStatusVo">
  450. SELECT
  451. ups.id,
  452. ups.period_id,
  453. cs.`name`,
  454. 1 as type,
  455. cs.section_type as section_type,
  456. ups.audit_reason
  457. FROM
  458. user_period up
  459. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  460. LEFT JOIN course_section cs ON cs.section_id = up.section_id
  461. WHERE
  462. 1 = 1
  463. AND user_id = #{userId}
  464. AND ups.period_status = 1
  465. AND ups.`status` = 0
  466. AND up.exam_id = 0
  467. and up.grade_id = #{gradeId}
  468. UNION
  469. SELECT
  470. ups.id,
  471. ups.period_id,
  472. exam_name as name,
  473. 2 as type,
  474. 0 as section_type,
  475. ups.audit_reason
  476. FROM
  477. user_period up
  478. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  479. LEFT JOIN exam e ON e.exam_id = up.exam_id
  480. WHERE
  481. 1 = 1
  482. AND user_id = #{userId}
  483. AND ups.period_status = 1
  484. AND ups.`status` = 0
  485. AND up.section_id = 0
  486. and up.grade_id = #{gradeId}
  487. </select>
  488. <select id="goodsRebuildStatus" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="Long">
  489. 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
  490. </select>
  491. <select id="goodsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  492. SELECT
  493. g.*,
  494. o.user_id,
  495. og.study_count as order_study_count,
  496. og.order_goods_id,
  497. og.grade_id,
  498. og.service_start_time,
  499. og.service_end_time,
  500. cb.goods_learning_order,
  501. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  502. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  503. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  504. (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  505. (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,
  506. (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,
  507. (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,
  508. (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,
  509. (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,
  510. (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,
  511. (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,
  512. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  513. <if test="userId != null and userId != ''">
  514. ,
  515. us.exam_status as sub_exam_status,
  516. us.performance as sub_performance,
  517. us.`result` as sub_result,
  518. us.subscribe_id,
  519. us.apply_site_start_time as sub_apply_site_start_time,
  520. us.apply_site_end_time as sub_apply_site_end_time,
  521. us.apply_site_exam_time as sub_apply_site_exam_time
  522. </if>
  523. FROM
  524. `order` o
  525. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  526. LEFT JOIN goods g on og.goods_id = g.goods_id
  527. LEFT JOIN course_business cb on g.business_id = cb.id
  528. <if test="userId != null and userId != ''">
  529. 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
  530. </if>
  531. where 1=1
  532. AND og.`status` = 1
  533. AND og.refund_status in (0,1,3)
  534. AND og.pay_status in (2,3,4)
  535. AND g.goods_type =1
  536. <if test="pageNum == null">
  537. 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
  538. </if>
  539. <if test="userId != null and userId != ''">
  540. and o.user_id = #{userId}
  541. </if>
  542. <if test="educationTypeId != null and educationTypeId != ''">
  543. AND g.education_type_id = #{educationTypeId}
  544. </if>
  545. <if test="businessId != null and businessId != ''">
  546. AND g.business_id = #{businessId}
  547. </if>
  548. <if test="orderGoodsId != null and orderGoodsId != ''">
  549. AND og.order_goods_id = #{orderGoodsId}
  550. </if>
  551. order by o.create_time desc
  552. </select>
  553. <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  554. SELECT
  555. c.*,
  556. #{gradeId} as grade_id,
  557. cs.subject_name,
  558. <if test="userId != null ">
  559. (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,
  560. </if>
  561. IFNULL(ge.exam_num,0) as exam_num
  562. FROM
  563. course c
  564. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  565. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  566. LEFT JOIN (SELECT
  567. COUNT( m.id ) AS exam_num,
  568. m.course_id
  569. FROM
  570. course_menu_exam m
  571. where
  572. m.type in (1,3) GROUP BY m.course_id
  573. ) ge on gc.course_id = ge.course_id
  574. where 1=1
  575. and gc.goods_id =#{goodsId}
  576. order by gc.sort asc
  577. </select>
  578. <select id="courseExamNum" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  579. SELECT
  580. c.*,
  581. #{gradeId} as grade_id
  582. FROM
  583. course c
  584. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  585. where 1=1
  586. and gc.goods_id =#{goodsId}
  587. order by gc.sort asc
  588. </select>
  589. <select id="rebuildNext" parameterType="Long" resultType="Long">
  590. SELECT
  591. COUNT( 1 )
  592. FROM
  593. user_period up
  594. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  595. WHERE
  596. up.goods_id = #{goodsId}
  597. AND up.grade_id = #{gradeId}
  598. AND ups.`status` = 0
  599. AND ups.period_status = 1
  600. </select>
  601. <select id="gradeIdSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  602. SELECT
  603. (SELECT
  604. COUNT( m.id )
  605. FROM
  606. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  607. where
  608. m.type in (1,3)
  609. and c.goods_id = #{goodsId}) as exam_num,
  610. (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
  611. = 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,
  612. cgu.grade_id,
  613. cg.class_start_time,
  614. cg.class_end_time,
  615. cg.class_status,
  616. cg.status,
  617. cg.learning_status,
  618. cgu.period_status,
  619. cg.learning_time_start,
  620. cgu.learn_status,
  621. cg.interface_account_id,
  622. cg.official_learning_url,
  623. cg.interface_push_id,
  624. cgu.official_status,
  625. cgu.period_plush,
  626. cgu.order_goods_id,
  627. cg.official_name
  628. FROM
  629. class_grade_user cgu
  630. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  631. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  632. WHERE
  633. 1=1
  634. <if test="gradeId != null and gradeId != ''">
  635. and cg.grade_id = #{gradeId}
  636. </if>
  637. and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  638. order by cg.create_time desc LIMIT 1
  639. </select>
  640. <select id="checkCourseHaveStudy" parameterType="Long" resultType="Long">
  641. SELECT
  642. count(*)
  643. FROM
  644. user_period up
  645. LEFT JOIN goods_course gc ON gc.goods_id = up.goods_id
  646. WHERE
  647. gc.course_id = #{courseId}
  648. </select>
  649. </mapper>