CourseMapper.xml 33 KB

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