mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-10-14 13:50:25 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -73,7 +73,7 @@ public class WechatPayCallbackService {
|
|||||||
callbackInfo.setCallbackType(TradeTypeEnum.PAY)
|
callbackInfo.setCallbackType(TradeTypeEnum.PAY)
|
||||||
.setChannel(isv? ChannelEnum.WECHAT_ISV.getCode():ChannelEnum.WECHAT.getCode());
|
.setChannel(isv? ChannelEnum.WECHAT_ISV.getCode():ChannelEnum.WECHAT.getCode());
|
||||||
|
|
||||||
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig(false);
|
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig(isv);
|
||||||
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
||||||
// v2 或 v3
|
// v2 或 v3
|
||||||
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V2)) {
|
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V2)) {
|
||||||
|
@@ -75,7 +75,7 @@ public class WechatRefundCallbackService {
|
|||||||
callbackInfo.setCallbackType(TradeTypeEnum.REFUND)
|
callbackInfo.setCallbackType(TradeTypeEnum.REFUND)
|
||||||
.setChannel(isv? ChannelEnum.WECHAT_ISV.getCode():ChannelEnum.WECHAT.getCode());
|
.setChannel(isv? ChannelEnum.WECHAT_ISV.getCode():ChannelEnum.WECHAT.getCode());
|
||||||
|
|
||||||
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig(false);
|
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig(isv);
|
||||||
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
||||||
// v2 或 v3
|
// v2 或 v3
|
||||||
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V2)) {
|
if (Objects.equals(config.getApiVersion(), WechatPayCode.API_V2)) {
|
||||||
|
@@ -66,7 +66,7 @@ public class WechatTransferCallbackService {
|
|||||||
CallbackLocal callbackInfo = PaymentContextLocal.get().getCallbackInfo();
|
CallbackLocal callbackInfo = PaymentContextLocal.get().getCallbackInfo();
|
||||||
callbackInfo.setChannel(isv? ChannelEnum.WECHAT_ISV.getCode():ChannelEnum.WECHAT.getCode())
|
callbackInfo.setChannel(isv? ChannelEnum.WECHAT_ISV.getCode():ChannelEnum.WECHAT.getCode())
|
||||||
.setCallbackType(TradeTypeEnum.TRANSFER);
|
.setCallbackType(TradeTypeEnum.TRANSFER);
|
||||||
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig(false);
|
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig(isv);
|
||||||
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
WxPayService wxPayService = wechatPayConfigService.wxJavaSdk(config);
|
||||||
// V3 回调接收处理
|
// V3 回调接收处理
|
||||||
String body = JakartaServletUtil.getBody(request);
|
String body = JakartaServletUtil.getBody(request);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.dromara.daxpay.channel.wechat.service.payment.refund;
|
package org.dromara.daxpay.channel.wechat.service.payment.refund;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.dromara.daxpay.channel.wechat.entity.config.WechatPayConfig;
|
import org.dromara.daxpay.channel.wechat.entity.config.WechatPayConfig;
|
||||||
import org.dromara.daxpay.channel.wechat.enums.WechatRefundStatusEnum;
|
import org.dromara.daxpay.channel.wechat.enums.WechatRefundStatusEnum;
|
||||||
import org.dromara.daxpay.channel.wechat.service.payment.config.WechatPayConfigService;
|
import org.dromara.daxpay.channel.wechat.service.payment.config.WechatPayConfigService;
|
||||||
@@ -48,6 +49,9 @@ public class WechatSubRefundV3Service {
|
|||||||
.setOutTradeNo(refundOrder.getOrderNo())
|
.setOutTradeNo(refundOrder.getOrderNo())
|
||||||
.setAmount(amount)
|
.setAmount(amount)
|
||||||
.setSubMchid(config.getSubMchId());
|
.setSubMchid(config.getSubMchId());
|
||||||
|
if (StrUtil.isBlank(request.getReason())){
|
||||||
|
request.setReason("退款");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
WxPayRefundV3Result result = wxPayService.refundV3(request);
|
WxPayRefundV3Result result = wxPayService.refundV3(request);
|
||||||
|
|
||||||
|
@@ -1,10 +1,8 @@
|
|||||||
package org.dromara.daxpay.core.result;
|
package org.dromara.daxpay.core.result;
|
||||||
|
|
||||||
import cn.bootx.platform.core.code.CommonCode;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.slf4j.MDC;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@@ -35,11 +33,11 @@ public class DaxResult<T>{
|
|||||||
private String sign;
|
private String sign;
|
||||||
|
|
||||||
@Schema(description = "响应时间")
|
@Schema(description = "响应时间")
|
||||||
private LocalDateTime resTime = LocalDateTime.now();
|
private LocalDateTime resTime;
|
||||||
|
|
||||||
/** 追踪ID */
|
/** 追踪ID */
|
||||||
@Schema(description = "追踪ID")
|
@Schema(description = "追踪ID")
|
||||||
private String traceId = MDC.get(CommonCode.TRACE_ID);
|
private String traceId;
|
||||||
|
|
||||||
public DaxResult(int successCode, T data, String msg) {
|
public DaxResult(int successCode, T data, String msg) {
|
||||||
this.code = successCode;
|
this.code = successCode;
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.dromara.daxpay.service.common.aop;
|
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.BizException;
|
||||||
import cn.bootx.platform.core.exception.ValidationFailedException;
|
import cn.bootx.platform.core.exception.ValidationFailedException;
|
||||||
import cn.bootx.platform.core.util.ValidationUtil;
|
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.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.slf4j.MDC;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付签名切面, 用于对支付参数进行校验和签名
|
* 支付签名切面, 用于对支付参数进行校验和签名
|
||||||
* 执行顺序: 过滤器 -> 拦截器 -> 切面 -> 方法
|
* 执行顺序: 过滤器 -> 拦截器 -> 切面 -> 方法
|
||||||
@@ -60,6 +64,8 @@ public class PaymentVerifyAspect {
|
|||||||
proceed = pjp.proceed();
|
proceed = pjp.proceed();
|
||||||
} catch (BizException ex) {
|
} catch (BizException ex) {
|
||||||
DaxResult<Void> result = new DaxResult<>(ex.getCode(), ex.getMessage());
|
DaxResult<Void> result = new DaxResult<>(ex.getCode(), ex.getMessage());
|
||||||
|
result.setTraceId(MDC.get(CommonCode.TRACE_ID));
|
||||||
|
result.setResTime(LocalDateTime.now());
|
||||||
paymentAssistService.sign(result);
|
paymentAssistService.sign(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,14 @@
|
|||||||
package org.dromara.daxpay.service.service.notice.callback;
|
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.core.util.JsonUtil;
|
||||||
import cn.bootx.platform.starter.redis.delay.service.DelayJobService;
|
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.core.result.DaxNoticeResult;
|
||||||
import org.dromara.daxpay.service.code.DaxPayCode;
|
import org.dromara.daxpay.service.code.DaxPayCode;
|
||||||
import org.dromara.daxpay.service.dao.notice.callback.MerchantCallbackRecordManager;
|
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.enums.NoticeSendTypeEnum;
|
||||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||||
import org.dromara.daxpay.service.service.notice.MerchantNoticeAssistService;
|
import org.dromara.daxpay.service.service.notice.MerchantNoticeAssistService;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import org.slf4j.MDC;
|
||||||
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.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
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)
|
var daxResult = new DaxNoticeResult<Map<String, Object>>(SUCCESS_CODE, JsonUtil.parseObj(task.getContent()), SUCCESS_MSG)
|
||||||
.setAppId(task.getAppId());
|
.setAppId(task.getAppId());
|
||||||
|
daxResult.setTraceId(MDC.get(CommonCode.TRACE_ID));
|
||||||
|
daxResult.setResTime(LocalDateTime.now());
|
||||||
paymentAssistService.sign(daxResult);
|
paymentAssistService.sign(daxResult);
|
||||||
HttpResponse execute = HttpUtil.createPost(task.getUrl())
|
HttpResponse execute = HttpUtil.createPost(task.getUrl())
|
||||||
.body(JsonUtil.toJsonStr(daxResult), ContentType.JSON.getValue())
|
.body(JsonUtil.toJsonStr(daxResult), ContentType.JSON.getValue())
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package org.dromara.daxpay.service.service.notice.notify;
|
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.core.util.JsonUtil;
|
||||||
import cn.bootx.platform.starter.redis.delay.service.DelayJobService;
|
import cn.bootx.platform.starter.redis.delay.service.DelayJobService;
|
||||||
import org.dromara.daxpay.core.enums.MerchantNotifyTypeEnum;
|
import org.dromara.daxpay.core.enums.MerchantNotifyTypeEnum;
|
||||||
@@ -20,6 +21,7 @@ import cn.hutool.http.HttpResponse;
|
|||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.slf4j.MDC;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
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)
|
var daxResult = new DaxNoticeResult<Map<String, Object>>(SUCCESS_CODE, JsonUtil.parseObj(task.getContent()), SUCCESS_MSG)
|
||||||
.setAppId(task.getAppId())
|
.setAppId(task.getAppId())
|
||||||
.setNoticeType(task.getNotifyType());
|
.setNoticeType(task.getNotifyType());
|
||||||
|
daxResult.setTraceId(MDC.get(CommonCode.TRACE_ID));
|
||||||
|
daxResult.setResTime(LocalDateTime.now());
|
||||||
paymentAssistService.sign(daxResult);
|
paymentAssistService.sign(daxResult);
|
||||||
|
|
||||||
HttpResponse execute = HttpUtil.createPost(url)
|
HttpResponse execute = HttpUtil.createPost(url)
|
||||||
|
Reference in New Issue
Block a user