CourseMapper.xml 30 KB

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