mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-13 13:20:23 +00:00
fix 优化处理通知和回调消息签名问题
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
package org.dromara.daxpay.core.result;
|
||||
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -35,11 +33,11 @@ public class DaxResult<T>{
|
||||
private String sign;
|
||||
|
||||
@Schema(description = "响应时间")
|
||||
private LocalDateTime resTime = LocalDateTime.now();
|
||||
private LocalDateTime resTime;
|
||||
|
||||
/** 追踪ID */
|
||||
@Schema(description = "追踪ID")
|
||||
private String traceId = MDC.get(CommonCode.TRACE_ID);
|
||||
private String traceId;
|
||||
|
||||
public DaxResult(int successCode, T data, String msg) {
|
||||
this.code = successCode;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.dromara.daxpay.service.common.aop;
|
||||
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import cn.bootx.platform.core.exception.BizException;
|
||||
import cn.bootx.platform.core.exception.ValidationFailedException;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
@@ -12,9 +13,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 支付签名切面, 用于对支付参数进行校验和签名
|
||||
* 执行顺序: 过滤器 -> 拦截器 -> 切面 -> 方法
|
||||
@@ -60,6 +64,8 @@ public class PaymentVerifyAspect {
|
||||
proceed = pjp.proceed();
|
||||
} catch (BizException ex) {
|
||||
DaxResult<Void> result = new DaxResult<>(ex.getCode(), ex.getMessage());
|
||||
result.setTraceId(MDC.get(CommonCode.TRACE_ID));
|
||||
result.setResTime(LocalDateTime.now());
|
||||
paymentAssistService.sign(result);
|
||||
return result;
|
||||
}
|
||||
|
@@ -1,7 +1,14 @@
|
||||
package org.dromara.daxpay.service.service.notice.callback;
|
||||
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import cn.bootx.platform.core.util.JsonUtil;
|
||||
import cn.bootx.platform.starter.redis.delay.service.DelayJobService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.daxpay.core.result.DaxNoticeResult;
|
||||
import org.dromara.daxpay.service.code.DaxPayCode;
|
||||
import org.dromara.daxpay.service.dao.notice.callback.MerchantCallbackRecordManager;
|
||||
@@ -11,12 +18,7 @@ import org.dromara.daxpay.service.entity.notice.callback.MerchantCallbackTask;
|
||||
import org.dromara.daxpay.service.enums.NoticeSendTypeEnum;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.dromara.daxpay.service.service.notice.MerchantNoticeAssistService;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -62,6 +64,8 @@ public class MerchantCallbackSendService {
|
||||
// 构造通知消息并签名
|
||||
var daxResult = new DaxNoticeResult<Map<String, Object>>(SUCCESS_CODE, JsonUtil.parseObj(task.getContent()), SUCCESS_MSG)
|
||||
.setAppId(task.getAppId());
|
||||
daxResult.setTraceId(MDC.get(CommonCode.TRACE_ID));
|
||||
daxResult.setResTime(LocalDateTime.now());
|
||||
paymentAssistService.sign(daxResult);
|
||||
HttpResponse execute = HttpUtil.createPost(task.getUrl())
|
||||
.body(JsonUtil.toJsonStr(daxResult), ContentType.JSON.getValue())
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.dromara.daxpay.service.service.notice.notify;
|
||||
|
||||
import cn.bootx.platform.core.code.CommonCode;
|
||||
import cn.bootx.platform.core.util.JsonUtil;
|
||||
import cn.bootx.platform.starter.redis.delay.service.DelayJobService;
|
||||
import org.dromara.daxpay.core.enums.MerchantNotifyTypeEnum;
|
||||
@@ -20,6 +21,7 @@ import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -70,6 +72,8 @@ public class MerchantNotifySendService {
|
||||
var daxResult = new DaxNoticeResult<Map<String, Object>>(SUCCESS_CODE, JsonUtil.parseObj(task.getContent()), SUCCESS_MSG)
|
||||
.setAppId(task.getAppId())
|
||||
.setNoticeType(task.getNotifyType());
|
||||
daxResult.setTraceId(MDC.get(CommonCode.TRACE_ID));
|
||||
daxResult.setResTime(LocalDateTime.now());
|
||||
paymentAssistService.sign(daxResult);
|
||||
|
||||
HttpResponse execute = HttpUtil.createPost(url)
|
||||
|
Reference in New Issue
Block a user