فهرست منبع

Merge remote-tracking branch 'origin/zx_saas_goods' into zx_saas_goods

zouxuan 1 سال پیش
والد
کامیت
596cbfd19f

+ 1 - 14
mec-application/src/main/java/com/ym/mec/teacher/controller/GoodsController.java

@@ -1,9 +1,5 @@
 package com.ym.mec.teacher.controller;
 
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.GoodsCategory;
-import com.ym.mec.biz.dal.wrapper.GoodsWrapper;
-import com.ym.mec.biz.service.GoodsCategoryService;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
@@ -15,8 +11,6 @@ import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Objects;
-
 @RequestMapping("${app-config.url.teacher:}/goods")
 @Api(tags = "商品(教材、辅件)服务")
 @RestController
@@ -24,18 +18,11 @@ public class GoodsController extends BaseController {
 
     @Autowired
     private GoodsService goodsService;
-    @Autowired
-    private GoodsCategoryService goodsCategoryService;
 
     @ApiOperation(value = "根据商品(教材、辅件)编号查询商品(教材、辅件)")
     @GetMapping("/get/{id}")
     public Object get(@ApiParam(value = "商品(教材、辅件)编号", required = true) @PathVariable("id") Integer id) {
-        GoodsWrapper.Goods goods = goodsService.getDetail(id);
-        GoodsCategory goodsCategory = goodsCategoryService.get(goods.getGoodsCategoryId());
-        if (Objects.nonNull(goodsCategory)) {
-            goods.setGoodsCategoryName(goodsCategory.getName());
-        }
-        return succeed(goods);
+        return succeed(goodsService.getDetail(id));
     }
 
 }

+ 1 - 17
mec-application/src/main/java/com/ym/mec/web/controller/GoodsController.java

@@ -3,19 +3,14 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.GoodsCategory;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.GoodsQuery;
 import com.ym.mec.biz.dal.page.GoodsQueryInfo;
 import com.ym.mec.biz.dal.wrapper.GoodsWrapper;
-import com.ym.mec.biz.service.GoodsCategoryService;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.dto.BrandDto;
-import com.ym.mec.common.dto.ProductCategoryDto;
-import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -30,10 +25,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
 
 @RequestMapping("${app-config.url.web:}/goods")
 @Api(tags = "商品(教材、辅件)服务")
