分店配置同步
This commit is contained in:
@@ -2,6 +2,7 @@ package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.account.dto.ShopConfigDTO;
|
||||
import com.czg.account.entity.ShopConfig;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.RedisService;
|
||||
@@ -20,6 +21,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 店铺配置扩展
|
||||
@@ -59,19 +62,17 @@ public class ShopConfigServiceImpl extends ServiceImpl<ShopConfigMapper, ShopCon
|
||||
shopIdList = new ArrayList<>();
|
||||
}
|
||||
// 防止报错
|
||||
shopIdList.add(-9999L);
|
||||
List<Long> extistList;
|
||||
if (!shopIdList.isEmpty()) {
|
||||
extistList = list(new QueryWrapper().in(ShopConfig::getId, shopIdList).select(ShopConfig::getId)).stream().map(ShopConfig::getId).toList();
|
||||
List<Long> finalShopIdList2 = shopIdList;
|
||||
extistList.stream().filter(id -> !finalShopIdList2.contains(id)).forEach(id -> {
|
||||
save(new ShopConfig().setId(id).setMainId(mainShopId).setIsEnableDiscount(0).setIsProductSuggest(0));
|
||||
});
|
||||
} else {
|
||||
extistList = new ArrayList<>();
|
||||
}
|
||||
Set<Long> childShopIdList = shopInfoMapper.selectListByQuery(new QueryWrapper().eq(ShopInfo::getMainId, mainShopId)
|
||||
.select(ShopInfo::getId)).stream().map(ShopInfo::getId).collect(Collectors.toSet());
|
||||
childShopIdList.add(mainShopId);
|
||||
List<Long> extistList = new ArrayList<>(list(new QueryWrapper().in(ShopConfig::getId, childShopIdList)).stream().map(ShopConfig::getId).toList());
|
||||
extistList.add(mainShopId);
|
||||
childShopIdList.stream().filter(id -> !extistList.contains(id)).forEach(id -> {
|
||||
save(new ShopConfig().setId(id).setMainId(id.equals(mainShopId) ? null : mainShopId).setIsEnableDiscount(0).setIsProductSuggest(0));
|
||||
});
|
||||
|
||||
if (isEnable == 0 && !onyUpValid) {
|
||||
|
||||
List<Long> finalShopIdList = shopIdList;
|
||||
updateChain().or(or -> {
|
||||
or.eq(ShopConfig::getId, mainShopId);
|
||||
|
||||
Reference in New Issue
Block a user