CourseMapper.xml 54 KB

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