CourseMapper.xml 38 KB

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