@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.qs.serve.common.config.properties.ProjectProperties ;
import com.qs.serve.common.model.dto.R ;
import com.qs.serve.common.model.enums.BudgetLogOptFlag ;
import com.qs.serve.common.util.* ;
import com.qs.serve.modules.bir.consts.BirActivityCenterGoodsUtil ;
import com.qs.serve.modules.bir.service.BirCenterRateService ;
@ -32,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal ;
import java.time.LocalDateTime ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.stream.Collectors ;
@ -363,6 +365,47 @@ public class TbsCostApplyPart1ServiceImpl implements TbsCostApplyPart1Service {
. eq ( TbsBudgetCostItem : : getCenterGoodItemId , centerGoods . getId ( ) ) ) ;
}
//更新预算占用
List < TbsBudgetLog > budgetLogList = tbsBudgetLogMapper . selectList ( new LambdaQueryWrapper < TbsBudgetLog > ( )
. eq ( TbsBudgetLog : : getActivityId , activityId )
. eq ( TbsBudgetLog : : getOptType , BudgetLogOptFlag . State_1 . getCode ( ) ) ) ;
if ( budgetLogList . size ( ) < 1 ) {
log . warn ( "活动ID:{} 无申请预算的日志" , activityId ) ;
return ;
}
if ( budgetLogList . size ( ) ! = activityCenterGoodsList . size ( ) ) {
log . warn ( "活动ID:{} 申请预算的日志数量不匹配" , activityId ) ;
return ;
}
List < TbsBudgetLog > updateBudgetLog = new ArrayList < > ( ) ;
for ( TbsActivityCenterGoods centerGoods : activityCenterGoodsList ) {
for ( TbsBudgetLog budgetLog : budgetLogList ) {
boolean eqSubjectId = centerGoods . getSubjectId ( ) . equals ( budgetLog . getSubjectId ( ) ) ;
boolean eqCenterId = centerGoods . getCenterId ( ) . equals ( budgetLog . getCenterId ( ) ) ;
boolean eqCenterType = centerGoods . getCenterType ( ) . equals ( budgetLog . getCenterType ( ) ) ;
boolean eqTargetType = centerGoods . getTargetType ( ) . equals ( budgetLog . getTargetType ( ) ) ;
boolean eqTargetId = centerGoods . getTargetId ( ) . equals ( budgetLog . getTargetId ( ) ) ;
if ( eqSubjectId & & eqCenterId & & eqCenterType & & eqTargetType & & eqTargetId ) {
TbsBudgetLog param = new TbsBudgetLog ( ) ;
param . setId ( budgetLog . getId ( ) ) ;
//负数
param . setAmount ( centerGoods . getCenterGoodsAmount ( ) . negate ( ) ) ;
updateBudgetLog . add ( param ) ;
}
}
}
if ( updateBudgetLog . size ( ) = = activityCenterGoodsList . size ( ) ) {
for ( TbsBudgetLog budgetLog : updateBudgetLog ) {
tbsBudgetLogMapper . updateById ( budgetLog ) ;
}
} else {
log . warn ( "活动ID:{} 申请预算的日志,更新数量不匹配" , activityId ) ;
}
}