GoodsMapper.xml 29 KB

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