瀏覽代碼

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

zouxuan 1 年之前
父節點
當前提交
974472ec32

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

@@ -24,6 +24,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -50,7 +51,7 @@ public class GoodsController extends BaseController {
     @ApiOperation(value = "新增商品(教材、辅件)")
     @ApiOperation(value = "新增商品(教材、辅件)")
     @PostMapping("/add")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('goods/add')")
     @PreAuthorize("@pcs.hasPermissions('goods/add')")
-    public Object add(GoodsWrapper.Goods goods){
+    public Object add(@RequestBody GoodsWrapper.Goods goods){
         goodsService.addGoods(goods,sysUserService.getUserId());
         goodsService.addGoods(goods,sysUserService.getUserId());
         return succeed();
         return succeed();
     }
     }
@@ -89,7 +90,7 @@ public class GoodsController extends BaseController {
     @ApiOperation(value = "修改商品(教材、辅件)")
     @ApiOperation(value = "修改商品(教材、辅件)")
     @PostMapping("/update")
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('goods/update')")
     @PreAuthorize("@pcs.hasPermissions('goods/update')")
-    public Object update(GoodsWrapper.Goods goods){
+    public Object update(@RequestBody GoodsWrapper.Goods goods){
         goods.setUpdateTime(new Date());
         goods.setUpdateTime(new Date());
         goodsService.updateGoods(goods);
         goodsService.updateGoods(goods);
         return succeed();
         return succeed();

+ 63 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/GoodsSubWrapper.java

@@ -0,0 +1,63 @@
+package com.ym.mec.biz.dal.wrapper;
+
+import com.alibaba.fastjson.JSON;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Optional;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * 组合商品,子商品信息
+ * 2024-02-26 15:42:42
+ */
+@ApiModel(value = "GoodsSubWrapper对象", description = "组合商品,子商品信息查询对象")
+public class GoodsSubWrapper {
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel(" GoodsSubQuery-组合商品,子商品信息")
+    public static class GoodsSubQuery implements QueryInfo {
+
+        @ApiModelProperty("当前页")
+        private Integer page;
+
+        @ApiModelProperty("分页行数")
+        private Integer rows;
+
+        @ApiModelProperty("关键字匹配")
+        private String keyword;
+
+        public String getKeyword() {
+            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
+        }
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static GoodsSubQuery from(String json) {
+            return JSON.parseObject(json, GoodsSubQuery.class);
+        }
+    }
+
+    @ApiModel(" GoodsSub-组合商品,子商品信息")
+    public static class GoodsSub {
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static GoodsSub from(String json) {
+            return JSON.parseObject(json, GoodsSub.class);
+        }
+    }
+
+}

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/GoodsWrapper.java

@@ -201,6 +201,9 @@ public class GoodsWrapper {
         @ApiModelProperty("成本")
         @ApiModelProperty("成本")
         private BigDecimal goodsPrice;
         private BigDecimal goodsPrice;
 
 
+        @ApiModelProperty("货号")
+        private String productSn;
+
         public String jsonString() {
         public String jsonString() {
             return JSON.toJSONString(this);
             return JSON.toJSONString(this);
         }
         }

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsSubService.java

@@ -0,0 +1,15 @@
+package com.ym.mec.biz.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.biz.dal.entity.GoodsSub;
+import com.ym.mec.biz.dal.mapper.GoodsSubMapper;
+
+/**
+ * 组合商品,子商品信息
+ * 2024-02-26 15:42:42
+ */
+public interface GoodsSubService extends IService<GoodsSub> {
+
+    GoodsSubMapper getBaseMapper();
+
+}

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

@@ -222,8 +222,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		Integer stock = productList.stream().map(PmsProductDto::getStock).min(Integer::compareTo).get();
 		Integer stock = productList.stream().map(PmsProductDto::getStock).min(Integer::compareTo).get();
 		goods.setStockCount(stock);
 		goods.setStockCount(stock);
 		goods.setSellCount(0);
 		goods.setSellCount(0);
-		Goods goodsRecord = new Goods();
-		BeanUtils.copyProperties(goods,goodsRecord);
+		Goods goodsRecord = JSON.parseObject(JSON.toJSONString(goods), Goods.class);
 		goodsRecord.setStatus(YesOrNoEnum.NO);
 		goodsRecord.setStatus(YesOrNoEnum.NO);
 		BigDecimal organCostPrice = goodsSubList.stream().map(GoodsWrapper.GoodsSub::getGoodsPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 		BigDecimal organCostPrice = goodsSubList.stream().map(GoodsWrapper.GoodsSub::getGoodsPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 		goodsRecord.setOrganCostPrice(organCostPrice);
 		goodsRecord.setOrganCostPrice(organCostPrice);
@@ -343,6 +342,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					next.setGoodsStatus(dto.getPublishStatus() == 1);
 					next.setGoodsStatus(dto.getPublishStatus() == 1);
 				}
 				}
 				next.setMallGoodsName(dto.getName());
 				next.setMallGoodsName(dto.getName());
+				next.setProductSn(dto.getProductSn());
 			}
 			}
 		});
 		});
 		return goodsSubList;
 		return goodsSubList;
