feat 转账SDK接口

This commit is contained in:
DaxPay
2024-06-20 11:28:38 +08:00
parent 777d691d71
commit f56e088bfe
13 changed files with 360 additions and 3 deletions

View File

@@ -89,6 +89,7 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>

View File

@@ -63,6 +63,7 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<plugin>

View File

@@ -231,6 +231,7 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
</plugins>

View File

@@ -360,6 +360,7 @@
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
</plugins>

View File

@@ -93,10 +93,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-parameters</compilerArgument>
</configuration>
</plugin>
<!--打包源码的插件-->

View File

@@ -0,0 +1,49 @@
package cn.daxpay.single.sdk.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 转账接收方类型
* @author xxm
* @since 2024/4/1
*/
@Getter
@AllArgsConstructor
public enum TransferPayeeTypeEnum {
/** 微信 个人 */
WX_PERSONAL("wx_personal","openid", "个人"),
/** 支付宝 userId 以2088开头的纯16位数字 */
ALI_USER_ID("ali_user_id","ALIPAY_USERID", "用户ID"),
/** 支付宝 openId */
ALI_OPEN_ID("ali_open_id","ALIPAY_OPENID", "openId"),
/** 支付宝 账号 支持邮箱和手机号格式 */
ALI_LOGIN_NAME("ali_login_name","ALIPAY_LOGONID", "账号");
/** 编码 */
private final String code;
/** 外部编码, 三方支付系统使用的编码 */
private final String outCode;
/** 名称 */
private final String name;
/**
* 根据编码查找
*/
public static TransferPayeeTypeEnum findByCode(String code) {
return Arrays.stream(TransferPayeeTypeEnum.values())
.filter(e -> e.getCode().equals(code))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("未找到对应的分账接收方类型"));
}
/** 微信支持类型 */
public static final List<TransferPayeeTypeEnum> WECHAT_LIST = Collections.singletonList(WX_PERSONAL);
/** 支付宝支持类型 */
public static final List<TransferPayeeTypeEnum> ALI_LIST = Collections.unmodifiableList(Arrays.asList(ALI_OPEN_ID, ALI_USER_ID, ALI_LOGIN_NAME));
}

View File

@@ -0,0 +1,23 @@
package cn.daxpay.single.sdk.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 转账状态
* @author xxm
* @since 2024/6/11
*/
@Getter
@AllArgsConstructor
public enum TransferStatusEnum {
TRANSFERRING("transferring", "转账中"),
SUCCESS("success", "转账成功"),
FAIL("fail", "转账失败"),
;
private final String code;
private final String name;
}

View File

@@ -0,0 +1,26 @@
package cn.daxpay.single.sdk.code;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 转账类型注解
* @author xxm
* @since 2024/6/6
*/
@Getter
@AllArgsConstructor
public enum TransferTypeEnum {
/** 转账给用户 */
USER("user", "转账给用户"),
/** 转账给员工 */
EMPLOYEE("employee", "转账给员工"),
/** 转账给合作伙 */
PARTNER("partner", "转账给合作伙"),
/** 转账给其他对象 */
OTHER("other", "转账给其他对象"),;
private final String code;
private final String name;
}

View File

@@ -0,0 +1,30 @@
package cn.daxpay.single.sdk.model.transfer;
import cn.daxpay.single.sdk.code.TransferStatusEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 转账结果
* @author xxm
* @since 2024/6/19
*/
@Getter
@Setter
@ToString(callSuper = true)
public class TransferModel extends DaxPayResponseModel {
/** 商户转账号 */
private String bizTransferNo;
/** 转账号 */
private String transferNo;
/**
* 状态
* @see TransferStatusEnum
*/
private String status;
}

View File

