|
@ -1,5 +1,6 @@ |
|
|
package com.qs.serve.modules.tbs.service.impl; |
|
|
package com.qs.serve.modules.tbs.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
@ -34,11 +35,17 @@ import com.qs.serve.modules.bms.mapper.BmsApplyMessageMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsRegionMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsSupplierTargetMapper; |
|
|
import com.qs.serve.modules.bms.mapper.BmsSupplierTargetMapper; |
|
|
|
|
|
import com.qs.serve.modules.bms.service.BmsSubjectRegionService; |
|
|
import com.qs.serve.modules.bms.service.BmsSubjectService; |
|
|
import com.qs.serve.modules.bms.service.BmsSubjectService; |
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|
|
import com.qs.serve.modules.erp.entity.dto.ErpDispatchSumVo; |
|
|
import com.qs.serve.modules.erp.entity.dto.ErpDispatchSumVo; |
|
|
import com.qs.serve.modules.erp.mapper.ErpDispatchDataMapper; |
|
|
import com.qs.serve.modules.erp.mapper.ErpDispatchDataMapper; |
|
|
import com.qs.serve.modules.goods.common.GoodsType; |
|
|
import com.qs.serve.modules.goods.common.GoodsType; |
|
|
|
|
|
import com.qs.serve.modules.goods.entity.GoodsCategory; |
|
|
|
|
|
import com.qs.serve.modules.goods.entity.GoodsSpu; |
|
|
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper; |
|
|
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsSkuMapper; |
|
|
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper; |
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateCallbackBo; |
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateCallbackBo; |
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateProcessBo; |
|
|
import com.qs.serve.modules.seeyon.entity.BaseCreateProcessBo; |
|
|
import com.qs.serve.modules.seeyon.service.SeeYonRequestService; |
|
|
import com.qs.serve.modules.seeyon.service.SeeYonRequestService; |
|
@ -95,6 +102,8 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
|
|
|
|
|
|
private RedisService redisService; |
|
|
private RedisService redisService; |
|
|
private TbsActivityChannelPointMapper tbsActivityChannelPointMapper; |
|
|
private TbsActivityChannelPointMapper tbsActivityChannelPointMapper; |
|
|
|
|
|
private TbsActivityTemplateRegionMapper tbsActivityTemplateRegionMapper; |
|
|
|
|
|
private TbsActivityTemplateMapper tbsActivityTemplateMapper; |
|
|
private VtbVerificationMapper vtbVerificationMapper; |
|
|
private VtbVerificationMapper vtbVerificationMapper; |
|
|
private TbsBudgetApplicationService budgetApplicationService; |
|
|
private TbsBudgetApplicationService budgetApplicationService; |
|
|
private TbsBudgetCostItemService budgetCostItemService; |
|
|
private TbsBudgetCostItemService budgetCostItemService; |
|
@ -120,6 +129,10 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
private VtbVerificationMapper verificationMapper; |
|
|
private VtbVerificationMapper verificationMapper; |
|
|
private SysAttachService sysAttachService; |
|
|
private SysAttachService sysAttachService; |
|
|
|
|
|
|
|
|
|
|
|
private GoodsSpuMapper goodsSpuMapper; |
|
|
|
|
|
private GoodsSkuMapper goodsSkuMapper; |
|
|
|
|
|
private GoodsCategoryMapper goodsCategoryMapper; |
|
|
|
|
|
|
|
|
private BirRoiRateService birRoiRateService; |
|
|
private BirRoiRateService birRoiRateService; |
|
|
private BirCenterRateService centerRateService; |
|
|
private BirCenterRateService centerRateService; |
|
|
private BirRoiRateMapper birRoiRateMapper; |
|
|
private BirRoiRateMapper birRoiRateMapper; |
|
@ -130,6 +143,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
|
|
|
|
|
|
private TbsBudgetMatchApplication tbsBudgetMatchApplication; |
|
|
private TbsBudgetMatchApplication tbsBudgetMatchApplication; |
|
|
|
|
|
|
|
|
|
|
|
private BmsSubjectRegionService bmsSubjectRegionService; |
|
|
private TbsCostCheckStateMapper costCheckStateMapper; |
|
|
private TbsCostCheckStateMapper costCheckStateMapper; |
|
|
private TbsCostApplyMapper tbsCostApplyMapper; |
|
|
private TbsCostApplyMapper tbsCostApplyMapper; |
|
|
private ProjectApisProperties projectApisProperties; |
|
|
private ProjectApisProperties projectApisProperties; |
|
@ -527,12 +541,94 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
return "success"; |
|
|
return "success"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean checkTemplateId(BmsSupplier supplier, TbsActivityTemplate template) { |
|
|
|
|
|
Long templateId = template.getId(); |
|
|
|
|
|
boolean isIgnore = template.getSaleRegionFlag().equals(0)&&template.getBizRegionFlag().equals(0); |
|
|
|
|
|
boolean isStop = template.getSaleRegionFlag().equals(2)&&template.getBizRegionFlag().equals(2); |
|
|
|
|
|
if(isStop){ |
|
|
|
|
|
Assert.throwEx("模板已停用"); |
|
|
|
|
|
} |
|
|
|
|
|
if(! isIgnore){ |
|
|
|
|
|
List<TbsActivityTemplateRegion> regionList = tbsActivityTemplateRegionMapper.selectList( |
|
|
|
|
|
new LambdaQueryWrapper<TbsActivityTemplateRegion>() |
|
|
|
|
|
.eq(TbsActivityTemplateRegion::getTemplateId,templateId)); |
|
|
|
|
|
List<String> bizRegionIds = supplier.listBizRegionIds(); |
|
|
|
|
|
List<String> saleRegionIds = supplier.listSaleRegionIds(); |
|
|
|
|
|
boolean isPass = false; |
|
|
|
|
|
for (TbsActivityTemplateRegion templateRegion : regionList) { |
|
|
|
|
|
if(templateRegion.getType().equals("sale")&&template.getSaleRegionFlag().equals(1)){ |
|
|
|
|
|
if(saleRegionIds.contains(templateRegion.getRegionId())){ |
|
|
|
|
|
isPass = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (templateRegion.getType().equals("biz")&&template.getBizRegionFlag().equals(1)){ |
|
|
|
|
|
if(bizRegionIds.contains(templateRegion.getRegionId())){ |
|
|
|
|
|
isPass = true; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(!isPass){ |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<String> checkTemplateId(List<BmsSupplier> supplierList, TbsActivityTemplate template) { |
|
|
|
|
|
Long templateId = template.getId(); |
|
|
|
|
|
boolean isIgnore = template.getSaleRegionFlag().equals(0)&&template.getBizRegionFlag().equals(0); |
|
|
|
|
|
boolean isStop = template.getSaleRegionFlag().equals(2)&&template.getBizRegionFlag().equals(2); |
|
|
|
|
|
if(isStop){ |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
if(! isIgnore){ |
|
|
|
|
|
List<TbsActivityTemplateRegion> regionList = tbsActivityTemplateRegionMapper.selectList( |
|
|
|
|
|
new LambdaQueryWrapper<TbsActivityTemplateRegion>() |
|
|
|
|
|
.eq(TbsActivityTemplateRegion::getTemplateId,templateId)); |
|
|
|
|
|
List<String> passSupplierIdList = new ArrayList<>(); |
|
|
|
|
|
for (BmsSupplier supplier : supplierList) { |
|
|
|
|
|
List<String> bizRegionIds = supplier.listBizRegionIds(); |
|
|
|
|
|
List<String> saleRegionIds = supplier.listSaleRegionIds(); |
|
|
|
|
|
boolean isPass = false; |
|
|
|
|
|
for (TbsActivityTemplateRegion templateRegion : regionList) { |
|
|
|
|
|
if(templateRegion.getType().equals("sale")&&template.getSaleRegionFlag().equals(1)){ |
|
|
|
|
|
if(saleRegionIds.contains(templateRegion.getRegionId())){ |
|
|
|
|
|
passSupplierIdList.add(supplier.getId()); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (templateRegion.getType().equals("biz")&&template.getBizRegionFlag().equals(1)){ |
|
|
|
|
|
if(bizRegionIds.contains(templateRegion.getRegionId())){ |
|
|
|
|
|
passSupplierIdList.add(supplier.getId()); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return passSupplierIdList; |
|
|
|
|
|
} |
|
|
|
|
|
return supplierList.stream().map(BmsSupplier::getId).collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void commitApply(String id) { |
|
|
public void commitApply(String id) { |
|
|
TbsCostApply tbsCostApply = this.getById(id); |
|
|
TbsCostApply tbsCostApply = this.getById(id); |
|
|
redisService.throwResLock(TbsCostApply.class.getSimpleName(),id); |
|
|
redisService.throwResLock(TbsCostApply.class.getSimpleName(),id); |
|
|
seeYonService.testConnection(); |
|
|
|
|
|
|
|
|
BmsSupplier supplier = bmsSupplierService.getById(tbsCostApply.getSupplierId()); |
|
|
|
|
|
if(supplier.getCostFlag().equals(0)||supplier.getStopFlag().equals(1)){ |
|
|
|
|
|
Assert.throwEx("["+supplier.getName()+"]无投放费用权限"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 商品拦截
|
|
|
|
|
|
List<TbsActivityGoods> activityCenterGoodsList = tbsActivityGoodsService.listByCostApplyId(Long.parseLong(id)); |
|
|
|
|
|
this.validActivityGoods(activityCenterGoodsList); |
|
|
|
|
|
|
|
|
if(!tbsCostApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode()) |
|
|
if(!tbsCostApply.getChargeState().equals(TbsCostApplyState.State_0_unPublish.getCode()) |
|
|
&&!tbsCostApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){ |
|
|
&&!tbsCostApply.getChargeState().equals(TbsCostApplyState.State_4_refused.getCode())){ |
|
|
Assert.throwEx("操作失败,申请费用状态不支持"); |
|
|
Assert.throwEx("操作失败,申请费用状态不支持"); |
|
@ -556,19 +652,52 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//判断是否进场费
|
|
|
//科目拦截:判断是否进场费
|
|
|
|
|
|
List<TbsActivitySubject> activitySubjects = tbsActivitySubjectService.listByCostApplyId(tbsCostApply.getId()); |
|
|
|
|
|
List<BmsSubject> subjectList = subjectService.listByIds( |
|
|
|
|
|
activitySubjects.stream().map(TbsActivitySubject::getSubjectId).collect(Collectors.toList())); |
|
|
if(tbsCostApply.getContractFlag()!=null&&tbsCostApply.getContractFlag().equals(2)){ |
|
|
if(tbsCostApply.getContractFlag()!=null&&tbsCostApply.getContractFlag().equals(2)){ |
|
|
if (activityList.size()>1){ |
|
|
if (activityList.size()>1){ |
|
|
Assert.throwEx("进场费类型只能有一个活动"); |
|
|
Assert.throwEx("进场费类型只能有一个活动"); |
|
|
} |
|
|
} |
|
|
List<TbsActivitySubject> activitySubjects = tbsActivitySubjectService.listByCostApplyId(tbsCostApply.getId()); |
|
|
if(subjectList.stream().anyMatch(s->s.getSlottingFlag().equals(0))){ |
|
|
List<Long> subjectIds = activitySubjects.stream().map(TbsActivitySubject::getSubjectId).collect(Collectors.toList()); |
|
|
Assert.throwEx("当前申请含非进场费类型科目"); |
|
|
LambdaQueryWrapper<BmsSubject> subjectLqw = new LambdaQueryWrapper<>(); |
|
|
} |
|
|
subjectLqw.in(BmsSubject::getId,subjectIds); |
|
|
} |
|
|
subjectLqw.eq(BmsSubject::getSlottingFlag,0); |
|
|
//模板拦截
|
|
|
long count = subjectService.count(subjectLqw); |
|
|
boolean isIgnoreSubject = false; |
|
|
if(count>0){ |
|
|
if(activityList.size()==1){ |
|
|
Assert.throwEx("改申请含非进场费类型科目"); |
|
|
Long templateId = activityList.get(0).getTemplateId(); |
|
|
|
|
|
if (templateId!=null){ |
|
|
|
|
|
// 模板不拦截科目范围
|
|
|
|
|
|
isIgnoreSubject = true; |
|
|
|
|
|
// 拦截模板的可见范围
|
|
|
|
|
|
TbsActivityTemplate activityTemplate = tbsActivityTemplateService.getById(tbsCostApply.getTemplateId()); |
|
|
|
|
|
boolean isPass = this.checkTemplateId(supplier,activityTemplate); |
|
|
|
|
|
if(!isPass){ |
|
|
|
|
|
Assert.throwEx("当前申请模板不可用"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 使用模板的忽略科目拦截
|
|
|
|
|
|
if(!isIgnoreSubject){ |
|
|
|
|
|
List<BmsSubjectRegion> subjectBizRegionList = bmsSubjectRegionService.listByRegionIds(supplier.listBizRegionIds(),1); |
|
|
|
|
|
List<BmsSubjectRegion> subjectSaleRegionList = bmsSubjectRegionService.listByRegionIds(supplier.listSaleRegionIds(),0); |
|
|
|
|
|
for (BmsSubject subject : subjectList) { |
|
|
|
|
|
if(subject.getBizRegionFlag().equals(0)&&subject.getSaleRegionFlag().equals(0)){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
if(subject.getBizRegionFlag().equals(1)){ |
|
|
|
|
|
if(subjectBizRegionList.stream().anyMatch(s->s.getSubjectId().equals(subject.getId()))){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(subject.getSaleRegionFlag().equals(1)){ |
|
|
|
|
|
if(subjectSaleRegionList.stream().anyMatch(s->s.getSubjectId().equals(subject.getId()))){ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
Assert.throwEx("当前申请含非业务区域科目:"+subject.getSubjectCode()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -605,7 +734,6 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
Assert.throwEx("没有有效的活动内容"); |
|
|
Assert.throwEx("没有有效的活动内容"); |
|
|
}else { |
|
|
}else { |
|
|
Long supplierId = activityList.get(0).getSupplierId(); |
|
|
Long supplierId = activityList.get(0).getSupplierId(); |
|
|
BmsSupplier supplier = bmsSupplierService.getById(supplierId); |
|
|
|
|
|
if(!supplier.getSupplierFlag().equals(1)&&!supplier.getSupplierFlag().equals(2)){ |
|
|
if(!supplier.getSupplierFlag().equals(1)&&!supplier.getSupplierFlag().equals(2)){ |
|
|
Assert.throwEx("协议类申请只对供应商开放"); |
|
|
Assert.throwEx("协议类申请只对供应商开放"); |
|
|
} |
|
|
} |
|
@ -620,10 +748,6 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
BmsSupplier supplier = bmsSupplierService.getById(tbsCostApply.getSupplierId()); |
|
|
|
|
|
if(supplier.getCostFlag().equals(0)){ |
|
|
|
|
|
Assert.throwEx("["+supplier.getName()+"]无投放费用权限"); |
|
|
|
|
|
} |
|
|
|
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
SysUser sysUser = sysUserService.getById(AuthContextUtils.getSysUserId()); |
|
|
sysUser.checkSyAccount(); |
|
|
sysUser.checkSyAccount(); |
|
|
|
|
|
|
|
@ -934,6 +1058,42 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 校验活动商品的有效性 |
|
|
|
|
|
* 此方法旨在确保参与活动的商品或类别处于有效状态,包括检查是否已下架和是否已启用费用 |
|
|
|
|
|
* @param activityCenterGoodsList 活动商品列表,包含待校验的商品或类别信息 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void validActivityGoods(List<TbsActivityGoods> activityCenterGoodsList) { |
|
|
|
|
|
List<TbsActivityGoods> spuGoods = activityCenterGoodsList.stream() |
|
|
|
|
|
.filter(a->a.getTargetType().equals("spu")).collect(Collectors.toList()); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(spuGoods)){ |
|
|
|
|
|
List<Long> spuIds = spuGoods.stream().map(TbsActivityGoods::getTargetId).collect(Collectors.toList()); |
|
|
|
|
|
List<GoodsSpu> skuList = goodsSpuMapper.selectBatchIds(spuIds); |
|
|
|
|
|
for (GoodsSpu spu : skuList) { |
|
|
|
|
|
if(spu.getShelf().equals(0)){ |
|
|
|
|
|
Assert.throwEx("【"+spu.getName()+"】已下架,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
if(spu.getCostFlag().equals(0)){ |
|
|
|
|
|
Assert.throwEx("【"+spu.getName()+"】未启用费用,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
List<TbsActivityGoods> cateGoods = activityCenterGoodsList.stream() |
|
|
|
|
|
.filter(a->!a.getTargetType().equals("spu")).collect(Collectors.toList()); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(cateGoods)){ |
|
|
|
|
|
List<Long> cateIds = cateGoods.stream().map(TbsActivityGoods::getTargetId).collect(Collectors.toList()); |
|
|
|
|
|
List<GoodsCategory> cateList = goodsCategoryMapper.selectBatchIds(cateIds); |
|
|
|
|
|
for (GoodsCategory cate : cateList) { |
|
|
|
|
|
if(cate.getCostFlag().equals(0)){ |
|
|
|
|
|
Assert.throwEx("【"+cate.getName()+"】未启用费用,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
if(cate.getEnable().equals(0)){ |
|
|
|
|
|
Assert.throwEx("【"+cate.getName()+"】已下架,请重新选择"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 创建协议类的申请DATA |
|
|
* 创建协议类的申请DATA |
|
|
* @param id |
|
|
* @param id |
|
|