|
|
@ -587,6 +587,8 @@ public class PortalOfCostApplication { |
|
|
|
final BigDecimal OneHundred = new BigDecimal("100"); |
|
|
|
LocalDateTime nowTime = LocalDateTime.now(); |
|
|
|
LocalDate nowDate = LocalDate.now(); |
|
|
|
LocalDate startDate = createBo.getStartDate(); |
|
|
|
LocalDate endDate = createBo.getEndDate(); |
|
|
|
String erpCode = createBo.getErpCode(); |
|
|
|
Long supplierId = Long.parseLong(supplier.getId()); |
|
|
|
BigDecimal totalAmount = createBo.getTotalAmount(); |
|
|
@ -628,10 +630,10 @@ public class PortalOfCostApplication { |
|
|
|
activity.setSupplierId(supplierId); |
|
|
|
activity.setSupplierName(supplier.getName()); |
|
|
|
activity.setSupplierCode(supplier.getCode()); |
|
|
|
activity.setActStartDate(nowDate); |
|
|
|
activity.setActEndDate(nowDate); |
|
|
|
activity.setPreStartDate(nowDate); |
|
|
|
activity.setPreEndDate(nowDate); |
|
|
|
activity.setActStartDate(startDate); |
|
|
|
activity.setActEndDate(endDate); |
|
|
|
activity.setPreStartDate(startDate); |
|
|
|
activity.setPreEndDate(endDate); |
|
|
|
activity.setPreCheckDate(nowDate); |
|
|
|
activity.setTotalAmount(totalAmount); |
|
|
|
activity.setUsedAmount(totalAmount); |
|
|
@ -696,10 +698,10 @@ public class PortalOfCostApplication { |
|
|
|
centerGoods.setSubjectCode(subject.getSubjectCode()); |
|
|
|
centerGoods.setSubjectName(subject.getSubjectName()); |
|
|
|
//设置活动时间
|
|
|
|
centerGoods.setActEndDate(nowDate); |
|
|
|
centerGoods.setActStartDate(nowDate); |
|
|
|
centerGoods.setPreEndDate(nowDate); |
|
|
|
centerGoods.setPreStartDate(nowDate); |
|
|
|
centerGoods.setActEndDate(endDate); |
|
|
|
centerGoods.setActStartDate(startDate); |
|
|
|
centerGoods.setPreEndDate(endDate); |
|
|
|
centerGoods.setPreStartDate(startDate); |
|
|
|
centerGoods.setPreCheckDate(nowDate); |
|
|
|
//设置目标
|
|
|
|
centerGoods.setTargetId(activityGoods.getTargetId()); |
|
|
@ -784,7 +786,8 @@ public class PortalOfCostApplication { |
|
|
|
|
|
|
|
//保存核销申请
|
|
|
|
VtbVerification verification = new VtbVerification(); |
|
|
|
verification.setVerificationCode("MHX"+ CodeGenUtil.generate(CodeGenUtil.SourceKey.Verification)); |
|
|
|
// verification.setVerificationCode("MHX"+ CodeGenUtil.generate(CodeGenUtil.SourceKey.Verification));
|
|
|
|
verification.setVerificationCode(costCode); |
|
|
|
verification.setVerificationMainCode(verification.getVerificationCode()); |
|
|
|
verification.setCostApplyId(costApply.getId()); |
|
|
|
verification.setFinishedTime(nowTime); |
|
|
@ -821,64 +824,72 @@ public class PortalOfCostApplication { |
|
|
|
verificationSubjectService.save(verificationSubject); |
|
|
|
|
|
|
|
//保存支付信息
|
|
|
|
String json = ThirtyVerificationUtil.buildJson(supplier, subject, totalAmount, activityTitle, verification); |
|
|
|
String COST_TO_PAY_API = projectApisProperties.getCostToPay(); |
|
|
|
log.info("COST_TO_PAY_API 支付单信息:{} 数据:{}",verification.getVerificationCode(),json); |
|
|
|
String rs = HttpUtil.doPost(COST_TO_PAY_API,json,null); |
|
|
|
if(rs==null||!rs.contains("200")){ |
|
|
|
log.error("COST_TO_PAY_API \n 请求参数:{},\n 支付单信息:{},\n 结果:{}",json,verification.getVerificationCode(),rs); |
|
|
|
//核销调度接口事务补偿
|
|
|
|
costApplyService.removeById(costApply.getId()); |
|
|
|
activityService.removeById(activity.getId()); |
|
|
|
activitySubjectService.removeById(activitySubject.getId()); |
|
|
|
activityCenterService.removeById(activityCenter.getId()); |
|
|
|
List<Long> goodIds = activityGoodsList.stream().map(TbsActivityGoods::getId).collect(Collectors.toList()); |
|
|
|
if(goodIds.size()>0){ |
|
|
|
activityGoodsService.removeBatchByIds(goodIds); |
|
|
|
} |
|
|
|
List<Long> good2Ids = activityCenterGoodsList.stream().map(TbsActivityCenterGoods::getId).collect(Collectors.toList()); |
|
|
|
if(good2Ids.size()>0){ |
|
|
|
activityCenterGoodsService.removeBatchByIds(good2Ids); |
|
|
|
} |
|
|
|
List<Long> logIds = budgetLogList.stream().map(TbsBudgetLog::getId).collect(Collectors.toList()); |
|
|
|
if(logIds.size()>0){ |
|
|
|
budgetLogService.removeBatchByIds(logIds); |
|
|
|
if(costCode.indexOf("DHX")==0) { |
|
|
|
//发货单的
|
|
|
|
String json = ThirtyVerificationUtil.buildJson(supplier, subject, totalAmount, activityTitle, verification); |
|
|
|
String COST_TO_PAY_API = projectApisProperties.getCostToPay(); |
|
|
|
log.info("COST_TO_PAY_API 支付单信息:{} 数据:{}", verification.getVerificationCode(), json); |
|
|
|
String rs = HttpUtil.doPost(COST_TO_PAY_API, json, null); |
|
|
|
if (rs == null || !rs.contains("200")) { |
|
|
|
log.error("COST_TO_PAY_API \n 请求参数:{},\n 支付单信息:{},\n 结果:{}", json, verification.getVerificationCode(), rs); |
|
|
|
//核销调度接口事务补偿
|
|
|
|
costApplyService.removeById(costApply.getId()); |
|
|
|
activityService.removeById(activity.getId()); |
|
|
|
activitySubjectService.removeById(activitySubject.getId()); |
|
|
|
activityCenterService.removeById(activityCenter.getId()); |
|
|
|
List<Long> goodIds = activityGoodsList.stream().map(TbsActivityGoods::getId).collect(Collectors.toList()); |
|
|
|
if (goodIds.size() > 0) { |
|
|
|
activityGoodsService.removeBatchByIds(goodIds); |
|
|
|
} |
|
|
|
List<Long> good2Ids = activityCenterGoodsList.stream().map(TbsActivityCenterGoods::getId).collect(Collectors.toList()); |
|
|
|
if (good2Ids.size() > 0) { |
|
|
|
activityCenterGoodsService.removeBatchByIds(good2Ids); |
|
|
|
} |
|
|
|
List<Long> logIds = budgetLogList.stream().map(TbsBudgetLog::getId).collect(Collectors.toList()); |
|
|
|
if (logIds.size() > 0) { |
|
|
|
budgetLogService.removeBatchByIds(logIds); |
|
|
|
} |
|
|
|
verificationService.removeById(verification.getId()); |
|
|
|
verificationSubjectService.removeById(verificationSubject.getId()); |
|
|
|
Assert.throwEx("连接支付接口异常"); |
|
|
|
} |
|
|
|
verificationService.removeById(verification.getId()); |
|
|
|
verificationSubjectService.removeById(verificationSubject.getId()); |
|
|
|
Assert.throwEx("连接支付接口异常"); |
|
|
|
log.info("COST_TO_PAY_API 支付单信息:{},结果:{}", verification.getVerificationCode(), rs); |
|
|
|
} |
|
|
|
log.info("COST_TO_PAY_API 支付单信息:{},结果:{}",verification.getVerificationCode(),rs); |
|
|
|
//保存支付
|
|
|
|
// PayPayment payPayment = new PayPayment();
|
|
|
|
// payPayment.setPayType(PaymentType.PAYMENT);
|
|
|
|
// payPayment.setPayCode("PM"+ StringUtils.genShortId());
|
|
|
|
// payPayment.setSupplierId(supplierId);
|
|
|
|
// payPayment.setSupplierCode(supplier.getCode());
|
|
|
|
// payPayment.setSupplierName(supplier.getName());
|
|
|
|
// payPayment.setPayAmount(totalAmount);
|
|
|
|
// payPayment.setUserId(user.getId());
|
|
|
|
// payPayment.setUserCode(user.getCode());
|
|
|
|
// payPayment.setUserName(user.getName());
|
|
|
|
// payPayment.setPayTime(nowTime);
|
|
|
|
// payPayment.setErpCode(erpCode);
|
|
|
|
// payPayment.setBillNumber(billNumber);
|
|
|
|
// paymentService.save(payPayment);
|
|
|
|
//
|
|
|
|
// PayPaymentItem paymentItem = new PayPaymentItem();
|
|
|
|
// paymentItem.setPaymentId(payPayment.getId());
|
|
|
|
// paymentItem.setPayType(PaymentType.PAYMENT);
|
|
|
|
// paymentItem.setSupplierId(supplierId);
|
|
|
|
// paymentItem.setItemPayAmount(totalAmount);
|
|
|
|
// paymentItem.setVerificationId(verification.getId());
|
|
|
|
// 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());
|
|
|
|
// paymentItemService.save(paymentItem);
|
|
|
|
if(costCode.indexOf("SHX")==0) { |
|
|
|
//发票的要直接支付
|
|
|
|
PayPayment payPayment = new PayPayment(); |
|
|
|
payPayment.setPayType(PaymentType.PAYMENT); |
|
|
|
payPayment.setPayCode("PM" + StringUtils.genShortId()); |
|
|
|
payPayment.setSupplierId(supplierId); |
|
|
|
payPayment.setSupplierCode(supplier.getCode()); |
|
|
|
payPayment.setSupplierName(supplier.getName()); |
|
|
|
payPayment.setPayAmount(totalAmount); |
|
|
|
payPayment.setUserId(user.getId()); |
|
|
|
payPayment.setUserCode(user.getCode()); |
|
|
|
payPayment.setUserName(user.getName()); |
|
|
|
payPayment.setPayTime(nowTime); |
|
|
|
payPayment.setErpCode(erpCode); |
|
|
|
payPayment.setBillNumber(billNumber); |
|
|
|
paymentService.save(payPayment); |
|
|
|
|
|
|
|
PayPaymentItem paymentItem = new PayPaymentItem(); |
|
|
|
paymentItem.setPaymentId(payPayment.getId()); |
|
|
|
paymentItem.setPayType(PaymentType.PAYMENT); |
|
|
|
paymentItem.setSupplierId(supplierId); |
|
|
|
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()); |
|
|
|
paymentItemService.save(paymentItem); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|