@@ -0,0 +1,100 @@
package cn.daxpay.single.sdk.model.transfer;
import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.TransferPayeeTypeEnum;
import cn.daxpay.single.sdk.code.TransferStatusEnum;
import cn.daxpay.single.sdk.code.TransferTypeEnum;
import cn.daxpay.single.sdk.net.DaxPayResponseModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.time.LocalDateTime;
/**
* 转账订单
* @author xxm
* @since 2024/6/20
*/
@Getter
@Setter
@ToString(callSuper = true)
public class TransferOrderModel extends DaxPayResponseModel {
/** 商户转账号 */
private String bizTransferNo;
/** 转账号 */
private String transferNo;
/** 通道转账号 */
private String outTransferNo;
/**
* 支付通道
* @see PayChannelEnum
*/
private String channel;
/** 转账金额 */
private Integer amount;
/** 标题 */
private String title;
/** 转账原因/备注 */
private String reason;
/**
* 转账类型, 微信使用
* @see TransferTypeEnum
*/
private String transferType;
/** 付款方 */
private String payer;
/**
* 收款人类型
* @see TransferPayeeTypeEnum
*/
private String payeeType;
/** 收款人账号 */
private String payeeAccount;
/** 收款人姓名 */
private String payeeName;
/**
* 状态
* @see TransferStatusEnum
*/
private String status;
/** 成功时间 */
private LocalDateTime successTime;
/** 异步通知地址 */
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回, 以最后一次为准 */
private String attach;
/** 请求时间,时间戳转时间 */
private LocalDateTime reqTime;
/** 终端ip */
private String clientIp;
/**
* 错误码
*/
private String errorCode;
/**
* 错误原因
*/
private String errorMsg;
}

View File

@@ -0,0 +1,43 @@
package cn.daxpay.single.sdk.param.transfer;
import cn.daxpay.single.sdk.model.transfer.TransferOrderModel;
import cn.daxpay.single.sdk.net.DaxPayRequest;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
*
* @author xxm
* @since 2024/6/20
*/
@Getter
@Setter
@ToString(callSuper = true)
public class QueryTransferParam extends DaxPayRequest<TransferOrderModel> {
/** 商户转账号 */
private String bizTransferNo;
/** 转账号 */
private String transferNo;
/**
* 方法请求路径
*/
@Override
public String path() {
return "/unipay/query/transfer";
}
/**
* 将请求返回结果反序列化为实体类
*/
@Override
public DaxPayResult<TransferOrderModel> toModel(String json) {
return JSONUtil.toBean(json, new TypeReference<DaxPayResult<TransferOrderModel>>() {}, false);
}
}

View File

@@ -0,0 +1,83 @@
package cn.daxpay.single.sdk.param.transfer;
import cn.daxpay.single.sdk.code.PayChannelEnum;
import cn.daxpay.single.sdk.code.TransferPayeeTypeEnum;
import cn.daxpay.single.sdk.code.TransferTypeEnum;
import cn.daxpay.single.sdk.model.transfer.TransferModel;
import cn.daxpay.single.sdk.net.DaxPayRequest;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 转账参数
* @author xxm
* @since 2024/6/19
*/
@Getter
@Setter
@ToString(callSuper = true)
public class TransferParam extends DaxPayRequest<TransferModel> {
/** 商户转账号 */
private String bizTransferNo;
/**
* 支付通道
* @see PayChannelEnum
*/
private String channel;
/** 转账金额 */
private Integer amount;
/** 标题 */
private String title;
/** 转账原因/备注 */
private String reason;
/**
* 转账类型, 微信使用
* @see TransferTypeEnum
*/
private String transferType;
/**
* 收款人账号类型
* @see TransferPayeeTypeEnum
*/
private String payeeType;
/** 收款人账号 */
private String payeeAccount;
/** 收款人姓名 */
private String payeeName;
/** 回调通知地址 */
private String notifyUrl;
/** 商户扩展参数,回调时会原样返回 */
private String attach;
/**
* 方法请求路径
*/
@Override
public String path() {
return "/unipay/transfer";
}
/**
* 将请求返回结果反序列化为实体类
*/
@Override
public DaxPayResult<TransferModel> toModel(String json) {
return JSONUtil.toBean(json, new TypeReference<DaxPayResult<TransferModel>>() {}, false);
}
}

View File

@@ -32,6 +32,4 @@ public class TransferResult extends PaymentCommonResult {
*/
@Schema(description = "状态")
private String status;
}