Browse Source

商品关联分部

zouxuan 4 years ago
parent
commit
a3ebf241bb

+ 18 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java

@@ -21,7 +21,7 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
      * @param subjectId
      * @return
      */
-    List<Goods> findGoodsBySubId(@Param("subjectId") Integer subjectId, @Param("type") String type);
+    List<Goods> findGoodsBySubId(@Param("subjectId") Integer subjectId, @Param("type") String type,@Param("organId")Integer organId);
 
     /**
      * 根据商品分类查找商品数量
@@ -115,8 +115,18 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
      */
     List<Goods> findBySns(@Param("sns") List<String> sns);
 
+    /**
+     * 获取内部库存预警商品
+     * @param innerRepertoryWarnNum
+     * @return
+     */
     String getInnerRepertoryWarnName(@Param("innerRepertoryWarnNum") String innerRepertoryWarnNum);
 
+    /**
+     * 获取外部库存预警商品
+     * @param outerRepertoryWarnNum
+     * @return
+     */
     String getOuterRepertoryWarnName(@Param("outerRepertoryWarnNum") String outerRepertoryWarnNum);
 
     /**
@@ -135,9 +145,14 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
      *
      * @return
      */
-    List<MusicGroupGoodsAndDiscountDto> getMusicGroupGoodsAndDiscount(@Param("subjectId") Integer subjectId, @Param("type") String type, @Param("courseViewType") Integer courseViewType);
+    List<MusicGroupGoodsAndDiscountDto> getMusicGroupGoodsAndDiscount(@Param("subjectId") Integer subjectId,
+                                                                      @Param("type") String type,
+                                                                      @Param("courseViewType") Integer courseViewType,
+                                                                      @Param("organId") Integer organId);
 
-    List<MusicGroupGoodsAndDiscountDto> getMusicGroupGoodsAndDiscountWithSubjects(@Param("subjectIds") String subjectIds, @Param("type") String type);
+    List<MusicGroupGoodsAndDiscountDto> getMusicGroupGoodsAndDiscountWithSubjects(@Param("subjectIds") String subjectIds,
+                                                                                  @Param("type") String type,
+                                                                                  @Param("organId") Integer organId);
 
     /**
      * 是否存在已上架的商品编号

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Goods.java

@@ -150,6 +150,17 @@ public class Goods {
 	@ApiModelProperty(value = "库存预警")
 	private YesOrNoEnum stockWarning;
 
+	@ApiModelProperty(value = "商品所属分部")
+	private String organIdList;
+
+	public String getOrganIdList() {
+		return organIdList;
+	}
+
+	public void setOrganIdList(String organIdList) {
+		this.organIdList = organIdList;
+	}
+
 	public String getCourseViewType() {
 		return courseViewType;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ReplacementInstrumentQueryInfo.java

@@ -5,12 +5,22 @@ import com.ym.mec.common.page.QueryInfo;
 
 public class ReplacementInstrumentQueryInfo extends QueryInfo {
 
+    private Integer organId;
+
     private Integer subjectId;
 
     private String brand;
 
     private String specification;
 
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
     public Integer getSubjectId() {
         return subjectId;
     }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -32,7 +32,7 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @param subjectId
      * @return
      */
