CourseMapper.xml 32 KB

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