@ -35,6 +35,7 @@ import com.qs.serve.modules.sys.service.SysUserService;
import com.qs.serve.modules.tbs.common.TbsActivityState ;
import com.qs.serve.modules.tbs.common.TbsActivityState ;
import com.qs.serve.modules.tbs.common.TbsCostApplyState ;
import com.qs.serve.modules.tbs.common.TbsCostApplyState ;
import com.qs.serve.modules.tbs.common.TbsSeeYonConst ;
import com.qs.serve.modules.tbs.common.TbsSeeYonConst ;
import com.qs.serve.modules.tbs.common.consts.ReleaseConst ;
import com.qs.serve.modules.tbs.common.util.QuarterUtil ;
import com.qs.serve.modules.tbs.common.util.QuarterUtil ;
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil ;
import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil ;
import com.qs.serve.modules.tbs.entity.* ;
import com.qs.serve.modules.tbs.entity.* ;
@ -478,18 +479,23 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
Assert . throwEx ( "用户编码不存在:" + userCode ) ;
Assert . throwEx ( "用户编码不存在:" + userCode ) ;
}
}
TbsActivity activity = activityService . getById ( activityId ) ;
TbsActivity activity = activityService . getById ( activityId ) ;
if ( ! activity . getActivityState ( ) . equals ( TbsActivityState . STATE_0_Todo ) ) {
BirActivityCenterGoodsUtil . buildBir ( activity . getCostApplyId ( ) ) ;
if ( ! throwEx ) {
if ( ReleaseConst . UseFilter ) {
return ;
if ( ! activity . getActivityState ( ) . equals ( TbsActivityState . STATE_0_Todo ) ) {
if ( ! throwEx ) {
return ;
}
Assert . throwEx ( "活动状态非待核销状态,操作失败" ) ;
}
}
Assert . throwEx ( "活动状态非待核销状态,操作失败" ) ;
}
}
if ( activity . getCancelFlag ( ) . equals ( 1 ) ) {
if ( activity . getCancelFlag ( ) . equals ( 1 ) ) {
Assert . throwEx ( "异动的活动,无法操作" ) ;
Assert . throwEx ( "异动的活动,无法操作" ) ;
}
}
TbsCostApply costApply = costApplyService . getById ( activity . getCostApplyId ( ) ) ;
TbsCostApply costApply = costApplyService . getById ( activity . getCostApplyId ( ) ) ;
if ( ! costApply . getChargeState ( ) . equals ( TbsCostApplyState . State_2_actioning . getCode ( ) ) ) {
if ( ReleaseConst . UseFilter ) {
Assert . throwEx ( "状态不支持释放活动费用" ) ;
if ( ! costApply . getChargeState ( ) . equals ( TbsCostApplyState . State_2_actioning . getCode ( ) ) ) {
Assert . throwEx ( "状态不支持释放活动费用" ) ;
}
}
}
BigDecimal releaseAmount = this . validActivity ( costApply . getContractFlag ( ) ! = null
BigDecimal releaseAmount = this . validActivity ( costApply . getContractFlag ( ) ! = null
& & costApply . getContractFlag ( ) . equals ( 1 ) , activity , false , false ) ;
& & costApply . getContractFlag ( ) . equals ( 1 ) , activity , false , false ) ;
@ -504,6 +510,13 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
param . setFinishedFlag ( 1 ) ;
param . setFinishedFlag ( 1 ) ;
activityService . updateById ( param ) ;
activityService . updateById ( param ) ;
//移除历史记录
fundFlowService . remove (
new LambdaQueryWrapper < VtbFundFlow > ( )
. eq ( VtbFundFlow : : getFundType , VtbFundFlowType . Release )
. eq ( VtbFundFlow : : getCostApplyId , activity . getCostApplyId ( ) )
. eq ( VtbFundFlow : : getActivityId , activity . getId ( ) )
) ;
VtbFundFlow fundFlow = new VtbFundFlow ( ) ;
VtbFundFlow fundFlow = new VtbFundFlow ( ) ;
fundFlow . setFundType ( VtbFundFlowType . Release ) ;
fundFlow . setFundType ( VtbFundFlowType . Release ) ;
fundFlow . setVerificationId ( 0L ) ;
fundFlow . setVerificationId ( 0L ) ;
@ -545,6 +558,13 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
TbsBudgetLog budgetLog = TbsBudgetLogBuildUtil . buildTbsBudgetLog ( BudgetLogOptFlag . State_4 , sysUser , costApply , currCostItem , currentBudget , amount , activity ) ;
TbsBudgetLog budgetLog = TbsBudgetLogBuildUtil . buildTbsBudgetLog ( BudgetLogOptFlag . State_4 , sysUser , costApply , currCostItem , currentBudget , amount , activity ) ;
budgetLogList . add ( budgetLog ) ;
budgetLogList . add ( budgetLog ) ;
}
}
//移除历史记录
budgetLogService . remove ( new LambdaQueryWrapper < TbsBudgetLog > ( )
. eq ( TbsBudgetLog : : getCostApplyId , activity . getCostApplyId ( ) )
. eq ( TbsBudgetLog : : getOptType , BudgetLogOptFlag . State_4 . getCode ( ) )
. eq ( TbsBudgetLog : : getActivityId , activity . getId ( ) )
) ;
//重新保存
if ( CollectionUtil . isNotEmpty ( budgetLogList ) ) {
if ( CollectionUtil . isNotEmpty ( budgetLogList ) ) {
budgetLogService . saveBatch ( budgetLogList ) ;
budgetLogService . saveBatch ( budgetLogList ) ;
}
}
@ -1160,24 +1180,26 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
boolean isOverTime =
boolean isOverTime =
( activity . getPreCheckDate ( ) ! = null & & nowDate . isAfter ( activity . getPreCheckDate ( ) ) & & activity . getPreEndDateBack ( ) = = null )
( activity . getPreCheckDate ( ) ! = null & & nowDate . isAfter ( activity . getPreCheckDate ( ) ) & & activity . getPreEndDateBack ( ) = = null )
| | ( activity . getPreEndDateBack ( ) ! = null & & nowDate . isAfter ( activity . getPreEndDateBack ( ) ) ) ;
| | ( activity . getPreEndDateBack ( ) ! = null & & nowDate . isAfter ( activity . getPreEndDateBack ( ) ) ) ;
if ( ! cotractFlag & & activity . getReopenFlag ( ) . equals ( 0 )
if ( ReleaseConst . UseFilter ) {
& & filterActTime
if ( ! cotractFlag & & activity . getReopenFlag ( ) . equals ( 0 )
& & isOverTime ) {
& & filterActTime
Assert . throwEx ( "活动已结束" ) ;
& & isOverTime ) {
}
Assert . throwEx ( "活动已结束" ) ;
if ( activity . getActivityState ( ) . equals ( TbsActivityState . STATE_1_Baning ) ) {
}
Assert . throwEx ( "活动冻结中" ) ;
if ( activity . getActivityState ( ) . equals ( TbsActivityState . STATE_1_Baning ) ) {
}
Assert . throwEx ( "活动冻结中" ) ;
if ( ( activity . getReleaseFlag ( ) ! = null & & activity . getReleaseFlag ( ) . equals ( 1 ) ) | | activity . getActivityState ( ) . equals ( TbsActivityState . STATE_4_Release ) ) {
}
Assert . throwEx ( "费用已释放" ) ;
if ( ( activity . getReleaseFlag ( ) ! = null & & activity . getReleaseFlag ( ) . equals ( 1 ) ) | | activity . getActivityState ( ) . equals ( TbsActivityState . STATE_4_Release ) ) {
}
Assert . throwEx ( "费用已释放" ) ;
if ( activity . getFinishedFlag ( ) . equals ( 1 ) ) {
}
Assert . throwEx ( "活动已完成" ) ;
if ( activity . getFinishedFlag ( ) . equals ( 1 ) ) {
}
Assert . throwEx ( "活动已完成" ) ;
if ( ! isCurrentCommit ) {
}
boolean isCommitting = this . checkCommitting ( activity . getId ( ) ) ;
if ( ! isCurrentCommit ) {
if ( isCommitting ) {
boolean isCommitting = this . checkCommitting ( activity . getId ( ) ) ;
Assert . throwEx ( "该活动核销中,操作失败" ) ;
if ( isCommitting ) {
Assert . throwEx ( "该活动核销中,操作失败" ) ;
}
}
}
}
}
List < VtbFundFlow > fundFlowList = fundFlowService . listByActivity ( activity . getId ( ) , VtbFundFlowType . Verification ) ;
List < VtbFundFlow > fundFlowList = fundFlowService . listByActivity ( activity . getId ( ) , VtbFundFlowType . Verification ) ;
@ -1187,6 +1209,7 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
}
}
BigDecimal allowAmount = activity . getTotalAmount ( ) . subtract ( totalFunFlow ) ;
BigDecimal allowAmount = activity . getTotalAmount ( ) . subtract ( totalFunFlow ) ;
if ( allowAmount . compareTo ( BigDecimal . ZERO ) < 0 ) {
if ( allowAmount . compareTo ( BigDecimal . ZERO ) < 0 ) {
log . error ( "无可用费用 activity id:{} code:{}" , activity . getId ( ) , activity . getActivityCode ( ) ) ;
Assert . throwEx ( "无可用费用" ) ;
Assert . throwEx ( "无可用费用" ) ;
}
}
return allowAmount ;
return allowAmount ;
@ -1269,6 +1292,7 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
log . info ( "活动核销提交成功。verificationId:{}" , verificationId ) ;
log . info ( "活动核销提交成功。verificationId:{}" , verificationId ) ;
VtbVerification verification = this . getById ( verificationId ) ;
VtbVerification verification = this . getById ( verificationId ) ;
if ( verification . getVerificationState ( ) > 1 ) {
if ( verification . getVerificationState ( ) > 1 ) {
log . warn ( "活动核销已提交成功,请勿重复提交。verificationId:{}" , verificationId ) ;
return ;
return ;
}
}
boolean checkZero = verification . getAmount ( ) . compareTo ( BigDecimal . ZERO ) = = 0 ;
boolean checkZero = verification . getAmount ( ) . compareTo ( BigDecimal . ZERO ) = = 0 ;
@ -1301,7 +1325,6 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
Map < Long , List < TbsActivityCenter > > centerMapBySubject = activityCenterList . stream ( )
Map < Long , List < TbsActivityCenter > > centerMapBySubject = activityCenterList . stream ( )
. collect ( Collectors . groupingBy ( TbsActivityCenter : : getSubjectId ) ) ;
. collect ( Collectors . groupingBy ( TbsActivityCenter : : getSubjectId ) ) ;
List < VtbFundFlow > addFundFlowList = new ArrayList < > ( ) ;
List < VtbFundFlow > addFundFlowList = new ArrayList < > ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
for ( VtbVerificationSubject verificationSubject : verificationSubjects ) {
for ( VtbVerificationSubject verificationSubject : verificationSubjects ) {
Long subjectId = verificationSubject . getSubjectId ( ) ;
Long subjectId = verificationSubject . getSubjectId ( ) ;
@ -1364,8 +1387,6 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
}
}
fundFlowService . saveBatch ( addFundFlowList ) ;
fundFlowService . saveBatch ( addFundFlowList ) ;
//fundFlow绑定考核期项,用于合计预算使用情况
//fundFlow绑定考核期项,用于合计预算使用情况
LambdaQueryWrapper < VtbVerificationSubject > subjectLqw = new LambdaQueryWrapper < > ( ) ;
LambdaQueryWrapper < VtbVerificationSubject > subjectLqw = new LambdaQueryWrapper < > ( ) ;