GoodsMapper.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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.goods.mapper.GoodsMapper">
  6. <resultMap type="com.zhongzheng.modules.goods.domain.Goods" id="GoodsResult">
  7. <result property="goodsId" column="goods_id"/>
  8. <result property="year" column="year"/>
  9. <result property="supplyId" column="supply_id"/>
  10. <result property="goodsType" column="goods_type"/>
  11. <result property="educationTypeId" column="education_type_id"/>
  12. <result property="businessId" column="business_id"/>
  13. <result property="schoolId" column="school_id"/>
  14. <result property="majorId" column="major_id"/>
  15. <result property="goodsName" column="goods_name"/>
  16. <result property="standPrice" column="stand_price"/>
  17. <result property="lowestPrice" column="lowest_price"/>
  18. <result property="createTime" column="create_time"/>
  19. <result property="updateTime" column="update_time"/>
  20. <result property="status" column="status"/>
  21. <result property="validityStartTime" column="validity_start_time"/>
  22. <result property="validityEndTime" column="validity_end_time"/>
  23. <result property="studyStartTime" column="study_start_time"/>
  24. <result property="studyEndTime" column="study_end_time"/>
  25. <result property="certificateIds" column="certificate_ids"/>
  26. <result property="introduce" column="introduce"/>
  27. <result property="suitableObject" column="suitable_object"/>
  28. <result property="buyNote" column="buy_note"/>
  29. <result property="pcDetailHtml" column="pc_detail_html"/>
  30. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  31. <result property="goodsStatus" column="goods_status"/>
  32. <result property="coverUrl" column="cover_url"/>
  33. <result property="classHours" column="class_hours"/>
  34. <result property="standPriceJson" column="stand_price_json"/>
  35. <result property="code" column="code"/>
  36. <result property="supplyName" column="supply_name"/>
  37. <result property="projectId" column="project_id"/>
  38. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  39. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  40. <result property="goodsPlayConfig" column="goods_play_config"/>
  41. <result property="goodsExamConfig" column="goods_exam_config"/>
  42. <result property="handoutsId" column="handouts_id"/>
  43. <result property="serviceTimeType" column="service_time_type"/>
  44. <result property="serviceTimeNum" column="service_time_num"/>
  45. <result property="sectionMaxNum" column="section_max_num"/>
  46. </resultMap>
  47. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  48. <result property="goodsId" column="goods_id"/>
  49. <result property="year" column="year"/>
  50. <result property="supplyId" column="supply_id"/>
  51. <result property="goodsType" column="goods_type"/>
  52. <result property="gradeId" column="grade_id"/>
  53. <result property="educationTypeId" column="education_type_id"/>
  54. <result property="businessId" column="business_id"/>
  55. <result property="schoolId" column="school_id"/>
  56. <result property="majorId" column="major_id"/>
  57. <result property="goodsName" column="goods_name"/>
  58. <result property="standPrice" column="stand_price"/>
  59. <result property="lowestPrice" column="lowest_price"/>
  60. <result property="createTime" column="create_time"/>
  61. <result property="updateTime" column="update_time"/>
  62. <result property="status" column="status"/>
  63. <result property="validityStartTime" column="validity_start_time"/>
  64. <result property="validityEndTime" column="validity_end_time"/>
  65. <result property="studyStartTime" column="study_start_time"/>
  66. <result property="studyEndTime" column="study_end_time"/>
  67. <result property="certificateIds" column="certificate_ids"/>
  68. <result property="introduce" column="introduce"/>
  69. <result property="suitableObject" column="suitable_object"/>
  70. <result property="buyNote" column="buy_note"/>
  71. <result property="pcDetailHtml" column="pc_detail_html"/>
  72. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  73. <result property="goodsStatus" column="goods_status"/>
  74. <result property="coverUrl" column="cover_url"/>
  75. <result property="classHours" column="class_hours"/>
  76. <result property="standPriceJson" column="stand_price_json"/>
  77. <result property="code" column="code"/>
  78. <result property="projectId" column="project_id"/>
  79. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  80. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  81. <result property="goodsAuditionExamConfig" column="goods_audition_exam_config"/>
  82. <result property="goodsPlayConfig" column="goods_play_config"/>
  83. <result property="goodsExamConfig" column="goods_exam_config"/>
  84. <result property="sectionMaxNum" column="section_max_num"/>
  85. <result property="supplyName" column="supply_name"/>
  86. <result property="educationName" column="education_name"/>
  87. <result property="projectName" column="project_name"/>
  88. <result property="businessName" column="business_name"/>
  89. <result property="schoolName" column="school_name"/>
  90. <result property="categoryName" column="category_name"/>
  91. <result property="handoutsId" column="handouts_id"/>
  92. <result property="templateType" column="template_type"/>
  93. <result property="period" column="period"/>
  94. <result property="makeStartTime" column="make_start_time"/>
  95. <result property="makeEndTime" column="make_end_time"/>
  96. <result property="studyCount" column="study_count"/>
  97. <result property="makeGoodsName" column="make_goods_name"/>
  98. <result property="makeGoodsCode" column="make_goods_code"/>
  99. <result property="courseNum" column="course_num"/>
  100. <result property="sectionNum" column="section_num"/>
  101. <result property="serviceTimeType" column="service_time_type"/>
  102. <result property="serviceTimeNum" column="service_time_num"/>
  103. <result property="gradeNum" column="grade_num"/>
  104. <result property="gradeId" column="grade_id"/>
  105. <result property="gradeName" column="grade_name"/>
  106. </resultMap>
  107. <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
  108. <result property="id" column="id"/>
  109. <result property="examNumberId" column="exam_number_id"/>
  110. <result property="goodsId" column="goods_id"/>
  111. <result property="goodsName" column="goods_name"/>
  112. <result property="code" column="code"/>
  113. <result property="standPrice" column="stand_price"/>
  114. <result property="goodsStatus" column="goods_status"/>
  115. <result property="validityStartTime" column="validity_start_time"/>
  116. <result property="validityEndTime" column="validity_end_time"/>
  117. <result property="goodsStatus" column="goods_status"/>
  118. <result property="status" column="status"/>
  119. <result property="selectStatus" column="select_status"/>
  120. </resultMap>
  121. <select id="selectAllList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsResultVo">
  122. SELECT
  123. g.*,
  124. ps.supply_name,
  125. cet.education_name,
  126. cpt.project_name,
  127. cb.business_name,
  128. s.school_name,
  129. m.category_name,
  130. ot.type AS template_type,
  131. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  132. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  133. <if test="sectionNum ==1">
  134. ,(SELECT COUNT(m.id)+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_module_chapter p on n.chapter_id = p.chapter_id LEFT JOIN course_menu m on m.menu_id = p.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(1))+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_menu m on m.menu_id = n.chapter_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(2)) FROM course_menu m LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(3)) as section_num
  135. </if>
  136. <if test="goodsType ==1">
  137. , (SELECT count(*) FROM goods_course where goods_id =g.goods_id ) as course_num
  138. , (SELECT count(*) FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
  139. </if>
  140. FROM
  141. goods g
  142. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  143. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  144. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  145. LEFT JOIN course_business cb ON g.business_id = cb.id
  146. LEFT JOIN school s ON s.id = g.school_id
  147. LEFT JOIN major m ON g.major_id = m.id
  148. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  149. WHERE
  150. 1 = 1
  151. <if test="status != null and status.size()!=0 ">
  152. AND g.status in
  153. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. <if test="goodsIds != null and goodsIds.size()!=0 ">
  158. AND g.goods_id in
  159. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  160. #{item}
  161. </foreach>
  162. </if>
  163. <if test="goodsType != null and goodsType != ''">
  164. AND g.goods_type = #{goodsType}
  165. </if>
  166. <if test="makeGoodsId != null and makeGoodsId != ''">
  167. AND g.make_goods_id = #{makeGoodsId}
  168. </if>
  169. <if test="goodsName != null and goodsName != ''">
  170. AND g.goods_name like concat('%', #{goodsName}, '%')
  171. </if>
  172. <if test="educationTypeId != null and educationTypeId != ''">
  173. AND g.education_type_id = #{educationTypeId}
  174. </if>
  175. <if test="businessIds != null and businessIds.size()!=0 ">
  176. AND g.business_id in
  177. <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
  178. #{item}
  179. </foreach>
  180. </if>
  181. <if test="businessId != null and businessId != ''">
  182. AND g.business_id = #{businessId}
  183. </if>
  184. <if test="schoolId != null and schoolId != ''">
  185. AND g.school_id = #{schoolId}
  186. </if>
  187. <if test="majorId != null and majorId != ''">
  188. AND g.major_id = #{majorId}
  189. </if>
  190. <if test="standPrice != null and standPrice != ''">
  191. AND g.stand_price = #{standPrice}
  192. </if>
  193. <if test="searchKey != null and searchKey != ''">
  194. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  195. </if>
  196. <if test="goodsStatus != null ">
  197. AND g.goods_status = #{goodsStatus}
  198. </if>
  199. <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
  200. and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN g.validity_start_time and g.validity_end_time
  201. </if>
  202. <if test="validityStartTime != null or validityEndTime != null ">
  203. AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime} BETWEEN g.validity_start_time and g.validity_end_time)
  204. </if>
  205. <if test="goodsType ==1 and subjectId >0">
  206. AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id = g.goods_id and c.`status` = 1
  207. AND c.subject_id = #{subjectId}) >0
  208. </if>
  209. <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
  210. AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id = g.goods_id and c.`status` = 1
  211. ) >0
  212. </if>
  213. <if test="goodsType ==2 and subjectId >0">
  214. AND g.goods_id in(
  215. SELECT
  216. ga.goods_id
  217. FROM
  218. goods_attached ga
  219. LEFT JOIN question_business qb ON ga.major_id = qb.major_id
  220. WHERE
  221. ((
  222. qb.type = 4
  223. AND ga.type = 1
  224. )
  225. OR ( qb.type = 3 AND ga.type = 2 )
  226. OR ( qb.type = 2 AND ga.type = 3 ))
  227. AND qb.subject_id = #{subjectId}
  228. )
  229. </if>
  230. <if test="sortType != null and sortType == 2">
  231. ORDER BY g.stand_price
  232. </if>
  233. <if test="sortType != null and sortType == 3">
  234. ORDER BY g.stand_price DESC
  235. </if>
  236. <if test="sortType == null or sortType == 1">
  237. ORDER BY g.create_time DESC
  238. </if>
  239. </select>
  240. <select id="selectListToInput" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsResultVo">
  241. SELECT
  242. g.*,
  243. ps.supply_name,
  244. cet.education_name,
  245. cpt.project_name,
  246. cb.business_name,
  247. s.school_name,
  248. m.category_name,
  249. ot.type AS template_type,
  250. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  251. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  252. <if test="sectionNum ==1">
  253. ,(SELECT COUNT(m.id)+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_module_chapter p on n.chapter_id = p.chapter_id LEFT JOIN course_menu m on m.menu_id = p.module_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(1))+(SELECT COUNT(n.id) FROM course_chapter_section n LEFT JOIN course_menu m on m.menu_id = n.chapter_id LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(2)) FROM course_menu m LEFT JOIN goods_course gc on gc.course_id = m.course_id where gc.goods_id = g.goods_id and m.type in(3)) as section_num
  254. </if>
  255. <if test="goodsType ==1">
  256. , (SELECT count(*) FROM goods_course where goods_id =g.goods_id ) as course_num
  257. , (SELECT count(*) FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where cgg.goods_id = g.goods_id and cg.`status` = 1 ) as grade_num
  258. , (SELECT cg.grade_id FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where cgg.goods_id = g.goods_id and cg.`status` = 1 AND (unix_timestamp(now()) &lt; cg.class_end_time or cg.class_start_time is null) AND cg.`status` = 1 AND (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = cg.grade_id and a.status =1) &lt; cg.student_upper limit 1) as grade_id
  259. , (SELECT cg.class_name FROM class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where cgg.goods_id = g.goods_id and cg.`status` = 1 AND (unix_timestamp(now()) &lt; cg.class_end_time or cg.class_start_time is null) AND cg.`status` = 1 AND (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = cg.grade_id and a.status =1) &lt; cg.student_upper limit 1) as grade_name
  260. </if>
  261. FROM
  262. goods g
  263. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  264. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  265. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  266. LEFT JOIN course_business cb ON g.business_id = cb.id
  267. LEFT JOIN school s ON s.id = g.school_id
  268. LEFT JOIN major m ON g.major_id = m.id
  269. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  270. WHERE
  271. 1 = 1
  272. <if test="status != null and status.size()!=0 ">
  273. AND g.status in
  274. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  275. #{item}
  276. </foreach>
  277. </if>
  278. <if test="goodsIds != null and goodsIds.size()!=0 ">
  279. AND g.goods_id in
  280. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  281. #{item}
  282. </foreach>
  283. </if>
  284. <if test="goodsType != null and goodsType != ''">
  285. AND g.goods_type = #{goodsType}
  286. </if>
  287. <if test="makeGoodsId != null and makeGoodsId != ''">
  288. AND g.make_goods_id = #{makeGoodsId}
  289. </if>
  290. <if test="goodsName != null and goodsName != ''">
  291. AND g.goods_name like concat('%', #{goodsName}, '%')
  292. </if>
  293. <if test="educationTypeId != null and educationTypeId != ''">
  294. AND g.education_type_id = #{educationTypeId}
  295. </if>
  296. <if test="businessIds != null and businessIds.size()!=0 ">
  297. AND g.business_id in
  298. <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
  299. #{item}
  300. </foreach>
  301. </if>
  302. <if test="businessId != null and businessId != ''">
  303. AND g.business_id = #{businessId}
  304. </if>
  305. <if test="schoolId != null and schoolId != ''">
  306. AND g.school_id = #{schoolId}
  307. </if>
  308. <if test="majorId != null and majorId != ''">
  309. AND g.major_id = #{majorId}
  310. </if>
  311. <if test="standPrice != null and standPrice != ''">
  312. AND g.stand_price = #{standPrice}
  313. </if>
  314. <if test="searchKey != null and searchKey != ''">
  315. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  316. </if>
  317. <if test="goodsStatus != null ">
  318. AND g.goods_status = #{goodsStatus}
  319. </if>
  320. <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
  321. and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN g.validity_start_time and g.validity_end_time
  322. </if>
  323. <if test="validityStartTime != null or validityEndTime != null ">
  324. AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime} BETWEEN g.validity_start_time and g.validity_end_time)
  325. </if>
  326. <if test="goodsType ==1 and subjectId >0">
  327. AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id = g.goods_id and c.`status` = 1
  328. AND c.subject_id = #{subjectId}) >0
  329. </if>
  330. <if test="goodsType ==1 and haveCourse != null and haveCourse == 1">
  331. AND (SELECT count(*) from goods_course gc LEFT JOIN course c ON gc.course_id = c.course_id where gc.goods_id = g.goods_id and c.`status` = 1
  332. ) >0
  333. </if>
  334. <if test="goodsType ==2 and subjectId >0">
  335. AND g.goods_id in(
  336. SELECT
  337. ga.goods_id
  338. FROM
  339. goods_attached ga
  340. LEFT JOIN question_business qb ON ga.major_id = qb.major_id
  341. WHERE
  342. ((
  343. qb.type = 4
  344. AND ga.type = 1
  345. )
  346. OR ( qb.type = 3 AND ga.type = 2 )
  347. OR ( qb.type = 2 AND ga.type = 3 ))
  348. AND qb.subject_id = #{subjectId}
  349. )
  350. </if>
  351. <if test="sortType != null and sortType == 2">
  352. ORDER BY g.stand_price
  353. </if>
  354. <if test="sortType != null and sortType == 3">
  355. ORDER BY g.stand_price DESC
  356. </if>
  357. <if test="sortType == null or sortType == 1">
  358. ORDER BY g.create_time DESC
  359. </if>
  360. </select>
  361. <select id="selectDetail" parameterType="Long" resultMap="GoodsResultVo">
  362. SELECT
  363. g.*,
  364. ps.supply_name,
  365. cet.education_name,
  366. cpt.project_name,
  367. cb.business_name,
  368. s.school_name,
  369. m.category_name,
  370. ot.type AS template_type,
  371. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  372. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code,
  373. (SELECT
  374. count( DISTINCT c.subject_id )
  375. FROM
  376. course c
  377. LEFT JOIN goods_course gc ON gc.course_id = c.course_id
  378. WHERE
  379. gc.goods_id = g.goods_id) as subject_num
  380. FROM
  381. goods g
  382. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  383. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  384. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  385. LEFT JOIN course_business cb ON g.business_id = cb.id
  386. LEFT JOIN school s ON s.id = g.school_id
  387. LEFT JOIN major m ON g.major_id = m.id
  388. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  389. WHERE
  390. g.goods_id = #{goodsId}
  391. </select>
  392. <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo" resultMap="ExamNumberGoodsVoResult">
  393. SELECT
  394. goods_id,
  395. goods_name,
  396. validity_start_time,
  397. validity_end_time,
  398. goods_status,
  399. status,
  400. CODE,
  401. stand_price,
  402. <if test="filtration != null and filtration == 1">
  403. (case WHEN (SELECT COUNT(gs.goods_id) FROM goods gs where 1=1 and gs.make_goods_id = g.goods_id and gs.status =1 and gs.goods_type =4) >0 then 0 ELSE 1 end) as select_status
  404. </if>
  405. <if test="filtration != null and filtration == 2">
  406. (case WHEN (SELECT COUNT(gs.goods_id) FROM goods gs where 1=1 and gs.make_goods_id = g.goods_id and gs.status =1 and gs.goods_type =3) >0 then 0 ELSE 1 end) as select_status
  407. </if>
  408. FROM
  409. goods g
  410. WHERE
  411. 1 = 1
  412. and g.status in(1)
  413. and g.goods_type=1
  414. <if test="businessId != null and businessId != ''">
  415. and g.business_id = #{businessId}
  416. </if>
  417. <if test="goodsId != null and goodsId != ''">
  418. and g.goods_id = #{goodsId}
  419. </if>
  420. <if test="projectId != null and projectId != ''">
  421. and g.project_id = #{projectId}
  422. </if>
  423. <if test="goodsType != null and goodsType != ''">
  424. and g.goods_type = #{goodsType}
  425. </if>
  426. <if test="goodsStatus != null and goodsStatus != ''">
  427. and g.goods_status = #{goodsStatus}
  428. </if>
  429. <if test="searchKey != null and searchKey != ''">
  430. and (g.goods_name like concat('%', #{searchKey}, '%') or g.code like concat('%', #{searchKey}, '%'))
  431. </if>
  432. order by g.create_time desc
  433. </select>
  434. <select id="selectUserDetail" parameterType="map" resultMap="GoodsResultVo">
  435. SELECT
  436. g.*,
  437. ps.supply_name,
  438. cet.education_name,
  439. cpt.project_name,
  440. cb.business_name,
  441. s.school_name,
  442. m.category_name,
  443. ot.type AS template_type,
  444. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  445. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code,
  446. (SELECT DISTINCT cg.grade_id FROM class_grade_user cgu LEFT JOIN class_grade_goods cgg on cgg.grade_id = cgu.grade_id LEFT JOIN class_grade cg on cg.grade_id = cgu.grade_id
  447. where cgu.user_id = #{userId} and cgg.goods_id=g.goods_id and cg.`status` =1 and unix_timestamp(now()) BETWEEN cg.class_start_time and cg.class_end_time) as grade_id
  448. FROM
  449. goods g
  450. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  451. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  452. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  453. LEFT JOIN course_business cb ON g.business_id = cb.id
  454. LEFT JOIN school s ON s.id = g.school_id
  455. LEFT JOIN major m ON g.major_id = m.id
  456. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  457. WHERE
  458. g.goods_id = #{goodsId}
  459. </select>
  460. <select id="getQuestionNum" parameterType="Long" resultType="Long">
  461. SELECT
  462. count( question_id ) question_num
  463. FROM
  464. exam_question
  465. WHERE
  466. find_in_set(
  467. exam_id,(
  468. SELECT
  469. concat(
  470. IFNULL((
  471. SELECT
  472. GROUP_CONCAT( exam_id )
  473. FROM
  474. question_chapter_exam
  475. WHERE
  476. FIND_IN_SET(chapter_exam_id,
  477. (SELECT
  478. concat(
  479. IFNULL(( SELECT GROUP_CONCAT( major_id ) eids FROM goods_attached WHERE goods_id = #{goodsId} AND type = 2 ), '' ),
  480. ',',
  481. IFNULL(
  482. (
  483. SELECT
  484. GROUP_CONCAT( chapter_exam_id ) eids2
  485. FROM
  486. question_module_chapter
  487. WHERE
  488. module_exam_id IN ( SELECT major_id FROM goods_attached WHERE goods_id = #{goodsId} AND type = 1 )),
  489. ''
  490. ))))),
  491. ''
  492. ),
  493. ',',
  494. IFNULL(( SELECT GROUP_CONCAT( major_id ) FROM goods_attached WHERE goods_id = #{goodsId} AND type = 3 ), '' ))))
  495. </select>
  496. <update id="queryUpGoods">
  497. update goods g set g.goods_status=0 where unix_timestamp(now()) > g.validity_end_time and g.goods_status = 1
  498. </update>
  499. </mapper>