zoujiajian 1 éve
szülő
commit
ef8bf93b09

+ 15 - 8
netflix-service/src/main/java/com/cyksj/service/mange/goods/GoodsDonCategoryServiceImpl.java

@@ -86,6 +86,9 @@ public class GoodsDonCategoryServiceImpl extends ServiceImpl<GoodsDonCategoryMap
 
 	@Override
 	public void handleGoodsRelate(Long goodsId, List<Long> categoryList) {
+		//更新第三方平台信息
+		updateThirdGoodsInfo(goodsId, categoryList);
+
 		if (CollUtil.isEmpty(categoryList)) {
 			goodsDonCategoryRelateMapper.delete(Wrappers.lambdaQuery(GoodsDonCategoryRelate.class).eq(GoodsDonCategoryRelate::getGoodsId, goodsId));
 			goodsDonMapper.update(null, Wrappers.lambdaUpdate(GoodsDon.class)
@@ -99,8 +102,7 @@ public class GoodsDonCategoryServiceImpl extends ServiceImpl<GoodsDonCategoryMap
 			return;
 		}
 		AtomicBoolean ic = new AtomicBoolean(true);
-		//是否是第三方商品
-		AtomicBoolean isThirdGoods = new AtomicBoolean(false);
+
 		//需要删除
 		goodsDonCategoryRelates.forEach(data -> {
 			if (!categoryList.contains(data.getCategory())) {
@@ -113,13 +115,18 @@ public class GoodsDonCategoryServiceImpl extends ServiceImpl<GoodsDonCategoryMap
 			return;
 		}
 		saveBatchRelate(goodsId, categoryList);
+	}
 
-		//第三方商品信息更新
-		categoryList.forEach(ct->{
-			if (Constant.THIRD_CATEGORY == ct) {
-				isThirdGoods.set(true);
-			}
-		});
+	private void updateThirdGoodsInfo(Long goodsId, List<Long> categoryList) {
+		AtomicBoolean isThirdGoods = new AtomicBoolean(false);
+		if (CollUtil.isNotEmpty(categoryList)) {
+			//第三方商品信息更新
+			categoryList.forEach(ct->{
+				if (Constant.THIRD_CATEGORY == ct) {
+					isThirdGoods.set(true);
+				}
+			});
+		}
 		goodsDonMapper.update(null, Wrappers.lambdaUpdate(GoodsDon.class)
 				.set(GoodsDon::getIsThirdGoods, isThirdGoods.get())
 				.eq(GoodsDon::getId, goodsId));