@@ -1149,9 +1149,9 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if (CollectionUtils.isEmpty(goodsSubs)) {
 		if (CollectionUtils.isEmpty(goodsSubs)) {
 			return true;
 			return true;
 		}
 		}
-		Map<Integer, Boolean> keyStatusMap = goodsSubModelList.stream().collect(Collectors.toMap(GoodsSubModel::getMallGoodsId, GoodsSubModel::getGoodsStatus));
+		Map<String, Boolean> keyStatusMap = goodsSubModelList.stream().collect(Collectors.toMap(next -> next.getMallGoodsId() + "_" + next.getSkuId(), GoodsSubModel::getGoodsStatus));
 		log.info(Thread.currentThread().getName() + "开始同步商品状态:0/" + goodsSubs.size());
 		log.info(Thread.currentThread().getName() + "开始同步商品状态:0/" + goodsSubs.size());
-		List<GoodsSub> goodsSubList = goodsSubs.stream().peek(next -> next.setGoodsStatus(keyStatusMap.get(next.getMallGoodsId()))).collect(Collectors.toList());
+		List<GoodsSub> goodsSubList = goodsSubs.stream().peek(next -> next.setGoodsStatus(keyStatusMap.get(next.getMallGoodsId() + "_" + next.getSku()))).collect(Collectors.toList());
 		// 下架的商品
 		// 下架的商品
 		List<GoodsSub> downGoods = goodsSubList.stream().filter(next -> Boolean.FALSE.equals(next.getGoodsStatus())).collect(Collectors.toList());
 		List<GoodsSub> downGoods = goodsSubList.stream().filter(next -> Boolean.FALSE.equals(next.getGoodsStatus())).collect(Collectors.toList());
 		if(!CollectionUtils.isEmpty(downGoods)){
 		if(!CollectionUtils.isEmpty(downGoods)){

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsSubServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.biz.dal.entity.GoodsSub;
+import com.ym.mec.biz.dal.mapper.GoodsSubMapper;
+import com.ym.mec.biz.service.GoodsSubService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 组合商品,子商品信息
+ * 2024-02-26 15:42:42
+ */
+@Slf4j
+@Service
+public class GoodsSubServiceImpl extends ServiceImpl<GoodsSubMapper, GoodsSub> implements GoodsSubService {
+
+    @Override
+    public GoodsSubMapper getBaseMapper() {
+        return baseMapper;
+    }
+
+}

+ 3 - 2
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/controller/open/OpenController.java

@@ -158,7 +158,8 @@ public class OpenController {
     @ApiOperation("分页获取所有商品属性分类")
     @ApiOperation("分页获取所有商品属性分类")
     @RequestMapping(value = "productAttribute/category/list", method = RequestMethod.GET)
     @RequestMapping(value = "productAttribute/category/list", method = RequestMethod.GET)
     public List<PmsProductAttributeCategory> getProductAttributeCategoryList() {
     public List<PmsProductAttributeCategory> getProductAttributeCategoryList() {
-        List<PmsProductAttributeCategory> productAttributeCategoryList = productAttributeCategoryService.getList(1, 99999);
-        return productAttributeCategoryList;
+        List<PmsProductAttributeCategory> productAttributeCategoryList = productAttributeCategoryService.getList(9999, 1);
+        CommonPage<PmsProductAttributeCategory> pmsProductAttributeCategoryCommonPage = CommonPage.restPage(productAttributeCategoryList);
+        return pmsProductAttributeCategoryCommonPage.getList();
     }
     }
 }
 }