|
|
@ -1,11 +1,14 @@ |
|
|
|
package com.qs.serve.modules.tzc.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.qs.serve.common.exception.Assert; |
|
|
|
import com.qs.serve.common.utils.CopierUtil; |
|
|
|
import com.qs.serve.common.utils.StringUtils; |
|
|
|
import com.qs.serve.framework.base.util.DebugStrUtil; |
|
|
|
import com.qs.serve.modules.erp.entity.vo.ErpDispatchSumPmsVo; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
@ -73,11 +76,13 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
// 默认延迟半个月
|
|
|
|
preCheckDays = 15; |
|
|
|
} |
|
|
|
// 自动核销日期类型:0-手动设置;1-自然月;2-自然周
|
|
|
|
if (rebate.getCheckAutoDateType().equals(1)){ |
|
|
|
// 自动核销日期类型:0-自然月;1-自然周;2-活动周期(作废);3-活动天数
|
|
|
|
if (rebate.getCheckAutoDateType().equals(0)){ |
|
|
|
preCheckDays = 30; |
|
|
|
}else if (rebate.getCheckAutoDateType().equals(2)){ |
|
|
|
}else if (rebate.getCheckAutoDateType().equals(1)){ |
|
|
|
preCheckDays = 7; |
|
|
|
}else if (rebate.getCheckAutoDateType().equals(3)){ |
|
|
|
preCheckDays = rebate.getCheckAutoDays(); |
|
|
|
} |
|
|
|
// 总返利金额
|
|
|
|
BigDecimal totalAllAmount = maxLevelsAmount.multiply(new BigDecimal(periodList.size())); |
|
|
@ -98,8 +103,6 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
tbsActivitySubjectService.remove(delQw); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 转化为费用申请
|
|
|
|
TbsCostApply costApply = new TbsCostApply(); |
|
|
|
boolean needComp = false; |
|
|
@ -131,9 +134,17 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
tbsCostApplyService.save(costApply); |
|
|
|
Long costApplyId = costApply.getId(); |
|
|
|
|
|
|
|
String levelRemark = levelsList.stream() |
|
|
|
.filter(a-> StringUtils.isNotEmpty(a.getExampleRemark())) |
|
|
|
.map(TzcRebateLevels::getExampleRemark) |
|
|
|
.collect(Collectors.joining(";")); |
|
|
|
levelRemark = levelRemark.substring(0,590) + "..."; |
|
|
|
|
|
|
|
Map<Long,List<TzcRebateCenter>> centerMap = centerList.stream() |
|
|
|
.collect(Collectors.groupingBy(TzcRebateCenter::getRebateSubjectId)); |
|
|
|
|
|
|
|
List<TbsActivity> activityList = new ArrayList<>(); |
|
|
|
|
|
|
|
for (int i = 0; i < periodList.size(); i++) { |
|
|
|
TzcRebatePeriod period = periodList.get(i); |
|
|
|
//构建活动
|
|
|
@ -144,7 +155,7 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
activity.setActivityCode(rebate.getRebateCode()+"_"+(i+1)); |
|
|
|
activity.setActivityState(TbsActivityState.STATE_0_Todo); |
|
|
|
activity.setCostPassFlag(0); |
|
|
|
activity.setActTitle(rebate.getRebateName()); |
|
|
|
activity.setActTitle(levelRemark); |
|
|
|
activity.setSupplierId(rebate.getSupplierId()); |
|
|
|
activity.setSupplierName(rebate.getSupplierName()); |
|
|
|
activity.setSupplierCode(rebate.getSupplierCode()); |
|
|
@ -158,6 +169,8 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
activity.setAutoCheckState(rebate.getCheckModel()); |
|
|
|
activity.setTotalAmount(maxLevelsAmount); |
|
|
|
tbsActivityService.save(activity); |
|
|
|
|
|
|
|
activityList.add(activity); |
|
|
|
Long activityId = activity.getId(); |
|
|
|
|
|
|
|
// 构建活动商品(ActivityGoods)
|
|
|
@ -210,6 +223,21 @@ public class TzcRebateApplication4CostServiceImpl implements TzcRebateApplicatio |
|
|
|
tbsActivityCenterGoodsService.saveBatch(centerGoodsList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 当不填写同期期间的发货金额时,则从数据库加载发货金额
|
|
|
|
for (TzcRebatePeriod period : periodList) { |
|
|
|
if (period.getSamePeriodAmount()==null){ |
|
|
|
for (TbsActivity activity : activityList) { |
|
|
|
if (period.getId().equals(activity.getRebatePeriodId())){ |
|
|
|
ErpDispatchSumPmsVo dispatchSumPmsVo = tbsActivityService.getDispatchSumByActivity(activity); |
|
|
|
period.setPeriodAmount(dispatchSumPmsVo.getTotalAmount()); |
|
|
|
tzcRebatePeriodService.updateById(period); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return costApplyId; |
|
|
|
} |
|
|
|
|
|
|
|