feat SDK调整和文档更新

This commit is contained in:
DaxPay
2024-10-23 14:57:23 +08:00
parent 8fcb16ca6f
commit e5f58a59dc
28 changed files with 275 additions and 147 deletions

View File

@@ -186,10 +186,6 @@
</includes>
<filtering>true</filtering>
</resource>
<!-- java类路径中会被打包的软件 -->
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>

View File

@@ -4,6 +4,9 @@ import cn.daxpay.single.sdk.code.AllocReceiverTypeEnum;
import cn.daxpay.single.sdk.code.AllocRelationTypeEnum;
import cn.daxpay.single.sdk.code.ChannelEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 分账接收方
@@ -13,34 +16,44 @@ import lombok.Data;
@Data
public class AllocReceiverModel {
/** 分账接收方编号, 需要保证唯一 */
private String receiverNo;
/** 分账接收方列表 */
private List<Receiver> receivers;
/**
* 所属通道
* @see ChannelEnum
* 分账接收方
*/
private String channel;
@Data
@Accessors(chain = true)
public static class Receiver{
/** 分账接收方编号, 需要保证唯一 */
private String receiverNo;
/**
* 分账接收方类型
* @see AllocReceiverTypeEnum
*/
private String receiverType;
/**
* 所属通道
* @see ChannelEnum
*/
private String channel;
/** 接收方账号 */
private String receiverAccount;
/**
* 分账接收方类型
* @see AllocReceiverTypeEnum
*/
private String receiverType;
/** 接收方姓名 */
private String receiverName;
/** 接收方账号 */
private String receiverAccount;
/**
* 分账关系类型
* @see AllocRelationTypeEnum
*/
private String relationType;
/** 接收方姓名 */
private String receiverName;
/** 关系名称 */
private String relationName;
/**
* 分账关系类型
* @see AllocRelationTypeEnum
*/
private String relationType;
/** 关系名称 */
private String relationName;
}
}

View File

@@ -1,18 +0,0 @@
package cn.daxpay.single.sdk.model.allocation;
import lombok.Data;
import java.util.List;
/**
* 分账接收方返回结果
* @author xxm
* @since 2024/5/21
*/
@Data
public class AllocReceiversModel{
/** 接收方列表 */
private List<AllocReceiverModel> receivers;
}

View File

@@ -57,7 +57,7 @@ public class AllocReceiverAddParam extends DaxPayRequest<AllocReceiverAddModel>
*/
@Override
public String path() {
return "/unipay/allocation/receiver/add";
return "/unipay/alloc/receiver/add";
}
/**

View File

@@ -1,22 +0,0 @@
package cn.daxpay.single.sdk.param.allocation;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
/**
* 分账接收方列表参数
* @author xxm
* @since 2024/5/21
*/
@Getter
@Setter
public class AllocReceiverParam {
/** 分账接收方编号 */
private String receiverNo;
/** 分账金额 */
private BigDecimal amount;
}

View File

@@ -27,7 +27,7 @@ public class AllocReceiverRemoveParam extends DaxPayRequest<AllocReceiverRemoveM
*/
@Override
public String path() {
return "/unipay/allocation/receiver/remove";
return "/unipay/alloc/receiver/remove";
}
/**

View File

@@ -0,0 +1,44 @@
package cn.daxpay.single.sdk.param.allocation;
import cn.daxpay.single.sdk.model.allocation.AllocReceiverModel;
import cn.daxpay.single.sdk.net.DaxPayRequest;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.daxpay.single.sdk.util.JsonUtil;
import cn.hutool.core.lang.TypeReference;
import lombok.Getter;
import lombok.Setter;
/**
* 分账接收方列表参数
* @author xxm
* @since 2024/5/21
*/
@Getter
@Setter
public class QueryAllocReceiverParam extends DaxPayRequest<AllocReceiverModel> {
/** 分账通道 */
private String channel;
/**
* 方法请求路径
*
* @return 请求路径
*/
@Override
public String path() {
return "/unipay/alloc/receiver/list";
}
/**
* 将请求返回结果反序列化为实体类
*
* @param json json字符串
* @return 反序列后的对象
*/
@Override
public DaxPayResult<AllocReceiverModel> toModel(String json) {
return JsonUtil.toBean(json, new TypeReference<DaxPayResult<AllocReceiverModel>>() {});
}
}

