From f86cd4a9ee43eb126207cf9188792abf8a8128ff Mon Sep 17 00:00:00 2001 From: Yen Date: Fri, 16 Dec 2022 10:52:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serve/modules/pay/common/PaymentType.java | 12 ++ .../pay/controller/PayPaymentController.java | 22 ++++ .../serve/modules/pay/entity/PayPayment.java | 8 ++ .../modules/pay/entity/PayPaymentItem.java | 7 ++ .../modules/pay/entity/bo/PayPaymentBo.java | 9 ++ .../modules/pay/entity/so/PayPaymentSo.java | 51 +-------- .../service/impl/PayPaymentServiceImpl.java | 108 +++++++++++------- .../controller/TbsCostApplyController.java | 1 + .../service/impl/TbsActivityServiceImpl.java | 2 +- 9 files changed, 132 insertions(+), 88 deletions(-) create mode 100644 src/main/java/com/qs/serve/modules/pay/common/PaymentType.java diff --git a/src/main/java/com/qs/serve/modules/pay/common/PaymentType.java b/src/main/java/com/qs/serve/modules/pay/common/PaymentType.java new file mode 100644 index 00000000..b2b49278 --- /dev/null +++ b/src/main/java/com/qs/serve/modules/pay/common/PaymentType.java @@ -0,0 +1,12 @@ +package com.qs.serve.modules.pay.common; + +/** + * @author YenHex + * @since 2022/12/16 + */ +public interface PaymentType { + + String PAYMENT = "pay"; + String UN_PAYMENT = "unPay"; + +} diff --git a/src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java b/src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java index 48a980c2..175337e7 100644 --- a/src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java +++ b/src/main/java/com/qs/serve/modules/pay/controller/PayPaymentController.java @@ -9,7 +9,9 @@ import com.qs.serve.common.model.enums.SystemModule; import com.qs.serve.common.util.PageUtil; import com.qs.serve.common.util.CopierUtil; import com.qs.serve.common.util.StringUtils; +import com.qs.serve.modules.pay.entity.PayPaymentItem; import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; +import com.qs.serve.modules.pay.service.PayPaymentItemService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.security.access.prepost.PreAuthorize; @@ -35,6 +37,7 @@ import java.util.List; public class PayPaymentController { private PayPaymentService payPaymentService; + private PayPaymentItemService paymentItemService; /** @@ -47,11 +50,30 @@ public class PayPaymentController { public R> getPage(PayPaymentSo param){ PayPayment entity = CopierUtil.copy(param,new PayPayment()); LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(entity); + if(param.getQueryStartTime()!=null){ + lqw.ge(PayPayment::getPayTime,param.getQueryStartTime()); + } + if(param.getQueryEndTime()!=null){ + lqw.le(PayPayment::getPayTime,param.getQueryEndTime()); + } PageUtil.startPage(); List list = payPaymentService.list(lqw); return R.byPageHelperList(list); } + /** + * 详情列表 + * @param id + * @return + */ + @GetMapping("/listDetails/{id}") + @PreAuthorize("hasRole('pay:payment:query')") + public R> listDetails(@PathVariable("id") Long id){ + List list= paymentItemService.listByPaymentId(id); + return R.ok(list); + } + + /** * ID查询 * @param id diff --git a/src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java b/src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java index dd38135c..a1a5447f 100644 --- a/src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java +++ b/src/main/java/com/qs/serve/modules/pay/entity/PayPayment.java @@ -31,6 +31,13 @@ public class PayPayment implements Serializable { @TableId(type = IdType.AUTO) private Long id; + /** + * 支付类型 + * pay - 支付 + * unPay - 不再支付 + **/ + private String payType; + /** 供应商id */ @NotNull(message = "供应商id不能为空") private Long supplierId; @@ -43,6 +50,7 @@ public class PayPayment implements Serializable { /** 供应商 */ @NotBlank(message = "供应商不能为空") @Length(max = 30,message = "供应商长度不能超过30字") + @TableField(condition = SqlCondition.LIKE) private String supplierName; /** 支付金额 */ diff --git a/src/main/java/com/qs/serve/modules/pay/entity/PayPaymentItem.java b/src/main/java/com/qs/serve/modules/pay/entity/PayPaymentItem.java index 5ac1937f..ce40171c 100644 --- a/src/main/java/com/qs/serve/modules/pay/entity/PayPaymentItem.java +++ b/src/main/java/com/qs/serve/modules/pay/entity/PayPaymentItem.java @@ -31,6 +31,13 @@ public class PayPaymentItem implements Serializable { @TableId(type = IdType.AUTO) private Long id; + /** + * 支付类型 + * pay - 支付 + * unPay - 不再支付 + **/ + private String payType; + /** 支付id */ @NotNull(message = "支付id不能为空") private Long paymentId; diff --git a/src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java b/src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java index 04ff3237..eff35814 100644 --- a/src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java +++ b/src/main/java/com/qs/serve/modules/pay/entity/bo/PayPaymentBo.java @@ -40,5 +40,14 @@ public class PayPaymentBo implements Serializable { @Length(max = 255,message = "备注长度不能超过255字") private String remark; + + /** + * 支付类型 + * pay - 支付 + * unPay - 不再支付 + **/ + @NotNull(message = "支付类型不能为空") + private String payType; + } diff --git a/src/main/java/com/qs/serve/modules/pay/entity/so/PayPaymentSo.java b/src/main/java/com/qs/serve/modules/pay/entity/so/PayPaymentSo.java index 5c5a8371..89fcc72f 100644 --- a/src/main/java/com/qs/serve/modules/pay/entity/so/PayPaymentSo.java +++ b/src/main/java/com/qs/serve/modules/pay/entity/so/PayPaymentSo.java @@ -25,60 +25,17 @@ public class PayPaymentSo implements Serializable { private static final long serialVersionUID = 1L; - /** id */ - private Long id; - - /** 供应商id */ - private Long supplierId; - - /** 供应商编码 */ - private String supplierCode; - /** 供应商 */ private String supplierName; - /** 支付金额 */ - private BigDecimal payAmount; - - /** 支付人id */ - private String userId; - - /** 支付人编码 */ - private String userCode; - - /** 支付人 */ - private String userName; - - /** 支付时间 */ + /** 开始时间 */ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime payTime; + private LocalDateTime queryStartTime; - /** 备注 */ - private String remark; - - /** 创建时间 */ - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime createTime; - - /** 最后更新时间 */ + /** 结束时间 */ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private LocalDateTime updateTime; - - /** 所属租户 */ - @JsonIgnore - @JsonProperty - private String tenantId; - - /** 创建人 */ - private String createBy; - - /** 更新人 */ - private String updateBy; + private LocalDateTime queryEndTime; - /** 逻辑删除标记(0:显示;1:隐藏) */ - @JsonIgnore - @JsonProperty - private String delFlag; } diff --git a/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java b/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java index 2013c17f..20c96ed6 100644 --- a/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java @@ -6,6 +6,7 @@ import com.qs.serve.common.util.Assert; import com.qs.serve.common.util.AuthContextUtils; import com.qs.serve.modules.bms.entity.BmsSupplier; import com.qs.serve.modules.bms.service.BmsSupplierService; +import com.qs.serve.modules.pay.common.PaymentType; import com.qs.serve.modules.pay.entity.PayPaymentItem; import com.qs.serve.modules.pay.entity.bo.PayPaymentBo; import com.qs.serve.modules.pay.entity.dto.PayPaymentAmountDto; @@ -18,6 +19,7 @@ import com.qs.serve.modules.vtb.entity.VtbVerificationSubject; import com.qs.serve.modules.vtb.service.VtbVerificationSubjectService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import com.qs.serve.modules.pay.entity.PayPayment; import com.qs.serve.modules.pay.service.PayPaymentService; @@ -49,6 +51,10 @@ public class PayPaymentServiceImpl extends ServiceImpl paymentItemList = new ArrayList<>(); List verificationSubjectUpdateList = new ArrayList<>(); for (VtbVerificationSubject verificationSubject : verificationSubjectList) { - //统计历史支付金额 - BigDecimal hisPayAmount = BigDecimal.ZERO; - List payPaymentItems = paymentItemService.listByVerSubjectId(verificationSubject.getId()); - for (PayPaymentItem paymentItem : payPaymentItems) { - hisPayAmount = hisPayAmount.add(paymentItem.getItemPayAmount()); - } - //当前项未支付 - BigDecimal shouldPay = verificationSubject.getUsedAmount().subtract(hisPayAmount); - //当前项支付金额 - BigDecimal currentItemPay; - if(currentBalance.compareTo(shouldPay)>0){ - currentItemPay = shouldPay; - currentBalance = currentBalance.subtract(shouldPay); - }else { - currentItemPay = currentBalance; - currentBalance = BigDecimal.ZERO; - } - PayPaymentItem paymentItem = new PayPaymentItem(); - paymentItem.setSupplierId(paymentBo.getSupplierId()); - paymentItem.setItemPayAmount(currentItemPay); - paymentItem.setVerificationId(verificationSubject.getVerificationId()); - paymentItem.setVerificationSubjectId(verificationSubject.getId()); - paymentItem.setCostApplyId(verificationSubject.getCostApplyId()); - paymentItem.setActivityId(verificationSubject.getActivityId()); - paymentItem.setSubjectId(verificationSubject.getSubjectId()); - paymentItem.setSubjectCode(verificationSubject.getSubjectCode()); - paymentItem.setSubjectName(verificationSubject.getSubjectName()); - paymentItemList.add(paymentItem); - //更新核销科目余额 - BigDecimal payAmountOfVer = verificationSubject.getPayAmount().add(currentItemPay); - VtbVerificationSubject subjectParam = new VtbVerificationSubject(); - subjectParam.setId(verificationSubject.getId()); - subjectParam.setPayAmount(payAmountOfVer); - if(verificationSubject.getUsedAmount().compareTo(payAmountOfVer)==0){ - subjectParam.setPayFinishedFlag(1); - } - verificationSubjectUpdateList.add(subjectParam); + currentBalance = this.buildPaymentItems(paymentBo, currentBalance, paymentItemList, verificationSubjectUpdateList, verificationSubject); if(currentBalance.compareTo(BigDecimal.ZERO)==0){ break; } } PayPayment payPayment = new PayPayment(); + payPayment.setPayType(payType); payPayment.setSupplierId(paymentBo.getSupplierId()); payPayment.setSupplierCode(supplier.getCode()); payPayment.setSupplierName(supplier.getName()); @@ -115,6 +86,7 @@ public class PayPaymentServiceImpl extends ServiceImpl actIds = paymentItemList.stream().map(PayPaymentItem::getActivityId).distinct().collect(Collectors.toList()); //关联活动编码 @@ -133,9 +105,65 @@ public class PayPaymentServiceImpl extends ServiceImpl paymentItemList, List verificationSubjectUpdateList, VtbVerificationSubject verificationSubject) { + //统计历史支付金额 + BigDecimal hisPayAmount = BigDecimal.ZERO; + List payPaymentItems = paymentItemService.listByVerSubjectId(verificationSubject.getId()); + for (PayPaymentItem paymentItem : payPaymentItems) { + hisPayAmount = hisPayAmount.add(paymentItem.getItemPayAmount()); + } + //当前项未支付 + BigDecimal shouldPay = verificationSubject.getUsedAmount().subtract(hisPayAmount); + //当前项支付金额 + BigDecimal currentItemPay; + if(currentBalance.compareTo(shouldPay)>0){ + currentItemPay = shouldPay; + currentBalance = currentBalance.subtract(shouldPay); + }else { + currentItemPay = currentBalance; + currentBalance = BigDecimal.ZERO; + } + PayPaymentItem paymentItem = new PayPaymentItem(); + paymentItem.setPayType(paymentBo.getPayType()); + paymentItem.setSupplierId(paymentBo.getSupplierId()); + paymentItem.setItemPayAmount(currentItemPay); + paymentItem.setVerificationId(verificationSubject.getVerificationId()); + paymentItem.setVerificationSubjectId(verificationSubject.getId()); + paymentItem.setCostApplyId(verificationSubject.getCostApplyId()); + paymentItem.setActivityId(verificationSubject.getActivityId()); + paymentItem.setSubjectId(verificationSubject.getSubjectId()); + paymentItem.setSubjectCode(verificationSubject.getSubjectCode()); + paymentItem.setSubjectName(verificationSubject.getSubjectName()); + paymentItemList.add(paymentItem); + //更新核销科目余额 + BigDecimal payAmountOfVer = verificationSubject.getPayAmount().add(currentItemPay); + VtbVerificationSubject subjectParam = new VtbVerificationSubject(); + subjectParam.setId(verificationSubject.getId()); + subjectParam.setPayAmount(payAmountOfVer); + if(verificationSubject.getUsedAmount().compareTo(payAmountOfVer)==0){ + subjectParam.setPayFinishedFlag(1); + } + verificationSubjectUpdateList.add(subjectParam); + return currentBalance; + } + @Override @Transactional(rollbackFor = Exception.class) public void cancel(Long id) { + PayPayment dbPay = this.getById(id); + if(dbPay.getCancelFlag().equals(1)){ + Assert.throwEx("已取消,请勿重复提交"); + } List paymentItemList = paymentItemService.listByPaymentId(id); List paymentItemIds = paymentItemList.stream().map(PayPaymentItem::getId) .distinct().collect(Collectors.toList()); @@ -174,12 +202,12 @@ public class PayPaymentServiceImpl extends ServiceImpl vtbVerificationSubjectList = verificationSubjectService.list(lqw); BigDecimal totalAmount = BigDecimal.ZERO; - BigDecimal payAmount = BigDecimal.ZERO; + BigDecimal hasAmount = BigDecimal.ZERO; for (VtbVerificationSubject verificationSubject : vtbVerificationSubjectList) { totalAmount = totalAmount.add(verificationSubject.getUsedAmount()); - payAmount = payAmount.add(verificationSubject.getPayAmount()); + hasAmount = hasAmount.add(verificationSubject.getPayAmount()); } - PayPaymentAmountDto amountDto = new PayPaymentAmountDto(totalAmount,payAmount,vtbVerificationSubjectList); + PayPaymentAmountDto amountDto = new PayPaymentAmountDto(totalAmount,hasAmount,vtbVerificationSubjectList); return amountDto; } diff --git a/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java b/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java index accef289..2c517cf2 100644 --- a/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java +++ b/src/main/java/com/qs/serve/modules/tbs/controller/TbsCostApplyController.java @@ -349,6 +349,7 @@ public class TbsCostApplyController { apply.setId(costApply.getId()); apply.setChargeState(TbsCostApplyState.State_2_actioning.getCode()); tbsCostApplyService.updateById(apply); + return R.ok(); }else if ("stop".equals(flag)){ TbsCostApply apply = new TbsCostApply(); apply.setId(costApply.getId()); diff --git a/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java b/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java index e275626e..ea4f1196 100644 --- a/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsActivityServiceImpl.java @@ -252,7 +252,7 @@ public class TbsActivityServiceImpl extends ServiceImpl