CourseMapper.xml 49 KB

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