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. 103
      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; package com.qs.serve.modules.third.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List; import java.util.List;
/** /**
@ -54,4 +57,13 @@ public class ProcessCreateCostApplyBo {
@NotNull(message = "存货编码 不能为空") @NotNull(message = "存货编码 不能为空")
private List<ProcessGoodsItem> goodsList; 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;
} }

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

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

Loading…
Cancel
Save