Commit 22a03a7e by 陶光胜

门店品牌变更

parent 765ca6a7
......@@ -106,13 +106,13 @@ public interface StoreRegionApiService {
* @Title: authorizeRegionToOther
* @Description:
* @author zhiwj
* @param fromEnterpriseId 原商户
* @param toEnterpriseId 被授权商户
* @param ownerEnterpriseId 原商户
* @param unionEnterpriseId 被授权商户
* @param storeRegionIdList
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
* @throws
*/
ServiceResponse<Integer> authorizeRegionToOther(Integer fromEnterpriseId, Integer toEnterpriseId, List<Integer> storeRegionIdList);
ServiceResponse<Integer> authorizeRegionToOther(Integer ownerEnterpriseId, Integer unionEnterpriseId, List<Integer> storeRegionIdList);
/**
* 收回授权
......
......@@ -101,9 +101,11 @@ public class StoreBrandServiceImpl implements StoreBrandService {
list.add(tabStoreBrandRef);
sort = sort - 1d;
}
/**新增需要共享的品牌***/
if(CollectionUtils.isNotEmpty(list)){
tabStoreBrandRefMapper.insertList(list);
}
/**删除本次***/
}
}
......
......@@ -132,37 +132,37 @@ public class StoreRegionApiServiceImpl implements StoreRegionApiService {
}
@Override
public ServiceResponse<Integer> authorizeRegionToOther(Integer fromEnterpriseId, Integer toEnterpriseId, List<Integer> newStoreRegionIdList) {
public ServiceResponse<Integer> authorizeRegionToOther(Integer ownerEnterpriseId, Integer unionEnterpriseId, List<Integer> newStoreRegionIdList) {
if (newStoreRegionIdList == null) {
newStoreRegionIdList = Collections.emptyList();
}
// 新的region是不是fromEnterpriseId所具有权限的
List<StoreRegionDTO> list = storeRegionService.listStoreRegionByIds(fromEnterpriseId, newStoreRegionIdList, StoreOwnTypeEnum.OWNER.getCode());
// 新的region是不是自有商户所具有权限的
List<StoreRegionDTO> list = storeRegionService.listStoreRegionByIds(ownerEnterpriseId, newStoreRegionIdList, StoreOwnTypeEnum.OWNER.getCode());
if (CollectionUtils.isEmpty(list) || list.size() != newStoreRegionIdList.size()) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR);
}
// 查询所有toEnterprise 已经具有的fromEnterprise权限
List<Integer> oldRelIdList = storeRegionRelService.listByAuthorize(fromEnterpriseId, toEnterpriseId);
// 查询所有联合商户 已经具有的自有商户权限
List<Integer> oldRelIdList = storeRegionRelService.listByAuthorize(ownerEnterpriseId, unionEnterpriseId);
Set<Integer> newRelSet = new HashSet<>(newStoreRegionIdList);
// 要删除的关联
List<Integer> delRelList = oldRelIdList.stream().filter(e -> !newRelSet.contains(e)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(delRelList)) {
storeRegionRelService.delByRegionIds(toEnterpriseId, delRelList, StoreOwnTypeEnum.OTHER.getCode());
storeRegionRelService.delByRegionIds(unionEnterpriseId, delRelList, StoreOwnTypeEnum.OTHER.getCode());
}
for (Integer regionId : newStoreRegionIdList) {
TabStoreRegionRel storeRegionRel = storeRegionRelService.getByRegionIdAndEnterpriseId(regionId, toEnterpriseId, StoreOwnTypeEnum.OTHER.getCode());
TabStoreRegionRel storeRegionRel = storeRegionRelService.getByRegionIdAndEnterpriseId(regionId, unionEnterpriseId, StoreOwnTypeEnum.OTHER.getCode());
if (storeRegionRel == null) {
// 插入
storeRegionRelService.saveByOther(fromEnterpriseId, toEnterpriseId, regionId);
storeRegionRelService.saveByOther(ownerEnterpriseId, unionEnterpriseId, regionId);
} else if (storeRegionRel.getDeleteFlag() == 1) {
// 状态更新为1
storeRegionRelService.updateStatusByOther(toEnterpriseId, regionId, 1);
storeRegionRelService.updateStatusByOther(unionEnterpriseId, regionId, 1);
}
}
// 调用门店自定义属性方法
storeFieldApiService.authStoreField(fromEnterpriseId, toEnterpriseId, newStoreRegionIdList);
storeFieldApiService.authStoreField(ownerEnterpriseId, unionEnterpriseId, newStoreRegionIdList);
return ServiceResponse.success();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment