diff --git a/_doc/Task.md b/_doc/Task.md index 819d98a8d..709862f13 100644 --- a/_doc/Task.md +++ b/_doc/Task.md @@ -1,6 +1,9 @@ 2.0.5: - [ ] 资金流水优化 -- [ ] 支持分账 +- [ ] 分账功能开发 + - [ ] 支付通道配置是否支持分账 + - [ ] 分账接收方管理 + - [ ] 分账订单管理 - [ ] 增加撤销功能,用于处理线下支付订单的情况 - [ ] 统计报表功能 - [x] 修复创建支付订单报错时, 订单保存数据不完整 diff --git a/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationReceiverController.java b/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationReceiverController.java new file mode 100644 index 000000000..9d8fce1e9 --- /dev/null +++ b/daxpay-single/daxpay-single-admin/src/main/java/cn/bootx/platform/daxpay/admin/controller/allocation/AllocationReceiverController.java @@ -0,0 +1,21 @@ +package cn.bootx.platform.daxpay.admin.controller.allocation; + +import cn.bootx.platform.daxpay.service.core.payment.allocation.service.AllocationReceiverService; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 对账接收方控制器 + * @author xxm + * @since 2024/3/28 + */ +@Tag(name = "对账接收方控制器") +@RestController +@RequestMapping("/allocation/receiver") +@RequiredArgsConstructor +public class AllocationReceiverController { + + private final AllocationReceiverService allocationReceiverService; +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/entity/AliPayConfig.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/entity/AliPayConfig.java index 6f5b13ddb..f1e3eb44f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/entity/AliPayConfig.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/entity/AliPayConfig.java @@ -41,6 +41,10 @@ public class AliPayConfig extends MpBaseEntity implements EntityBaseFunction { diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverManager.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverManager.java index 4b2457f36..7994062f2 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverManager.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverManager.java @@ -6,10 +6,10 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Repository; -/** - * - * @author xxm - * @since 2024/3/27 +/** + * + * @author xxm + * @since 2024/3/27 */ @Slf4j @Repository diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverMapper.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverMapper.java index e3bd557ac..1bf29e638 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverMapper.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/dao/AllocationReceiverMapper.java @@ -4,10 +4,10 @@ import cn.bootx.platform.daxpay.service.core.payment.allocation.entity.Allocatio import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -/** - * - * @author xxm - * @since 2024/3/27 +/** + * + * @author xxm + * @since 2024/3/27 */ @Mapper public interface AllocationReceiverMapper extends BaseMapper { 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 09bb90def..e76a09c9e 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,8 +1,14 @@ package cn.bootx.platform.daxpay.service.core.payment.allocation.entity; +import cn.bootx.platform.common.core.function.EntityBaseFunction; import cn.bootx.platform.common.mybatisplus.base.MpBaseEntity; import cn.bootx.platform.daxpay.code.AllocationRelationTypeEnum; +import cn.bootx.platform.daxpay.code.PayChannelEnum; +import cn.bootx.platform.daxpay.service.core.payment.allocation.convert.AllocationReceiverConvert; +import cn.bootx.platform.daxpay.service.dto.allocation.AllocationReceiverDto; import cn.bootx.table.modify.annotation.DbColumn; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.TableField; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; @@ -15,36 +21,58 @@ import lombok.experimental.Accessors; @EqualsAndHashCode(callSuper = true) @Data @Accessors(chain = true) -public class AllocationReceiver extends MpBaseEntity { +public class AllocationReceiver extends MpBaseEntity implements EntityBaseFunction { - @DbColumn(name = "账号别名") + @DbColumn(comment = "账号别名") private String name; - @DbColumn(name = "所属通道") + /** + * @see PayChannelEnum + */ + @DbColumn(comment = "所属通道") + @TableField(updateStrategy = FieldStrategy.NEVER) private String channel; /** * 分账接收方类型 个人/商户 */ - @DbColumn(name = "分账接收方类型") + @DbColumn(comment = "分账接收方类型") + @TableField(updateStrategy = FieldStrategy.NEVER) private String receiverType; - @DbColumn(name = "接收方账号") + @DbColumn(comment = "接收方账号") + @TableField(updateStrategy = FieldStrategy.NEVER) private String receiverAccount; + @DbColumn(comment = "账号类型") + private String accountType; + /** 接收方姓名 */ - @DbColumn(name = "接收方姓名") + @DbColumn(comment = "接收方姓名") + @TableField(updateStrategy = FieldStrategy.NEVER) private String receiverName; /** * 分账关系类型 * @see AllocationRelationTypeEnum */ - @DbColumn(name = "分账关系类型") + @DbColumn(comment = "分账关系类型") + @TableField(updateStrategy = FieldStrategy.NEVER) private String relationType; - @DbColumn(name = "关系名称") + @DbColumn(comment = "关系名称") + @TableField(updateStrategy = FieldStrategy.NEVER) private String relationName; + @DbColumn(comment = "是否已经同步到网关") + private boolean sync; + + /** + * 转换 + */ + @Override + public AllocationReceiverDto toDto() { + return AllocationReceiverConvert.CONVERT.convert(this); + } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationReceiverService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationReceiverService.java index 28cd08b76..398af2c1f 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationReceiverService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/allocation/service/AllocationReceiverService.java @@ -1,5 +1,9 @@ package cn.bootx.platform.daxpay.service.core.payment.allocation.service; +import cn.bootx.platform.daxpay.service.core.payment.allocation.convert.AllocationReceiverConvert; +import cn.bootx.platform.daxpay.service.core.payment.allocation.dao.AllocationReceiverManager; +import cn.bootx.platform.daxpay.service.core.payment.allocation.entity.AllocationReceiver; +import cn.bootx.platform.daxpay.service.param.allocation.AllocationReceiverParam; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -13,4 +17,47 @@ import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor public class AllocationReceiverService { + + private final AllocationReceiverManager manager; + + /** + * 添加分账接收方 + */ + public void add(AllocationReceiverParam param){ + // 首先添加网关的分账接收方 + AllocationReceiver receiver = AllocationReceiverConvert.CONVERT.convert(param); + receiver.setSync(false); + manager.save(receiver); + } + + /** + * 修改 + */ + public void update(AllocationReceiverParam param){ + + } + + /** + * 删除分账接收方 + */ + public void remove(Long id){ + // 首先删除网关的分账接收方 + + // 然后删除本地数据 + } + + /** + * 同步到三方支付系统中 + */ + public void registerByGateway(Long id){ + + } + + /** + * 从三方支付系统中删除 + */ + public void removeByGateway(Long id){ + + } + } 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 new file mode 100644 index 000000000..7828fc1e7 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/allocation/AllocationReceiverDto.java @@ -0,0 +1,60 @@ +package cn.bootx.platform.daxpay.service.dto.allocation; + +import cn.bootx.platform.common.core.rest.dto.BaseDto; +import cn.bootx.platform.daxpay.code.AllocationRelationTypeEnum; +import cn.bootx.platform.daxpay.code.PayChannelEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * 分账接收方参数 + * @author xxm + * @since 2024/3/28 + */ +@EqualsAndHashCode(callSuper = true) +@Data +@Accessors(chain = true) +@Schema(title = "分账接收方参数") +public class AllocationReceiverDto extends BaseDto { + + @Schema(description = "主键") + private Long id; + + @Schema(description = "账号别名") + private String name; + + /** + * @see PayChannelEnum + */ + @Schema(description = "所属通道") + private String channel; + + /** + * 分账接收方类型 个人/商户 + */ + @Schema(description = "分账接收方类型") + private String receiverType; + + + @Schema(description = "接收方账号") + private String receiverAccount; + + /** 接收方姓名 */ + @Schema(description = "接收方姓名") + private String receiverName; + + /** + * 分账关系类型 + * @see AllocationRelationTypeEnum + */ + @Schema(description = "分账关系类型") + private String relationType; + + @Schema(description = "关系名称") + private String relationName; + + @Schema(description = "是否已经同步到网关") + private boolean sync; +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/alipay/AliPayConfigDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/alipay/AliPayConfigDto.java index 4909a5f93..df1a38d0d 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/alipay/AliPayConfigDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/alipay/AliPayConfigDto.java @@ -29,6 +29,9 @@ public class AliPayConfigDto extends BaseDto implements Serializable { @Schema(description = "是否启用") private Boolean enable; + @Schema(description = "是否支付分账") + private Boolean allocation; + @Schema(description = "支付限额") private Integer singleLimit; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/wechat/WeChatPayConfigDto.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/wechat/WeChatPayConfigDto.java index 7d5f148a5..35501b486 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/wechat/WeChatPayConfigDto.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/dto/channel/wechat/WeChatPayConfigDto.java @@ -31,6 +31,9 @@ public class WeChatPayConfigDto extends BaseDto implements Serializable { @Schema(description = "是否启用") private Boolean enable; + @Schema(description = "是否支付分账") + private Boolean allocation; + @Schema(description = "支付限额") private Integer singleLimit; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationReceiverParam.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationReceiverParam.java new file mode 100644 index 000000000..d0c013517 --- /dev/null +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/allocation/AllocationReceiverParam.java @@ -0,0 +1,58 @@ +package cn.bootx.platform.daxpay.service.param.allocation; + +import cn.bootx.platform.daxpay.code.AllocationRelationTypeEnum; +import cn.bootx.platform.daxpay.code.PayChannelEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 分账接收方参数 + * @author xxm + * @since 2024/3/28 + */ +@Data +@Accessors(chain = true) +@Schema(title = "分账接收方参数") +public class AllocationReceiverParam { + + @Schema(description = "主键") + private Long id; + + @Schema(description = "账号别名") + private String name; + + /** + * @see PayChannelEnum + */ + @Schema(description = "所属通道") + private String channel; + + /** + * 分账接收方类型 个人/商户 + */ + @Schema(description = "分账接收方类型") + private String receiverType; + + + @Schema(description = "接收方账号") + private String receiverAccount; + + /** 接收方姓名 */ + @Schema(description = "接收方姓名") + private String receiverName; + + /** + * 分账关系类型 + * @see AllocationRelationTypeEnum + */ + @Schema(description = "分账关系类型") + private String relationType; + + @Schema(description = "关系名称") + private String relationName; + + @Schema(description = "是否已经同步到网关") + private boolean sync; + +} diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/alipay/AliPayConfigParam.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/alipay/AliPayConfigParam.java index 210a6eff6..c24fd0855 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/alipay/AliPayConfigParam.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/alipay/AliPayConfigParam.java @@ -21,6 +21,9 @@ public class AliPayConfigParam { @Schema(description = "是否启用") private Boolean enable; + @Schema(description = "是否支付分账") + private Boolean allocation; + @Schema(description = "支付限额") private Integer singleLimit; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/wechat/WeChatPayConfigParam.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/wechat/WeChatPayConfigParam.java index 714d282c9..106226e68 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/wechat/WeChatPayConfigParam.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/channel/wechat/WeChatPayConfigParam.java @@ -29,6 +29,9 @@ public class WeChatPayConfigParam { @DbColumn(comment = "是否启用") private Boolean enable; + @Schema(description = "是否支付分账") + private Boolean allocation; + @Schema(description = "支付限额") private Integer singleLimit;