CourseMapper.xml 52 KB

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