@@ -43,8 +34,6 @@ public class GoodsController extends BaseController {
     @Autowired
     private GoodsService goodsService;
     @Autowired
-    private GoodsCategoryService goodsCategoryService;
-    @Autowired
     private SysUserService sysUserService;
     @Autowired
     private EmployeeDao employeeDao;
@@ -100,12 +89,7 @@ public class GoodsController extends BaseController {
     @ApiOperation(value = "根据商品(教材、辅件)编号查询商品(教材、辅件)")
     @GetMapping("/get/{id}")
     public Object get(@ApiParam(value = "商品(教材、辅件)编号", required = true) @PathVariable("id") Integer id){
-        GoodsWrapper.Goods goods = goodsService.getDetail(id);
-        GoodsCategory goodsCategory = goodsCategoryService.get(goods.getGoodsCategoryId());
-        if(Objects.nonNull(goodsCategory)){
-            goods.setGoodsCategoryName(goodsCategory.getName());
-        }
-        return succeed(goods);
+        return succeed(goodsService.getDetail(id));
     }
 
     @ApiOperation(value = "分页查询商品(教材、辅件)列表")

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

@@ -57,6 +57,8 @@ public class GoodsQueryInfo extends QueryInfo {
 
     private Integer subjectId;
 
+    private String goodsCategoryIds;
+
     public Integer getNoOrganSearch() {
         return noOrganSearch;
     }
@@ -184,4 +186,12 @@ public class GoodsQueryInfo extends QueryInfo {
     public void setBrandId(String brandId) {
         this.brandId = brandId;
     }
+
+    public String getGoodsCategoryIds() {
+        return goodsCategoryIds;
+    }
+
+    public void setGoodsCategoryIds(String goodsCategoryIds) {
+        this.goodsCategoryIds = goodsCategoryIds;
+    }
 }

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

@@ -69,6 +69,8 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      */
     List<Goods> findTypeGoods(String type, Integer tenantId);
 
+    PageInfo<Goods> queryPage(GoodsQueryInfo queryInfo);
+
     /**
      * @describe 商品导入
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!

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

@@ -47,7 +47,6 @@ import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.entity.UploadReturnBean;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
@@ -129,9 +128,13 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if (CollectionUtils.isEmpty(rows)) {
 			throw new BizException("没有查询到商品信息");
 		}
+		List<ProductCategoryDto> productCategoryDtos = treeToList(queryGoodsCategoryList());
+		Map<Long, String> IdNamemap = productCategoryDtos.stream().collect(Collectors.toMap(ProductCategoryDto::getId, ProductCategoryDto::getName));
+
 		List<Organization> all = organizationDao.findAll(params);
 		Map<Integer, String> organizationMap = all.stream().collect(Collectors.toMap(Organization::getId, Organization::getName));
 		for (Goods goods : rows) {
+			goods.setGoodsCategoryName(IdNamemap.getOrDefault(Long.valueOf(goods.getGoodsCategoryId()),""));
 			if(StringUtils.isNotEmpty(goods.getStudentShowOrganId())){
 				String[] split = goods.getStudentShowOrganId().split(",");
 				StringBuffer sb = new StringBuffer();
@@ -381,7 +384,18 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
-	public PageInfo<Goods> queryPage(QueryInfo queryInfo) {
+	public PageInfo<Goods> queryPage(GoodsQueryInfo queryInfo) {
+		Integer goodsCategoryId = queryInfo.getGoodsCategoryId();
+		if (goodsCategoryId != null) {
+			Map<Long, ProductCategoryDto> idCategoryMap = mallFeignService.listWithChildren().stream().collect(Collectors.toMap(ProductCategoryDto::getId, Function.identity()));
+			if (idCategoryMap.containsKey(Long.valueOf(goodsCategoryId))) {
+				ProductCategoryDto productCategoryDto = idCategoryMap.get(Long.valueOf(goodsCategoryId));
+				List<String> categoryIdList = productCategoryDto.getChildren().stream().map(ProductCategoryDto::getId).map(String::valueOf).distinct().collect(Collectors.toList());
+				categoryIdList.add(goodsCategoryId.toString());
+				queryInfo.setGoodsCategoryIds(String.join(",", categoryIdList));
+				queryInfo.setGoodsCategoryId(null);
+			}
+		}
 		PageInfo<Goods> page = super.queryPage(queryInfo);
 
 		List<Goods> rows = page.getRows();
@@ -1124,6 +1138,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		}
 		GoodsWrapper.Goods detail = JSON.parseObject(JSON.toJSONString(goods), GoodsWrapper.Goods.class);
 		detail.setGoodsSubList(queryGoodsSubByGoodId(goodsId));
+
+		List<ProductCategoryDto> productCategoryDtos = treeToList(queryGoodsCategoryList());
+		Map<Long, String> IdNamemap = productCategoryDtos.stream().collect(Collectors.toMap(ProductCategoryDto::getId, ProductCategoryDto::getName));
+		detail.setGoodsCategoryName(IdNamemap.getOrDefault(Long.valueOf(detail.getGoodsCategoryId()), ""));
 		return detail;
 	}
 
@@ -1163,6 +1181,21 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 
 			BigDecimal organCostPrice = goodsSubList.stream().map(GoodsWrapper.GoodsSub::getGoodsPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 			goodsInfo.setOrganCostPrice(organCostPrice);
+
+			//获取最小的库存数
+			String skuIds = goodsSubList.stream().map(e -> e.getSku().toString()).collect(Collectors.joining(","));
+			PmsProductQueryParamDto paramDto = new PmsProductQueryParamDto();
+			paramDto.setSkuStockIds(skuIds);
+			paramDto.setPageSize(1000);
+			paramDto.setPageNum(1);
+			paramDto.setJson(JSON.toJSONString(paramDto));
+			List<PmsProductDto> productList = mallFeignService.getProductList(paramDto).getRows();
+			if(CollectionUtils.isEmpty(productList)){
+				throw new BizException("子商品不存在");
+			}
+			//获取最小库存数量
+			Integer stock = productList.stream().map(PmsProductDto::getStock).min(Integer::compareTo).get();
+			goodsInfo.setStockCount(stock);
 		}
 		update(goodsInfo);
 	}

+ 12 - 9
mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml

@@ -328,6 +328,9 @@
             <if test="goodsCategoryId != null">
                 AND g.goods_category_id_ = #{goodsCategoryId}
             </if>
+            <if test="goodsCategoryIds != null">
+                AND find_in_set(g.goods_category_id_,#{goodsCategoryIds})
+            </if>
             <if test="type != null">
                 AND g.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
@@ -518,14 +521,14 @@
     </select>
 
     <select id="getGoodsInfo" resultMap="Goods">
-        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
-                                                          LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
+        SELECT g.* FROM goods g
+<!----><!--                                                          LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_-->
         WHERE g.id_=#{id}
     </select>
 
     <select id="getGoodiesAndCate" resultMap="Goods">
-        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
-        LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
+        SELECT g.* FROM goods g
+<!--        LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_-->
         WHERE g.id_ IN
         <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
             #{goodsId}
@@ -542,7 +545,7 @@
         SELECT g.id_,g.brand_,g.specification_,g.brief_ param_,g.market_price_,g.discount_price_,g.group_purchase_price_ sale_price_,
         (g.discount_price_-g.group_purchase_price_) depreciation_price_
         FROM subject_goods_mapper sgm
-        LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_
+<!--        LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_-->
         LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
         <include refid="replacementQuerySql"/>
         <include refid="global.limit"/>
@@ -551,7 +554,7 @@
     <select id="getReplacementInstrumentCount" resultType="int">
         SELECT COUNT(*)
         FROM subject_goods_mapper sgm
-        LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_
+<!--        LEFT JOIN goods_category gc ON gc.id_=sgm.goods_category_id_-->
         LEFT JOIN goods g ON sgm.goods_category_id_ = g.goods_category_id_
         <include refid="replacementQuerySql"/>
         <include refid="global.limit"/>
@@ -560,10 +563,10 @@
         select SUM(organ_cost_price_) from goods where FIND_IN_SET(id_,#{complementGoodsIdList});
     </select>
     <select id="exportGoods" resultMap="Goods">
-        SELECT g.*,gc.name_ goods_category_name_,
+        SELECT g.*,
         GROUP_CONCAT(gs.name_) child_name_,GROUP_CONCAT(gs.sn_) child_sn_,
         GROUP_CONCAT(gs.id_) child_id_,GROUP_CONCAT(gs.organ_cost_price_) child_organ_cost_price_ FROM goods g
-        LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_
+<!--        LEFT JOIN goods_category gc ON g.goods_category_id_ = gc.id_-->
         left join goods gs ON FIND_IN_SET(gs.id_,g.complement_goods_id_list_)
         <include refid="queryGoodsPageSql"/>
         GROUP BY g.id_
@@ -574,7 +577,7 @@
         <where>
             g.status_ != 0
             AND g.type_ = 'INSTRUMENT'
-            AND gc.del_flag_ = 0 and g.tenant_id_ = #{tenantId}
+<!--            AND gc.del_flag_ = 0 and g.tenant_id_ = #{tenantId}-->
             <if test="organId != null">
                 AND FIND_IN_SET(#{organId},g.replacement_show_organ_id_)
             </if>

+ 12 - 0
mec-mall/mall-mbg/src/main/java/com/yonge/cooleshow/mbg/model/PmsProduct.java

@@ -24,6 +24,9 @@ public class PmsProduct implements Serializable {
     @ApiModelProperty(value = "货号")
     private String productSn;
 
+    @ApiModelProperty(value = "产品类型")
+    private String productType;
+
     @ApiModelProperty(value = "删除状态:0->未删除;1->已删除")
     private Integer deleteStatus;
 
@@ -473,6 +476,14 @@ public class PmsProduct implements Serializable {
         this.detailMobileHtml = detailMobileHtml;
     }
 
+    public String getProductType() {
+        return productType;
+    }
+
+    public void setProductType(String productType) {
+        this.productType = productType;
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
@@ -487,6 +498,7 @@ public class PmsProduct implements Serializable {
         sb.append(", name=").append(name);
         sb.append(", pic=").append(pic);
         sb.append(", productSn=").append(productSn);
+        sb.append(", productType=").append(productType);
         sb.append(", deleteStatus=").append(deleteStatus);
         sb.append(", publishStatus=").append(publishStatus);
         sb.append(", newStatus=").append(newStatus);

+ 20 - 3
mec-mall/mall-mbg/src/main/resources/config/mybatis/PmsProductMapper.xml

@@ -10,6 +10,7 @@
     <result column="name" jdbcType="VARCHAR" property="name" />
     <result column="pic" jdbcType="VARCHAR" property="pic" />
     <result column="product_sn" jdbcType="VARCHAR" property="productSn" />
+    <result column="product_type" jdbcType="VARCHAR" property="productType" />
     <result column="delete_status" jdbcType="INTEGER" property="deleteStatus" />
     <result column="publish_status" jdbcType="INTEGER" property="publishStatus" />
     <result column="new_status" jdbcType="INTEGER" property="newStatus" />
@@ -108,7 +109,7 @@
   </sql>
   <sql id="Base_Column_List">
     id, brand_id, product_category_id, feight_template_id, product_attribute_category_id, 
-    name, pic, product_sn, delete_status, publish_status, new_status, recommand_status, 
+    name, pic, product_sn, product_type, delete_status, publish_status, new_status, recommand_status,
     verify_status, sort, sale, price, promotion_price, gift_growth, gift_point, use_point_limit, 
     sub_title, original_price, stock, low_stock, unit, weight, preview_status, service_ids, 
     keywords, note, album_pics, detail_title, promotion_start_time, promotion_end_time, 
@@ -171,7 +172,7 @@
     </selectKey>
     insert into pms_product (brand_id, product_category_id, feight_template_id, 
       product_attribute_category_id, name, pic, 
-      product_sn, delete_status, publish_status, 
+      product_sn, product_type, delete_status, publish_status,
       new_status, recommand_status, verify_status, 
       sort, sale, price, 
       promotion_price, gift_growth, gift_point, 
@@ -185,7 +186,7 @@
       detail_html, detail_mobile_html,lock_stock)
     values (#{brandId,jdbcType=BIGINT}, #{productCategoryId,jdbcType=BIGINT}, #{feightTemplateId,jdbcType=BIGINT}, 
       #{productAttributeCategoryId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{pic,jdbcType=VARCHAR}, 
-      #{productSn,jdbcType=VARCHAR}, #{deleteStatus,jdbcType=INTEGER}, #{publishStatus,jdbcType=INTEGER}, 
+      #{productSn,jdbcType=VARCHAR}, #{productType,jdbcType=VARCHAR}, #{deleteStatus,jdbcType=INTEGER}, #{publishStatus,jdbcType=INTEGER},
       #{newStatus,jdbcType=INTEGER}, #{recommandStatus,jdbcType=INTEGER}, #{verifyStatus,jdbcType=INTEGER}, 
       #{sort,jdbcType=INTEGER}, #{sale,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, 
       #{promotionPrice,jdbcType=DECIMAL}, #{giftGrowth,jdbcType=INTEGER}, #{giftPoint,jdbcType=INTEGER}, 
@@ -225,6 +226,9 @@
       <if test="productSn != null">
         product_sn,
       </if>
+      <if test="productType != null">
+        product_type,
+      </if>
       <if test="deleteStatus != null">
         delete_status,
       </if>
@@ -354,6 +358,9 @@
       <if test="productSn != null">
         #{productSn,jdbcType=VARCHAR},
       </if>
+      <if test="productType != null">
+        #{productType,jdbcType=VARCHAR},
+      </if>
       <if test="deleteStatus != null">
         #{deleteStatus,jdbcType=INTEGER},
       </if>
@@ -495,6 +502,9 @@
       <if test="record.productSn != null">
         product_sn = #{record.productSn,jdbcType=VARCHAR},
       </if>
+      <if test="record.productType != null">
+        product_sn = #{record.productType,jdbcType=VARCHAR},
+      </if>
       <if test="record.deleteStatus != null">
         delete_status = #{record.deleteStatus,jdbcType=INTEGER},
       </if>
@@ -615,6 +625,7 @@
       name = #{record.name,jdbcType=VARCHAR},
       pic = #{record.pic,jdbcType=VARCHAR},
       product_sn = #{record.productSn,jdbcType=VARCHAR},
+      product_type = #{record.productType,jdbcType=VARCHAR},
       delete_status = #{record.deleteStatus,jdbcType=INTEGER},
       publish_status = #{record.publishStatus,jdbcType=INTEGER},
       new_status = #{record.newStatus,jdbcType=INTEGER},
@@ -664,6 +675,7 @@
       name = #{record.name,jdbcType=VARCHAR},
       pic = #{record.pic,jdbcType=VARCHAR},
       product_sn = #{record.productSn,jdbcType=VARCHAR},
+      product_type = #{record.productType,jdbcType=VARCHAR},
       delete_status = #{record.deleteStatus,jdbcType=INTEGER},
       publish_status = #{record.publishStatus,jdbcType=INTEGER},
       new_status = #{record.newStatus,jdbcType=INTEGER},
@@ -723,6 +735,9 @@
       <if test="productSn != null">
         product_sn = #{productSn,jdbcType=VARCHAR},
       </if>
+      <if test="productType != null">
+        product_type = #{productType,jdbcType=VARCHAR},
+      </if>
       <if test="deleteStatus != null">
         delete_status = #{deleteStatus,jdbcType=INTEGER},
       </if>
@@ -840,6 +855,7 @@
       name = #{name,jdbcType=VARCHAR},
       pic = #{pic,jdbcType=VARCHAR},
       product_sn = #{productSn,jdbcType=VARCHAR},
+      product_type = #{productType,jdbcType=VARCHAR},
       delete_status = #{deleteStatus,jdbcType=INTEGER},
       publish_status = #{publishStatus,jdbcType=INTEGER},
       new_status = #{newStatus,jdbcType=INTEGER},
@@ -886,6 +902,7 @@
       name = #{name,jdbcType=VARCHAR},
       pic = #{pic,jdbcType=VARCHAR},
       product_sn = #{productSn,jdbcType=VARCHAR},
+      product_type = #{productType,jdbcType=VARCHAR},
       delete_status = #{deleteStatus,jdbcType=INTEGER},
       publish_status = #{publishStatus,jdbcType=INTEGER},
       new_status = #{newStatus,jdbcType=INTEGER},