diff --git a/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java b/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java index bd7eda04..13d784b3 100644 --- a/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierServiceImpl.java @@ -121,7 +121,7 @@ public class BmsSupplierServiceImpl extends ServiceImpl lqw = new LambdaQueryWrapper<>(); lqw.eq(BmsSupplier::getCode,code); 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); } diff --git a/src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetCostItem.java b/src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetCostItem.java index e8f5a85c..2d83bef0 100644 --- a/src/main/java/com/qs/serve/modules/tbs/entity/TbsBudgetCostItem.java +++ b/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.setAmount(this.centerGoodsAmount); item.setTargetType(this.targetType); + item.setTargetId(this.targetId); item.setTargetCode(this.targetCode); item.setTargetName(this.targetName); item.setTargetLevelPathIds(this.targetLevelPathIds); diff --git a/src/main/java/com/qs/serve/modules/third/PortalOfCostController.java b/src/main/java/com/qs/serve/modules/third/PortalOfCostController.java index d4532ec2..fce7d199 100644 --- a/src/main/java/com/qs/serve/modules/third/PortalOfCostController.java +++ b/src/main/java/com/qs/serve/modules/third/PortalOfCostController.java @@ -33,7 +33,7 @@ public class PortalOfCostController { @PostMapping("create") public R createCostProcess(@Valid @RequestBody ProcessCreateBo createBo){ portalOfCostApplication.createCostProcess(createBo); - return R.error(); + return R.ok(); } } diff --git a/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java b/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java index 673d21f4..089741e1 100644 --- a/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java +++ b/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java @@ -18,9 +18,11 @@ public class ProcessCreateBo { private String userCode; /** 费用编码 */ + @NotNull(message = "费用编码 不能为空") private String costCode; /** 费用主题 */ + @NotNull(message = "费用主题 不能为空") private String costTheme; /** 活动编码(可为空) */ @@ -29,21 +31,25 @@ public class ProcessCreateBo { /** 活动标题(可为空) */ private String activityTitle; + /** 客户编号 */ @NotNull(message = "客户编码 不能为空") private String customerCode; - /** 暂无异于,记录在支付表(可为空) */ + /** 暂无应用场景,记录在支付表(可为空) */ private String erpCode; + /** 发票号 */ @NotNull(message = "发票号 不能为空") private String billNumber; /** 客户所属 */ private String customerBelong; + /** 统计金额 */ @NotNull(message = "合计金额 不能为空") private BigDecimal totalAmount; + /** 科目编码 */ @NotNull(message = "科目编码 不能为空") private String subjectCode; diff --git a/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java b/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java index 0044555b..757fe86a 100644 --- a/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java +++ b/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.entity.VtbVerification; 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.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -82,6 +84,8 @@ public class PortalOfCostApplication { private PayPaymentService paymentService; private PayPaymentItemService paymentItemService; + private VtbVerificationService verificationService; + private VtbVerificationSubjectService verificationSubjectService; @Transactional(rollbackFor = Exception.class) @@ -92,6 +96,13 @@ public class PortalOfCostApplication { if(supplier==null){Assert.throwEx("客户不存在,请重新编辑");} BmsSubject subject = subjectService.getByCode(createBo.getSubjectCode()); if(subject==null){Assert.throwEx("科目不存在,请重新编辑");} + //发票号 + String billNumber = createBo.getBillNumber(); + //拦截是否已保存 + LambdaQueryWrapper payLqw = new LambdaQueryWrapper<>(); + payLqw.eq(PayPayment::getBillNumber,billNumber); + long countPay = paymentService.count(payLqw); + if(countPay>0){Assert.throwEx("发票号已存在,请勿重复提交");} //初始化sku列表 List processGoodsItems = createBo.getGoodsList(); List skuList = this.initSkuListOfProcess(createBo); @@ -101,17 +112,21 @@ public class PortalOfCostApplication { final BigDecimal OneHundred = new BigDecimal("100"); LocalDateTime nowTime = LocalDateTime.now(); LocalDate nowDate = LocalDate.now(); - String billNumber = createBo.getBillNumber(); String erpCode = createBo.getErpCode(); Long supplierId = Long.parseLong(supplier.getId()); BigDecimal totalAmount = createBo.getTotalAmount(); String costCode = createBo.getCostCode(); String costTheme = createBo.getCostTheme(); -// String random = String.format("%03d",new Random().nextInt(999)); -// activity.setActivityCode("G"+ StringUtils.genShortId() + random); 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(); + if(!StringUtils.hasText(activityTitle)){ + activityTitle = "由核销API生成的活动"; + } //构建费用申请 TbsCostApply costApply = new TbsCostApply(); costApply.setCode(costCode); @@ -211,6 +226,7 @@ public class PortalOfCostApplication { centerGoods.setPreCheckDate(nowDate); //设置目标 centerGoods.setTargetId(activityGoods.getTargetId()); + centerGoods.setTargetType(activityGoods.getTargetType()); centerGoods.setTargetCode(activityGoods.getTargetCode()); centerGoods.setTargetName(activityGoods.getTargetName()); centerGoods.setTargetLevelPathIds(activityGoods.getTargetLevelPathIds()); @@ -301,9 +317,11 @@ public class PortalOfCostApplication { verification.setAmount(totalAmount); verification.setAmountRecord(totalAmount); verification.setPaymentState(ResultFlag.OK); + verificationService.save(verification); //保存核销费用结果 VtbVerificationSubject verificationSubject = new VtbVerificationSubject(); + verificationSubject.setVerificationId(verification.getId()); verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1"); verificationSubject.setCostApplyId(costApply.getId()); verificationSubject.setActivityId(activity.getId()); @@ -318,6 +336,7 @@ public class PortalOfCostApplication { verificationSubject.setUsedAmountRecord(totalAmount); verificationSubject.setCountPerson(0); verificationSubject.setCountSession(0); + verificationSubjectService.save(verificationSubject); //保存支付 PayPayment payPayment = new PayPayment();