|
@ -933,7 +933,134 @@ public class PortalOfCostApplication { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 协议类费用 核销支付记录 |
|
|
|
|
|
* @param createBo |
|
|
|
|
|
*/ |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void createByContractCheck(ProcessCreateContractCheckBo createBo){ |
|
|
|
|
|
TbsCostApply costApply = costApplyService.getByCode(createBo.getCostCode()); |
|
|
|
|
|
TbsActivity activity = activityService.listByCostApplyId(costApply.getId()).get(0); |
|
|
|
|
|
List<TbsActivitySubject> subjectList = activitySubjectService.listByActivityId(activity.getId()); |
|
|
|
|
|
BmsSupplier supplier = supplierService.getById(costApply.getSupplierId()); |
|
|
|
|
|
BigDecimal totalAmount = createBo.getAmount(); |
|
|
|
|
|
SysUser user = userService.getByAccount(createBo.getUserCode()); |
|
|
|
|
|
LocalDateTime nowTime = LocalDateTime.now(); |
|
|
|
|
|
//保存核销申请
|
|
|
|
|
|
VtbVerification verification = new VtbVerification(); |
|
|
|
|
|
verification.setDisCode(createBo.getDispatchCode()); |
|
|
|
|
|
verification.setBillNumber(createBo.getBillNumber()); |
|
|
|
|
|
verification.setVerificationCode("HXC"+ CodeGenUtil.generate(CodeGenUtil.SourceKey.Verification)); |
|
|
|
|
|
verification.setVerificationMainCode(verification.getVerificationCode()); |
|
|
|
|
|
verification.setCostApplyId(costApply.getId()); |
|
|
|
|
|
verification.setFinishedTime(nowTime); |
|
|
|
|
|
verification.setVerificationState(VtbVerificationState.Finished.getCode()); |
|
|
|
|
|
verification.setActivityId(activity.getId()); |
|
|
|
|
|
verification.setSupplierId(activity.getSupplierId()); |
|
|
|
|
|
verification.setSupplierCode(activity.getSupplierCode()); |
|
|
|
|
|
verification.setSupplierName(activity.getSupplierName()); |
|
|
|
|
|
verification.setUserId(user.getId()); |
|
|
|
|
|
verification.setUserCode(user.getCode()); |
|
|
|
|
|
verification.setUserName(user.getName()); |
|
|
|
|
|
verification.setAmount(totalAmount); |
|
|
|
|
|
verification.setAmountRecord(totalAmount); |
|
|
|
|
|
verification.setPaymentState(ResultFlag.OK); |
|
|
|
|
|
verificationService.save(verification); |
|
|
|
|
|
|
|
|
|
|
|
//协议类的要直接支付
|
|
|
|
|
|
PayPayment payPayment = new PayPayment(); |
|
|
|
|
|
payPayment.setPayType(PaymentType.PAYMENT); |
|
|
|
|
|
payPayment.setPayCode("PM" + StringUtils.genShortId()); |
|
|
|
|
|
payPayment.setSupplierId(Long.parseLong(supplier.getId())); |
|
|
|
|
|
payPayment.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
payPayment.setSupplierName(supplier.getName()); |
|
|
|
|
|
payPayment.setPayAmount(totalAmount); |
|
|
|
|
|
payPayment.setCostApplyId(costApply.getId()); |
|
|
|
|
|
payPayment.setUserId(user.getId()); |
|
|
|
|
|
payPayment.setUserCode(user.getCode()); |
|
|
|
|
|
payPayment.setUserName(user.getName()); |
|
|
|
|
|
payPayment.setPayTime(nowTime); |
|
|
|
|
|
payPayment.setErpCode(createBo.getDispatchCode()); |
|
|
|
|
|
payPayment.setBillNumber(createBo.getBillNumber()); |
|
|
|
|
|
payPayment.setCreateBy(user.getName()); |
|
|
|
|
|
payPayment.setCreateTime(LocalDateTime.now()); |
|
|
|
|
|
paymentService.save(payPayment); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存核销费用结果
|
|
|
|
|
|
BigDecimal subjectSurplus = createBo.getAmount(); |
|
|
|
|
|
for (TbsActivitySubject subject : subjectList) { |
|
|
|
|
|
if(subjectSurplus.compareTo(BigDecimal.ZERO)==0){ |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
//当前项支付多少
|
|
|
|
|
|
BigDecimal currItemAmount; |
|
|
|
|
|
//科目还有多少金额未支付
|
|
|
|
|
|
BigDecimal totalUnPay = subject.getUsedAmount()==null?subject.getAmount():subject.getAmount().subtract(subject.getUsedAmount()); |
|
|
|
|
|
//节点金额>科目的剩余金额
|
|
|
|
|
|
if(totalUnPay.compareTo(subjectSurplus)>=0){ |
|
|
|
|
|
currItemAmount = subjectSurplus; |
|
|
|
|
|
subjectSurplus = BigDecimal.ZERO; |
|
|
|
|
|
}else { |
|
|
|
|
|
subjectSurplus = subjectSurplus.subtract(totalUnPay); |
|
|
|
|
|
currItemAmount = totalUnPay; |
|
|
|
|
|
} |
|
|
|
|
|
//科目总支付
|
|
|
|
|
|
BigDecimal totalPay = subject.getUsedAmount().add(currItemAmount); |
|
|
|
|
|
|
|
|
|
|
|
VtbVerificationSubject verificationSubject = new VtbVerificationSubject(); |
|
|
|
|
|
verificationSubject.setVerificationId(verification.getId()); |
|
|
|
|
|
verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1"); |
|
|
|
|
|
verificationSubject.setCostApplyId(costApply.getId()); |
|
|
|
|
|
verificationSubject.setActivityId(activity.getId()); |
|
|
|
|
|
verificationSubject.setSubjectId(subject.getId()); |
|
|
|
|
|
verificationSubject.setSubjectCode(subject.getSubjectCode()); |
|
|
|
|
|
verificationSubject.setSubjectName(subject.getSubjectName()); |
|
|
|
|
|
verificationSubject.setSupplierId(Long.parseLong(supplier.getId())); |
|
|
|
|
|
verificationSubject.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
verificationSubject.setSupplierName(supplier.getName()); |
|
|
|
|
|
verificationSubject.setPayFinishedFlag(ResultFlag.OK); |
|
|
|
|
|
verificationSubject.setUsedAmount(currItemAmount); |
|
|
|
|
|
verificationSubject.setUsedAmountRecord(currItemAmount); |
|
|
|
|
|
verificationSubject.setCountPerson(0); |
|
|
|
|
|
verificationSubject.setCountSession(0); |
|
|
|
|
|
|
|
|
|
|
|
PayPaymentItem paymentItem = new PayPaymentItem(); |
|
|
|
|
|
paymentItem.setPaymentId(payPayment.getId()); |
|
|
|
|
|
paymentItem.setPayType(PaymentType.PAYMENT); |
|
|
|
|
|
paymentItem.setSupplierId(Long.parseLong(supplier.getId())); |
|
|
|
|
|
paymentItem.setItemPayAmount(totalAmount); |
|
|
|
|
|
paymentItem.setVerificationId(verification.getId()); |
|
|
|
|
|
paymentItem.setVerificationCode(verification.getVerificationCode()); |
|
|
|
|
|
paymentItem.setVerificationMainCode(verification.getVerificationCode()); |
|
|
|
|
|
paymentItem.setVerificationSubjectId(verificationSubject.getId()); |
|
|
|
|
|
paymentItem.setCostApplyId(costApply.getId()); |
|
|
|
|
|
paymentItem.setActivityId(activity.getId()); |
|
|
|
|
|
paymentItem.setActivityCode(activity.getActivityCode()); |
|
|
|
|
|
paymentItem.setSubjectId(subject.getId()); |
|
|
|
|
|
paymentItem.setSubjectCode(subject.getSubjectCode()); |
|
|
|
|
|
paymentItem.setSubjectName(subject.getSubjectName()); |
|
|
|
|
|
paymentItem.setCreateBy(user.getName()); |
|
|
|
|
|
paymentItem.setCreateTime(LocalDateTime.now()); |
|
|
|
|
|
|
|
|
|
|
|
//保存和更新项
|
|
|
|
|
|
TbsActivitySubject activitySubject = new TbsActivitySubject(); |
|
|
|
|
|
activitySubject.setId(subject.getId()); |
|
|
|
|
|
activitySubject.setUsedAmount(totalPay); |
|
|
|
|
|
activitySubjectService.updateById(subject); |
|
|
|
|
|
paymentItemService.save(paymentItem); |
|
|
|
|
|
verificationSubjectService.save(verificationSubject); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 协议类费用 释放接口,释放合同不再支付的金额; |
|
|
|
|
|
* @param contractBo |
|
|
|
|
|
*/ |
|
|
|
|
|
public void releaseContractCost(ProcessReleaseContractBo contractBo){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 创建流程中,初始化SKU列表 |
|
|
* 创建流程中,初始化SKU列表 |
|
|