CourseMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  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="supplyName" column="supply_name"/>
  169. <result property="educationName" column="education_name"/>
  170. <result property="projectName" column="project_name"/>
  171. <result property="businessName" column="business_name"/>
  172. <result property="schoolName" column="school_name"/>
  173. <result property="categoryName" column="category_name"/>
  174. <result property="handoutsId" column="handouts_id"/>
  175. <result property="templateType" column="template_type"/>
  176. <result property="period" column="period"/>
  177. <result property="makeStartTime" column="make_start_time"/>
  178. <result property="makeEndTime" column="make_end_time"/>
  179. <result property="studyCount" column="order_study_count"/>
  180. <result property="makeGoodsName" column="make_goods_name"/>
  181. <result property="makeGoodsCode" column="make_goods_code"/>
  182. <result property="applyStatus" column="apply_status"/>
  183. <result property="beforeStatus" column="before_status"/>
  184. <result property="applyName" column="apply_name"/>
  185. <result property="beforeName" column="before_name"/>
  186. <result property="courseNum" column="course_num"/>
  187. <result property="orderGoodsId" column="order_goods_id"/>
  188. <result property="profileStatus" column="profile_status"/>
  189. <result property="profileTpStatus" column="profile_tp_status"/>
  190. <result property="subExamStatus" column="sub_exam_status"/>
  191. <result property="subPerformance" column="sub_performance"/>
  192. <result property="subResult" column="sub_result"/>
  193. <result property="subApplySiteStartTime" column="sub_apply_site_start_time"/>
  194. <result property="subApplySiteEndTime" column="sub_apply_site_end_time"/>
  195. <result property="subApplySiteExamTime" column="sub_apply_site_exam_time"/>
  196. <result property="gradeId" column="grade_id"/>
  197. <result property="subscribeId" column="subscribe_id"/>
  198. <result property="serviceStartTime" column="service_start_time"/>
  199. <result property="serviceEndTime" column="service_end_time"/>
  200. <result property="subjectNames" column="subject_names"/>
  201. <result property="sectionNum" column="section_num"/>
  202. <result property="goodsLearningOrder" column="goods_learning_order"/>
  203. </resultMap>
  204. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  205. <result property="gradeId" column="grade_id"/>
  206. <result property="classStatus" column="class_status"/>
  207. <result property="officialName" column="official_name"/>
  208. <result property="className" column="class_name"/>
  209. <result property="studentUpper" column="student_upper"/>
  210. <result property="learningTimeStart" column="learning_time_start"/>
  211. <result property="learningStatus" column="learning_status"/>
  212. <result property="status" column="status"/>
  213. <result property="classStartTime" column="class_start_time"/>
  214. <result property="classEndTime" column="class_end_time"/>
  215. <result property="examineId" column="examine_id"/>
  216. <result property="areasId" column="areas_id"/>
  217. <result property="sysUserId" column="sys_user_id"/>
  218. <result property="interfacePushId" column="interface_push_id"/>
  219. <result property="remark" column="remark"/>
  220. <result property="interfaceAccountId" column="interface_account_id"/>
  221. <result property="interfacePeriodId" column="interface_period_id"/>
  222. <result property="interfaceAccountName" column="interface_account_name"/>
  223. <result property="interfacePeriodName" column="interface_period_name"/>
  224. <result property="interfacePushName" column="interface_push_name"/>
  225. <result property="studentNum" column="student_num"/>
  226. <result property="periodStatus" column="period_status"/>
  227. <result property="examNum" column="exam_num"/>
  228. <result property="recordNum" column="record_num"/>
  229. <result property="interfacePushId" column="interface_push_id"/>
  230. <result property="interfaceAccountId" column="interface_account_id"/>
  231. <result property="officialLearningUrl" column="official_learning_url"/>
  232. <result property="learnStatus" column="learn_status"/>
  233. <result property="officialStatus" column="official_status"/>
  234. <result property="periodPlush" column="period_plush"/>
  235. <result property="orderGoodsId" column="order_goods_id"/>
  236. <result property="officialName" column="official_name"/>
  237. <result property="userId" column="user_id"/>
  238. </resultMap>
  239. <select id="findGoodsList" resultMap="CourseGoodsListResult">
  240. SELECT
  241. g.goods_name,
  242. g.goods_id
  243. FROM
  244. goods_course gc
  245. LEFT JOIN goods g ON gc.goods_id = g.goods_id
  246. WHERE
  247. gc.course_id =#{course_id}
  248. </select>
  249. <resultMap type="com.zhongzheng.modules.course.vo.CourseGoodsVo" id="CourseGoodsListResult">
  250. <result property="goodsName" column="goods_name"/>
  251. <result property="goodsId" column="goods_id"/>
  252. </resultMap>
  253. <select id="selectCourseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseResultVo">
  254. SELECT
  255. c.*,
  256. cet.education_name,
  257. cpt.project_name,
  258. cb.business_name,
  259. s.school_name,
  260. m.category_name,
  261. cs.subject_name
  262. FROM
  263. course c
  264. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id AND cet.status =1
  265. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id AND cpt.status =1
  266. LEFT JOIN course_business cb ON c.business_id = cb.id AND cb.status =1
  267. LEFT JOIN school s ON s.id = c.school_id AND s.status =1
  268. LEFT JOIN major m ON c.major_id = m.id AND m.status =1
  269. LEFT JOIN course_subject cs ON cs.id = c.subject_id AND cs.status =1
  270. WHERE
  271. 1 = 1 AND c.status !=-1 AND c.course_show =1
  272. <if test="subjectIds != null and subjectIds.size()!=0 ">
  273. AND c.subject_id in
  274. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  275. #{item}
  276. </foreach>
  277. </if>
  278. <if test="status != null and status.size()!=0 ">
  279. AND c.status in
  280. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  281. #{item}
  282. </foreach>
  283. </if>
  284. <if test="educationTypeId != null and educationTypeId != ''">
  285. AND c.education_type_id = #{educationTypeId}
  286. </if>
  287. <if test="subjectId != null and subjectId != ''">
  288. AND c.subject_id = #{subjectId}
  289. </if>
  290. <if test="businessId != null and businessId != ''">
  291. AND c.business_id = #{businessId}
  292. </if>
  293. <if test="prefixName != null and prefixName != ''">
  294. AND c.prefix_name like concat('%', #{prefixName}, '%')
  295. </if>
  296. <if test="courseName != null and courseName != ''">
  297. AND c.course_name like concat('%', #{courseName}, '%')
  298. </if>
  299. <if test="publishStatus != null ">
  300. AND c.publish_status = #{publishStatus}
  301. </if>
  302. <if test="schoolId != null and schoolId != ''">
  303. AND c.school_id = #{schoolId}
  304. </if>
  305. <if test="majorId != null and majorId != ''">
  306. AND c.major_id = #{majorId}
  307. </if>
  308. <if test="key != null and key != ''">
  309. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  310. </if>
  311. GROUP BY
  312. c.course_id
  313. ORDER BY c.create_time DESC
  314. </select>
  315. <select id="selectCourseList_COUNT" resultType="Long">
  316. SELECT
  317. count(distinct c.course_id )
  318. FROM
  319. course c
  320. WHERE
  321. 1 = 1 AND c.status !=-1 AND c.course_show =1
  322. <if test="subjectIds != null and subjectIds.size()!=0 ">
  323. AND c.subject_id in
  324. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  325. #{item}
  326. </foreach>
  327. </if>
  328. <if test="status != null and status.size()!=0 ">
  329. AND c.status in
  330. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  331. #{item}
  332. </foreach>
  333. </if>
  334. <if test="educationTypeId != null and educationTypeId != ''">
  335. AND c.education_type_id = #{educationTypeId}
  336. </if>
  337. <if test="subjectId != null and subjectId != ''">
  338. AND c.subject_id = #{subjectId}
  339. </if>
  340. <if test="businessId != null and businessId != ''">
  341. AND c.business_id = #{businessId}
  342. </if>
  343. <if test="prefixName != null and prefixName != ''">
  344. AND c.prefix_name like concat('%', #{prefixName}, '%')
  345. </if>
  346. <if test="courseName != null and courseName != ''">
  347. AND c.course_name like concat('%', #{courseName}, '%')
  348. </if>
  349. <if test="publishStatus != null ">
  350. AND c.publish_status = #{publishStatus}
  351. </if>
  352. <if test="schoolId != null and schoolId != ''">
  353. AND c.school_id = #{schoolId}
  354. </if>
  355. <if test="majorId != null and majorId != ''">
  356. AND c.major_id = #{majorId}
  357. </if>
  358. <if test="key != null and key != ''">
  359. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  360. </if>
  361. </select>
  362. <select id="selectDetailById" parameterType="Long" resultMap="CourseResultVo">
  363. SELECT
  364. c.*,
  365. cet.education_name,
  366. cpt.project_name,
  367. cb.business_name,
  368. s.school_name,
  369. m.category_name,
  370. cs.subject_name
  371. FROM
  372. course c
  373. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  374. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  375. LEFT JOIN course_business cb ON c.business_id = cb.id
  376. LEFT JOIN school s ON s.id = c.school_id
  377. LEFT JOIN major m ON c.major_id = m.id
  378. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  379. WHERE
  380. course_id = #{id}
  381. </select>
  382. <select id="getCourseUserVoInfo" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserVo">
  383. SELECT
  384. c.*,
  385. cet.education_name,
  386. cpt.project_name,
  387. cb.business_name,
  388. s.school_name,
  389. m.category_name,
  390. cs.subject_name
  391. FROM
  392. course c
  393. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  394. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  395. LEFT JOIN course_business cb ON c.business_id = cb.id
  396. LEFT JOIN school s ON s.id = c.school_id
  397. LEFT JOIN major m ON c.major_id = m.id
  398. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  399. WHERE
  400. course_id = #{id}
  401. </select>
  402. <select id="listGoodsPeriodVo" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo" resultMap="GoodsPeriodVo">
  403. SELECT
  404. g.goods_id,
  405. g.goods_name,
  406. g.`year`,
  407. cgu.period_status,
  408. (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,
  409. (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,
  410. cgu.grade_id,
  411. (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,
  412. (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,
  413. (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,
  414. cgu.order_goods_id,
  415. og.service_start_time,
  416. og.service_end_time,
  417. cg.class_start_time,
  418. cg.class_end_time,
  419. cg.learning_status,
  420. cgu.official_status,
  421. cg.learning_time_start,
  422. cg.class_status,
  423. cg.interface_push_id,
  424. cb.business_name,
  425. g.business_id,
  426. cet.education_name,
  427. cpt.project_name,
  428. cb.business_name,
  429. cg.official_name
  430. FROM
  431. class_grade_user cgu
  432. LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  433. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  434. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  435. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  436. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  437. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  438. LEFT JOIN course_business cb ON g.business_id = cb.id
  439. WHERE
  440. cgu.user_id =#{userId}
  441. AND cg.status=1 AND cgu.`status`=1 AND cgu.change_grade=0
  442. <if test="educationTypeId != null and educationTypeId != ''">
  443. AND g.education_type_id = #{educationTypeId}
  444. </if>
  445. <if test="businessId != null and businessId != ''">
  446. AND g.business_id = #{businessId}
  447. </if>
  448. ORDER BY cgu.create_time DESC
  449. </select>
  450. <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="GoodsPeriodStatusVo">
  451. SELECT
  452. ups.id,
  453. ups.period_id,
  454. cs.`name`,
  455. 1 as type,
  456. cs.section_type as section_type,
  457. ups.audit_reason
  458. FROM
  459. user_period up
  460. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  461. LEFT JOIN course_section cs ON cs.section_id = up.section_id
  462. WHERE
  463. 1 = 1
  464. AND user_id = #{userId}
  465. AND ups.period_status = 1
  466. AND ups.`status` = 0
  467. AND up.exam_id = 0
  468. and up.grade_id = #{gradeId}
  469. UNION
  470. SELECT
  471. ups.id,
  472. ups.period_id,
  473. exam_name as name,
  474. 2 as type,
  475. 0 as section_type,
  476. ups.audit_reason
  477. FROM
  478. user_period up
  479. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  480. LEFT JOIN exam e ON e.exam_id = up.exam_id
  481. WHERE
  482. 1 = 1
  483. AND user_id = #{userId}
  484. AND ups.period_status = 1
  485. AND ups.`status` = 0
  486. AND up.section_id = 0
  487. and up.grade_id = #{gradeId}
  488. </select>
  489. <select id="goodsRebuildStatus" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="Long">
  490. 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
  491. </select>
  492. <select id="goodsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  493. SELECT
  494. g.*,
  495. o.user_id,
  496. og.study_count as order_study_count,
  497. og.order_goods_id,
  498. og.grade_id,
  499. og.service_start_time,
  500. og.service_end_time,
  501. cb.goods_learning_order,
  502. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  503. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  504. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  505. (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  506. (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,
  507. (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,
  508. (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,
  509. (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,
  510. (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,
  511. (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,
  512. (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,
  513. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  514. <if test="userId != null and userId != ''">
  515. ,
  516. us.exam_status as sub_exam_status,
  517. us.performance as sub_performance,
  518. us.`result` as sub_result,
  519. us.subscribe_id,
  520. us.apply_site_start_time as sub_apply_site_start_time,
  521. us.apply_site_end_time as sub_apply_site_end_time,
  522. us.apply_site_exam_time as sub_apply_site_exam_time
  523. </if>
  524. FROM
  525. `order` o
  526. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  527. LEFT JOIN goods g on og.goods_id = g.goods_id
  528. LEFT JOIN course_business cb on g.business_id = cb.id
  529. <if test="userId != null and userId != ''">
  530. 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
  531. </if>
  532. where 1=1
  533. AND og.`status` = 1
  534. AND og.refund_status in (0,1,3)
  535. AND og.pay_status in (2,3,4)
  536. AND g.goods_type =1
  537. <if test="pageNum == null">
  538. 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
  539. </if>
  540. <if test="userId != null and userId != ''">
  541. and o.user_id = #{userId}
  542. </if>
  543. <if test="educationTypeId != null and educationTypeId != ''">
  544. AND g.education_type_id = #{educationTypeId}
  545. </if>
  546. <if test="businessId != null and businessId != ''">
  547. AND g.business_id = #{businessId}
  548. </if>
  549. <if test="orderGoodsId != null and orderGoodsId != ''">
  550. AND og.order_goods_id = #{orderGoodsId}
  551. </if>
  552. <if test="goodsId != null and goodsId != ''">
  553. AND og.goods_id = #{goodsId}
  554. </if>
  555. order by o.create_time desc
  556. </select>
  557. <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  558. SELECT
  559. c.*,
  560. #{gradeId} as grade_id,
  561. cs.subject_name,
  562. <if test="userId != null ">
  563. (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,
  564. </if>
  565. IFNULL(ge.exam_num,0) as exam_num
  566. FROM
  567. course c
  568. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  569. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  570. LEFT JOIN (SELECT
  571. COUNT( m.id ) AS exam_num,
  572. m.course_id
  573. FROM
  574. course_menu_exam m
  575. where
  576. m.type in (1,3) GROUP BY m.course_id
  577. ) ge on gc.course_id = ge.course_id
  578. where 1=1
  579. and gc.goods_id =#{goodsId}
  580. order by gc.sort asc
  581. </select>
  582. <select id="courseExamNum" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  583. SELECT
  584. c.*,
  585. #{gradeId} as grade_id
  586. FROM
  587. course c
  588. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  589. where 1=1
  590. and gc.goods_id =#{goodsId}
  591. order by gc.sort asc
  592. </select>
  593. <select id="rebuildNext" parameterType="Long" resultType="Long">
  594. SELECT
  595. COUNT( 1 )
  596. FROM
  597. user_period up
  598. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  599. WHERE
  600. up.goods_id = #{goodsId}
  601. AND up.grade_id = #{gradeId}
  602. AND ups.`status` = 0
  603. AND ups.period_status = 1
  604. </select>
  605. <select id="gradeIdSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  606. SELECT
  607. (SELECT
  608. COUNT( m.id )
  609. FROM
  610. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  611. where
  612. m.type in (1,3)
  613. and c.goods_id = #{goodsId}) as exam_num,
  614. (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
  615. = 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,
  616. cgu.grade_id,
  617. cg.class_start_time,
  618. cg.class_end_time,
  619. cg.class_status,
  620. cg.status,
  621. cg.learning_status,
  622. cgu.period_status,
  623. cg.learning_time_start,
  624. cgu.learn_status,
  625. cg.interface_account_id,
  626. cg.official_learning_url,
  627. cg.interface_push_id,
  628. cgu.official_status,
  629. cgu.period_plush,
  630. cgu.order_goods_id,
  631. cg.official_name
  632. FROM
  633. class_grade_user cgu
  634. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  635. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  636. WHERE
  637. 1=1
  638. <if test="gradeId != null and gradeId != ''">
  639. and cg.grade_id = #{gradeId}
  640. </if>
  641. and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  642. order by cg.create_time desc LIMIT 1
  643. </select>
  644. <select id="gradeIdSelectTenant" parameterType="map" resultMap="ClassGradeVoResult" >
  645. SELECT
  646. (SELECT
  647. COUNT( m.id )
  648. FROM
  649. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  650. where
  651. m.type in (1,3)
  652. and c.goods_id = #{goodsId}) as exam_num,
  653. (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
  654. = 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,
  655. cgu.grade_id,
  656. cg.class_start_time,
  657. cg.class_end_time,
  658. cg.class_status,
  659. cg.status,
  660. cg.learning_status,
  661. cgu.period_status,
  662. cg.learning_time_start,
  663. cgu.learn_status,
  664. cg.interface_account_id,
  665. cg.official_learning_url,
  666. cg.interface_push_id,
  667. cgu.official_status,
  668. cgu.period_plush,
  669. cgu.order_goods_id,
  670. cg.official_name
  671. FROM
  672. class_grade_user cgu
  673. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  674. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  675. WHERE
  676. 1=1 and cgu.tenant_id = #{tenantId}
  677. and cg.tenant_id = #{tenantId}
  678. and cgg.tenant_id = #{tenantId}
  679. <if test="gradeId != null and gradeId != ''">
  680. and cg.grade_id = #{gradeId}
  681. </if>
  682. and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  683. order by cg.create_time desc LIMIT 1
  684. </select>
  685. <select id="checkCourseHaveStudy" parameterType="Long" resultType="Long">
  686. SELECT
  687. count(*)
  688. FROM
  689. user_period up
  690. LEFT JOIN goods_course gc ON gc.goods_id = up.goods_id
  691. WHERE
  692. gc.course_id = #{courseId}
  693. </select>
  694. <select id="gradeIdUserSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  695. SELECT
  696. (SELECT
  697. ifnull(COUNT( m.id ),0)
  698. FROM
  699. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  700. where
  701. m.type in (1,3)
  702. and c.goods_id = #{goodsId}) as exam_num,
  703. (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
  704. = 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,
  705. cgu.grade_id,
  706. cgu.user_id,
  707. cgu.order_goods_id
  708. FROM
  709. class_grade_user cgu
  710. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  711. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  712. WHERE
  713. 1=1
  714. <if test="gradeId != null and gradeId != ''">
  715. and cg.grade_id = #{gradeId}
  716. </if>
  717. and cg.`status` =1 and cgu.change_grade = 0 and cgu.`status` = 1
  718. </select>
  719. <select id="getCourseByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.Course">
  720. select * from course where code = #{code} and tenant_id = #{newTenantId}
  721. </select>
  722. </mapper>