feat SDK编写

This commit is contained in:
bootx
2024-02-02 21:33:46 +08:00
parent dd1d70dcfb
commit e2ab1ea2f0
57 changed files with 1302 additions and 44 deletions

View File

@@ -46,7 +46,7 @@ public class VoucherPayService {
VoucherPayParam voucherPayParam;
try {
// 储值卡参数验证
String extraParamsJson = payChannelParam.getChannelExtra();
String extraParamsJson = payChannelParam.getChannelParam();
if (StrUtil.isNotBlank(extraParamsJson)) {
voucherPayParam = JSONUtil.toBean(extraParamsJson, VoucherPayParam.class);
} else {

View File

@@ -32,7 +32,7 @@ public class PayNoticeResult {
* @see PayChannelEnum#ASYNC_TYPE_CODE
*/
@Schema(description = "异步支付通道")
private String asyncPayChannel;
private String asyncChannel;
@Schema(description = "支付金额")
private Integer amount;

View File

@@ -97,7 +97,7 @@ public class PayBuilder {
.setPayWay(channelParam.getWay())
.setAmount(channelParam.getAmount())
.setRefundableBalance(channelParam.getAmount())
.setChannelExtra(channelParam.getChannelExtra());
.setChannelExtra(channelParam.getChannelParam());
}
/**
@@ -126,7 +126,7 @@ public class PayBuilder {
paymentResult = new PayResult();
paymentResult.setPaymentId(payOrder.getId());
paymentResult.setAsyncPay(payOrder.isAsyncPay());
paymentResult.setAsyncPayChannel(payOrder.getAsyncChannel());
paymentResult.setAsyncChannel(payOrder.getAsyncChannel());
paymentResult.setStatus(payOrder.getStatus());
// 设置异步支付参数

View File

@@ -68,7 +68,7 @@ public class PayChannelOrderService {
.setAmount(payChannelParam.getAmount())
.setRefundableBalance(payChannelParam.getAmount())
.setPayTime(LocalDateTime.now())
.setChannelExtra(payChannelParam.getChannelExtra())
.setChannelExtra(payChannelParam.getChannelParam())
.setStatus(payStatus.getCode());
channelOrderManager.deleteByPaymentIdAndAsync(payOrder.getId());
channelOrderManager.save(payChannelOrder);
@@ -77,7 +77,7 @@ public class PayChannelOrderService {
payOrderChannelOpt.get()
.setPayWay(payChannelParam.getWay())
.setPayTime(LocalDateTime.now())
.setChannelExtra(payChannelParam.getChannelExtra())
.setChannelExtra(payChannelParam.getChannelParam())
.setStatus(payStatus.getCode());
channelOrderManager.updateById(payOrderChannelOpt.get());
}

View File

@@ -85,6 +85,7 @@ public class PayAssistService {
asyncPayInfo.setExpiredTime(payParam.getExpiredTime());
return;
}
// 读取本地时间
LocalDateTime paymentExpiredTime = PayUtil.getPaymentExpiredTime(platform.getOrderTimeout());
asyncPayInfo.setExpiredTime(paymentExpiredTime);
}

View File

@@ -102,10 +102,10 @@ public class PayService {
// 组装支付参数
PayParam payParam = new PayParam();
PayChannelParam payChannelParam = new PayChannelParam();
payChannelParam.setChannel(simplePayParam.getPayChannel());
payChannelParam.setChannel(simplePayParam.getChannel());
payChannelParam.setWay(simplePayParam.getPayWay());
payChannelParam.setAmount(simplePayParam.getAmount());
payChannelParam.setChannelExtra(simplePayParam.getChannelExtra());
payChannelParam.setChannelParam(simplePayParam.getChannelParam());
BeanUtil.copyProperties(simplePayParam,payParam, CopyOptions.create().ignoreNullValue());
payParam.setPayChannels(Collections.singletonList(payChannelParam));
// 复用支付下单接口

View File

@@ -52,7 +52,7 @@ public class AliPayStrategy extends AbsPayStrategy {
public void doBeforePayHandler() {
try {
// 支付宝参数验证
String extraParamsJson = this.getPayChannelParam().getChannelExtra();
String extraParamsJson = this.getPayChannelParam().getChannelParam();
if (StrUtil.isNotBlank(extraParamsJson)) {
this.aliPayParam = JSONUtil.toBean(extraParamsJson, AliPayParam.class);
}

View File

@@ -54,7 +54,7 @@ public class WalletPayStrategy extends AbsPayStrategy {
WalletPayParam walletPayParam = new WalletPayParam();
try {
// 钱包参数验证
String extraParamsJson = this.getPayChannelParam().getChannelExtra();
String extraParamsJson = this.getPayChannelParam().getChannelParam();
if (StrUtil.isNotBlank(extraParamsJson)) {
walletPayParam = JSONUtil.toBean(extraParamsJson, WalletPayParam.class);
}

View File

@@ -55,7 +55,7 @@ public class WeChatPayStrategy extends AbsPayStrategy {
public void doBeforePayHandler() {
try {
// 微信参数验证
String extraParamsJson = this.getPayChannelParam().getChannelExtra();
String extraParamsJson = this.getPayChannelParam().getChannelParam();
if (StrUtil.isNotBlank(extraParamsJson)) {
this.weChatPayParam = JSONUtil.toBean(extraParamsJson, WeChatPayParam.class);
}

View File

@@ -42,7 +42,7 @@ public class PayCallbackRecord extends MpCreateEntity implements EntityBaseFunct
* @see PayChannelEnum#getCode()
*/
@DbColumn(comment = "支付通道")
private String payChannel;
private String channel;
/**
* 回调类型

View File

@@ -30,7 +30,7 @@ public class PayCallbackRecordDto extends BaseDto {
* @see PayChannelEnum#getCode()
*/
@Schema(description = "支付通道")
private String payChannel;
private String channel;
/**
* 回调类型

View File

@@ -109,7 +109,7 @@ public abstract class AbsCallbackStrategy implements PayStrategy {
.orElse(null);
PayCallbackRecord payNotifyRecord = new PayCallbackRecord()
.setPayChannel(this.getChannel().getCode())
.setChannel(this.getChannel().getCode())
.setNotifyInfo(JSONUtil.toJsonStr(callbackInfo.getCallbackParam()))
.setOrderId(callbackInfo.getOrderId())
.setGatewayOrderNo(callbackInfo.getGatewayOrderNo())

View File

@@ -30,13 +30,12 @@ public class PayCallbackRecordQuery extends QueryOrder {
* @see PayChannelEnum#getCode()
*/
@Schema(description = "支付通道")
private String payChannel;
private String channel;
/**
* 回调处理状态
* @see PayCallbackStatusEnum
* @see RefundCallbackStatusEnum
*/
@Schema(description = "回调处理状态")
private String status;

View File

@@ -40,7 +40,7 @@ class PaymentSignServiceTest {
p1.setWay("wx_app");
AliPayParam aliPayParam = new AliPayParam();
aliPayParam.setAuthCode("6688");
p1.setChannelExtra(JSONUtil.toJsonStr(aliPayParam));
p1.setChannelParam(JSONUtil.toJsonStr(aliPayParam));
PayChannelParam p2 = new PayChannelParam();
p2.setAmount(100);
@@ -49,7 +49,7 @@ class PaymentSignServiceTest {
WeChatPayParam weChatPayParam = new WeChatPayParam();
weChatPayParam.setOpenId("w2qsz2xawe3gbhyyff28fs01fd");
weChatPayParam.setAuthCode("8866");
p2.setChannelExtra(JSONUtil.toJsonStr(weChatPayParam));
p2.setChannelParam(JSONUtil.toJsonStr(weChatPayParam));
List<PayChannelParam> payWays = Arrays.asList(p1, p2);
payParam.setPayChannels(payWays);