diff --git a/_doc/Task.md b/_doc/Task.md index e1a80ae48..da457f719 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -2,8 +2,8 @@ - [ ] 资金流水优化 - [x] 支付通道配置是否支持分账 - [ ] 分账接收方管理 - - [ ] 管理 - - [ ] 同步 + - [x] 管理 + - [x] 同步 - [ ] 分账组管理 - [ ] 管理 - [ ] 绑定 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationGroup.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationGroup.java index 069a6eb91..3fa429621 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationGroup.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationGroup.java @@ -23,7 +23,7 @@ import lombok.experimental.Accessors; @Data @Accessors(chain = true) @DbTable(comment = "分账组") -@TableName("pay_allocation_receiver_group") +@TableName("pay_allocation_group") public class AllocationGroup extends MpBaseEntity implements EntityBaseFunction { @DbComment("名称") diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationReceiver.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationReceiver.java index 56929a92f..c556ee80d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationReceiver.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/entity/AllocationReceiver.java @@ -1,5 +1,6 @@ package cn.bootx.platform.daxpay.service.core.payment.allocation.entity; +import cn.bootx.platform.common.core.annotation.EncryptionField; import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; import cn.bootx.platform.daxpay.code.AllocationReceiverTypeEnum; @@ -47,6 +48,7 @@ public class AllocationReceiver extends MpBaseEntity implements EntityBaseFuncti @DbColumn(comment = "接收方账号") + @EncryptionField private String receiverAccount; /** 接收方姓名 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationGroupService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationGroupService.java index d690994b9..a453ed885 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationGroupService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationGroupService.java @@ -1,5 +1,6 @@ package cn.bootx.platform.daxpay.service.core.payment.allocation.service; +import cn.bootx.platform.common.core.exception.BizException; import cn.bootx.platform.common.core.exception.DataNotExistException; import cn.bootx.platform.common.core.function.CollectorsFunction; import cn.bootx.platform.common.core.rest.PageResult; @@ -77,6 +78,7 @@ public class AllocationGroupService { AllocationReceiver allocationReceiver = receiverMap.get(o.getReceiverId()); return new AllocationGroupReceiverResult() .setId(o.getId()) + .setName(allocationReceiver.getName()) .setReceiverId(allocationReceiver.getId()) .setReceiverAccount(allocationReceiver.getReceiverAccount()) .setReceiverName(allocationReceiver.getReceiverName()) @@ -135,13 +137,25 @@ public class AllocationGroupService { if (receivers.size() != receiverIds.size()){ throw new DataNotExistException("传入的分账接收房数量与查询到的不一致"); } - // 接收方需要已经同步到三方值系统中 + // 接收方需要已经同步到三方系统中 receivers.stream() .filter(receiver -> Objects.equals(receiver.getSync(), Boolean.FALSE)) .findAny() .ifPresent(receiver -> { - throw new DataNotExistException("接收方未同步到三方值系统中"); + throw new BizException("接收方未同步到三方值系统中"); }); + // 接收方只能为一个支付通道 + long count = receivers.stream() + .map(AllocationReceiver::getChannel) + .distinct() + .count(); + if (count > 1){ + throw new BizException("接收方只能为一个支付通道"); + } + // 检查接收方和传入的通道是否是不一致 + if (!Objects.equals(group.getChannel(), receivers.get(0).getChannel())){ + throw new BizException("接收方和传入的通道不一致"); + } // 保存分账接收者 List groupReceivers = receivers.stream() @@ -193,8 +207,8 @@ public class AllocationGroupService { // 更新分账比例 group.setTotalRate(group.getTotalRate() - groupReceiver.getRate()); // 更新接收比例 - groupReceiverManager.updateById(groupReceiver); - groupManager.deleteById(group); + groupReceiverManager.deleteById(receiverId); + groupManager.updateById(group); } /** diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationGroupReceiverResult.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationGroupReceiverResult.java index 2da533e80..6966f7e46 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationGroupReceiverResult.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationGroupReceiverResult.java @@ -19,9 +19,12 @@ public class AllocationGroupReceiverResult { @Schema(description = "主键") private Long id; - @Schema(description = "接收者ID") + @Schema(description = "接收方ID") private Long receiverId; + @Schema(description = "接收方账号别名") + private String name; + @Schema(description = "分账比例(万分之多少)") private Integer rate; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationReceiverDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationReceiverDto.java index 45b2c55bf..543e821f4 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationReceiverDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationReceiverDto.java @@ -4,6 +4,7 @@ import cn.bootx.platform.common.core.rest.dto.BaseDto; import cn.bootx.platform.daxpay.code.AllocationReceiverTypeEnum; import cn.bootx.platform.daxpay.code.AllocationRelationTypeEnum; import cn.bootx.platform.daxpay.code.PayChannelEnum; +import cn.bootx.platform.starter.data.perm.sensitive.SensitiveInfo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -41,6 +42,7 @@ public class AllocationReceiverDto extends BaseDto { @Schema(description = "接收方账号") + @SensitiveInfo private String receiverAccount; /** 接收方姓名 */ diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationGroupReceiverParam.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationGroupReceiverParam.java index 01e718dd6..da3feacfd 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationGroupReceiverParam.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationGroupReceiverParam.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.Max; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; @@ -23,6 +24,7 @@ public class AllocationGroupReceiverParam { @Schema(description = "分账比例(万分之多少)") @NotNull(message = "分账比例不可为空") - @Min(value = 1,message = "分账比例最低为1") + @Min(value = 0,message = "分账比例不可为负数") + @Max(value = 10000,message = "分账比例不可超过100%") private Integer rate; }