-    List<Goods> findGoodsBySubId(Integer subjectId,String type);
+    List<Goods> findGoodsBySubId(Integer subjectId,String type,Integer organId);
 
     /**
      * 根据商品分类id查找商品数量

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -174,8 +174,8 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
-	public List<Goods> findGoodsBySubId(Integer subjectId,String type) {
-		return goodsDao.findGoodsBySubId(subjectId,type);
+	public List<Goods> findGoodsBySubId(Integer subjectId,String type,Integer organId) {
+		return goodsDao.findGoodsBySubId(subjectId,type,organId);
 	}
 
 	public int findGoodsNumByCategoryId(Integer goodsCategoryId){

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java

@@ -239,10 +239,12 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
 
     @Override
     public List<MusicGroupGoodsAndDiscountDto> getSubjectGoods(Integer subjectId, String type, Integer chargeTypeId, Integer courseViewType, String musicGroupId) {
+        Integer organId = null;
         if (StringUtils.isNotEmpty(musicGroupId)) {
             MusicGroup musicGroup = musicGroupService.get(musicGroupId);
             courseViewType = musicGroup.getCourseViewType().getCode();
             courseViewType = courseViewType == 3?2:courseViewType;
+            organId = musicGroup.getOrganId();
         }
         List<MusicGroupGoodsAndDiscountDto> goodsList = goodsDao.getMusicGroupGoodsAndDiscount(subjectId, type, courseViewType);
         if (chargeTypeId == null || (type != null && !"INSTRUMENT".equals(type))) {

+ 27 - 4
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -41,6 +41,7 @@
         <result column="replacement_show_" property="replacementShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="stock_warning_" property="stockWarning" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="course_view_type_" property="courseViewType"/>
+        <result column="organ_id_list_" property="organIdList"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -63,20 +64,21 @@
         INSERT INTO goods
         (goods_category_id_,sn_,name_,brand_,specification_,image_,stock_count_,tax_stock_count_,sell_count_,market_price_,
         discount_price_,group_purchase_price_,brief_,desc_,is_new_,is_top_,status_,memo_,publish_time_,
-        complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,client_show_,educational_show_,music_group_show_,replacement_show_,stock_warning_,stock_type_,course_view_type_)
+        complement_goods_id_list_,update_time_,create_time_,type_,agree_cost_price_,client_show_,educational_show_,
+         music_group_show_,replacement_show_,stock_warning_,stock_type_,course_view_type_,organ_id_list_)
         VALUES(#{goodsCategoryId},#{sn},#{name},#{brand},#{specification},#{image},#{stockCount},#{taxStockCount},#{sellCount},#{marketPrice},
         #{discountPrice},#{groupPurchasePrice},#{brief},#{desc},
         #{isNew,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isTop,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{memo},#{publishTime},#{complementGoodsIdList},now(),now(),#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{agreeCostPrice},
         #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{educationalShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         #{musicGroupShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{replacementShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseViewType})
+        #{stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{courseViewType},#{organIdList})
     </insert>
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
         INSERT INTO goods
         (goods_category_id_,name_,brand_,specification_,image_,market_price_,
         discount_price_,group_purchase_price_,brief_,desc_,update_time_,create_time_,type_,agree_cost_price_,sn_,
-        stock_count_,tax_stock_count_,client_show_,educational_show_,music_group_show_,replacement_show_,stock_warning_,stock_type_,course_view_type_)
+        stock_count_,tax_stock_count_,client_show_,educational_show_,music_group_show_,replacement_show_,stock_warning_,stock_type_,course_view_type_,organ_id_list_)
         VALUES
         <foreach collection="list" separator="," item="goods">
             (#{goods.goodsCategoryId},#{goods.name},#{goods.brand},#{goods.specification},#{goods.image},#{goods.marketPrice},
@@ -87,13 +89,16 @@
         	#{goods.musicGroupShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
         	#{goods.replacementShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             #{goods.stockWarning,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-            #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.courseViewType})
+            #{goods.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goods.courseViewType},#{goods.organIdList})
         </foreach>
     </insert>
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.Goods">
         UPDATE goods
         <set>
+            <if test="organIdList != null and organIdList != ''">
+                organ_id_list_ = #{organIdList},
+            </if>
             <if test="courseViewType != null">
                 course_view_type_ = #{courseViewType},
             </if>
@@ -190,6 +195,9 @@
         <foreach collection="goodsList" item="goods" separator=";">
             UPDATE goods
             <set>
+                <if test="goods.organIdList != null and goods.organIdList != ''">
+                    organ_id_list_ = #{goods.organIdList},
+                </if>
                 <if test="goods.courseViewType != null">
                     course_view_type_ = #{goods.courseViewType},
                 </if>
@@ -304,6 +312,9 @@
 
     <sql id="queryGoodsPageSql">
         <where>
+            <if test="organId != null">
+                AND FIND_IN_SET(#{organId},g.organ_id_list_)
+            </if>
             <if test="goodsCategoryId != null">
                 AND g.goods_category_id_ = #{goodsCategoryId}
             </if>
@@ -350,6 +361,9 @@
         SELECT g.* FROM subject_goods_mapper sgm
         LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
         WHERE sgm.subject_id_ = #{subjectId} AND g.type_ = #{type} and g.status_ != 0
+        <if test="organId != null">
+            AND FIND_IN_SET(#{organId},g.organ_id_list_)
+        </if>
     </select>
 
     <!-- 根据 -->
@@ -418,6 +432,9 @@
         SELECT g.* FROM subject_goods_mapper sgm
         LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
         WHERE sgm.subject_id_ = #{subjectId} AND g.music_group_show_ = 1 AND g.status_ != 0
+        <if test="organId != null">
+            AND FIND_IN_SET(#{organId},g.organ_id_list_)
+        </if>
         <if test="type!=null">
             AND g.type_ = #{type}
         </if>
@@ -430,6 +447,9 @@
         SELECT g.* FROM subject_goods_mapper sgm
         LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
         WHERE FIND_IN_SET(sgm.subject_id_, #{subjectIds}) and g.status_ != 0
+        <if test="organId != null">
+            AND FIND_IN_SET(#{organId},g.organ_id_list_)
+        </if>
         <if test="type!=null">
             AND g.type_ = #{type}
         </if>
@@ -484,6 +504,9 @@
             AND g.status_ != 0
             AND g.type_ = 'INSTRUMENT'
             AND gc.del_flag_ = 0
+            <if test="organId != null">
+                AND FIND_IN_SET(#{organId},g.organ_id_list_)
+            </if>
             <if test="subjectId != null">
                 AND sgm.subject_id_ = #{subjectId}
             </if>

+ 15 - 2
mec-student/src/main/java/com/ym/mec/student/controller/GoodsController.java

@@ -1,8 +1,10 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsCategory;
 import com.ym.mec.biz.service.GoodsCategoryService;
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -54,8 +56,19 @@ public class GoodsController extends BaseController {
     @ApiOperation(value = "通过科目编号、商品分类 查询商品(教材、辅件)列表")
     @GetMapping("/queryGoodsBySubId")
     @ApiImplicitParams({ @ApiImplicitParam(name = "subjectId", value = "科目编号", required = true, dataType = "Integer"),
+            @ApiImplicitParam(name = "organId", value = "分部编号", required = true, dataType = "Integer"),
             @ApiImplicitParam(name = "type", value = "INSTRUMENT 乐器, ACCESSORIES 教辅", required = true, dataType = "String")})
-    public Object findGoodsBySubId(Integer subjectId,String type){
-        return succeed(goodsService.findGoodsBySubId(subjectId,type));
+    public Object findGoodsBySubId(Integer subjectId,String type,Integer organId){
+        if(organId == null){
+            SysUser sysUser = sysUserFeignService.queryUserInfo();
+            if(sysUser == null){
+                throw new BizException("请先登录");
+            }
+            organId = sysUser.getOrganId();
+            if(organId == null){
+                throw new BizException("学员分部异常,请联系管理员");
+            }
+        }
+        return succeed(goodsService.findGoodsBySubId(subjectId,type,organId));
     }
 }

+ 1 - 0
mec-student/src/main/java/com/ym/mec/student/controller/ReplacementInstrumentController.java

@@ -34,6 +34,7 @@ public class ReplacementInstrumentController extends BaseController {
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
+        queryInfo.setOrganId(sysUser.getOrganId());
         return succeed(replacementInstrumentService.getPageList(queryInfo));
     }
 

+ 7 - 2
mec-web/src/main/java/com/ym/mec/web/controller/GoodsController.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.service.GoodsCategoryService;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -118,8 +119,12 @@ public class GoodsController extends BaseController {
     @GetMapping("/queryGoodsBySubId")
     @PreAuthorize("@pcs.hasPermissions('goods/queryGoodsBySubId')")
     @ApiImplicitParams({ @ApiImplicitParam(name = "subjectId", value = "科目编号", required = true, dataType = "Integer"),
+            @ApiImplicitParam(name = "organId", value = "分部编号", required = true, dataType = "Integer"),
             @ApiImplicitParam(name = "type", value = "INSTRUMENT 乐器, ACCESSORIES 教辅", required = true, dataType = "String")})
-    public Object findGoodsBySubId(Integer subjectId,String type){
-        return succeed(goodsService.findGoodsBySubId(subjectId,type));
+    public Object findGoodsBySubId(Integer subjectId,String type,Integer organId){
+        if(organId == null){
+            throw new BizException("请选择用户分部");
+        }
+        return succeed(goodsService.findGoodsBySubId(subjectId,type,organId));
     }
 }

+ 4 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentController.java

@@ -7,6 +7,7 @@ import com.ym.mec.biz.dal.page.ReplacementInstrumentQueryInfo;
 import com.ym.mec.biz.service.ReplacementInstrumentService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -31,6 +32,9 @@ public class ReplacementInstrumentController extends BaseController {
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
+        if(queryInfo.getOrganId() == null){
+            throw new BizException("参数校验失败:学员分部为空");
+        }
         return succeed(replacementInstrumentService.getPageList(queryInfo));
     }