CourseMapper.xml 50 KB

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