mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-07 13:10:44 +00:00
feat 分账组管理
This commit is contained in:
@@ -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<AllocationGroupDto> {
|
||||
|
||||
@DbComment("名称")
|
||||
|
@@ -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;
|
||||
|
||||
/** 接收方姓名 */
|
||||
|
@@ -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<AllocationGroupReceiver> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
/** 接收方姓名 */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user