Browse Source

调度系统生成费用的接口

v1.0
15989082884@163.com 2 years ago
parent
commit
d92fb9370e
  1. 12
      src/main/java/com/qs/serve/modules/third/entity/ProcessCreateCostApplyBo.java
  2. 139
      src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java

12
src/main/java/com/qs/serve/modules/third/entity/ProcessCreateCostApplyBo.java

@ -1,9 +1,12 @@
package com.qs.serve.modules.third.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
/**
@ -54,4 +57,13 @@ public class ProcessCreateCostApplyBo {
@NotNull(message = "存货编码 不能为空")
private List<ProcessGoodsItem> goodsList;
@NotNull(message = "开始时间 不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private LocalDate startDate;
@NotNull(message = "结束时间 不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private LocalDate endDate;
}

139
src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java

@ -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);
}
}

Loading…
Cancel
Save