|
|
@ -8,15 +8,32 @@ import com.qs.serve.common.model.dto.R; |
|
|
|
import com.qs.serve.common.model.enums.BizType; |
|
|
|
import com.qs.serve.common.model.enums.SystemModule; |
|
|
|
import com.qs.serve.common.util.Assert; |
|
|
|
import com.qs.serve.common.util.CollectionUtil; |
|
|
|
import com.qs.serve.common.util.CopierUtil; |
|
|
|
import com.qs.serve.common.util.PageUtil; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsCostCenter; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsRegion; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsRegion2; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
|
import com.qs.serve.modules.bms.service.BmsCostCenterService; |
|
|
|
import com.qs.serve.modules.bms.service.BmsRegion2Service; |
|
|
|
import com.qs.serve.modules.bms.service.BmsRegionService; |
|
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsCategory; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsSku; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsSpu; |
|
|
|
import com.qs.serve.modules.goods.service.GoodsCategoryService; |
|
|
|
import com.qs.serve.modules.goods.service.GoodsSkuService; |
|
|
|
import com.qs.serve.modules.goods.service.GoodsSpuService; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsCenterType; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsGoodsType; |
|
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
|
import com.qs.serve.modules.tbs.entity.bo.TbsActivityDefaultCenterBo; |
|
|
|
import com.qs.serve.modules.tbs.entity.bo.TbsActivityReopenBo; |
|
|
|
import com.qs.serve.modules.tbs.entity.vo.TbsActivityCenterGoodsVo; |
|
|
|
import com.qs.serve.modules.tbs.entity.vo.TbsActivityDefaultCenterVo; |
|
|
|
import com.qs.serve.modules.tbs.service.*; |
|
|
|
import com.qs.serve.modules.vtb.service.VtbVerificationService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
@ -56,11 +73,20 @@ public class TbsActivityController { |
|
|
|
private final TbsActivityChannelService activityChannelService; |
|
|
|
private final TbsActivityChannelPointService activityChannelPointService; |
|
|
|
|
|
|
|
private final GoodsSkuService goodsSkuService; |
|
|
|
private final GoodsSpuService goodsSpuService; |
|
|
|
private final GoodsCategoryService goodsCategoryService; |
|
|
|
|
|
|
|
private final BmsSupplierService bmsSupplierService; |
|
|
|
private final BmsCostCenterService bmsCostCenterService; |
|
|
|
private final BmsRegion2Service bmsRegion2Service; |
|
|
|
private final BmsRegionService bmsRegionService; |
|
|
|
|
|
|
|
private final VtbVerificationService verificationService; |
|
|
|
|
|
|
|
private final TbsActivityApplicationService tbsActivityApplicationService; |
|
|
|
private final TbsBudgetService tbsBudgetService; |
|
|
|
private final TbsBudgetConditionService tbsBudgetConditionService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 列表 |
|
|
@ -283,5 +309,98 @@ public class TbsActivityController { |
|
|
|
return R.ok(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取默认的成本中心 |
|
|
|
* @param defaultCenterBo |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("/getDefaultCenter") |
|
|
|
public R<TbsActivityDefaultCenterVo> getDefaultCenter(@RequestBody TbsActivityDefaultCenterBo defaultCenterBo){ |
|
|
|
String goodsType = defaultCenterBo.getActivityGoodsType(); |
|
|
|
List<Long> goodsIds = defaultCenterBo.getGoodsIds(); |
|
|
|
Long subjectId = defaultCenterBo.getSubjectId(); |
|
|
|
Long supplierId = defaultCenterBo.getSupplierId(); |
|
|
|
BmsSupplier supplier = bmsSupplierService.getById(supplierId); |
|
|
|
List<TbsBudget> centerBudgetList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(goodsIds)&&subjectId!=null){ |
|
|
|
LambdaQueryWrapper<TbsBudget> lqw = new LambdaQueryWrapper<>(); |
|
|
|
lqw.eq(TbsBudget::getBudgetState,1); |
|
|
|
lqw.eq(TbsBudget::getSubjectId,subjectId); |
|
|
|
List<TbsBudget> budgetList = tbsBudgetService.list(lqw); |
|
|
|
List<String> idPaths = new ArrayList<>(); |
|
|
|
if(budgetList.size()>0){ |
|
|
|
if(TbsGoodsType.spu.name().equals(goodsType)){ |
|
|
|
for (Long goodsId : goodsIds) { |
|
|
|
GoodsSpu goodsSpu = goodsSpuService.getById(goodsId); |
|
|
|
String idPath = goodsSpu.getCategoryFirst()+"_"+goodsSpu.getCategorySecond()+"_" |
|
|
|
+goodsSpu.getCategoryThird()+"_"+goodsSpu.getId(); |
|
|
|
idPaths.add(idPath); |
|
|
|
} |
|
|
|
}else if(TbsGoodsType.sku.name().equals(goodsType)){ |
|
|
|
for (Long goodsId : goodsIds) { |
|
|
|
GoodsSku sku = goodsSkuService.getById(goodsId); |
|
|
|
GoodsSpu goodsSpu = goodsSpuService.getById(sku.getSpuId()); |
|
|
|
String idPath = goodsSpu.getCategoryFirst()+"_"+goodsSpu.getCategorySecond()+"_" |
|
|
|
+goodsSpu.getCategoryThird()+"_"+goodsSpu.getId()+"_"+sku.getId(); |
|
|
|
idPaths.add(idPath); |
|
|
|
} |
|
|
|
}else { |
|
|
|
for (Long goodsId : goodsIds) { |
|
|
|
GoodsCategory category = goodsCategoryService.getById(goodsId); |
|
|
|
idPaths.add(category.getLevelPath()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (TbsBudget budget : budgetList) { |
|
|
|
if(budget.getConditionFlag().equals(1)){ |
|
|
|
List<TbsBudgetCondition> budgetConditions = tbsBudgetConditionService.getByBudgetId(budget.getId()); |
|
|
|
for (int i = 0; i < idPaths.size(); i++) { |
|
|
|
String idPath = idPaths.get(i); |
|
|
|
boolean isMatch = false; |
|
|
|
for (TbsBudgetCondition budgetCondition : budgetConditions) { |
|
|
|
if(idPath.contains(budgetCondition.getTargetLevelPathIds())){ |
|
|
|
isMatch = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if(!isMatch){ |
|
|
|
break; |
|
|
|
} |
|
|
|
//满足条件
|
|
|
|
if(i+1==idPaths.size()){ |
|
|
|
centerBudgetList.add(budget); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}else { |
|
|
|
centerBudgetList.add(budget); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
List<BmsCostCenter> costCenters = new ArrayList<>(); |
|
|
|
List<BmsRegion> saleRegions = new ArrayList<>(); |
|
|
|
List<BmsRegion2> bizRegions = new ArrayList<>(); |
|
|
|
for (TbsBudget budget : centerBudgetList) { |
|
|
|
if(budget.getCenterType().equals(TbsCenterType.center.name())){ |
|
|
|
BmsCostCenter costCenter = bmsCostCenterService.getById(budget.getCenterId()); |
|
|
|
costCenters.add(costCenter); |
|
|
|
}else if (budget.getCenterType().equals(TbsCenterType.bizRegion.name())){ |
|
|
|
BmsRegion2 region2 = bmsRegion2Service.getById(budget.getCenterId()); |
|
|
|
bizRegions.add(region2); |
|
|
|
}else if (budget.getCenterType().equals(TbsCenterType.saleRegion.name())){ |
|
|
|
BmsRegion region = bmsRegionService.getById(budget.getCenterId()); |
|
|
|
saleRegions.add(region); |
|
|
|
} |
|
|
|
} |
|
|
|
TbsActivityDefaultCenterVo defaultCenterVo = new TbsActivityDefaultCenterVo(); |
|
|
|
defaultCenterVo.setSupplier(supplier); |
|
|
|
defaultCenterVo.setCostCenters(costCenters); |
|
|
|
defaultCenterVo.setSaleRegions(saleRegions); |
|
|
|
defaultCenterVo.setBizRegions(bizRegions); |
|
|
|
return R.ok(defaultCenterVo); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|