Browse Source

添加核销系统生成费用接口

contract
Yen 2 years ago
parent
commit
d970f2c736
  1. 2
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java
  2. 1
      src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetCostItem.java
  3. 2
      src/main/java/com/qs/serve/modules/third/PortalOfCostController.java
  4. 8
      src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java
  5. 25
      src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java

2
src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java

@ -121,7 +121,7 @@ public class BmsSupplierServiceImpl extends ServiceImpl<BmsSupplierMapper,BmsSup
LambdaQueryWrapper<BmsSupplier> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<BmsSupplier> lqw = new LambdaQueryWrapper<>();
lqw.eq(BmsSupplier::getCode,code); lqw.eq(BmsSupplier::getCode,code);
if(belong!=null){ if(belong!=null){
lqw.eq(BmsSupplier::getBelong,belong); lqw.and(a->a.eq(BmsSupplier::getBelong,belong).or().isNull(BmsSupplier::getBelong));
} }
return this.getOne(lqw,false); return this.getOne(lqw,false);
} }

1
src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetCostItem.java

@ -269,6 +269,7 @@ public class TbsBudgetCostItem implements Serializable {
item.setCenterName(this.centerName); item.setCenterName(this.centerName);
item.setAmount(this.centerGoodsAmount); item.setAmount(this.centerGoodsAmount);
item.setTargetType(this.targetType); item.setTargetType(this.targetType);
item.setTargetId(this.targetId);
item.setTargetCode(this.targetCode); item.setTargetCode(this.targetCode);
item.setTargetName(this.targetName); item.setTargetName(this.targetName);
item.setTargetLevelPathIds(this.targetLevelPathIds); item.setTargetLevelPathIds(this.targetLevelPathIds);

2
src/main/java/com/qs/serve/modules/third/PortalOfCostController.java

@ -33,7 +33,7 @@ public class PortalOfCostController {
@PostMapping("create") @PostMapping("create")
public R<?> createCostProcess(@Valid @RequestBody ProcessCreateBo createBo){ public R<?> createCostProcess(@Valid @RequestBody ProcessCreateBo createBo){
portalOfCostApplication.createCostProcess(createBo); portalOfCostApplication.createCostProcess(createBo);
return R.error(); return R.ok();
} }
} }

8
src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java

