CourseMapper.xml 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  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. <result property="firstChoice" column="first_choice"/>
  29. </resultMap>
  30. <resultMap type="com.zhongzheng.modules.course.vo.CourseVo" id="CourseResultVo">
  31. <result property="courseId" column="course_id"/>
  32. <result property="prefixName" column="prefix_name"/>
  33. <result property="coverUrl" column="cover_url"/>
  34. <result property="introduction" column="introduction"/>
  35. <result property="status" column="status"/>
  36. <result property="educationTypeId" column="education_type_id"/>
  37. <result property="businessId" column="business_id"/>
  38. <result property="schoolId" column="school_id"/>
  39. <result property="courseName" column="course_name"/>
  40. <result property="publishStatus" column="publish_status"/>
  41. <result property="sort" column="sort"/>
  42. <result property="suitableObject" column="suitable_object"/>
  43. <result property="pcDetailHtml" column="pc_detail_html"/>
  44. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  45. <result property="majorId" column="major_id"/>
  46. <result property="code" column="code"/>
  47. <result property="subjectId" column="subject_id"/>
  48. <result property="projectId" column="project_id"/>
  49. <result property="createTime" column="create_time"/>
  50. <result property="updateTime" column="update_time"/>
  51. <result property="educationName" column="education_name"/>
  52. <result property="projectName" column="project_name"/>
  53. <result property="businessName" column="business_name"/>
  54. <result property="schoolName" column="school_name"/>
  55. <result property="categoryName" column="category_name"/>
  56. <result property="subjectName" column="subject_name"/>
  57. <result property="courseShow" column="course_show"/>
  58. <result property="firstChoice" column="first_choice"/>
  59. <result property="viewSign" column="view_sign"/>
  60. <collection property="goodsList" column="course_id" select="findGoodsList"/>
  61. </resultMap>
  62. <resultMap type="com.zhongzheng.modules.course.vo.CourseUserVo" id="CourseUserVo">
  63. <result property="courseId" column="course_id"/>
  64. <result property="prefixName" column="prefix_name"/>
  65. <result property="coverUrl" column="cover_url"/>
  66. <result property="gradeId" column="grade_id"/>
  67. <result property="introduction" column="introduction"/>
  68. <result property="status" column="status"/>
  69. <result property="educationTypeId" column="education_type_id"/>
  70. <result property="businessId" column="business_id"/>
  71. <result property="schoolId" column="school_id"/>
  72. <result property="courseName" column="course_name"/>
  73. <result property="publishStatus" column="publish_status"/>
  74. <result property="sort" column="sort"/>
  75. <result property="suitableObject" column="suitable_object"/>
  76. <result property="pcDetailHtml" column="pc_detail_html"/>
  77. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  78. <result property="majorId" column="major_id"/>
  79. <result property="code" column="code"/>
  80. <result property="subjectId" column="subject_id"/>
  81. <result property="projectId" column="project_id"/>
  82. <result property="createTime" column="create_time"/>
  83. <result property="updateTime" column="update_time"/>
  84. <result property="educationName" column="education_name"/>
  85. <result property="projectName" column="project_name"/>
  86. <result property="businessName" column="business_name"/>
  87. <result property="schoolName" column="school_name"/>
  88. <result property="categoryName" column="category_name"/>
  89. <result property="subjectName" column="subject_name"/>
  90. <result property="examNum" column="exam_num"/>
  91. <result property="recordNum" column="record_num"/>
  92. </resultMap>
  93. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsPeriodVo" id="GoodsPeriodVo">
  94. <result property="goodsId" column="goods_id"/>
  95. <result property="year" column="year"/>
  96. <result property="goodsName" column="goods_name"/>
  97. <result property="periodStatus" column="period_status"/>
  98. <result property="rebuild" column="rebuild"/>
  99. <result property="gradeId" column="grade_id"/>
  100. <result property="examNum" column="exam_num"/>
  101. <result property="recordNum" column="record_num"/>
  102. <result property="applyStatus" column="apply_status"/>
  103. <result property="beforeStatus" column="before_status"/>
  104. <result property="applyName" column="apply_name"/>
  105. <result property="beforeName" column="before_name"/>
  106. <result property="rebuildNum" column="rebuildNum"/>
  107. <result property="rebuildStatus" column="rebuild_status"/>
  108. <result property="orderGoodsId" column="order_goods_id"/>
  109. <result property="serviceStartTime" column="service_start_time"/>
  110. <result property="serviceEndTime" column="service_end_time"/>
  111. <result property="classStartTime" column="class_start_time"/>
  112. <result property="classEndTime" column="class_end_time"/>
  113. <result property="externalLink" column="external_link"/>
  114. <result property="externalLinkStatus" column="external_link_status"/>
  115. <result property="learningStatus" column="learning_status"/>
  116. <result property="classStatus" column="class_status"/>
  117. <result property="learningTimeStart" column="learning_time_start"/>
  118. <result property="interfacePushId" column="interface_push_id"/>
  119. <result property="officialStatus" column="official_status"/>
  120. <result property="businessId" column="business_id"/>
  121. <result property="educationName" column="education_name"/>
  122. <result property="projectName" column="project_name"/>
  123. <result property="businessName" column="business_name"/>
  124. <result property="officialName" column="official_name"/>
  125. </resultMap>
  126. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo" id="GoodsPeriodStatusVo">
  127. <result property="id" column="id"/>
  128. <result property="type" column="type"/>
  129. <result property="name" column="name"/>
  130. <result property="periodId" column="period_id"/>
  131. <result property="sectionType" column="section_type"/>
  132. <result property="auditReason" column="audit_reason"/>
  133. </resultMap>
  134. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsUserVo" id="GoodsUserVo">
  135. <result property="goodsId" column="goods_id"/>
  136. <result property="year" column="year"/>
  137. <result property="supplyId" column="supply_id"/>
  138. <result property="userId" column="user_id"/>
  139. <result property="goodsType" column="goods_type"/>
  140. <result property="educationTypeId" column="education_type_id"/>
  141. <result property="businessId" column="business_id"/>
  142. <result property="schoolId" column="school_id"/>
  143. <result property="majorId" column="major_id"/>
  144. <result property="goodsName" column="goods_name"/>
  145. <result property="standPrice" column="stand_price"/>
  146. <result property="lowestPrice" column="lowest_price"/>
  147. <result property="createTime" column="create_time"/>
  148. <result property="updateTime" column="update_time"/>
  149. <result property="status" column="status"/>
  150. <result property="validityStartTime" column="validity_start_time"/>
  151. <result property="validityEndTime" column="validity_end_time"/>
  152. <result property="studyStartTime" column="study_start_time"/>
  153. <result property="studyEndTime" column="study_end_time"/>
  154. <result property="certificateIds" column="certificate_ids"/>
  155. <result property="introduce" column="introduce"/>
  156. <result property="suitableObject" column="suitable_object"/>
  157. <result property="buyNote" column="buy_note"/>
  158. <result property="pcDetailHtml" column="pc_detail_html"/>
  159. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  160. <result property="goodsStatus" column="goods_status"/>
  161. <result property="coverUrl" column="cover_url"/>
  162. <result property="classHours" column="class_hours"/>
  163. <result property="standPriceJson" column="stand_price_json"/>
  164. <result property="code" column="code"/>
  165. <result property="projectId" column="project_id"/>
  166. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  167. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  168. <result property="goodsPlayConfig" column="goods_play_config"/>
  169. <result property="goodsExamConfig" column="goods_exam_config"/>
  170. <result property="gradeId" column="grade_id"/>
  171. <result property="rebuildStatus" column="rebuild_status"/>
  172. <result property="sectionMaxNum" column="section_max_num"/>
  173. <result property="externalLink" column="external_link"/>
  174. <result property="externalLinkStatus" column="external_link_status"/>
  175. <result property="supplyName" column="supply_name"/>
  176. <result property="educationName" column="education_name"/>
  177. <result property="projectName" column="project_name"/>
  178. <result property="businessName" column="business_name"/>
  179. <result property="schoolName" column="school_name"/>
  180. <result property="categoryName" column="category_name"/>
  181. <result property="handoutsId" column="handouts_id"/>
  182. <result property="templateType" column="template_type"/>
  183. <result property="period" column="period"/>
  184. <result property="makeStartTime" column="make_start_time"/>
  185. <result property="makeEndTime" column="make_end_time"/>
  186. <result property="studyCount" column="order_study_count"/>
  187. <result property="makeGoodsName" column="make_goods_name"/>
  188. <result property="makeGoodsCode" column="make_goods_code"/>
  189. <result property="applyStatus" column="apply_status"/>
  190. <result property="beforeStatus" column="before_status"/>
  191. <result property="applyName" column="apply_name"/>
  192. <result property="beforeName" column="before_name"/>
  193. <result property="courseNum" column="course_num"/>
  194. <result property="orderGoodsId" column="order_goods_id"/>
  195. <result property="profileStatus" column="profile_status"/>
  196. <result property="profileTpStatus" column="profile_tp_status"/>
  197. <result property="sevenYear" column="seven_year"/>
  198. <result property="orderYear" column="order_year"/>
  199. <result property="ogCreateTime" column="og_create_time"/>
  200. <result property="subExamStatus" column="sub_exam_status"/>
  201. <result property="subPerformance" column="sub_performance"/>
  202. <result property="subResult" column="sub_result"/>
  203. <result property="subApplySiteStartTime" column="sub_apply_site_start_time"/>
  204. <result property="subApplySiteEndTime" column="sub_apply_site_end_time"/>
  205. <result property="subApplySiteExamTime" column="sub_apply_site_exam_time"/>
  206. <result property="gradeId" column="grade_id"/>
  207. <result property="subscribeId" column="subscribe_id"/>
  208. <result property="serviceStartTime" column="service_start_time"/>
  209. <result property="serviceEndTime" column="service_end_time"/>
  210. <result property="subjectNames" column="subject_names"/>
  211. <result property="sectionNum" column="section_num"/>
  212. <result property="goodsLearningOrder" column="goods_learning_order"/>
  213. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  214. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  215. <result property="startTime" column="start_time"/>
  216. <result property="endTime" column="end_time"/>
  217. <result property="openGoodsTime" column="open_goods_time"/>
  218. <result property="oldOrderSn" column="old_order_sn"/>
  219. <result property="profileChangeStatus" column="profile_change_status"/>
  220. </resultMap>
  221. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  222. <result property="id" column="id"/>
  223. <result property="gradeId" column="grade_id"/>
  224. <result property="classStatus" column="class_status"/>
  225. <result property="officialName" column="official_name"/>
  226. <result property="className" column="class_name"/>
  227. <result property="studentUpper" column="student_upper"/>
  228. <result property="learningTimeStart" column="learning_time_start"/>
  229. <result property="learningStatus" column="learning_status"/>
  230. <result property="status" column="status"/>
  231. <result property="classStartTime" column="class_start_time"/>
  232. <result property="classEndTime" column="class_end_time"/>
  233. <result property="examineId" column="examine_id"/>
  234. <result property="areasId" column="areas_id"/>
  235. <result property="sysUserId" column="sys_user_id"/>
  236. <result property="interfacePushId" column="interface_push_id"/>
  237. <result property="remark" column="remark"/>
  238. <result property="interfaceAccountId" column="interface_account_id"/>
  239. <result property="interfacePeriodId" column="interface_period_id"/>
  240. <result property="interfaceAccountName" column="interface_account_name"/>
  241. <result property="interfacePeriodName" column="interface_period_name"/>
  242. <result property="interfacePushName" column="interface_push_name"/>
  243. <result property="studentNum" column="student_num"/>
  244. <result property="periodStatus" column="period_status"/>
  245. <result property="examNum" column="exam_num"/>
  246. <result property="recordNum" column="record_num"/>
  247. <result property="interfacePushId" column="interface_push_id"/>
  248. <result property="interfaceAccountId" column="interface_account_id"/>
  249. <result property="officialLearningUrl" column="official_learning_url"/>
  250. <result property="learnStatus" column="learn_status"/>
  251. <result property="officialStatus" column="official_status"/>
  252. <result property="periodPlush" column="period_plush"/>
  253. <result property="orderGoodsId" column="order_goods_id"/>
  254. <result property="officialName" column="official_name"/>
  255. <result property="userId" column="user_id"/>
  256. <result property="periodWaitTime" column="period_wait_time"/>
  257. <result property="officialStatusMsg" column="official_status_msg"/>
  258. <result property="sevenPushReason" column="seven_push_reason"/>
  259. </resultMap>
  260. <select id="findGoodsList" resultMap="CourseGoodsListResult">
  261. SELECT
  262. g.goods_name,
  263. g.goods_id
  264. FROM
  265. goods_course gc
  266. LEFT JOIN goods g ON gc.goods_id = g.goods_id
  267. WHERE
  268. gc.course_id =#{course_id}
  269. </select>
  270. <resultMap type="com.zhongzheng.modules.course.vo.CourseGoodsVo" id="CourseGoodsListResult">
  271. <result property="goodsName" column="goods_name"/>
  272. <result property="goodsId" column="goods_id"/>
  273. </resultMap>
  274. <select id="selectCourseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseResultVo">
  275. SELECT
  276. c.*,
  277. cet.education_name,
  278. cpt.project_name,
  279. cb.business_name,
  280. s.school_name,
  281. m.category_name,
  282. cs.subject_name
  283. FROM
  284. course c
  285. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id AND cet.status =1
  286. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id AND cpt.status =1
  287. LEFT JOIN course_business cb ON c.business_id = cb.id AND cb.status =1
  288. LEFT JOIN school s ON s.id = c.school_id AND s.status =1
  289. LEFT JOIN major m ON c.major_id = m.id AND m.status =1
  290. LEFT JOIN course_subject cs ON cs.id = c.subject_id AND cs.status =1
  291. WHERE
  292. 1 = 1 AND c.status !=-1 AND c.course_show =1 AND c.first_choice =0
  293. <if test="subjectIds != null and subjectIds.size()!=0 ">
  294. AND c.subject_id in
  295. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  296. #{item}
  297. </foreach>
  298. </if>
  299. <if test="status != null and status.size()!=0 ">
  300. AND c.status in
  301. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  302. #{item}
  303. </foreach>
  304. </if>
  305. <if test="educationTypeId != null and educationTypeId != ''">
  306. AND c.education_type_id = #{educationTypeId}
  307. </if>
  308. <if test="subjectId != null and subjectId != ''">
  309. AND c.subject_id = #{subjectId}
  310. </if>
  311. <if test="businessId != null and businessId != ''">
  312. AND c.business_id = #{businessId}
  313. </if>
  314. <if test="viewSign != null and viewSign != ''">
  315. AND c.view_sign = #{viewSign}
  316. </if>
  317. <if test="prefixName != null and prefixName != ''">
  318. AND c.prefix_name like concat('%', #{prefixName}, '%')
  319. </if>
  320. <if test="courseName != null and courseName != ''">
  321. AND c.course_name like concat('%', #{courseName}, '%')
  322. </if>
  323. <if test="publishStatus != null ">
  324. AND c.publish_status = #{publishStatus}
  325. </if>
  326. <if test="schoolId != null and schoolId != ''">
  327. AND c.school_id = #{schoolId}
  328. </if>
  329. <if test="majorId != null and majorId != ''">
  330. AND c.major_id = #{majorId}
  331. </if>
  332. <if test="key != null and key != ''">
  333. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  334. </if>
  335. GROUP BY
  336. c.course_id
  337. ORDER BY c.create_time DESC
  338. </select>
  339. <select id="selectCourseList_COUNT" resultType="Long">
  340. SELECT
  341. count(distinct c.course_id )
  342. FROM
  343. course c
  344. WHERE
  345. 1 = 1 AND c.status !=-1 AND c.course_show =1 AND c.first_choice =0
  346. <if test="subjectIds != null and subjectIds.size()!=0 ">
  347. AND c.subject_id in
  348. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  349. #{item}
  350. </foreach>
  351. </if>
  352. <if test="status != null and status.size()!=0 ">
  353. AND c.status in
  354. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  355. #{item}
  356. </foreach>
  357. </if>
  358. <if test="educationTypeId != null and educationTypeId != ''">
  359. AND c.education_type_id = #{educationTypeId}
  360. </if>
  361. <if test="subjectId != null and subjectId != ''">
  362. AND c.subject_id = #{subjectId}
  363. </if>
  364. <if test="businessId != null and businessId != ''">
  365. AND c.business_id = #{businessId}
  366. </if>
  367. <if test="prefixName != null and prefixName != ''">
  368. AND c.prefix_name like concat('%', #{prefixName}, '%')
  369. </if>
  370. <if test="courseName != null and courseName != ''">
  371. AND c.course_name like concat('%', #{courseName}, '%')
  372. </if>
  373. <if test="publishStatus != null ">
  374. AND c.publish_status = #{publishStatus}
  375. </if>
  376. <if test="schoolId != null and schoolId != ''">
  377. AND c.school_id = #{schoolId}
  378. </if>
  379. <if test="majorId != null and majorId != ''">
  380. AND c.major_id = #{majorId}
  381. </if>
  382. <if test="key != null and key != ''">
  383. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  384. </if>
  385. </select>
  386. <select id="selectDetailById" parameterType="Long" resultMap="CourseResultVo">
  387. SELECT
  388. c.*,
  389. cet.education_name,
  390. cpt.project_name,
  391. cb.business_name,
  392. s.school_name,
  393. m.category_name,
  394. cs.subject_name
  395. FROM
  396. course c
  397. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  398. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  399. LEFT JOIN course_business cb ON c.business_id = cb.id
  400. LEFT JOIN school s ON s.id = c.school_id
  401. LEFT JOIN major m ON c.major_id = m.id
  402. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  403. WHERE
  404. course_id = #{id}
  405. </select>
  406. <select id="getCourseUserVoInfo" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserVo">
  407. SELECT
  408. c.*,
  409. cet.education_name,
  410. cpt.project_name,
  411. cb.business_name,
  412. s.school_name,
  413. m.category_name,
  414. cs.subject_name
  415. FROM
  416. course c
  417. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  418. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  419. LEFT JOIN course_business cb ON c.business_id = cb.id
  420. LEFT JOIN school s ON s.id = c.school_id
  421. LEFT JOIN major m ON c.major_id = m.id
  422. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  423. WHERE
  424. course_id = #{id}
  425. </select>
  426. <select id="listGoodsPeriodVo" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo" resultMap="GoodsPeriodVo">
  427. SELECT
  428. g.goods_id,
  429. g.goods_name,
  430. g.`year`,
  431. cgu.period_status,
  432. (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,
  433. (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,
  434. cgu.grade_id,
  435. (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 = og.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,
  436. (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 = og.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,
  437. (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 = og.goods_id and eb.`status` = 1 and unix_timestamp(now()) BETWEEN eb.before_start_time and eb.before_end_time) as before_name,
  438. cgu.order_goods_id,
  439. og.service_start_time,
  440. og.service_end_time,
  441. cg.class_start_time,
  442. cg.class_end_time,
  443. cg.learning_status,
  444. cgu.official_status,
  445. cg.learning_time_start,
  446. cg.class_status,
  447. cg.interface_push_id,
  448. cb.business_name,
  449. g.business_id,
  450. cet.education_name,
  451. cpt.project_name,
  452. cb.business_name,
  453. cg.official_name,
  454. g.external_link,
  455. g.external_link_status
  456. FROM
  457. class_grade_user cgu
  458. LEFT JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
  459. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  460. LEFT JOIN goods g on g.goods_id=og.goods_id
  461. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  462. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  463. LEFT JOIN course_business cb ON g.business_id = cb.id
  464. WHERE
  465. cgu.user_id =#{userId}
  466. AND cg.status=1 AND cgu.`status`=1 AND cgu.change_grade=0
  467. <if test="educationTypeId != null and educationTypeId != ''">
  468. AND g.education_type_id = #{educationTypeId}
  469. </if>
  470. <if test="businessId != null and businessId != ''">
  471. AND g.business_id = #{businessId}
  472. </if>
  473. ORDER BY cgu.create_time DESC
  474. </select>
  475. <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="GoodsPeriodStatusVo">
  476. SELECT
  477. ups.id,
  478. ups.period_id,
  479. cs.`name`,
  480. 1 as type,
  481. cs.section_type as section_type,
  482. ups.audit_reason
  483. FROM
  484. user_period up
  485. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  486. LEFT JOIN course_section cs ON cs.section_id = up.section_id
  487. WHERE
  488. 1 = 1
  489. AND user_id = #{userId}
  490. AND ups.period_status = 1
  491. AND ups.`status` = 0
  492. AND up.exam_id = 0
  493. and up.grade_id = #{gradeId}
  494. and (up.order_goods_id = #{orderGoodsId} or up.order_goods_id is null)
  495. UNION
  496. SELECT
  497. ups.id,
  498. ups.period_id,
  499. exam_name as name,
  500. 2 as type,
  501. 0 as section_type,
  502. ups.audit_reason
  503. FROM
  504. user_period up
  505. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  506. LEFT JOIN exam e ON e.exam_id = up.exam_id
  507. WHERE
  508. 1 = 1
  509. AND user_id = #{userId}
  510. AND ups.period_status = 1
  511. AND ups.`status` = 0
  512. AND up.section_id = 0
  513. and up.grade_id = #{gradeId}
  514. and (up.order_goods_id = #{orderGoodsId} or up.order_goods_id is null)
  515. </select>
  516. <select id="goodsRebuildStatus" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="Long">
  517. 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
  518. </select>
  519. <select id="goodsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  520. SELECT
  521. g.*,
  522. o.user_id,
  523. og.study_count as order_study_count,
  524. og.order_goods_id,
  525. og.grade_id,
  526. og.service_start_time,
  527. og.service_end_time,
  528. og.create_time as og_create_time,
  529. og.seven_year as order_year,
  530. cb.goods_learning_order,
  531. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  532. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  533. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  534. (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  535. <if test="querySign == null or querySign == 0">
  536. (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,
  537. </if>
  538. (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,
  539. (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,
  540. (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,
  541. (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,
  542. (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,
  543. (SELECT change_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_change_status,
  544. (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,
  545. <if test="querySign == null or querySign == 0">
  546. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names,
  547. </if>
  548. (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id) as study_status
  549. <if test="userId != null and userId != ''">
  550. ,
  551. us.exam_status as sub_exam_status,
  552. us.performance as sub_performance,
  553. us.`result` as sub_result,
  554. us.subscribe_id,
  555. us.apply_site_start_time as sub_apply_site_start_time,
  556. us.apply_site_end_time as sub_apply_site_end_time,
  557. us.apply_site_exam_time as sub_apply_site_exam_time
  558. </if>
  559. FROM
  560. `order` o
  561. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  562. LEFT JOIN goods g on og.goods_id = g.goods_id
  563. LEFT JOIN course_business cb on g.business_id = cb.id
  564. <if test="userId != null and userId != ''">
  565. 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
  566. </if>
  567. where 1=1
  568. AND og.`status` = 1
  569. -- AND og.refund_status in (0,1,3)
  570. AND og.refund_status in (0,3)
  571. AND og.pay_status in (2,3,4)
  572. AND g.goods_type =1
  573. <if test="orderGoodsIds != null and orderGoodsIds.size()!=0 ">
  574. AND og.order_goods_id in
  575. <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
  576. #{item}
  577. </foreach>
  578. </if>
  579. </select>
  580. <select id="goodsProgressList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  581. SELECT
  582. g.*,
  583. u.realname,
  584. u.id_card,
  585. u.telphone,
  586. o.user_id,
  587. og.order_goods_id,
  588. og.grade_id,
  589. og.create_time as open_goods_time
  590. FROM
  591. `order` o
  592. LEFT JOIN `user` u ON u.user_id = o.user_id
  593. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  594. LEFT JOIN goods g on og.goods_id = g.goods_id
  595. where 1=1
  596. AND og.`status` = 1
  597. AND og.refund_status in (0,3)
  598. AND og.pay_status in (2,3,4)
  599. <if test="educationTypeId != null and educationTypeId != ''">
  600. AND g.education_type_id = #{educationTypeId}
  601. </if>
  602. <if test="businessId != null and businessId != ''">
  603. AND g.business_id = #{businessId}
  604. </if>
  605. <if test="orderGoodsId != null and orderGoodsId != ''">
  606. AND og.order_goods_id = #{orderGoodsId}
  607. </if>
  608. <if test="goodsId != null and goodsId != ''">
  609. AND og.goods_id = #{goodsId}
  610. </if>
  611. <if test="oldCompanyId != null and oldCompanyId != ''">
  612. AND o.old_company_id = #{oldCompanyId}
  613. </if>
  614. <if test="oldInstitutionId != null and oldInstitutionId != ''">
  615. AND o.old_institution_id = #{oldInstitutionId}
  616. </if>
  617. <if test="oldCustomerId != null and oldCustomerId != ''">
  618. AND o.old_customer_id = #{oldCustomerId}
  619. </if>
  620. <if test="userId != null and userId != ''">
  621. and o.user_id = #{userId}
  622. </if>
  623. <if test="realname != null and realname !='' ">
  624. AND u.realname like concat('%', #{realname}, '%')
  625. </if>
  626. <if test="idCard != null and idCard !='' ">
  627. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  628. </if>
  629. <if test="telphone != null and telphone !='' ">
  630. AND u.telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  631. </if>
  632. <if test="studyFinishStatus != null and studyFinishStatus == 1">
  633. AND (SELECT cgu.period_wait_time FROM class_grade_user cgu where cgu.`status`=1 and cgu.grade_id = og.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id) >0
  634. </if>
  635. <if test="studyFinishStatus != null and studyFinishStatus == 2">
  636. AND (SELECT cgu.period_wait_time FROM class_grade_user cgu where cgu.`status`=1 and cgu.grade_id = og.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id) is null
  637. </if>
  638. order by og.create_time desc
  639. </select>
  640. <select id="goodsStudyProgressList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  641. SELECT
  642. g.*,
  643. u.realname,
  644. u.id_card,
  645. u.telphone,
  646. o.user_id,
  647. og.order_goods_id,
  648. og.grade_id,
  649. IFNULL(ge.exam_num,0) as exam_num,
  650. og.create_time as open_goods_time,
  651. (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,3) and ubr.report_status=1 and ubr.grade_id = og.grade_id and ubr.user_id = o.user_id and ubr.current_status = 1) as record_num,
  652. (SELECT cgu.period_wait_time FROM class_grade_user cgu where cgu.`status`=1 and cgu.grade_id = og.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id) as end_time,
  653. oi.old_order_sn
  654. FROM
  655. `order` o
  656. LEFT JOIN `user` u ON u.user_id = o.user_id
  657. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  658. LEFT JOIN goods g on og.goods_id = g.goods_id
  659. LEFT JOIN course_business cb on g.business_id = cb.id
  660. LEFT JOIN order_input oi on oi.input_order_sn = o.input_order_sn
  661. LEFT JOIN (SELECT
  662. COUNT( m.id ) AS exam_num,
  663. c.goods_id
  664. FROM
  665. course_menu_exam m
  666. LEFT JOIN goods_course c ON m.course_id = c.course_id
  667. where
  668. m.type in (1,3)
  669. GROUP BY c.goods_id ) ge on og.goods_id = ge.goods_id
  670. where 1=1
  671. AND og.`status` = 1
  672. -- AND og.refund_status in (0,1,3)
  673. AND og.refund_status in (0,3)
  674. AND og.pay_status in (2,3,4)
  675. AND g.goods_type =1
  676. <if test="userId != null and userId != ''">
  677. and o.user_id = #{userId}
  678. </if>
  679. <if test="educationTypeId != null and educationTypeId != ''">
  680. AND g.education_type_id = #{educationTypeId}
  681. </if>
  682. <if test="businessId != null and businessId != ''">
  683. AND g.business_id = #{businessId}
  684. </if>
  685. <if test="orderGoodsId != null and orderGoodsId != ''">
  686. AND og.order_goods_id = #{orderGoodsId}
  687. </if>
  688. <if test="goodsId != null and goodsId != ''">
  689. AND og.goods_id = #{goodsId}
  690. </if>
  691. <if test="oldCompanyId != null and oldCompanyId != ''">
  692. AND o.old_company_id = #{oldCompanyId}
  693. </if>
  694. <if test="oldInstitutionId != null and oldInstitutionId != ''">
  695. AND o.old_institution_id = #{oldInstitutionId}
  696. </if>
  697. <if test="oldCustomerId != null and oldCustomerId != ''">
  698. AND o.old_customer_id = #{oldCustomerId}
  699. </if>
  700. <if test="userId != null and userId != ''">
  701. and o.user_id = #{userId}
  702. </if>
  703. <if test="realname != null and realname !='' ">
  704. AND u.realname like concat('%', #{realname}, '%')
  705. </if>
  706. <if test="idCard != null and idCard !='' ">
  707. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  708. </if>
  709. <if test="telphone != null and telphone !='' ">
  710. AND u.telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  711. </if>
  712. <if test="oldOrderSn != null and oldOrderSn != ''">
  713. AND oi.old_order_sn = #{oldOrderSn}
  714. </if>
  715. <if test="studyFinishStatus != null and studyFinishStatus == 1">
  716. AND (SELECT cgu.period_wait_time FROM class_grade_user cgu where cgu.`status`=1 and cgu.grade_id = og.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id) >0
  717. </if>
  718. <if test="studyFinishStatus != null and studyFinishStatus == 2">
  719. AND (SELECT cgu.period_wait_time FROM class_grade_user cgu where cgu.`status`=1 and cgu.grade_id = og.grade_id and cgu.user_id = o.user_id and cgu.order_goods_id = og.order_goods_id) is null
  720. </if>
  721. order by og.create_time desc
  722. </select>
  723. <select id="goodsHandoutsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  724. SELECT
  725. g.*,
  726. o.user_id,
  727. og.study_count as order_study_count,
  728. og.order_goods_id,
  729. og.service_start_time,
  730. og.service_end_time,
  731. cb.goods_learning_order,
  732. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  733. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  734. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  735. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  736. FROM
  737. `order` o
  738. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  739. LEFT JOIN goods g on og.goods_id = g.goods_id
  740. LEFT JOIN course_business cb on g.business_id = cb.id
  741. where 1=1
  742. AND og.`status` = 1
  743. -- AND og.refund_status in (0,1,3)
  744. AND og.refund_status in (0,3)
  745. AND og.pay_status in (2,3,4)
  746. AND g.goods_type =8
  747. <if test="userId != null and userId != ''">
  748. and o.user_id = #{userId}
  749. </if>
  750. <if test="educationTypeId != null and educationTypeId != ''">
  751. AND g.education_type_id = #{educationTypeId}
  752. </if>
  753. <if test="businessId != null and businessId != ''">
  754. AND g.business_id = #{businessId}
  755. </if>
  756. <if test="orderGoodsId != null and orderGoodsId != ''">
  757. AND og.order_goods_id = #{orderGoodsId}
  758. </if>
  759. <if test="goodsId != null and goodsId != ''">
  760. AND og.goods_id = #{goodsId}
  761. </if>
  762. order by og.create_time desc
  763. </select>
  764. <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  765. SELECT
  766. c.*,
  767. #{gradeId} as grade_id,
  768. cs.subject_name,
  769. <if test="userId != null ">
  770. (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,
  771. </if>
  772. IFNULL(ge.exam_num,0) as exam_num
  773. FROM
  774. course c
  775. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  776. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  777. LEFT JOIN (SELECT
  778. COUNT( m.id ) AS exam_num,
  779. m.course_id
  780. FROM
  781. course_menu_exam m
  782. where
  783. m.type in (1,3) GROUP BY m.course_id
  784. ) ge on gc.course_id = ge.course_id
  785. where 1=1
  786. and gc.goods_id =#{goodsId}
  787. order by gc.sort asc
  788. </select>
  789. <select id="courseExamNum" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  790. SELECT
  791. c.*,
  792. #{gradeId} as grade_id
  793. FROM
  794. course c
  795. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  796. where 1=1
  797. and gc.goods_id =#{goodsId}
  798. order by gc.sort asc
  799. </select>
  800. <select id="rebuildNext" parameterType="Long" resultType="Long">
  801. SELECT
  802. COUNT( 1 )
  803. FROM
  804. user_period up
  805. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  806. WHERE
  807. up.goods_id = #{goodsId}
  808. AND up.grade_id = #{gradeId}
  809. AND ups.`status` = 0
  810. AND ups.period_status = 1
  811. </select>
  812. <select id="gradeIdSimpleSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  813. SELECT
  814. (SELECT
  815. COUNT( m.id )
  816. FROM
  817. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  818. where
  819. m.type in (1,3)
  820. and c.goods_id = #{goodsId}) as exam_num,
  821. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  822. cgu.grade_id,
  823. cg.class_start_time,
  824. cg.class_end_time,
  825. cg.class_status,
  826. cg.status,
  827. cg.learning_status,
  828. cgu.period_status,
  829. cg.learning_time_start,
  830. cgu.learn_status,
  831. cg.interface_account_id,
  832. cg.official_learning_url,
  833. cg.interface_push_id,
  834. cgu.official_status,
  835. cgu.period_plush,
  836. cgu.order_goods_id,
  837. cg.official_name,
  838. cgu.id,
  839. cgu.period_wait_time
  840. FROM
  841. class_grade_user cgu
  842. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  843. WHERE
  844. 1=1
  845. <if test="gradeId != null and gradeId != ''">
  846. and cg.grade_id = #{gradeId}
  847. </if>
  848. <if test="orderGoodsId != null and orderGoodsId != ''">
  849. and cgu.order_goods_id = #{orderGoodsId}
  850. </if>
  851. and cg.`status` =1 and cgu.change_grade = 0 and cgu.user_id=#{userId}
  852. order by cg.create_time desc LIMIT 1
  853. </select>
  854. <select id="gradeIdSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  855. SELECT
  856. (SELECT
  857. COUNT( m.id )
  858. FROM
  859. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  860. where
  861. m.type in (1,3)
  862. and c.goods_id = #{goodsId}) as exam_num,
  863. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  864. cgu.grade_id,
  865. cg.class_start_time,
  866. cg.class_end_time,
  867. cg.class_status,
  868. cg.class_name,
  869. cg.status,
  870. cg.learning_status,
  871. cgu.period_status,
  872. cg.learning_time_start,
  873. cgu.learn_status,
  874. cg.interface_account_id,
  875. cg.official_learning_url,
  876. cg.interface_push_id,
  877. cgu.official_status,
  878. cgu.period_plush,
  879. cgu.order_goods_id,
  880. cg.official_name,
  881. cgu.period_wait_time,
  882. cgu.seven_push_reason,
  883. cgu.official_status_msg
  884. FROM
  885. class_grade_user cgu
  886. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  887. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  888. WHERE
  889. 1=1
  890. <if test="gradeId != null and gradeId != ''">
  891. and cg.grade_id = #{gradeId}
  892. </if>
  893. <if test="orderGoodsId != null and orderGoodsId != ''">
  894. and cgu.order_goods_id = #{orderGoodsId}
  895. </if>
  896. and cg.`status` =1 and og.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  897. order by cg.create_time desc LIMIT 1
  898. </select>
  899. <select id="gradeIdSelectTenant" parameterType="map" resultMap="ClassGradeVoResult" >
  900. SELECT
  901. (SELECT
  902. COUNT( m.id )
  903. FROM
  904. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  905. where
  906. m.type in (1,3)
  907. and c.goods_id = #{goodsId}) as exam_num,
  908. (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.grade_id = cg.grade_id and ubr.order_goods_id = cgu.order_goods_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  909. cgu.grade_id,
  910. cg.class_start_time,
  911. cg.class_end_time,
  912. cg.class_status,
  913. cg.status,
  914. cg.learning_status,
  915. cgu.period_status,
  916. cg.learning_time_start,
  917. cgu.learn_status,
  918. cg.interface_account_id,
  919. cg.official_learning_url,
  920. cg.interface_push_id,
  921. cgu.official_status,
  922. cgu.period_plush,
  923. cgu.order_goods_id,
  924. cg.official_name
  925. FROM
  926. class_grade_user cgu
  927. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  928. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  929. WHERE
  930. 1=1 and cgu.tenant_id = #{tenantId}
  931. and cg.tenant_id = #{tenantId}
  932. and og.tenant_id = #{tenantId}
  933. <if test="gradeId != null and gradeId != ''">
  934. and cg.grade_id = #{gradeId}
  935. </if>
  936. and cg.`status` =1 and og.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  937. order by cg.create_time desc LIMIT 1
  938. </select>
  939. <select id="checkCourseHaveStudy" parameterType="Long" resultType="Long">
  940. SELECT
  941. count(*)
  942. FROM
  943. user_period up
  944. LEFT JOIN goods_course gc ON gc.goods_id = up.goods_id
  945. WHERE
  946. gc.course_id = #{courseId}
  947. </select>
  948. <select id="gradeIdUserSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  949. SELECT
  950. (SELECT
  951. ifnull(COUNT( m.id ),0)
  952. FROM
  953. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  954. where
  955. m.type in (1,3)
  956. and c.goods_id = #{goodsId}) as exam_num,
  957. (SELECT ifnull(COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id),0) FROM user_bank_record ubr where ubr.`status`=1 and ubr.report_status=1 and ubr.order_goods_id = cgu.order_goods_id and ubr.grade_id = cg.grade_id and ubr.user_id = cgu.user_id and ubr.current_status = 1) as record_num,
  958. cgu.grade_id,
  959. cgu.user_id,
  960. cgu.order_goods_id
  961. FROM
  962. class_grade_user cgu
  963. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  964. WHERE
  965. 1=1
  966. <if test="gradeId != null and gradeId != ''">
  967. and cg.grade_id = #{gradeId}
  968. </if>
  969. and cg.`status` =1 and cgu.change_grade = 0 and cgu.`status` = 1
  970. </select>
  971. <select id="getCourseByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.Course">
  972. select * from course where code = #{code} and tenant_id = #{newTenantId}
  973. </select>
  974. <select id="getCourseByNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.Course">
  975. select * from course where course_id = #{cid}
  976. </select>
  977. <select id="getCourseByTenantTwo" parameterType="map" resultType="java.lang.Long">
  978. select * from course where course_name = #{courseName} and code = #{code} and tenant_id = #{tenantId}
  979. </select>
  980. <select id="getSpecialQuestionList" parameterType="com.zhongzheng.modules.order.bo.SpecialQuestionBo" resultType="com.zhongzheng.modules.order.vo.SpecialQuestionVo">
  981. SELECT
  982. g.goods_id,
  983. g.cover_url,
  984. gqr.id as qsId,
  985. og.order_goods_id,
  986. o.order_sn,
  987. g.`year`,
  988. g.goods_type,
  989. g.education_type_id,
  990. g.project_id,
  991. g.business_id,
  992. g.major_id,
  993. g.goods_name,
  994. g.tenant_id,
  995. CONCAT( cb.business_name, cpt.project_name ) AS businessName,
  996. og.service_start_time,
  997. og.service_end_time
  998. FROM
  999. `order` o
  1000. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  1001. LEFT JOIN goods_question_rel gqr ON og.order_goods_id = gqr.qs_order_goods_id
  1002. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1003. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1004. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1005. LEFT JOIN course_business cb ON g.business_id = cb.id
  1006. LEFT JOIN question_merchant qm ON g.question_merchant_id = qm.merchant_id
  1007. WHERE
  1008. o.`status` = 1
  1009. AND og.refund_status != 2
  1010. AND og.pay_status IN ( 2, 3, 4 )
  1011. AND g.goods_type = 9
  1012. AND o.user_id = #{userId}
  1013. <if test="questionMerchantId != null and questionMerchantId != ''">
  1014. AND g.question_merchant_id = #{questionMerchantId}
  1015. </if>
  1016. </select>
  1017. <select id="getSpecialQuestionCount" parameterType="com.zhongzheng.modules.order.bo.SpecialQuestionBo" resultType="java.lang.Long">
  1018. SELECT
  1019. count(distinct g.goods_id)
  1020. FROM
  1021. `order` o
  1022. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  1023. LEFT JOIN goods g ON og.goods_id = g.goods_id
  1024. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  1025. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  1026. LEFT JOIN course_business cb ON g.business_id = cb.id
  1027. LEFT JOIN question_merchant qm ON g.question_merchant_id = qm.merchant_id
  1028. WHERE
  1029. o.`status` = 1
  1030. AND og.refund_status != 2
  1031. AND og.pay_status IN ( 2, 3, 4 )
  1032. AND g.goods_type = 9
  1033. AND o.user_id = #{userId}
  1034. <if test="questionMerchantId != null and questionMerchantId != ''">
  1035. AND g.question_merchant_id = #{questionMerchantId}
  1036. </if>
  1037. </select>
  1038. <select id="getOrderGoodsIds" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="java.lang.Long">
  1039. SELECT
  1040. og.order_goods_id
  1041. FROM
  1042. `order` o
  1043. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  1044. LEFT JOIN goods g on og.goods_id = g.goods_id
  1045. LEFT JOIN course_business cb on g.business_id = cb.id
  1046. <if test="userId != null and userId != ''">
  1047. 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
  1048. </if>
  1049. where 1=1
  1050. AND og.`status` = 1
  1051. -- AND og.refund_status in (0,1,3)
  1052. AND og.refund_status in (0,3)
  1053. AND og.pay_status in (2,3,4)
  1054. AND g.goods_type =1
  1055. <if test="pageNum == null">
  1056. 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
  1057. </if>
  1058. <if test="userId != null and userId != ''">
  1059. and o.user_id = #{userId}
  1060. </if>
  1061. <if test="educationTypeId != null and educationTypeId != ''">
  1062. AND g.education_type_id = #{educationTypeId}
  1063. </if>
  1064. <if test="businessId != null and businessId != ''">
  1065. AND g.business_id = #{businessId}
  1066. </if>
  1067. <if test="orderGoodsId != null and orderGoodsId != ''">
  1068. AND og.order_goods_id = #{orderGoodsId}
  1069. </if>
  1070. <if test="goodsId != null and goodsId != ''">
  1071. AND og.goods_id = #{goodsId}
  1072. </if>
  1073. <if test="studyStatus != null and studyStatus == 3">
  1074. and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status != -1) >0
  1075. </if>
  1076. <if test="studyStatus != null and studyStatus == 2">
  1077. and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status = -1) >0
  1078. and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) >0
  1079. </if>
  1080. <if test="studyStatus != null and studyStatus == 1">
  1081. and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) =0
  1082. </if>
  1083. order by og.create_time desc
  1084. </select>
  1085. </mapper>