CourseMapper.xml 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  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="subExamStatus" column="sub_exam_status"/>
  195. <result property="subPerformance" column="sub_performance"/>
  196. <result property="subResult" column="sub_result"/>
  197. <result property="subApplySiteStartTime" column="sub_apply_site_start_time"/>
  198. <result property="subApplySiteEndTime" column="sub_apply_site_end_time"/>
  199. <result property="subApplySiteExamTime" column="sub_apply_site_exam_time"/>
  200. <result property="gradeId" column="grade_id"/>
  201. <result property="subscribeId" column="subscribe_id"/>
  202. <result property="serviceStartTime" column="service_start_time"/>
  203. <result property="serviceEndTime" column="service_end_time"/>
  204. <result property="subjectNames" column="subject_names"/>
  205. <result property="sectionNum" column="section_num"/>
  206. <result property="goodsLearningOrder" column="goods_learning_order"/>
  207. <result property="realName" column="realname"/>
  208. <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  209. <result property="telPhone" column="telphone" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
  210. <result property="studyStatus" column="study_status"/>
  211. </resultMap>
  212. <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">
  213. <result property="gradeId" column="grade_id"/>
  214. <result property="classStatus" column="class_status"/>
  215. <result property="officialName" column="official_name"/>
  216. <result property="className" column="class_name"/>
  217. <result property="studentUpper" column="student_upper"/>
  218. <result property="learningTimeStart" column="learning_time_start"/>
  219. <result property="learningStatus" column="learning_status"/>
  220. <result property="status" column="status"/>
  221. <result property="classStartTime" column="class_start_time"/>
  222. <result property="classEndTime" column="class_end_time"/>
  223. <result property="examineId" column="examine_id"/>
  224. <result property="areasId" column="areas_id"/>
  225. <result property="sysUserId" column="sys_user_id"/>
  226. <result property="interfacePushId" column="interface_push_id"/>
  227. <result property="remark" column="remark"/>
  228. <result property="interfaceAccountId" column="interface_account_id"/>
  229. <result property="interfacePeriodId" column="interface_period_id"/>
  230. <result property="interfaceAccountName" column="interface_account_name"/>
  231. <result property="interfacePeriodName" column="interface_period_name"/>
  232. <result property="interfacePushName" column="interface_push_name"/>
  233. <result property="studentNum" column="student_num"/>
  234. <result property="periodStatus" column="period_status"/>
  235. <result property="examNum" column="exam_num"/>
  236. <result property="recordNum" column="record_num"/>
  237. <result property="interfacePushId" column="interface_push_id"/>
  238. <result property="interfaceAccountId" column="interface_account_id"/>
  239. <result property="officialLearningUrl" column="official_learning_url"/>
  240. <result property="learnStatus" column="learn_status"/>
  241. <result property="officialStatus" column="official_status"/>
  242. <result property="periodPlush" column="period_plush"/>
  243. <result property="orderGoodsId" column="order_goods_id"/>
  244. <result property="officialName" column="official_name"/>
  245. <result property="userId" column="user_id"/>
  246. <result property="periodWaitTime" column="period_wait_time"/>
  247. </resultMap>
  248. <select id="findGoodsList" resultMap="CourseGoodsListResult">
  249. SELECT
  250. g.goods_name,
  251. g.goods_id
  252. FROM
  253. goods_course gc
  254. LEFT JOIN goods g ON gc.goods_id = g.goods_id
  255. WHERE
  256. gc.course_id =#{course_id}
  257. </select>
  258. <resultMap type="com.zhongzheng.modules.course.vo.CourseGoodsVo" id="CourseGoodsListResult">
  259. <result property="goodsName" column="goods_name"/>
  260. <result property="goodsId" column="goods_id"/>
  261. </resultMap>
  262. <select id="selectCourseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseResultVo">
  263. SELECT
  264. c.*,
  265. cet.education_name,
  266. cpt.project_name,
  267. cb.business_name,
  268. s.school_name,
  269. m.category_name,
  270. cs.subject_name
  271. FROM
  272. course c
  273. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id AND cet.status =1
  274. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id AND cpt.status =1
  275. LEFT JOIN course_business cb ON c.business_id = cb.id AND cb.status =1
  276. LEFT JOIN school s ON s.id = c.school_id AND s.status =1
  277. LEFT JOIN major m ON c.major_id = m.id AND m.status =1
  278. LEFT JOIN course_subject cs ON cs.id = c.subject_id AND cs.status =1
  279. WHERE
  280. 1 = 1 AND c.status !=-1 AND c.course_show =1
  281. <if test="subjectIds != null and subjectIds.size()!=0 ">
  282. AND c.subject_id in
  283. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  284. #{item}
  285. </foreach>
  286. </if>
  287. <if test="status != null and status.size()!=0 ">
  288. AND c.status in
  289. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  290. #{item}
  291. </foreach>
  292. </if>
  293. <if test="educationTypeId != null and educationTypeId != ''">
  294. AND c.education_type_id = #{educationTypeId}
  295. </if>
  296. <if test="subjectId != null and subjectId != ''">
  297. AND c.subject_id = #{subjectId}
  298. </if>
  299. <if test="businessId != null and businessId != ''">
  300. AND c.business_id = #{businessId}
  301. </if>
  302. <if test="prefixName != null and prefixName != ''">
  303. AND c.prefix_name like concat('%', #{prefixName}, '%')
  304. </if>
  305. <if test="courseName != null and courseName != ''">
  306. AND c.course_name like concat('%', #{courseName}, '%')
  307. </if>
  308. <if test="publishStatus != null ">
  309. AND c.publish_status = #{publishStatus}
  310. </if>
  311. <if test="schoolId != null and schoolId != ''">
  312. AND c.school_id = #{schoolId}
  313. </if>
  314. <if test="majorId != null and majorId != ''">
  315. AND c.major_id = #{majorId}
  316. </if>
  317. <if test="key != null and key != ''">
  318. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  319. </if>
  320. GROUP BY
  321. c.course_id
  322. ORDER BY c.create_time DESC
  323. </select>
  324. <select id="selectCourseList_COUNT" resultType="Long">
  325. SELECT
  326. count(distinct c.course_id )
  327. FROM
  328. course c
  329. WHERE
  330. 1 = 1 AND c.status !=-1 AND c.course_show =1
  331. <if test="subjectIds != null and subjectIds.size()!=0 ">
  332. AND c.subject_id in
  333. <foreach collection="subjectIds" item="item" index="index" open="(" close=")" separator=",">
  334. #{item}
  335. </foreach>
  336. </if>
  337. <if test="status != null and status.size()!=0 ">
  338. AND c.status in
  339. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  340. #{item}
  341. </foreach>
  342. </if>
  343. <if test="educationTypeId != null and educationTypeId != ''">
  344. AND c.education_type_id = #{educationTypeId}
  345. </if>
  346. <if test="subjectId != null and subjectId != ''">
  347. AND c.subject_id = #{subjectId}
  348. </if>
  349. <if test="businessId != null and businessId != ''">
  350. AND c.business_id = #{businessId}
  351. </if>
  352. <if test="prefixName != null and prefixName != ''">
  353. AND c.prefix_name like concat('%', #{prefixName}, '%')
  354. </if>
  355. <if test="courseName != null and courseName != ''">
  356. AND c.course_name like concat('%', #{courseName}, '%')
  357. </if>
  358. <if test="publishStatus != null ">
  359. AND c.publish_status = #{publishStatus}
  360. </if>
  361. <if test="schoolId != null and schoolId != ''">
  362. AND c.school_id = #{schoolId}
  363. </if>
  364. <if test="majorId != null and majorId != ''">
  365. AND c.major_id = #{majorId}
  366. </if>
  367. <if test="key != null and key != ''">
  368. AND (c.course_name like concat('%', #{key}, '%') or c.code = #{key} or c.prefix_name like concat('%', #{key}, '%'))
  369. </if>
  370. </select>
  371. <select id="selectDetailById" parameterType="Long" resultMap="CourseResultVo">
  372. SELECT
  373. c.*,
  374. cet.education_name,
  375. cpt.project_name,
  376. cb.business_name,
  377. s.school_name,
  378. m.category_name,
  379. cs.subject_name
  380. FROM
  381. course c
  382. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  383. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  384. LEFT JOIN course_business cb ON c.business_id = cb.id
  385. LEFT JOIN school s ON s.id = c.school_id
  386. LEFT JOIN major m ON c.major_id = m.id
  387. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  388. WHERE
  389. course_id = #{id}
  390. </select>
  391. <select id="getCourseUserVoInfo" parameterType="com.zhongzheng.modules.course.bo.CourseMenuQueryBo" resultMap="CourseUserVo">
  392. SELECT
  393. c.*,
  394. cet.education_name,
  395. cpt.project_name,
  396. cb.business_name,
  397. s.school_name,
  398. m.category_name,
  399. cs.subject_name
  400. FROM
  401. course c
  402. LEFT JOIN course_education_type cet ON c.education_type_id = cet.id
  403. LEFT JOIN course_project_type cpt ON c.project_id = cpt.id
  404. LEFT JOIN course_business cb ON c.business_id = cb.id
  405. LEFT JOIN school s ON s.id = c.school_id
  406. LEFT JOIN major m ON c.major_id = m.id
  407. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  408. WHERE
  409. course_id = #{id}
  410. </select>
  411. <select id="listGoodsPeriodVo" parameterType="com.zhongzheng.modules.user.bo.UserPlanQueryBo" resultMap="GoodsPeriodVo">
  412. SELECT
  413. g.goods_id,
  414. g.goods_name,
  415. g.`year`,
  416. cgu.period_status,
  417. (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,
  418. (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,
  419. cgu.grade_id,
  420. (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,
  421. (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,
  422. (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,
  423. cgu.order_goods_id,
  424. og.service_start_time,
  425. og.service_end_time,
  426. cg.class_start_time,
  427. cg.class_end_time,
  428. cg.learning_status,
  429. cgu.official_status,
  430. cg.learning_time_start,
  431. cg.class_status,
  432. cg.interface_push_id,
  433. cb.business_name,
  434. g.business_id,
  435. cet.education_name,
  436. cpt.project_name,
  437. cb.business_name,
  438. cg.official_name,
  439. g.external_link,
  440. g.external_link_status
  441. FROM
  442. class_grade_user cgu
  443. LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id
  444. LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  445. LEFT JOIN goods g on g.goods_id=cgg.goods_id
  446. LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id
  447. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  448. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  449. LEFT JOIN course_business cb ON g.business_id = cb.id
  450. WHERE
  451. cgu.user_id =#{userId}
  452. AND cg.status=1 AND cgu.`status`=1 AND cgu.change_grade=0
  453. <if test="educationTypeId != null and educationTypeId != ''">
  454. AND g.education_type_id = #{educationTypeId}
  455. </if>
  456. <if test="businessId != null and businessId != ''">
  457. AND g.business_id = #{businessId}
  458. </if>
  459. ORDER BY cgu.create_time DESC
  460. </select>
  461. <select id="listSection" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="GoodsPeriodStatusVo">
  462. SELECT
  463. ups.id,
  464. ups.period_id,
  465. cs.`name`,
  466. 1 as type,
  467. cs.section_type as section_type,
  468. ups.audit_reason
  469. FROM
  470. user_period up
  471. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  472. LEFT JOIN course_section cs ON cs.section_id = up.section_id
  473. WHERE
  474. 1 = 1
  475. AND user_id = #{userId}
  476. AND ups.period_status = 1
  477. AND ups.`status` = 0
  478. AND up.exam_id = 0
  479. and up.grade_id = #{gradeId}
  480. UNION
  481. SELECT
  482. ups.id,
  483. ups.period_id,
  484. exam_name as name,
  485. 2 as type,
  486. 0 as section_type,
  487. ups.audit_reason
  488. FROM
  489. user_period up
  490. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  491. LEFT JOIN exam e ON e.exam_id = up.exam_id
  492. WHERE
  493. 1 = 1
  494. AND user_id = #{userId}
  495. AND ups.period_status = 1
  496. AND ups.`status` = 0
  497. AND up.section_id = 0
  498. and up.grade_id = #{gradeId}
  499. </select>
  500. <select id="goodsRebuildStatus" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="Long">
  501. 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
  502. </select>
  503. <select id="goodsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  504. SELECT
  505. g.*,
  506. o.user_id,
  507. og.study_count as order_study_count,
  508. og.order_goods_id,
  509. og.grade_id,
  510. og.service_start_time,
  511. og.service_end_time,
  512. cb.goods_learning_order,
  513. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  514. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  515. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  516. (SELECT COUNT(1) FROM goods_course gc where gc.goods_id = g.goods_id) as course_num,
  517. (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,
  518. (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,
  519. (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,
  520. (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,
  521. (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,
  522. (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,
  523. (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,
  524. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names,
  525. (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
  526. <if test="userId != null and userId != ''">
  527. ,
  528. us.exam_status as sub_exam_status,
  529. us.performance as sub_performance,
  530. us.`result` as sub_result,
  531. us.subscribe_id,
  532. us.apply_site_start_time as sub_apply_site_start_time,
  533. us.apply_site_end_time as sub_apply_site_end_time,
  534. us.apply_site_exam_time as sub_apply_site_exam_time
  535. </if>
  536. FROM
  537. `order` o
  538. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  539. LEFT JOIN goods g on og.goods_id = g.goods_id
  540. LEFT JOIN course_business cb on g.business_id = cb.id
  541. <if test="userId != null and userId != ''">
  542. 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
  543. </if>
  544. where 1=1
  545. AND og.`status` = 1
  546. -- AND og.refund_status in (0,1,3)
  547. AND og.refund_status in (0,3)
  548. AND og.pay_status in (2,3,4)
  549. AND g.goods_type =1
  550. <if test="pageNum == null">
  551. 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
  552. </if>
  553. <if test="userId != null and userId != ''">
  554. and o.user_id = #{userId}
  555. </if>
  556. <if test="educationTypeId != null and educationTypeId != ''">
  557. AND g.education_type_id = #{educationTypeId}
  558. </if>
  559. <if test="businessId != null and businessId != ''">
  560. AND g.business_id = #{businessId}
  561. </if>
  562. <if test="orderGoodsId != null and orderGoodsId != ''">
  563. AND og.order_goods_id = #{orderGoodsId}
  564. </if>
  565. <if test="goodsId != null and goodsId != ''">
  566. AND og.goods_id = #{goodsId}
  567. </if>
  568. <if test="studyStatus != null and studyStatus == 3">
  569. 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
  570. </if>
  571. <if test="studyStatus != null and studyStatus == 2">
  572. 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
  573. 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
  574. </if>
  575. <if test="studyStatus != null and studyStatus == 1">
  576. 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
  577. </if>
  578. order by og.create_time desc
  579. </select>
  580. <select id="goodsStudyProgressList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  581. SELECT
  582. g.*,
  583. u.realname,
  584. u.id_card,
  585. u.telphone,
  586. o.user_id,
  587. og.order_goods_id,
  588. og.grade_id,
  589. IFNULL(ge.exam_num,0) as exam_num,
  590. (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
  591. FROM
  592. `order` o
  593. LEFT JOIN `user` u ON u.user_id = o.user_id
  594. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  595. LEFT JOIN goods g on og.goods_id = g.goods_id
  596. LEFT JOIN course_business cb on g.business_id = cb.id
  597. LEFT JOIN (SELECT
  598. COUNT( m.id ) AS exam_num,
  599. c.goods_id
  600. FROM
  601. course_menu_exam m
  602. LEFT JOIN goods_course c ON m.course_id = c.course_id
  603. where
  604. m.type in (1,3)
  605. GROUP BY c.goods_id ) ge on og.goods_id = ge.goods_id
  606. where 1=1
  607. AND og.`status` = 1
  608. -- AND og.refund_status in (0,1,3)
  609. AND og.refund_status in (0,3)
  610. AND og.pay_status in (2,3,4)
  611. AND g.goods_type =1
  612. <if test="userId != null and userId != ''">
  613. and o.user_id = #{userId}
  614. </if>
  615. <if test="educationTypeId != null and educationTypeId != ''">
  616. AND g.education_type_id = #{educationTypeId}
  617. </if>
  618. <if test="businessId != null and businessId != ''">
  619. AND g.business_id = #{businessId}
  620. </if>
  621. <if test="orderGoodsId != null and orderGoodsId != ''">
  622. AND og.order_goods_id = #{orderGoodsId}
  623. </if>
  624. <if test="goodsId != null and goodsId != ''">
  625. AND og.goods_id = #{goodsId}
  626. </if>
  627. <if test="oldCompanyId != null and oldCompanyId != ''">
  628. AND o.old_company_id = #{oldCompanyId}
  629. </if>
  630. <if test="oldInstitutionId != null and oldInstitutionId != ''">
  631. AND o.old_institution_id = #{oldInstitutionId}
  632. </if>
  633. <if test="oldCustomerId != null and oldCustomerId != ''">
  634. AND o.old_customer_id = #{oldCustomerId}
  635. </if>
  636. <if test="userId != null and userId != ''">
  637. and o.user_id = #{userId}
  638. </if>
  639. <if test="realname != null and realname !='' ">
  640. AND u.realname like concat('%', #{realname}, '%')
  641. </if>
  642. <if test="idCard != null and idCard !='' ">
  643. AND u.id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  644. </if>
  645. <if test="telphone != null and telphone !='' ">
  646. AND u.telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  647. </if>
  648. order by og.create_time desc
  649. </select>
  650. <select id="goodsHandoutsList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="GoodsUserVo">
  651. SELECT
  652. g.*,
  653. o.user_id,
  654. og.study_count as order_study_count,
  655. og.order_goods_id,
  656. og.service_start_time,
  657. og.service_end_time,
  658. cb.goods_learning_order,
  659. (SELECT cet.education_name FROM course_education_type cet where cet.id = g.education_type_id) as education_name,
  660. (SELECT cet.project_name FROM course_project_type cet where cet.id = g.project_id) as project_name,
  661. (SELECT cet.business_name FROM course_business cet where cet.id = g.business_id) as business_name,
  662. (SELECT GROUP_CONCAT(subject_name) from course_subject where FIND_IN_SET(id,g.subject_ids)) subject_names
  663. FROM
  664. `order` o
  665. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  666. LEFT JOIN goods g on og.goods_id = g.goods_id
  667. LEFT JOIN course_business cb on g.business_id = cb.id
  668. where 1=1
  669. AND og.`status` = 1
  670. -- AND og.refund_status in (0,1,3)
  671. AND og.refund_status in (0,3)
  672. AND og.pay_status in (2,3,4)
  673. AND g.goods_type =8
  674. <if test="userId != null and userId != ''">
  675. and o.user_id = #{userId}
  676. </if>
  677. <if test="educationTypeId != null and educationTypeId != ''">
  678. AND g.education_type_id = #{educationTypeId}
  679. </if>
  680. <if test="businessId != null and businessId != ''">
  681. AND g.business_id = #{businessId}
  682. </if>
  683. <if test="orderGoodsId != null and orderGoodsId != ''">
  684. AND og.order_goods_id = #{orderGoodsId}
  685. </if>
  686. <if test="goodsId != null and goodsId != ''">
  687. AND og.goods_id = #{goodsId}
  688. </if>
  689. order by og.create_time desc
  690. </select>
  691. <select id="courseList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  692. SELECT
  693. c.*,
  694. #{gradeId} as grade_id,
  695. cs.subject_name,
  696. <if test="userId != null ">
  697. (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,
  698. </if>
  699. IFNULL(ge.exam_num,0) as exam_num
  700. FROM
  701. course c
  702. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  703. LEFT JOIN course_subject cs ON cs.id = c.subject_id
  704. LEFT JOIN (SELECT
  705. COUNT( m.id ) AS exam_num,
  706. m.course_id
  707. FROM
  708. course_menu_exam m
  709. where
  710. m.type in (1,3) GROUP BY m.course_id
  711. ) ge on gc.course_id = ge.course_id
  712. where 1=1
  713. and gc.goods_id =#{goodsId}
  714. order by gc.sort asc
  715. </select>
  716. <select id="courseExamNum" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultMap="CourseUserVo">
  717. SELECT
  718. c.*,
  719. #{gradeId} as grade_id
  720. FROM
  721. course c
  722. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  723. where 1=1
  724. and gc.goods_id =#{goodsId}
  725. order by gc.sort asc
  726. </select>
  727. <select id="rebuildNext" parameterType="Long" resultType="Long">
  728. SELECT
  729. COUNT( 1 )
  730. FROM
  731. user_period up
  732. LEFT JOIN user_period_status ups ON up.id = ups.period_id
  733. WHERE
  734. up.goods_id = #{goodsId}
  735. AND up.grade_id = #{gradeId}
  736. AND ups.`status` = 0
  737. AND ups.period_status = 1
  738. </select>
  739. <select id="gradeIdSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  740. SELECT
  741. (SELECT
  742. COUNT( m.id )
  743. FROM
  744. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  745. where
  746. m.type in (1,3)
  747. and c.goods_id = #{goodsId}) as exam_num,
  748. (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
  749. = 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,
  750. cgu.grade_id,
  751. cg.class_start_time,
  752. cg.class_end_time,
  753. cg.class_status,
  754. cg.status,
  755. cg.learning_status,
  756. cgu.period_status,
  757. cg.learning_time_start,
  758. cgu.learn_status,
  759. cg.interface_account_id,
  760. cg.official_learning_url,
  761. cg.interface_push_id,
  762. cgu.official_status,
  763. cgu.period_plush,
  764. cgu.order_goods_id,
  765. cg.official_name,
  766. cgu.period_wait_time
  767. FROM
  768. class_grade_user cgu
  769. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  770. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  771. WHERE
  772. 1=1
  773. <if test="gradeId != null and gradeId != ''">
  774. and cg.grade_id = #{gradeId}
  775. </if>
  776. and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  777. order by cg.create_time desc LIMIT 1
  778. </select>
  779. <select id="gradeIdSelectTenant" parameterType="map" resultMap="ClassGradeVoResult" >
  780. SELECT
  781. (SELECT
  782. COUNT( m.id )
  783. FROM
  784. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  785. where
  786. m.type in (1,3)
  787. and c.goods_id = #{goodsId}) as exam_num,
  788. (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
  789. = 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,
  790. cgu.grade_id,
  791. cg.class_start_time,
  792. cg.class_end_time,
  793. cg.class_status,
  794. cg.status,
  795. cg.learning_status,
  796. cgu.period_status,
  797. cg.learning_time_start,
  798. cgu.learn_status,
  799. cg.interface_account_id,
  800. cg.official_learning_url,
  801. cg.interface_push_id,
  802. cgu.official_status,
  803. cgu.period_plush,
  804. cgu.order_goods_id,
  805. cg.official_name
  806. FROM
  807. class_grade_user cgu
  808. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  809. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  810. WHERE
  811. 1=1 and cgu.tenant_id = #{tenantId}
  812. and cg.tenant_id = #{tenantId}
  813. and cgg.tenant_id = #{tenantId}
  814. <if test="gradeId != null and gradeId != ''">
  815. and cg.grade_id = #{gradeId}
  816. </if>
  817. and cg.`status` =1 and cgg.goods_id = #{goodsId} and cgu.change_grade = 0 and cgu.user_id=#{userId}
  818. order by cg.create_time desc LIMIT 1
  819. </select>
  820. <select id="checkCourseHaveStudy" parameterType="Long" resultType="Long">
  821. SELECT
  822. count(*)
  823. FROM
  824. user_period up
  825. LEFT JOIN goods_course gc ON gc.goods_id = up.goods_id
  826. WHERE
  827. gc.course_id = #{courseId}
  828. </select>
  829. <select id="gradeIdUserSelect" parameterType="map" resultMap="ClassGradeVoResult" >
  830. SELECT
  831. (SELECT
  832. ifnull(COUNT( m.id ),0)
  833. FROM
  834. goods_course c LEFT JOIN course_menu_exam m ON m.course_id = c.course_id
  835. where
  836. m.type in (1,3)
  837. and c.goods_id = #{goodsId}) as exam_num,
  838. (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
  839. = 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,
  840. cgu.grade_id,
  841. cgu.user_id,
  842. cgu.order_goods_id
  843. FROM
  844. class_grade_user cgu
  845. LEFT JOIN class_grade cg on cgu.grade_id = cg.grade_id
  846. LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id
  847. WHERE
  848. 1=1
  849. <if test="gradeId != null and gradeId != ''">
  850. and cg.grade_id = #{gradeId}
  851. </if>
  852. and cg.`status` =1 and cgu.change_grade = 0 and cgu.`status` = 1
  853. </select>
  854. <select id="getCourseByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.Course">
  855. select * from course where code = #{code} and tenant_id = #{newTenantId}
  856. </select>
  857. <select id="getCourseByNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.Course">
  858. select * from course where course_id = #{cid}
  859. </select>
  860. <select id="getCourseByTenantTwo" parameterType="map" resultType="java.lang.Long">
  861. select * from course where course_name = #{courseName} and code = #{code} and tenant_id = #{tenantId}
  862. </select>
  863. <select id="getSpecialQuestionList" parameterType="com.zhongzheng.modules.order.bo.SpecialQuestionBo" resultType="com.zhongzheng.modules.order.vo.SpecialQuestionVo">
  864. SELECT
  865. g.goods_id,
  866. g.cover_url,
  867. gqr.id as qsId,
  868. og.order_goods_id,
  869. o.order_sn,
  870. g.`year`,
  871. g.goods_type,
  872. g.education_type_id,
  873. g.project_id,
  874. g.business_id,
  875. g.major_id,
  876. g.goods_name,
  877. CONCAT( cb.business_name, cpt.project_name ) AS businessName,
  878. og.service_start_time,
  879. og.service_end_time
  880. FROM
  881. `order` o
  882. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  883. LEFT JOIN goods_question_rel gqr ON og.order_goods_id = gqr.qs_order_goods_id
  884. LEFT JOIN goods g ON og.goods_id = g.goods_id
  885. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  886. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  887. LEFT JOIN course_business cb ON g.business_id = cb.id
  888. LEFT JOIN question_merchant qm ON g.question_merchant_id = qm.merchant_id
  889. WHERE
  890. o.`status` = 1
  891. AND og.refund_status != 2
  892. AND og.pay_status IN ( 2, 3, 4 )
  893. AND g.goods_type = 9
  894. AND o.user_id = #{userId}
  895. <if test="questionMerchantId != null and questionMerchantId != ''">
  896. AND g.question_merchant_id = #{questionMerchantId}
  897. </if>
  898. </select>
  899. <select id="getSpecialQuestionCount" parameterType="com.zhongzheng.modules.order.bo.SpecialQuestionBo" resultType="java.lang.Long">
  900. SELECT
  901. count(distinct g.goods_id)
  902. FROM
  903. `order` o
  904. LEFT JOIN order_goods og ON og.order_sn = o.order_sn
  905. LEFT JOIN goods g ON og.goods_id = g.goods_id
  906. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  907. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  908. LEFT JOIN course_business cb ON g.business_id = cb.id
  909. LEFT JOIN question_merchant qm ON g.question_merchant_id = qm.merchant_id
  910. WHERE
  911. o.`status` = 1
  912. AND og.refund_status != 2
  913. AND og.pay_status IN ( 2, 3, 4 )
  914. AND g.goods_type = 9
  915. AND o.user_id = #{userId}
  916. <if test="questionMerchantId != null and questionMerchantId != ''">
  917. AND g.question_merchant_id = #{questionMerchantId}
  918. </if>
  919. </select>
  920. </mapper>