修改退款审核、退款环节,记录操作人ID,通过请求token获取用户ID(需要增加sa-token配置);修改定时任务配置,支付状态检查(12小时执行一次)、退款状态检查分开配置(半小时执行一次)

This commit is contained in:
jkcdev 2025-05-21 10:14:23 +08:00
parent de701c4726
commit 4a30209d25
3 changed files with 14 additions and 10 deletions

View File

@ -2,9 +2,7 @@ package com.cdzy.payment.config;
import com.wechat.pay.java.core.Config; import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAPublicKeyConfig; import com.wechat.pay.java.core.RSAPublicKeyConfig;
import com.wechat.pay.java.core.cipher.RSASigner;
import com.wechat.pay.java.core.cipher.Signer; import com.wechat.pay.java.core.cipher.Signer;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.jsapi.JsapiService; import com.wechat.pay.java.service.payments.jsapi.JsapiService;
import com.wechat.pay.java.service.refund.RefundService; import com.wechat.pay.java.service.refund.RefundService;
import lombok.Data; import lombok.Data;
@ -12,8 +10,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.security.PrivateKey;
/** /**
* 微信支付配置参数 * 微信支付配置参数
* *
@ -67,10 +63,15 @@ public class WxPayConfig {
*/ */
private Integer expireMinute = 1440; private Integer expireMinute = 1440;
/** /**
* 定时任务执行表达式 * 支付状态检查定时任务执行表达式
* 默认每12小时执行1次 * 默认每12小时执行1次
*/ */
private String cronExpression = "0 0 0,12 * * ?"; private String paySchedule = "0 0 0/12 * * ?";
/**
* 退款状态检查定时任务执行表达式
* 默认每30分钟执行1次
*/
private String refundSchedule = "0 0/30 * * * ?";
@Bean @Bean
public Config certificateConfig() { public Config certificateConfig() {

View File

@ -29,7 +29,9 @@ public class ScheduledTaskManager {
@PostConstruct @PostConstruct
public void init() { public void init() {
String CRON_EXPRESSION = wxPayConfig.getCronExpression(); String CRON_EXPRESSION_PAY = wxPayConfig.getPaySchedule();
String CRON_EXPRESSION_REFUND = wxPayConfig.getRefundSchedule();
// 启动定时任务 // 启动定时任务
// 1. 每隔30秒执行1次查询创建未超过5分钟并且未支付的订单 // 1. 每隔30秒执行1次查询创建未超过5分钟并且未支付的订单
threadPoolTaskScheduler.schedule(new Runnable() { threadPoolTaskScheduler.schedule(new Runnable() {
@ -41,7 +43,7 @@ public class ScheduledTaskManager {
log.error("checkOrderStatus 执行异常", e); log.error("checkOrderStatus 执行异常", e);
} }
} }
}, new CronTrigger(CRON_EXPRESSION)); }, new CronTrigger(CRON_EXPRESSION_PAY));
//========支付系统自动关闭不主动关闭每次发起请求的时候检测是否关闭======== //========支付系统自动关闭不主动关闭每次发起请求的时候检测是否关闭========
//// 2. 每隔30秒执行1次查询创建超过5分钟并且未支付的订单 //// 2. 每隔30秒执行1次查询创建超过5分钟并且未支付的订单
@ -66,7 +68,7 @@ public class ScheduledTaskManager {
log.error("checkRefundStatus 执行异常", e); log.error("checkRefundStatus 执行异常", e);
} }
} }
}, new CronTrigger(CRON_EXPRESSION)); }, new CronTrigger(CRON_EXPRESSION_REFUND));
} }
} }

View File

@ -43,7 +43,8 @@ payment:
pay-notify_url: http://192.168.2.156:10017/wxPayment/pay-notify pay-notify_url: http://192.168.2.156:10017/wxPayment/pay-notify
refund-notify_url: http://192.168.2.156:10017/wxPayment/refund-notify refund-notify_url: http://192.168.2.156:10017/wxPayment/refund-notify
expire-minutes: 1440 expire-minutes: 1440
cron-expression: 0 0 0,12 * * ? pay-schedule: 0 0 0/12 * * ?
refund-schedule: 0 0/30 * * * ?
task-scheduler-pool: task-scheduler-pool:
poolSize: 100 poolSize: 100
threadNamePrefix: task-scheduled- threadNamePrefix: task-scheduled-