GoodsMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. </resultMap>
  44. <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">
  45. <result property="goodsId" column="goods_id"/>
  46. <result property="year" column="year"/>
  47. <result property="supplyId" column="supply_id"/>
  48. <result property="goodsType" column="goods_type"/>
  49. <result property="educationTypeId" column="education_type_id"/>
  50. <result property="businessId" column="business_id"/>
  51. <result property="schoolId" column="school_id"/>
  52. <result property="majorId" column="major_id"/>
  53. <result property="goodsName" column="goods_name"/>
  54. <result property="standPrice" column="stand_price"/>
  55. <result property="lowestPrice" column="lowest_price"/>
  56. <result property="createTime" column="create_time"/>
  57. <result property="updateTime" column="update_time"/>
  58. <result property="status" column="status"/>
  59. <result property="validityStartTime" column="validity_start_time"/>
  60. <result property="validityEndTime" column="validity_end_time"/>
  61. <result property="studyStartTime" column="study_start_time"/>
  62. <result property="studyEndTime" column="study_end_time"/>
  63. <result property="certificateIds" column="certificate_ids"/>
  64. <result property="introduce" column="introduce"/>
  65. <result property="suitableObject" column="suitable_object"/>
  66. <result property="buyNote" column="buy_note"/>
  67. <result property="pcDetailHtml" column="pc_detail_html"/>
  68. <result property="mobileDetailHtml" column="mobile_detail_html"/>
  69. <result property="goodsStatus" column="goods_status"/>
  70. <result property="coverUrl" column="cover_url"/>
  71. <result property="classHours" column="class_hours"/>
  72. <result property="standPriceJson" column="stand_price_json"/>
  73. <result property="code" column="code"/>
  74. <result property="projectId" column="project_id"/>
  75. <result property="goodsAuditionConfig" column="goods_audition_config"/>
  76. <result property="goodsPhotographConfig" column="goods_photograph_config"/>
  77. <result property="goodsAuditionExamConfig" column="goods_audition_exam_config"/>
  78. <result property="goodsPlayConfig" column="goods_play_config"/>
  79. <result property="goodsExamConfig" column="goods_exam_config"/>
  80. <result property="supplyName" column="supply_name"/>
  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="handoutsId" column="handouts_id"/>
  87. <result property="templateType" column="template_type"/>
  88. <result property="period" column="period"/>
  89. <result property="makeStartTime" column="make_start_time"/>
  90. <result property="makeEndTime" column="make_end_time"/>
  91. <result property="studyCount" column="study_count"/>
  92. <result property="makeGoodsName" column="make_goods_name"/>
  93. <result property="makeGoodsCode" column="make_goods_code"/>
  94. </resultMap>
  95. <resultMap type="com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo" id="ExamNumberGoodsVoResult">
  96. <result property="id" column="id"/>
  97. <result property="examNumberId" column="exam_number_id"/>
  98. <result property="goodsId" column="goods_id"/>
  99. <result property="goodsName" column="goods_name"/>
  100. <result property="code" column="code"/>
  101. <result property="standPrice" column="stand_price"/>
  102. <result property="goodsStatus" column="goods_status"/>
  103. </resultMap>
  104. <select id="selectList" parameterType="com.zhongzheng.modules.goods.bo.GoodsQueryBo" resultMap="GoodsResultVo">
  105. SELECT
  106. g.*,
  107. ps.supply_name,
  108. cet.education_name,
  109. cpt.project_name,
  110. cb.business_name,
  111. s.school_name,
  112. m.category_name,
  113. ot.type AS template_type,
  114. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  115. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  116. FROM
  117. goods g
  118. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  119. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  120. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  121. LEFT JOIN course_business cb ON g.business_id = cb.id
  122. LEFT JOIN school s ON s.id = g.school_id
  123. LEFT JOIN major m ON g.major_id = m.id
  124. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  125. <if test="goodsType ==1 and subjectId >0">
  126. LEFT JOIN goods_course gc ON gc.goods_id = g.goods_id
  127. LEFT JOIN course c ON gc.course_id = c.course_id
  128. </if>
  129. <if test="goodsType ==2 and subjectId >0">
  130. LEFT JOIN goods_attached ga on g.goods_id = ga.goods_id
  131. LEFT JOIN question_business qb on ga.major_id = qb.major_id
  132. </if>
  133. WHERE
  134. 1 = 1
  135. <if test="status != null and status.size()!=0 ">
  136. AND g.status in
  137. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  138. #{item}
  139. </foreach>
  140. </if>
  141. <if test="goodsIds != null and goodsIds.size()!=0 ">
  142. AND g.goods_id in
  143. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  144. #{item}
  145. </foreach>
  146. </if>
  147. <if test="goodsType != null and goodsType != ''">
  148. AND g.goods_type = #{goodsType}
  149. </if>
  150. <if test="goodsName != null and goodsName != ''">
  151. AND g.goods_name like concat('%', #{goodsName}, '%')
  152. </if>
  153. <if test="educationTypeId != null and educationTypeId != ''">
  154. AND g.education_type_id = #{educationTypeId}
  155. </if>
  156. <if test="businessIds != null and businessIds.size()!=0 ">
  157. AND g.business_id in
  158. <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
  159. #{item}
  160. </foreach>
  161. </if>
  162. <if test="businessId != null and businessId != ''">
  163. AND g.business_id = #{businessId}
  164. </if>
  165. <if test="schoolId != null and schoolId != ''">
  166. AND g.school_id = #{schoolId}
  167. </if>
  168. <if test="majorId != null and majorId != ''">
  169. AND g.major_id = #{majorId}
  170. </if>
  171. <if test="goodsStatus != null ">
  172. AND g.goods_status = #{goodsStatus}
  173. </if>
  174. <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
  175. and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN g.validity_start_time and g.validity_end_time
  176. </if>
  177. <if test="validityStartTime != null or validityEndTime != null ">
  178. AND (#{validityStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{validityEndTime} BETWEEN g.validity_start_time and g.validity_end_time)
  179. </if>
  180. <if test="goodsType ==1 and subjectId >0">
  181. AND c.`status` = 1
  182. AND c.subject_id = #{subjectId}
  183. </if>
  184. <if test="goodsType ==2 and subjectId >0">
  185. AND ((
  186. qb.type = 4
  187. AND ga.type = 1
  188. )
  189. OR ( qb.type = 3 AND ga.type = 2 )
  190. OR ( qb.type = 2 AND ga.type = 3 )) AND qb.subject_id = #{subjectId}
  191. </if>
  192. ORDER BY g.update_time DESC
  193. </select>
  194. <select id="selectDetail" parameterType="Long" resultMap="GoodsResultVo">
  195. SELECT
  196. g.*,
  197. ps.supply_name,
  198. cet.education_name,
  199. cpt.project_name,
  200. cb.business_name,
  201. s.school_name,
  202. m.category_name,
  203. ot.type AS template_type,
  204. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  205. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  206. FROM
  207. goods g
  208. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  209. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  210. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  211. LEFT JOIN course_business cb ON g.business_id = cb.id
  212. LEFT JOIN school s ON s.id = g.school_id
  213. LEFT JOIN major m ON g.major_id = m.id
  214. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  215. WHERE
  216. g.goods_id = #{goodsId}
  217. </select>
  218. <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo" resultMap="ExamNumberGoodsVoResult">
  219. SELECT
  220. goods_id,
  221. goods_name,
  222. CODE,
  223. stand_price,
  224. <if test="filtration != null and filtration == 1">
  225. (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 goods_status
  226. </if>
  227. <if test="filtration != null and filtration == 2">
  228. (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 goods_status
  229. </if>
  230. FROM
  231. goods g
  232. WHERE
  233. 1 = 1
  234. and g.status in(1)
  235. and g.goods_type=1
  236. <if test="businessId != null and businessId != ''">
  237. and g.business_id = #{businessId}
  238. </if>
  239. <if test="goodsId != null and goodsId != ''">
  240. and g.goods_id = #{goodsId}
  241. </if>
  242. <if test="projectId != null and projectId != ''">
  243. and g.project_id = #{projectId}
  244. </if>
  245. <if test="goodsType != null and goodsType != ''">
  246. and g.goods_type = #{goodsType}
  247. </if>
  248. <if test="goodsStatus != null and goodsStatus != ''">
  249. and g.goods_status = #{goodsStatus}
  250. </if>
  251. </select>
  252. </mapper>