parent
be61a9dfea
commit
4ce545f944
|
|
@ -9,6 +9,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.czg.account.entity.ShopConfig;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.enums.BranchDataSyncMethodEnum;
|
||||
import com.czg.account.service.ShopConfigService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
|
|
@ -19,6 +20,7 @@ import com.czg.product.service.*;
|
|||
import com.czg.product.vo.ProductGroupVo;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.row.DbChain;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
|
|
@ -219,6 +221,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncUnitBySourceShop(Long sourceShopId, Long unitId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(unitId, "{}不能为空", "单位ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 1);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -285,6 +288,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncSpecBySourceShop(Long sourceShopId, Long specId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(specId, "{}不能为空", "规格ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 1);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -375,6 +379,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncCategoryBySourceShop(Long sourceShopId, Long categoryId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(categoryId, "{}不能为空", "分类ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 1);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -452,6 +457,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncProductBySourceShop(Long sourceShopId, Long productId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(productId, "{}不能为空", "商品ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 1);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -560,6 +566,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncGroupBySourceShop(Long sourceShopId, Long groupId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(groupId, "{}不能为空", "分组ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 1);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -778,6 +785,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncConsGroupBySourceShop(Long sourceShopId, Long consGroupId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(consGroupId, "{}不能为空", "耗材分组ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 2);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -839,6 +847,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncConsInfoBySourceShop(Long sourceShopId, Long consInfoId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(consInfoId, "{}不能为空", "耗材ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 2);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -894,6 +903,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncConsProBySourceShop(Long sourceShopId, Long sourceProdId, Long sysUserId) {
|
||||
assertAutoSync(sourceShopId);
|
||||
AssertUtil.isNull(sourceProdId, "{}不能为空", "商品ID");
|
||||
Set<Long> shopIds = checkSourceShopInfo(sourceShopId, 2);
|
||||
if (CollUtil.isEmpty(shopIds)) {
|
||||
|
|
@ -940,4 +950,19 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
prodConsRelationService.saveBatch(newSaveList, 100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 断言是否支持自动同步
|
||||
*
|
||||
* @param sourceShopId 源店铺ID
|
||||
*/
|
||||
private void assertAutoSync(Long sourceShopId) {
|
||||
String branchDataSyncMethod = DbChain.table("tb_shop_config").select("branch_data_sync_method").where("id = ?", sourceShopId).objAs(String.class);
|
||||
if (branchDataSyncMethod == null) {
|
||||
throw new CzgException("主店未配置数据同步方式");
|
||||
}
|
||||
if (!BranchDataSyncMethodEnum.AUTO.getValue().equals(branchDataSyncMethod)) {
|
||||
throw new CzgException("主店数据同步方式不是自动同步");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue