CourseMapper.xml 37 KB

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