GoodsMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. WHERE
  126. 1 = 1
  127. <if test="status != null and status.size()!=0 ">
  128. AND g.status in
  129. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  130. #{item}
  131. </foreach>
  132. </if>
  133. <if test="goodsIds != null and goodsIds.size()!=0 ">
  134. AND g.goods_id in
  135. <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
  136. #{item}
  137. </foreach>
  138. </if>
  139. <if test="goodsType != null and goodsType != ''">
  140. AND g.goods_type = #{goodsType}
  141. </if>
  142. <if test="goodsName != null and goodsName != ''">
  143. AND g.goods_name like concat('%', #{goodsName}, '%')
  144. </if>
  145. <if test="educationTypeId != null and educationTypeId != ''">
  146. AND g.education_type_id = #{educationTypeId}
  147. </if>
  148. <if test="businessIds != null and businessIds.size()!=0 ">
  149. AND g.business_id in
  150. <foreach collection="businessIds" item="item" index="index" open="(" close=")" separator=",">
  151. #{item}
  152. </foreach>
  153. </if>
  154. <if test="businessId != null and businessId != ''">
  155. AND g.business_id = #{businessId}
  156. </if>
  157. <if test="schoolId != null and schoolId != ''">
  158. AND g.school_id = #{schoolId}
  159. </if>
  160. <if test="majorId != null and majorId != ''">
  161. AND g.major_id = #{majorId}
  162. </if>
  163. <if test="goodsStatus != null ">
  164. AND g.goods_status = #{goodsStatus}
  165. </if>
  166. <if test="studyStartTime != null and studyStartTime != '' and studyEndTime != null and studyEndTime != ''">
  167. and #{studyStartTime} BETWEEN g.validity_start_time and g.validity_end_time or #{studyEndTime} BETWEEN g.validity_start_time and g.validity_end_time
  168. </if>
  169. ORDER BY g.update_time DESC
  170. </select>
  171. <select id="selectDetail" parameterType="Long" resultMap="GoodsResultVo">
  172. SELECT
  173. g.*,
  174. ps.supply_name,
  175. cet.education_name,
  176. cpt.project_name,
  177. cb.business_name,
  178. s.school_name,
  179. m.category_name,
  180. ot.type AS template_type,
  181. (SELECT gs.goods_name FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_name,
  182. (SELECT gs.code FROM goods gs where 1=1 and g.make_goods_id = gs.goods_id) as make_goods_code
  183. FROM
  184. goods g
  185. LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id
  186. LEFT JOIN course_education_type cet ON g.education_type_id = cet.id
  187. LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
  188. LEFT JOIN course_business cb ON g.business_id = cb.id
  189. LEFT JOIN school s ON s.id = g.school_id
  190. LEFT JOIN major m ON g.major_id = m.id
  191. LEFT JOIN order_input_template ot ON cb.template_status = ot.id
  192. WHERE
  193. g.goods_id = #{goodsId}
  194. </select>
  195. <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo" resultMap="ExamNumberGoodsVoResult">
  196. SELECT
  197. goods_id,
  198. goods_name,
  199. CODE,
  200. stand_price,
  201. <if test="filtration != null and filtration == 1">
  202. (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
  203. </if>
  204. <if test="filtration != null and filtration == 2">
  205. (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
  206. </if>
  207. FROM
  208. goods g
  209. WHERE
  210. 1 = 1
  211. and g.status in(1)
  212. and g.goods_type=1
  213. <if test="businessId != null and businessId != ''">
  214. and g.business_id = #{businessId}
  215. </if>
  216. <if test="goodsId != null and goodsId != ''">
  217. and g.goods_id = #{goodsId}
  218. </if>
  219. <if test="projectId != null and projectId != ''">
  220. and g.project_id = #{projectId}
  221. </if>
  222. <if test="goodsType != null and goodsType != ''">
  223. and g.goods_type = #{goodsType}
  224. </if>
  225. </select>
  226. </mapper>