|
|
@ -1,6 +1,7 @@ |
|
|
|
package com.qs.serve.modules.tbs.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.qs.serve.common.model.enums.BudgetLogOptFlag; |
|
|
|
import com.qs.serve.common.model.consts.BudgetLogRollbackFlag; |
|
|
|
import com.qs.serve.common.model.dto.R; |
|
|
@ -21,16 +22,11 @@ import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsSeeYonConst; |
|
|
|
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil; |
|
|
|
import com.qs.serve.modules.tbs.entity.TbsActivity; |
|
|
|
import com.qs.serve.modules.tbs.entity.TbsActivitySubject; |
|
|
|
import com.qs.serve.modules.tbs.entity.TbsBudgetLog; |
|
|
|
import com.qs.serve.modules.tbs.entity.TbsCostApply; |
|
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
|
import com.qs.serve.modules.tbs.entity.bo.TbsAffairCommitBo; |
|
|
|
import com.qs.serve.modules.tbs.entity.vo.CtpAffairVo; |
|
|
|
import com.qs.serve.modules.tbs.mapper.TbsActivityMapper; |
|
|
|
import com.qs.serve.modules.tbs.mapper.TbsActivitySlottingFeeMapper; |
|
|
|
import com.qs.serve.modules.tbs.mapper.TbsActivitySubjectMapper; |
|
|
|
import com.qs.serve.modules.tbs.mapper.TbsBudgetLogMapper; |
|
|
|
import com.qs.serve.modules.tbs.mapper.*; |
|
|
|
import com.qs.serve.modules.tbs.service.TbsActivityCenterGoodsService; |
|
|
|
import com.qs.serve.modules.tbs.service.TbsBudgetLogService; |
|
|
|
import com.qs.serve.modules.tbs.service.TbsCostApplyPart1Service; |
|
|
|
import com.qs.serve.modules.tbs.service.TbsCostApplyService; |
|
|
@ -38,6 +34,8 @@ import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
@ -66,6 +64,9 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
|
|
|
|
private final TbsCostApplyPart1Service costApplyPart1Service; |
|
|
|
private final TbsActivitySubjectMapper activitySubjectMapper; |
|
|
|
private final TbsActivityCenterMapper activityCenterMapper; |
|
|
|
private final TbsActivityCenterGoodsMapper activityCenterGoodsMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public SysUserService getSysUserService() { |
|
|
@ -216,8 +217,11 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
@Override |
|
|
|
public Object doFinished(TbsAffairCommitBo param) { |
|
|
|
Long targetId = Long.parseLong(this.getTargetId(param)); |
|
|
|
// 更新金额
|
|
|
|
BigDecimal totalApply = checkToChangeAmount(param, targetId); |
|
|
|
TbsCostApply apply = new TbsCostApply(); |
|
|
|
apply.setId(targetId); |
|
|
|
apply.setTotalActivityAmount(totalApply); |
|
|
|
apply.setChargeState(TbsCostApplyState.State_2_actioning.getCode()); |
|
|
|
costApplyService.updateById(apply); |
|
|
|
TbsCostApply costApply = costApplyService.getById(targetId); |
|
|
@ -236,6 +240,87 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private BigDecimal checkToChangeAmount(TbsAffairCommitBo param, Long targetId) { |
|
|
|
if(CollectionUtil.isNotEmpty(param.getAffairSubjectLines())){ |
|
|
|
BigDecimal n100 = new BigDecimal("100"); |
|
|
|
QueryWrapper comm_qw = new QueryWrapper(); |
|
|
|
comm_qw.eq("cost_apply_id", targetId); |
|
|
|
List<TbsActivity> activityList = tbsActivityMapper.selectList(comm_qw); |
|
|
|
List<TbsActivitySubject> activitySubjectList = activitySubjectMapper.selectList(comm_qw); |
|
|
|
List<TbsActivityCenter> activityCenterList = activityCenterMapper.selectList(comm_qw); |
|
|
|
TbsActivityCenterGoodsService tbsActivityCenterGoodsService = SpringUtils.getBean(TbsActivityCenterGoodsService.class); |
|
|
|
List<TbsActivityCenterGoods> activityCenterGoodsList = tbsActivityCenterGoodsService.listByCostApplyId(targetId); |
|
|
|
//初始化重新计算
|
|
|
|
activityList.forEach(a->a.setTotalAmount(BigDecimal.ZERO)); |
|
|
|
//先计算科目的费用
|
|
|
|
for (TbsActivitySubject subject : activitySubjectList) { |
|
|
|
for (TbsAffairCommitBo.AffairSubjectLine subjectLine : param.getAffairSubjectLines()) { |
|
|
|
if(subjectLine.getSubjectId().equals(subject.getId())){ |
|
|
|
BigDecimal subjectAmount = subjectLine.getAmount(); |
|
|
|
//重新计算活动金额
|
|
|
|
for (TbsActivity activity : activityList) { |
|
|
|
if(subject.getActivityId().equals(activity.getId())){ |
|
|
|
activity.setTotalAmount(activity.getTotalAmount().add(subjectAmount)); |
|
|
|
} |
|
|
|
} |
|
|
|
if(subject.getOrgAmount()==null){ |
|
|
|
//只对第一次赋值
|
|
|
|
subject.setOrgAmount(subject.getAmount()); |
|
|
|
} |
|
|
|
subject.setAmount(subjectAmount); |
|
|
|
subject.setCountPerson(subjectLine.getCountPerson()); |
|
|
|
subject.setCountSession(subjectLine.getCountSession()); |
|
|
|
//更新科目
|
|
|
|
activitySubjectMapper.updateById(subject); |
|
|
|
//计算科目下的成本中心
|
|
|
|
for (TbsActivityCenter activityCenter : activityCenterList) { |
|
|
|
boolean eqActivity = activityCenter.getActivityId().equals(subject.getActivityId()); |
|
|
|
boolean eqSubject = activityCenter.getSubjectId().equals(subject.getSubjectId()); |
|
|
|
if(eqActivity&&eqSubject){ |
|
|
|
BigDecimal centerAmt = activityCenter.getCenterRate() |
|
|
|
.multiply(subjectAmount).divide(n100,2, RoundingMode.HALF_UP); |
|
|
|
if (activityCenter.getOrgCenterAmount()==null){ |
|
|
|
//只对第一次赋值
|
|
|
|
activityCenter.setOrgCenterAmount(activityCenter.getCenterAmount()); |
|
|
|
} |
|
|
|
activityCenter.setCenterAmount(centerAmt); |
|
|
|
activityCenterMapper.updateById(activityCenter); |
|
|
|
//计算成本中心下的商品
|
|
|
|
for (TbsActivityCenterGoods centerGoods : activityCenterGoodsList) { |
|
|
|
boolean eqActivity4Goods = centerGoods.getActivityId().equals(activityCenter.getActivityId()); |
|
|
|
boolean eqCenter4Goods = centerGoods.getCenterType().equals(activityCenter.getCenterType()) |
|
|
|
&¢erGoods.getCenterId().equals(activityCenter.getCenterId()); |
|
|
|
boolean eqSubject4Goods = centerGoods.getSubjectId().equals(activityCenter.getSubjectId()); |
|
|
|
if(eqActivity4Goods&&eqCenter4Goods&&eqSubject4Goods){ |
|
|
|
if(centerGoods.getOrgCenterGoodsAmount()==null){ |
|
|
|
//只对第一次赋值
|
|
|
|
centerGoods.setOrgCenterAmount(activityCenter.getOrgCenterAmount()); |
|
|
|
centerGoods.setOrgCenterGoodsAmount(centerGoods.getCenterGoodsAmount()); |
|
|
|
} |
|
|
|
centerGoods.setCenterAmount(centerAmt); |
|
|
|
centerGoods.setCenterGoodsAmount(centerAmt.multiply(centerGoods.getCenterGoodsRate()).divide(n100,2,RoundingMode.HALF_DOWN)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//更新活动
|
|
|
|
BigDecimal total = BigDecimal.ZERO; |
|
|
|
for (TbsActivity activity : activityList) { |
|
|
|
tbsActivityMapper.updateById(activity); |
|
|
|
total = total.add(activity.getTotalAmount()); |
|
|
|
} |
|
|
|
//更新活动的商品
|
|
|
|
tbsActivityCenterGoodsService.updateBatchById(activityCenterGoodsList); |
|
|
|
return total; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object doRefuse(TbsAffairCommitBo param) { |
|
|
|
Long costApplyId = Long.parseLong(this.getTargetId(param)); |
|
|
@ -319,18 +404,6 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
R<String> result = getRequestService().commonCommit(affairCommit, templateCode ,syFormId); |
|
|
|
boolean isBackCommit = affairCommit.getState()==2; |
|
|
|
if(result.getStatus()==200){ |
|
|
|
// 更新金额
|
|
|
|
if(CollectionUtil.isNotEmpty(affairCommit.getAffairSubjectLines())){ |
|
|
|
List<Long> actSubjectIds = affairCommit.getAffairSubjectLines().stream() |
|
|
|
.map(TbsAffairCommitBo.AffairSubjectLine::getSubjectId).collect(Collectors.toList()); |
|
|
|
LambdaQueryWrapper<TbsActivitySubject> subLqw = new LambdaQueryWrapper<>(); |
|
|
|
subLqw.in(TbsActivitySubject::getId,actSubjectIds); |
|
|
|
subLqw.in(TbsActivitySubject::getCostApplyId,affairCommit.getCostApplyId()); |
|
|
|
List<TbsActivitySubject> activitySubjectList = activitySubjectMapper.selectList(subLqw); |
|
|
|
for (TbsAffairCommitBo.AffairSubjectLine subjectLine : affairCommit.getAffairSubjectLines()) { |
|
|
|
//TODO
|
|
|
|
} |
|
|
|
} |
|
|
|
// 判断是否含有下个节点
|
|
|
|
String flag = result.getData(); |
|
|
|
//审批中(next)、完成(finish)、拒绝(refused)
|
|
|
|