|
@ -52,10 +52,14 @@ import com.qs.serve.modules.tzc.entity.TzcPolicy; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyGoods; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyGoods; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyItem; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyItem; |
|
|
import com.qs.serve.modules.tzc.entity.dto.PolicyItemDto; |
|
|
import com.qs.serve.modules.tzc.entity.dto.PolicyItemDto; |
|
|
|
|
|
import com.qs.serve.modules.tzc.mapper.TzcPolicyItemMapper; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyApplicationService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyApplicationService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyGoodsService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyGoodsService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyItemService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyItemService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyService; |
|
|
import com.qs.serve.modules.tzc.service.TzcPolicyService; |
|
|
|
|
|
import com.qs.serve.modules.vtb.common.VtbFundFlowType; |
|
|
|
|
|
import com.qs.serve.modules.vtb.entity.VtbFundFlow; |
|
|
|
|
|
import com.qs.serve.modules.vtb.service.VtbFundFlowService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.jetbrains.annotations.NotNull; |
|
|
import org.jetbrains.annotations.NotNull; |
|
@ -80,6 +84,7 @@ public class TzcPolicyApplicationServiceImpl implements TzcPolicyApplicationServ |
|
|
|
|
|
|
|
|
private TzcPolicyService tzcPolicyService; |
|
|
private TzcPolicyService tzcPolicyService; |
|
|
private TzcPolicyItemService tzcPolicyItemService; |
|
|
private TzcPolicyItemService tzcPolicyItemService; |
|
|
|
|
|
private TzcPolicyItemMapper tzcPolicyItemMapper; |
|
|
private TzcPolicyGoodsService tzcPolicyGoodsService; |
|
|
private TzcPolicyGoodsService tzcPolicyGoodsService; |
|
|
private TbsCostUnItemPolicyService tbsCostUnItemPolicyService; |
|
|
private TbsCostUnItemPolicyService tbsCostUnItemPolicyService; |
|
|
private TbsBudgetCostItemPolicyService tbsBudgetCostItemPolicyService; |
|
|
private TbsBudgetCostItemPolicyService tbsBudgetCostItemPolicyService; |
|
@ -100,6 +105,7 @@ public class TzcPolicyApplicationServiceImpl implements TzcPolicyApplicationServ |
|
|
private final BmsRegionMapper regionMapper; |
|
|
private final BmsRegionMapper regionMapper; |
|
|
private final BmsRegion2Mapper region2Mapper; |
|
|
private final BmsRegion2Mapper region2Mapper; |
|
|
private ProjectApisProperties projectApisProperties; |
|
|
private ProjectApisProperties projectApisProperties; |
|
|
|
|
|
private final VtbFundFlowService vtbFundFlowService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void syncPolicy(Long policyId) { |
|
|
public void syncPolicy(Long policyId) { |
|
@ -113,8 +119,74 @@ public class TzcPolicyApplicationServiceImpl implements TzcPolicyApplicationServ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void releasePolicy(Long policyId) { |
|
|
public void releasePolicyItem(Long policyItemId) { |
|
|
|
|
|
TzcPolicyItem policyItem = tzcPolicyItemService.getById(policyItemId); |
|
|
|
|
|
if(!policyItem.getPolicyItemStatus().equals(TzPolicyItemStatus.Status_3_Finished)){ |
|
|
|
|
|
Assert.throwEx("政策项的状态不支持"); |
|
|
|
|
|
} |
|
|
|
|
|
Long policyId = policyItem.getPolicyId(); |
|
|
|
|
|
TzcPolicy policy = tzcPolicyService.getById(policyId); |
|
|
|
|
|
if(!policy.getPolicyStatus().equals(TzcPolicyStatus.Status_2_PassSuccess)){ |
|
|
|
|
|
Assert.throwEx("政策的状态不支持"); |
|
|
|
|
|
} |
|
|
|
|
|
BigDecimal usedAmt = tzcPolicyItemMapper.sumPolicyItemTranAmt(policyItem.getId()); |
|
|
|
|
|
BigDecimal surplusAmt = policyItem.getDiscountMax().subtract(usedAmt); |
|
|
|
|
|
if(surplusAmt.compareTo(BigDecimal.ZERO)>0){ |
|
|
|
|
|
LambdaQueryWrapper<TbsBudgetLog> tbsLogLqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
tbsLogLqw.eq(TbsBudgetLog::getPolicyItemId,policyItem.getId()); |
|
|
|
|
|
tbsLogLqw.eq(TbsBudgetLog::getOptType,BudgetLogOptFlag.State_11.getCode()); |
|
|
|
|
|
TbsBudgetLog budgetLog = budgetLogService.getOne(tbsLogLqw,false); |
|
|
|
|
|
if(budgetLog==null){ |
|
|
|
|
|
Assert.throwEx("政策预算数据异常:"+policyItem.getPolicyItemCode()); |
|
|
|
|
|
} |
|
|
|
|
|
//余额大于0则释放
|
|
|
|
|
|
VtbFundFlow fundFlow = new VtbFundFlow(); |
|
|
|
|
|
fundFlow.setFundType(VtbFundFlowType.Release); |
|
|
|
|
|
fundFlow.setVerificationId(0L); |
|
|
|
|
|
fundFlow.setCenterGoodsCode("0"); |
|
|
|
|
|
fundFlow.setCostApplyId(0L); |
|
|
|
|
|
fundFlow.setActivityId(0L); |
|
|
|
|
|
fundFlow.setSupplierId(0L); |
|
|
|
|
|
fundFlow.setSupplierCode(""); |
|
|
|
|
|
fundFlow.setSupplierName(""); |
|
|
|
|
|
fundFlow.setPolicyId(policyId); |
|
|
|
|
|
fundFlow.setPolicyItemId(policyItem.getId()); |
|
|
|
|
|
fundFlow.setUsedAmount(surplusAmt); |
|
|
|
|
|
vtbFundFlowService.save(fundFlow); |
|
|
|
|
|
|
|
|
|
|
|
budgetLog.setCreateBy(null); |
|
|
|
|
|
budgetLog.setCreateTime(null); |
|
|
|
|
|
budgetLog.setUpdateBy(null); |
|
|
|
|
|
budgetLog.setUpdateTime(null); |
|
|
|
|
|
budgetLog.setId(null); |
|
|
|
|
|
BudgetLogOptFlag optFlag = BudgetLogOptFlag.State_16; |
|
|
|
|
|
//正数
|
|
|
|
|
|
budgetLog.setAmount(surplusAmt); |
|
|
|
|
|
budgetLog.setOptType(optFlag.getCode()); |
|
|
|
|
|
budgetLogService.save(budgetLog); |
|
|
|
|
|
|
|
|
|
|
|
policyItem.setUsedAmount(policyItem.getDiscountMax()); |
|
|
|
|
|
policyItem.setPolicyItemStatus(TzPolicyItemStatus.Status_3_Finished); |
|
|
|
|
|
|
|
|
|
|
|
tzcPolicyItemService.updateById(policyItem); |
|
|
|
|
|
} |
|
|
|
|
|
//标记政策已完成
|
|
|
|
|
|
List<TzcPolicyItem> listByPolicyId = tzcPolicyItemService.listByPolicyId(policyId); |
|
|
|
|
|
boolean allFinished = true; |
|
|
|
|
|
for (TzcPolicyItem item : listByPolicyId) { |
|
|
|
|
|
if(!item.getPolicyItemStatus().equals(TzPolicyItemStatus.Status_3_Finished)){ |
|
|
|
|
|
if (item.getDiscountMax().compareTo(item.getUsedAmount())==0){ |
|
|
|
|
|
item.setPolicyItemStatus(TzPolicyItemStatus.Status_3_Finished); |
|
|
|
|
|
tzcPolicyItemService.updateById(item); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
allFinished = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(allFinished){ |
|
|
|
|
|
policy.setPolicyStatus(TzcPolicyStatus.Status_3_Success); |
|
|
|
|
|
tzcPolicyService.updateById(policy); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|