ref 相关记录调整

This commit is contained in:
DaxPay
2024-04-29 18:06:22 +08:00
parent d36f10c14d
commit 66921cc1a7
17 changed files with 136 additions and 124 deletions

View File

@@ -14,8 +14,6 @@ public enum PayApiCallBackTypeEnum {
/** 支持所有回调类型 */
ALL("all"),
/** 支持异步回调通知 */
ASYNC_NOTICE("async_notice"),
/** 不支持退掉通知 */
NONE("none");

View File

@@ -74,7 +74,7 @@ public class AliPayService {
Integer amount = payOrder.getAmount();
String payBody = null;
// 异步线程存储
PayLocal asyncPayInfo = PaymentContextLocal.get().getPayInfo();
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();
// wap支付
if (Objects.equals(payOrder.getMethod(), PayMethodEnum.WAP.getCode())) {
payBody = this.wapPay(amount, payOrder, alipayConfig);
@@ -96,7 +96,7 @@ public class AliPayService {
this.barCode(amount, payOrder, aliPayParam, alipayConfig);
}
// 通常是发起支付的参数
asyncPayInfo.setPayBody(payBody);
payInfo.setPayBody(payBody);
}
/**
@@ -238,7 +238,7 @@ public class AliPayService {
* 付款码支付
*/
public void barCode(int amount, PayOrder payOrder, AliPayParam aliPayParam, AliPayConfig alipayConfig) {
PayLocal asyncPayInfo = PaymentContextLocal.get().getPayInfo();
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();
AlipayTradePayModel model = new AlipayTradePayModel();
model.setSubject(payOrder.getTitle());
@@ -259,7 +259,7 @@ public class AliPayService {
// 支付成功处理 金额2000以下免密支付, 记录支付完成相关信息
if (Objects.equals(response.getCode(), AliPayCode.SUCCESS)) {
asyncPayInfo.setOutOrderNo(response.getTradeNo())
payInfo.setOutOrderNo(response.getTradeNo())
.setComplete(true);
}
// 非支付中响应码, 进行错误处理

View File

@@ -14,7 +14,6 @@ import cn.bootx.platform.daxpay.service.core.channel.union.entity.UnionPayConfig
import cn.bootx.platform.daxpay.service.core.payment.callback.service.PayCallbackService;
import cn.bootx.platform.daxpay.service.core.payment.callback.service.RefundCallbackService;
import cn.bootx.platform.daxpay.service.core.record.callback.service.PayCallbackRecordService;
import cn.bootx.platform.daxpay.service.func.AbsCallbackStrategy;
import cn.bootx.platform.daxpay.service.sdk.union.api.UnionPayKit;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.thread.ThreadUtil;
@@ -25,7 +24,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.Map;

View File

@@ -68,7 +68,7 @@ public class UnionPayService {
public void pay(PayOrder payOrder, UnionPayParam unionPayParam, UnionPayKit unionPayKit){
Integer amount = payOrder.getAmount();
BigDecimal totalFee = BigDecimal.valueOf(amount * 0.01);
PayLocal asyncPayInfo = PaymentContextLocal.get().getPayInfo();;
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();;
String payBody = null;
PayMethodEnum payMethodEnum = PayMethodEnum.findByCode(payOrder.getMethod());
@@ -97,7 +97,7 @@ public class UnionPayService {
payBody = this.b2bPay(totalFee, payOrder, unionPayKit);
}
asyncPayInfo.setPayBody(payBody);
payInfo.setPayBody(payBody);
}
/**

View File

@@ -9,12 +9,10 @@ import cn.bootx.platform.daxpay.service.code.PayRepairSourceEnum;
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
import cn.bootx.platform.daxpay.service.common.context.CallbackLocal;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.channel.alipay.service.AliPayConfigService;
import cn.bootx.platform.daxpay.service.core.channel.wechat.entity.WeChatPayConfig;
import cn.bootx.platform.daxpay.service.core.payment.callback.service.PayCallbackService;
import cn.bootx.platform.daxpay.service.core.payment.callback.service.RefundCallbackService;
import cn.bootx.platform.daxpay.service.core.record.callback.service.PayCallbackRecordService;
import cn.bootx.platform.daxpay.service.func.AbsCallbackStrategy;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
@@ -24,7 +22,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

View File

@@ -87,7 +87,7 @@ public class WeChatPayService {
Integer amount = payOrder.getAmount();
String totalFee = String.valueOf(amount);
PayLocal asyncPayInfo = PaymentContextLocal.get().getPayInfo();;
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();;
String payBody = null;
PayMethodEnum payMethodEnum = PayMethodEnum.findByCode(payOrder.getMethod());
@@ -111,7 +111,7 @@ public class WeChatPayService {
else if (payMethodEnum == PayMethodEnum.BARCODE) {
this.barCodePay(totalFee, payOrder, weChatPayParam.getAuthCode(), weChatPayConfig);
}
asyncPayInfo.setPayBody(payBody);
payInfo.setPayBody(payBody);
}
/**
@@ -181,7 +181,7 @@ public class WeChatPayService {
* 付款码支付
*/
private void barCodePay(String amount, PayOrder payOrder, String authCode, WeChatPayConfig weChatPayConfig) {
PayLocal asyncPayInfo = PaymentContextLocal.get().getPayInfo();
PayLocal payInfo = PaymentContextLocal.get().getPayInfo();
Map<String, String> params = BarPayModel.builder()
.appid(weChatPayConfig.getWxAppId())
@@ -210,14 +210,14 @@ public class WeChatPayService {
String errCode = result.get(WeChatPayCode.ERR_CODE);
// 支付成功处理,
if (Objects.equals(resultCode, WeChatPayCode.PAY_SUCCESS)) {
asyncPayInfo.setOutOrderNo(result.get(WeChatPayCode.TRANSACTION_ID)).setComplete(true);
payInfo.setOutOrderNo(result.get(WeChatPayCode.TRANSACTION_ID)).setComplete(true);
return;
}
// 支付中, 发起轮训同步
if (Objects.equals(resultCode, WeChatPayCode.PAY_FAIL)
&& Objects.equals(errCode, WeChatPayCode.PAY_USERPAYING)) {
SpringUtil.getBean(this.getClass()).rotationSync(payOrder);
asyncPayInfo.setOutOrderNo(result.get(WeChatPayCode.TRANSACTION_ID));
payInfo.setOutOrderNo(result.get(WeChatPayCode.TRANSACTION_ID));
return;
}
// 支付撤销

View File

@@ -73,23 +73,23 @@ public class PayAssistService {
.equals(payParam.getChannel())) {
return;
}
PayLocal asyncPayInfo = PaymentContextLocal.get()
PayLocal payInfo = PaymentContextLocal.get()
.getPayInfo();
PlatformLocal platform = PaymentContextLocal.get()
.getPlatformInfo();
// 支付订单是非为空
if (Objects.nonNull(order)) {
asyncPayInfo.setExpiredTime(order.getExpiredTime());
payInfo.setExpiredTime(order.getExpiredTime());
return;
}
// 支付参数传入
if (Objects.nonNull(payParam.getExpiredTime())) {
asyncPayInfo.setExpiredTime(payParam.getExpiredTime());
payInfo.setExpiredTime(payParam.getExpiredTime());
return;
}
// 读取本地时间
LocalDateTime paymentExpiredTime = PayUtil.getPaymentExpiredTime(platform.getOrderTimeout());
asyncPayInfo.setExpiredTime(paymentExpiredTime);
payInfo.setExpiredTime(paymentExpiredTime);
}
/**
@@ -243,10 +243,10 @@ public class PayAssistService {
payResult.setStatus(payOrder.getStatus());
// 设置支付参数
PayLocal asyncPayInfo = PaymentContextLocal.get()
PayLocal payInfo = PaymentContextLocal.get()
.getPayInfo();
if (StrUtil.isNotBlank(asyncPayInfo.getPayBody())) {
payResult.setPayBody(asyncPayInfo.getPayBody());
if (StrUtil.isNotBlank(payInfo.getPayBody())) {
payResult.setPayBody(payInfo.getPayBody());
}
// 签名
return payResult;

View File

@@ -136,9 +136,9 @@ public class RefundAssistService {
*/
@Transactional(rollbackFor = Exception.class)
public void updateOrder(RefundOrder refundOrder){
RefundLocal asyncRefundInfo = PaymentContextLocal.get().getRefundInfo();
refundOrder.setStatus(asyncRefundInfo.getStatus().getCode())
.setOutRefundNo(asyncRefundInfo.getOutRefundNo());
RefundLocal refundInfo = PaymentContextLocal.get().getRefundInfo();
refundOrder.setStatus(refundInfo.getStatus().getCode())
.setOutRefundNo(refundInfo.getOutRefundNo());
// 退款成功更新退款时间
if (Objects.equals(refundOrder.getStatus(), SUCCESS.getCode())){
// TODO 读取网关返回的退款时间和完成时间

View File

@@ -36,7 +36,7 @@ public class PayCloseRecord extends MpCreateEntity implements EntityBaseFunction
* 关闭的支付通道
* @see PayChannelEnum
*/
@DbColumn(comment = "关闭的异步支付通道")
@DbColumn(comment = "关闭的支付通道")
private String channel;
/**
@@ -47,7 +47,7 @@ public class PayCloseRecord extends MpCreateEntity implements EntityBaseFunction
/** 错误码 */
@DbColumn(comment = "错误码")
private String code;
private String errorCode;
/** 错误消息 */
@DbColumn(comment = "错误消息")

View File

@@ -67,8 +67,8 @@ public class PayRepairRecord extends MpCreateEntity implements EntityBaseFunctio
@DbColumn(comment = "修复方式")
private String repairWay;
/** 修复的异步通道 */
@DbColumn(comment = "修复的异步通道")
/** 修复的通道 */
@DbColumn(comment = "修复的通道")
private String channel;
/**

View File

@@ -42,7 +42,7 @@ public class PayCloseRecordDto extends BaseDto {
/** 错误码 */
@DbColumn(comment = "错误码")
private String code;
private String errorCode;
/** 错误消息 */
@DbColumn(comment = "错误消息")

View File

@@ -6,7 +6,6 @@ import cn.bootx.platform.daxpay.service.code.PayRepairSourceEnum;
import cn.bootx.platform.daxpay.service.code.PayRepairWayEnum;
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
import cn.bootx.platform.daxpay.service.code.RefundRepairWayEnum;
import cn.bootx.table.modify.annotation.DbColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -40,6 +39,14 @@ public class PayRepairRecordDto extends BaseDto {
@Schema(description = "本地业务号")
private String tradeNo;
/**
* 修复方式
* @see PayRepairWayEnum
* @see RefundRepairWayEnum
*/
@Schema(description = "修复方式")
private String repairWay;
/**
* 修复类型 支付修复/退款修复
* @see PaymentTypeEnum
@@ -54,14 +61,6 @@ public class PayRepairRecordDto extends BaseDto {
@Schema(description = "修复来源")
private String repairSource;
/**
* 修复方式
* @see PayRepairWayEnum
* @see RefundRepairWayEnum
*/
@Schema(description = "修复方式")
private String repairWay;
/** 修复的异步通道 */
@Schema(description = "修复的异步通道")
private String channel;

View File

@@ -1,27 +0,0 @@
package cn.bootx.platform.daxpay.service.func;
import cn.bootx.platform.daxpay.service.code.PayCallbackStatusEnum;
import cn.bootx.platform.daxpay.service.code.PayRepairSourceEnum;
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
import cn.bootx.platform.daxpay.service.common.context.CallbackLocal;
import cn.bootx.platform.daxpay.service.common.local.PaymentContextLocal;
import cn.bootx.platform.daxpay.service.core.payment.callback.service.PayCallbackService;
import cn.bootx.platform.daxpay.service.core.payment.callback.service.RefundCallbackService;
import cn.bootx.platform.daxpay.service.core.record.callback.entity.PayCallbackRecord;
import cn.bootx.platform.daxpay.service.core.record.callback.service.PayCallbackRecordService;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import java.util.Map;
/**
* 回调处理抽象类, 处理支付回调和退款回调
*
* @author xxm
* @since 2021/6/21
*/
@Slf4j
@Deprecated
public abstract class AbsCallbackStrategy implements PayStrategy {
}

View File

@@ -2,6 +2,7 @@ package cn.bootx.platform.daxpay.service.param.record;
import cn.bootx.platform.common.core.rest.param.QueryOrder;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.table.modify.annotation.DbColumn;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -18,19 +19,36 @@ import lombok.experimental.Accessors;
@Schema(title = "支付关闭记录")
public class PayCloseRecordQuery extends QueryOrder {
@Schema(description = "支付记录id")
private Long paymentId;
/** 订单号 */
@DbColumn(comment = "订单号")
private String orderNo;
@Schema(description = "业务号")
private String businessNo;
/** 商户订单号 */
@DbColumn(comment = "商户订单号")
private String bizOrderNo;
/**
* 关闭的异步支付通道, 可以为空
* @see PayChannelEnum#getCode()
* 关闭的支付通道
* @see PayChannelEnum
*/
@Schema(description = "关闭的异步支付通道")
private String asyncChannel;
@DbColumn(comment = "关闭的异步支付通道")
private String channel;
@Schema(description = "请求链路ID")
private String reqId;
/**
* 是否关闭成功
*/
@DbColumn(comment = "是否关闭成功")
private boolean closed;
/** 错误码 */
@DbColumn(comment = "错误码")
private String errorCode;
/** 错误消息 */
@DbColumn(comment = "错误消息")
private String errorMsg;
/** 客户端IP */
@DbColumn(comment = "客户端IP")
private String clientIp;
}

View File

@@ -5,6 +5,7 @@ import cn.bootx.platform.daxpay.code.PayStatusEnum;
import cn.bootx.platform.daxpay.service.code.PayRepairSourceEnum;
import cn.bootx.platform.daxpay.service.code.PayRepairWayEnum;
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
import cn.bootx.platform.daxpay.service.code.RefundRepairWayEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -20,23 +21,31 @@ import lombok.experimental.Accessors;
@Schema(title = "支付修复记录查询参数")
public class PayRepairRecordQuery {
/** 本地订单ID */
@Schema(description = "本地订单ID")
private Long orderId;
/** 本地订单号 */
@Schema(description = "本地订单号")
private String orderNo;
@Schema(description = "修复单号")
private String repairNo;
/**
* 修复类型
* 修复
* 如果一次修复产生的修复记录有多个记录, 使用这个作为关联
*/
@Schema(description = "修复号")
private String repairNo;
/** 支付ID/退款ID */
@Schema(description = "本地订单ID")
private Long tradeId;
/**
* 本地交易号, 支付号/退款号
*/
@Schema(description = "本地业务号")
private String tradeNo;
/**
* 修复类型 支付修复/退款修复
* @see PaymentTypeEnum
*/
@Schema(description = "修复类型")
private String repairType;
/**
* 修复来源
* @see PayRepairSourceEnum
@@ -47,13 +56,14 @@ public class PayRepairRecordQuery {
/**
* 修复方式
* @see PayRepairWayEnum
* @see RefundRepairWayEnum
*/
@Schema(description = "修复方式")
private String repairWay;
/** 修复的异步通道 */
@Schema(description = "修复的异步通道")
private String asyncChannel;
private String channel;
/**
* 修复前状态
@@ -68,7 +78,4 @@ public class PayRepairRecordQuery {
*/
@Schema(description = "修复后状态")
private String afterStatus;
@Schema(description = "请求链路ID")
private String reqId;
}

View File

@@ -3,7 +3,10 @@ package cn.bootx.platform.daxpay.service.param.record;
import cn.bootx.platform.common.core.annotation.QueryParam;
import cn.bootx.platform.daxpay.code.PayChannelEnum;
import cn.bootx.platform.daxpay.code.PaySyncStatusEnum;
import cn.bootx.table.modify.annotation.DbColumn;
import cn.bootx.platform.daxpay.code.RefundSyncStatusEnum;
import cn.bootx.platform.daxpay.service.code.PaymentTypeEnum;
import cn.bootx.table.modify.mysql.annotation.DbMySqlFieldType;
import cn.bootx.table.modify.mysql.constants.MySqlFieldTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -19,43 +22,64 @@ import lombok.experimental.Accessors;
@Schema(title = "支付同步记录查询参数")
public class PaySyncRecordQuery {
/** 本地订单id */
@Schema(description = "本地订单id")
private Long orderId;
/** 本地交易号 */
@Schema(description = "本地订单ID")
private String tradeNo;
@Schema(description = "本地订单号")
private String orderNo;
/** 商户交易号 */
@Schema(description = "商户交易号")
private String bizTradeNo;
/** 网关订单号 */
@Schema(description = "网关订单")
private String gatewayOrderNo;
/** 三方交易号 */
@Schema(description = "三方交易")
private String outTradeNo;
/** 同步类型 */
/**
* 三方支付返回状态
* @see PaySyncStatusEnum
* @see RefundSyncStatusEnum
*/
@Schema(description = "网关返回状态")
private String outTradeStatus;
/**
* 同步类型 支付/退款
* @see PaymentTypeEnum
*/
@Schema(description = "同步类型")
private String syncType;
/**
* 支付通道
* 同步的异步通道
* @see PayChannelEnum#getCode()
*/
@Schema(description = "支付通道")
private String asyncChannel;
@Schema(description = "同步的异步通道")
private String channel;
@Schema(description = "请求链路ID")
private String reqId;
/** 网关返回的同步消息 */
@DbMySqlFieldType(MySqlFieldTypeEnum.LONGTEXT)
@Schema(description = "同步消息")
private String syncInfo;
/**
* 同步状态
* @see PaySyncStatusEnum
* 支付单如果状态不一致, 是否进行修复
*/
@Schema(description = "同步状态")
private String gatewayStatus;
@Schema(description = "是否进行修复")
private boolean repair;
/**
* 支付单如果状态不一致, 是否修复成功
*/
@DbColumn(comment = "是否进行修复")
private Boolean repairOrder;
/** 修复单号 */
@Schema(description = "修复单号")
private String repairNo;
/** 错误码 */
@Schema(description = "错误码")
private String errorCode;
/** 错误消息 */
@Schema(description = "错误消息")
private String errorMsg;
/** 客户端IP */
@Schema(description = "客户端IP")