CourseMapper.xml 55 KB

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