@ -18,9 +18,11 @@ public class ProcessCreateBo {
private String userCode; private String userCode;
/** 费用编码 */ /** 费用编码 */
@NotNull(message = "费用编码 不能为空")
private String costCode; private String costCode;
/** 费用主题 */ /** 费用主题 */
@NotNull(message = "费用主题 不能为空")
private String costTheme; private String costTheme;
/** 活动编码(可为空) */ /** 活动编码(可为空) */
@ -29,21 +31,25 @@ public class ProcessCreateBo {
/** 活动标题(可为空) */ /** 活动标题(可为空) */
private String activityTitle; private String activityTitle;
/** 客户编号 */
@NotNull(message = "客户编码 不能为空") @NotNull(message = "客户编码 不能为空")
private String customerCode; private String customerCode;
/** 暂无异于,记录在支付表(可为空) */ /** 暂无应用场景,记录在支付表(可为空) */
private String erpCode; private String erpCode;
/** 发票号 */
@NotNull(message = "发票号 不能为空") @NotNull(message = "发票号 不能为空")
private String billNumber; private String billNumber;
/** 客户所属 */ /** 客户所属 */
private String customerBelong; private String customerBelong;
/** 统计金额 */
@NotNull(message = "合计金额 不能为空") @NotNull(message = "合计金额 不能为空")
private BigDecimal totalAmount; private BigDecimal totalAmount;
/** 科目编码 */
@NotNull(message = "科目编码 不能为空") @NotNull(message = "科目编码 不能为空")
private String subjectCode; private String subjectCode;

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

@ -35,6 +35,8 @@ import com.qs.serve.modules.third.entity.ProcessGoodsItem;
import com.qs.serve.modules.vtb.common.VtbVerificationState; import com.qs.serve.modules.vtb.common.VtbVerificationState;
import com.qs.serve.modules.vtb.entity.VtbVerification; import com.qs.serve.modules.vtb.entity.VtbVerification;
import com.qs.serve.modules.vtb.entity.VtbVerificationSubject; import com.qs.serve.modules.vtb.entity.VtbVerificationSubject;
import com.qs.serve.modules.vtb.service.VtbVerificationService;
import com.qs.serve.modules.vtb.service.VtbVerificationSubjectService;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -82,6 +84,8 @@ public class PortalOfCostApplication {
private PayPaymentService paymentService; private PayPaymentService paymentService;
private PayPaymentItemService paymentItemService; private PayPaymentItemService paymentItemService;
private VtbVerificationService verificationService;
private VtbVerificationSubjectService verificationSubjectService;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -92,6 +96,13 @@ public class PortalOfCostApplication {
if(supplier==null){Assert.throwEx("客户不存在,请重新编辑");} if(supplier==null){Assert.throwEx("客户不存在,请重新编辑");}
BmsSubject subject = subjectService.getByCode(createBo.getSubjectCode()); BmsSubject subject = subjectService.getByCode(createBo.getSubjectCode());
if(subject==null){Assert.throwEx("科目不存在,请重新编辑");} if(subject==null){Assert.throwEx("科目不存在,请重新编辑");}
//发票号
String billNumber = createBo.getBillNumber();
//拦截是否已保存
LambdaQueryWrapper<PayPayment> payLqw = new LambdaQueryWrapper<>();
payLqw.eq(PayPayment::getBillNumber,billNumber);
long countPay = paymentService.count(payLqw);
if(countPay>0){Assert.throwEx("发票号已存在,请勿重复提交");}
//初始化sku列表 //初始化sku列表
List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList(); List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList();
List<GoodsSku> skuList = this.initSkuListOfProcess(createBo); List<GoodsSku> skuList = this.initSkuListOfProcess(createBo);
@ -101,17 +112,21 @@ 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();
String billNumber = createBo.getBillNumber();
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();
String costCode = createBo.getCostCode(); String costCode = createBo.getCostCode();
String costTheme = createBo.getCostTheme(); String costTheme = createBo.getCostTheme();
// String random = String.format("%03d",new Random().nextInt(999));
// activity.setActivityCode("G"+ StringUtils.genShortId() + random);
String activityCode = createBo.getActivityCode(); String activityCode = createBo.getActivityCode();
if(!StringUtils.hasText(activityCode)){
String random = String.format("%03d",new Random().nextInt(999));
activityCode = "G"+ StringUtils.genShortId() + random;
}
String activityTitle = createBo.getActivityTitle(); String activityTitle = createBo.getActivityTitle();
if(!StringUtils.hasText(activityTitle)){
activityTitle = "由核销API生成的活动";
}
//构建费用申请 //构建费用申请
TbsCostApply costApply = new TbsCostApply(); TbsCostApply costApply = new TbsCostApply();
costApply.setCode(costCode); costApply.setCode(costCode);
@ -211,6 +226,7 @@ public class PortalOfCostApplication {
centerGoods.setPreCheckDate(nowDate); centerGoods.setPreCheckDate(nowDate);
//设置目标 //设置目标
centerGoods.setTargetId(activityGoods.getTargetId()); centerGoods.setTargetId(activityGoods.getTargetId());
centerGoods.setTargetType(activityGoods.getTargetType());
centerGoods.setTargetCode(activityGoods.getTargetCode()); centerGoods.setTargetCode(activityGoods.getTargetCode());
centerGoods.setTargetName(activityGoods.getTargetName()); centerGoods.setTargetName(activityGoods.getTargetName());
centerGoods.setTargetLevelPathIds(activityGoods.getTargetLevelPathIds()); centerGoods.setTargetLevelPathIds(activityGoods.getTargetLevelPathIds());
@ -301,9 +317,11 @@ public class PortalOfCostApplication {
verification.setAmount(totalAmount); verification.setAmount(totalAmount);
verification.setAmountRecord(totalAmount); verification.setAmountRecord(totalAmount);
verification.setPaymentState(ResultFlag.OK); verification.setPaymentState(ResultFlag.OK);
verificationService.save(verification);
//保存核销费用结果 //保存核销费用结果
VtbVerificationSubject verificationSubject = new VtbVerificationSubject(); VtbVerificationSubject verificationSubject = new VtbVerificationSubject();
verificationSubject.setVerificationId(verification.getId());
verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1"); verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1");
verificationSubject.setCostApplyId(costApply.getId()); verificationSubject.setCostApplyId(costApply.getId());
verificationSubject.setActivityId(activity.getId()); verificationSubject.setActivityId(activity.getId());
@ -318,6 +336,7 @@ public class PortalOfCostApplication {
verificationSubject.setUsedAmountRecord(totalAmount); verificationSubject.setUsedAmountRecord(totalAmount);
verificationSubject.setCountPerson(0); verificationSubject.setCountPerson(0);
verificationSubject.setCountSession(0); verificationSubject.setCountSession(0);
verificationSubjectService.save(verificationSubject);
//保存支付 //保存支付
PayPayment payPayment = new PayPayment(); PayPayment payPayment = new PayPayment();

Loading…
Cancel
Save