View File

@@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode;
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class QueryPayParam extends DaxPayRequest<PayOrderModel> {
public class PayQueryParam extends DaxPayRequest<PayOrderModel> {
/** 订单号 */
private String orderNo;

View File

@@ -28,7 +28,7 @@ public class PaySyncParam extends DaxPayRequest<PaySyncModel> {
*/
@Override
public String path() {
return "/unipay/sync/pay";
return "/unipay/sync/order/pay";
}
/**

View File

@@ -15,7 +15,7 @@ import lombok.EqualsAndHashCode;
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class QueryRefundParam extends DaxPayRequest<RefundOrderModel> {
public class RefundQueryParam extends DaxPayRequest<RefundOrderModel> {
/** 退款号 */

View File

@@ -28,7 +28,7 @@ public class RefundSyncParam extends DaxPayRequest<RefundSyncModel> {
*/
@Override
public String path() {
return "/unipay/sync/refund";
return "/unipay/sync/order/refund";
}
/**

View File

@@ -17,7 +17,7 @@ import lombok.ToString;
@Getter
@Setter
@ToString(callSuper = true)
public class QueryTransferParam extends DaxPayRequest<TransferOrderModel> {
public class TransferQueryParam extends DaxPayRequest<TransferOrderModel> {
/** 商户转账号 */
private String bizTransferNo;

View File

@@ -0,0 +1,41 @@
package cn.daxpay.single.sdk.param.trade.transfer;
import cn.daxpay.single.sdk.model.trade.refund.RefundSyncModel;
import cn.daxpay.single.sdk.net.DaxPayRequest;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.daxpay.single.sdk.util.JsonUtil;
import cn.hutool.core.lang.TypeReference;
import lombok.Getter;
import lombok.Setter;
/**
* 转账订单同步参数
* @author xxm
* @since 2024/2/7
*/
@Getter
@Setter
public class TransferSyncParam extends DaxPayRequest<RefundSyncModel> {
/** 商户转账号 */
private String bizTransferNo;
/** 转账号 */
private String transferNo;
/**
* 方法请求路径
*/
@Override
public String path() {
return "/unipay/sync/order/transfer";
}
/**
* 将请求返回结果反序列化为实体类
*/
@Override
public DaxPayResult<RefundSyncModel> toModel(String json) {
return JsonUtil.toBean(json, new TypeReference<DaxPayResult<RefundSyncModel>>() {});
}
}

View File

@@ -5,13 +5,16 @@ import cn.daxpay.single.sdk.code.AllocRelationTypeEnum;
import cn.daxpay.single.sdk.code.ChannelEnum;
import cn.daxpay.single.sdk.code.SignTypeEnum;
import cn.daxpay.single.sdk.model.allocation.AllocReceiverAddModel;
import cn.daxpay.single.sdk.model.allocation.AllocReceiverModel;
import cn.daxpay.single.sdk.model.allocation.AllocReceiverRemoveModel;
import cn.daxpay.single.sdk.net.DaxPayConfig;
import cn.daxpay.single.sdk.net.DaxPayKit;
import cn.daxpay.single.sdk.param.allocation.AllocReceiverAddParam;
import cn.daxpay.single.sdk.param.allocation.AllocReceiverRemoveParam;
import cn.daxpay.single.sdk.param.allocation.QueryAllocReceiverParam;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.daxpay.single.sdk.util.JsonUtil;
import cn.daxpay.single.sdk.util.PaySignUtil;
import org.junit.Before;
import org.junit.Test;
@@ -26,22 +29,14 @@ public class AllocReceiverTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.build();
DaxPayKit.initConfig(config);
}
/**
* 查询
*/
@Test
public void query() {
AllocReceiverAddParam param = new AllocReceiverAddParam();
param.setChannel(ChannelEnum.ALI.getCode());
}
/**
* 添加
*/
@@ -68,6 +63,20 @@ public class AllocReceiverTest {
param.setReceiverNo("123456");
DaxPayResult<AllocReceiverRemoveModel> execute = DaxPayKit.execute(param);
System.out.println(JsonUtil.toJsonStr(execute));
System.out.println(PaySignUtil.hmacSha256Sign(execute, "123456"));
}
/**
* 列表
*/
@Test
public void list() {
QueryAllocReceiverParam param = new QueryAllocReceiverParam();
param.setChannel(ChannelEnum.ALI.getCode());
param.setClientIp("127.0.0.1");
DaxPayResult<AllocReceiverModel> execute = DaxPayKit.execute(param);
System.out.println(JsonUtil.toJsonStr(execute));
System.out.println(PaySignUtil.hmacSha256Sign(execute, "123456"));
}
}

View File

@@ -4,7 +4,7 @@ import cn.daxpay.single.sdk.code.SignTypeEnum;
import cn.daxpay.single.sdk.model.trade.pay.PayOrderModel;
import cn.daxpay.single.sdk.net.DaxPayConfig;
import cn.daxpay.single.sdk.net.DaxPayKit;
import cn.daxpay.single.sdk.param.trade.pay.QueryPayParam;
import cn.daxpay.single.sdk.param.trade.pay.PayQueryParam;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.daxpay.single.sdk.util.JsonUtil;
import org.junit.Before;
@@ -21,8 +21,9 @@ public class QueryPayOrderTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.build();
DaxPayKit.initConfig(config);
@@ -30,7 +31,7 @@ public class QueryPayOrderTest {
@Test
public void testPay() {
QueryPayParam param = new QueryPayParam();
PayQueryParam param = new PayQueryParam();
param.setBizOrderNoeNo("P17141882417921");
param.setClientIp("127.0.0.1");

View File

@@ -4,7 +4,7 @@ import cn.daxpay.single.sdk.code.SignTypeEnum;
import cn.daxpay.single.sdk.model.trade.refund.RefundOrderModel;
import cn.daxpay.single.sdk.net.DaxPayConfig;
import cn.daxpay.single.sdk.net.DaxPayKit;
import cn.daxpay.single.sdk.param.trade.refund.QueryRefundParam;
import cn.daxpay.single.sdk.param.trade.refund.RefundQueryParam;
import cn.daxpay.single.sdk.response.DaxPayResult;
import cn.daxpay.single.sdk.util.JsonUtil;
import org.junit.Before;
@@ -21,8 +21,9 @@ public class QueryRefundOrderTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.build();
DaxPayKit.initConfig(config);
@@ -30,7 +31,7 @@ public class QueryRefundOrderTest {
@Test
public void testRefund() {
QueryRefundParam param = new QueryRefundParam();
RefundQueryParam param = new RefundQueryParam();
param.setRefundNo("DEVR24051020531763000014");
param.setClientIp("127.0.0.1");

View File

@@ -20,10 +20,10 @@ public class CloseOrderTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.appId("M8088873888246277")
.build();
DaxPayKit.initConfig(config);
}

View File

@@ -21,8 +21,9 @@ public class PayOrderSyncTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.build();
DaxPayKit.initConfig(config);

View File

@@ -27,10 +27,10 @@ public class PayOrderTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.appId("M8088873888246277")
.build();
DaxPayKit.initConfig(config);
}

View File

@@ -21,8 +21,9 @@ public class RefundOrderSyncTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.build();
DaxPayKit.initConfig(config);

View File

@@ -27,10 +27,10 @@ public class RefundOrderTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.appId("M8088873888246277")
.build();
DaxPayKit.initConfig(config);
}
@@ -49,6 +49,6 @@ public class RefundOrderTest {
DaxPayResult<RefundModel> execute = DaxPayKit.execute(param);
System.out.println(JsonUtil.toJsonStr(execute));
System.out.println(PaySignUtil.verifyHmacSha256Sign(execute.getData(), "123456", execute.getSign()));
System.out.println(PaySignUtil.verifyHmacSha256Sign(execute, "123456", execute.getSign()));
}
}

View File

@@ -25,10 +25,10 @@ public class TransferOrderTest {
public void init() {
// 初始化支付配置
DaxPayConfig config = DaxPayConfig.builder()
.serviceUrl("http://127.0.0.1:10880")
.serviceUrl("http://127.0.0.1:9999")
.signSecret("123456")
.appId("M7934041241299655")
.signType(SignTypeEnum.HMAC_SHA256)
.appId("M8207639754663343")
.build();
DaxPayKit.initConfig(config);
}