瀏覽代碼

商品状态同步

yuanliang 1 年之前
父節點
當前提交
039d3085ee

+ 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.PathVariable;
 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.RestController;
 
@@ -50,7 +51,7 @@ public class GoodsController extends BaseController {
     @ApiOperation(value = "新增商品(教材、辅件)")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('goods/add')")
-    public Object add(GoodsWrapper.Goods goods){
+    public Object add(@RequestBody GoodsWrapper.Goods goods){
         goodsService.addGoods(goods,sysUserService.getUserId());
         return succeed();
     }
@@ -89,7 +90,7 @@ public class GoodsController extends BaseController {
     @ApiOperation(value = "修改商品(教材、辅件)")
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('goods/update')")
-    public Object update(GoodsWrapper.Goods goods){
+    public Object update(@RequestBody GoodsWrapper.Goods goods){
         goods.setUpdateTime(new Date());
         goodsService.updateGoods(goods);
         return succeed();

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

@@ -1149,9 +1149,9 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if (CollectionUtils.isEmpty(goodsSubs)) {
 			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());
-		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());
 		if(!CollectionUtils.isEmpty(downGoods)){