|
|
@ -220,7 +220,7 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
// 更新金额
|
|
|
|
TbsCostApply apply = new TbsCostApply(); |
|
|
|
// TODO 1.有修改金额为0的异常;2.需要调整预算占用
|
|
|
|
// BigDecimal totalApply = checkToChangeAmount(param, targetId);
|
|
|
|
BigDecimal totalApply = checkToChangeAmount(param); |
|
|
|
apply.setId(targetId); |
|
|
|
// if(totalApply!=null){
|
|
|
|
// apply.setTotalActivityAmount(totalApply);
|
|
|
@ -244,7 +244,8 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private BigDecimal checkToChangeAmount(TbsAffairCommitBo param, Long targetId) { |
|
|
|
public BigDecimal checkToChangeAmount(TbsAffairCommitBo param) { |
|
|
|
Long targetId = Long.parseLong(this.getTargetId(param)); |
|
|
|
if(CollectionUtil.isNotEmpty(param.getAffairSubjectLines())){ |
|
|
|
BigDecimal n100 = new BigDecimal("100"); |
|
|
|
QueryWrapper comm_qw = new QueryWrapper(); |
|
|
@ -259,6 +260,9 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
//先计算科目的费用
|
|
|
|
for (TbsActivitySubject subject : activitySubjectList) { |
|
|
|
for (TbsAffairCommitBo.AffairSubjectLine subjectLine : param.getAffairSubjectLines()) { |
|
|
|
if(subjectLine.getAmount().compareTo(BigDecimal.ZERO)<=0){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
if(subjectLine.getSubjectId().equals(subject.getId())){ |
|
|
|
BigDecimal subjectAmount = subjectLine.getAmount(); |
|
|
|
//重新计算活动金额
|
|
|
@ -290,7 +294,9 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
activityCenter.setCenterAmount(centerAmt); |
|
|
|
activityCenterMapper.updateById(activityCenter); |
|
|
|
//计算成本中心下的商品
|
|
|
|
for (TbsActivityCenterGoods centerGoods : activityCenterGoodsList) { |
|
|
|
BigDecimal tmpCenterAmt = centerAmt; |
|
|
|
for (int i = 0; i < activityCenterGoodsList.size(); i++) { |
|
|
|
TbsActivityCenterGoods centerGoods = activityCenterGoodsList.get(i); |
|
|
|
boolean eqActivity4Goods = centerGoods.getActivityId().equals(activityCenter.getActivityId()); |
|
|
|
boolean eqCenter4Goods = centerGoods.getCenterType().equals(activityCenter.getCenterType()) |
|
|
|
&¢erGoods.getCenterId().equals(activityCenter.getCenterId()); |
|
|
@ -302,9 +308,15 @@ public class TbsCostApplyOperationServiceImpl implements SeeYonOperationService |
|
|
|
centerGoods.setOrgCenterGoodsAmount(centerGoods.getCenterGoodsAmount()); |
|
|
|
} |
|
|
|
centerGoods.setCenterAmount(centerAmt); |
|
|
|
centerGoods.setCenterGoodsAmount(centerAmt.multiply(centerGoods.getCenterGoodsRate()).divide(n100,2,RoundingMode.HALF_DOWN)); |
|
|
|
BigDecimal centerGoodAmt = null; |
|
|
|
if(i+1==activityCenterGoodsList.size()){ |
|
|
|
centerGoodAmt = tmpCenterAmt; |
|
|
|
}else { |
|
|
|
centerGoodAmt = centerAmt.multiply(centerGoods.getCenterGoodsRate()).divide(n100,2,RoundingMode.HALF_DOWN); |
|
|
|
tmpCenterAmt = tmpCenterAmt.subtract(centerGoodAmt); |
|
|
|
} |
|
|
|
centerGoods.setCenterGoodsAmount(centerGoodAmt); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|