|
@ -1,6 +1,7 @@ |
|
|
package com.qs.serve.modules.tzc.service.impl; |
|
|
package com.qs.serve.modules.tzc.service.impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.qs.serve.common.config.DevEnvironmentConfig; |
|
|
import com.qs.serve.common.config.DevEnvironmentConfig; |
|
|
import com.qs.serve.common.config.properties.ProjectApisProperties; |
|
|
import com.qs.serve.common.config.properties.ProjectApisProperties; |
|
|
import com.qs.serve.common.config.properties.ProjectProperties; |
|
|
import com.qs.serve.common.config.properties.ProjectProperties; |
|
@ -134,12 +135,69 @@ public class TzcPolicyApplicationServiceImpl implements TzcPolicyApplicationServ |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("释放过期费用失败,itemId:{} 原因:{}",id,e.getMessage()); |
|
|
log.error("释放过期费用失败,itemId:{} 原因:{}",id,e.getMessage()); |
|
|
} |
|
|
} |
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void cancelReleasePolicyItem(Long policyItemId) { |
|
|
|
|
|
TzcPolicyItem policyItem = tzcPolicyItemService.getById(policyItemId); |
|
|
|
|
|
if(policyItem.getPolicyEndDate().atStartOfDay().isBefore(LocalDateTime.now())){ |
|
|
|
|
|
Assert.throwEx("政策项已过期,不支持取消释放"); |
|
|
|
|
|
} |
|
|
|
|
|
if(!policyItem.getPolicyItemStatus().equals(TzPolicyItemStatus.Status_3_Finished)|| |
|
|
|
|
|
!policyItem.getReleaseFlag().equals(1)){ |
|
|
|
|
|
Assert.throwEx("政策项的状态不支持"); |
|
|
|
|
|
} |
|
|
|
|
|
//查询已转移金额,金额为正数
|
|
|
|
|
|
BigDecimal usedAmt = tzcPolicyItemMapper.sumPolicyItemTranAmt(policyItem.getId()); |
|
|
|
|
|
if(policyItem.getUsedAmount().compareTo(usedAmt)!=0){ |
|
|
|
|
|
Assert.throwEx("政策的已用金额异常"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//移除流水
|
|
|
|
|
|
vtbFundFlowService.remove(new LambdaQueryWrapper<VtbFundFlow>() |
|
|
|
|
|
.eq(VtbFundFlow::getPolicyItemId,policyItemId) |
|
|
|
|
|
.eq(VtbFundFlow::getFundType,VtbFundFlowType.Release) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
//移除Log释放
|
|
|
|
|
|
List<TbsBudgetLog> budgetLogList = budgetLogService.list(new LambdaQueryWrapper<TbsBudgetLog>() |
|
|
|
|
|
.eq(TbsBudgetLog::getOptType,BudgetLogOptFlag.State_16.getCode()) |
|
|
|
|
|
.eq(TbsBudgetLog::getPolicyItemId,policyItemId) |
|
|
|
|
|
); |
|
|
|
|
|
BigDecimal totalRelease = BigDecimal.ZERO; |
|
|
|
|
|
for (TbsBudgetLog budgetLog : budgetLogList) { |
|
|
|
|
|
totalRelease = totalRelease.add(budgetLog.getAmount()); |
|
|
|
|
|
} |
|
|
|
|
|
if(policyItem.getReleaseAmount().compareTo(totalRelease)!=0){ |
|
|
|
|
|
Assert.throwEx("释放金额异常"); |
|
|
|
|
|
} |
|
|
|
|
|
List<Long> logIds = budgetLogList.stream().map(TbsBudgetLog::getId).collect(Collectors.toList()); |
|
|
|
|
|
budgetLogService.removeBatchByIds(logIds); |
|
|
|
|
|
|
|
|
|
|
|
//恢复状态
|
|
|
|
|
|
policyItem.setReleaseAmount(BigDecimal.ZERO); |
|
|
|
|
|
policyItem.setReleaseFlag(0); |
|
|
|
|
|
policyItem.setReleaseTime(null); |
|
|
|
|
|
policyItem.setReleaseUserId(""); |
|
|
|
|
|
policyItem.setReleaseUserCode(""); |
|
|
|
|
|
policyItem.setReleaseUserName(""); |
|
|
|
|
|
policyItem.setPolicyItemStatus(TzPolicyItemStatus.Status_2_SyncSuccess); |
|
|
|
|
|
tzcPolicyItemService.updateById(policyItem); |
|
|
|
|
|
|
|
|
|
|
|
//恢复主表状态
|
|
|
|
|
|
Long policyId = policyItem.getPolicyId(); |
|
|
|
|
|
TzcPolicy policy = tzcPolicyService.getById(policyId); |
|
|
|
|
|
if(policy.getPolicyStatus().equals(TzcPolicyStatus.Status_3_Success)){ |
|
|
|
|
|
policy.setPolicyStatus(TzcPolicyStatus.Status_2_PassSuccess); |
|
|
|
|
|
tzcPolicyService.updateById(policy); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void releasePolicyItem(Long policyItemId, SysUser user) { |
|
|
public void releasePolicyItem(Long policyItemId, SysUser user) { |
|
|
TzcPolicyItem policyItem = tzcPolicyItemService.getById(policyItemId); |
|
|
TzcPolicyItem policyItem = tzcPolicyItemService.getById(policyItemId); |
|
|
if(!policyItem.getPolicyItemStatus().equals(TzPolicyItemStatus.Status_2_SyncSuccess)){ |
|
|
if(!policyItem.getPolicyItemStatus().equals(TzPolicyItemStatus.Status_2_SyncSuccess)){ |
|
|