CourseMapper.xml 32 KB

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