Compare commits

...

2 Commits

Author SHA1 Message Date
menxipeng
98565c9150 微信支付部分 2025-11-26 22:40:03 +08:00
menxipeng
30589acd69 微信支付部分 2025-11-25 23:32:39 +08:00
20 changed files with 930 additions and 346 deletions

View File

@@ -64,6 +64,15 @@ public class FileController extends BaseController {
response.setContentType("application/json;charset=UTF-8");
response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
return;
}else{
// 检查会员时间
if (!MusicUtil.getShopIsVip(shopUser)) {
if (shopUser.getVip() == 1){
// 会员已过期修改为非会员
shopUser.setVip(2L);
shopUserMapper.updateShopUser(shopUser);
}
}
}
//shopUser = shopUserMapper.selectShopUserByUserId(userId);
// MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);

View File

@@ -0,0 +1,83 @@
package com.ruoyi.web.controller.back;
import com.alipay.easysdk.factory.Factory;
import com.ruoyi.system.service.IOrderInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* 描述:
*
* @author MXP by 2025/11/25
*/
@RestController
@RequestMapping("/call/back")
public class HandleAlipayNotify {
private static final Logger log = LoggerFactory.getLogger(HandleAlipayNotify.class);
@Autowired
private IOrderInfoService orderService;
@PostMapping("/alipay")
public String handleAlipayNotify(HttpServletRequest request) {
try {
// 1. 将异步通知的参数转换为Map
Map<String, String> params = new HashMap<>();
Map<String, String[]> requestParams = request.getParameterMap();
log.info("支付宝异步通知参数: {}", requestParams);
for (String name : requestParams.keySet()) {
String[] values = requestParams.get(name);
String valueStr = "";
for (int i = 0; i < values.length; i++) {
valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr + values[i] + ",";
}
params.put(name, valueStr);
}
log.info("支付宝异步通知处理后参数: {}", params);
// 2. 验证签名(非常重要!防止伪造通知)
// 使用SDK验证签名
boolean signVerified = Factory
.Payment
.Common()
.verifyNotify(params);
if (signVerified) {
// 签名验证成功,说明通知是支付宝发的
// 3. 验证商户APP_ID是否匹配
String appId = params.get("app_id");
if (!"<你的APPID>".equals(appId)) {
return "failure";
}
// 4. 处理业务逻辑
String tradeStatus = params.get("trade_status");
String outTradeNo = params.get("out_trade_no"); // 你的订单号
String tradeNo = params.get("trade_no"); // 支付宝的交易号
if ("TRADE_SUCCESS".equals(tradeStatus)) {
// 支付成功!
orderService.processPaymentAliResult(outTradeNo, tradeNo);
return "success";
}
} else {
// 签名验证失败,记录日志,可能是恶意请求
return "failure";
}
} catch (Exception e) {
e.printStackTrace();
}
// 处理失败,支付宝会稍后重发通知
return "failure";
}
}

View File

@@ -1,16 +1,30 @@
package com.ruoyi.web.controller.back;
import com.ruoyi.common.core.domain.entity.OrderInfo;
import com.ruoyi.common.enums.OrderStatus;
import cn.hutool.json.JSONUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.IOrderInfoService;
import com.ruoyi.system.util.WeChatPayUtil;
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import com.wechat.pay.contrib.apache.httpclient.auth.Verifier;
import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials;
import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.payments.model.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.ValidationException;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.util.HashMap;
import java.util.Map;
@@ -18,93 +32,120 @@ import java.util.Map;
@RequestMapping("/call/back")
public class WechatPayNotifyController {
private static final Logger log = LoggerFactory.getLogger(WechatPayNotifyController.class);
@Autowired
private IOrderInfoService orderService;
/**
* 微信支付结果回调接口
* POST /api/wechat/pay/notify
*/
@PostMapping("/wechat")
public Map<String, String> handleWechatPayNotify(HttpServletRequest request,
HttpServletResponse response) {
public Map<String, String> handleWechatPayNotify(HttpServletRequest request, HttpServletResponse response) {
Map<String, String> result = new HashMap<>();
try {
System.out.println("收到微信支付回调通知");
// 1. 读取请求体
String requestBody = getRequestBody(request);
log.info("微信支付回调参数: {}", requestBody);
if (StringUtils.isEmpty(requestBody)) {
result.put("code", "FAIL");
result.put("message", "请求体为空");
return result;
}
// 1. 构建回调参数
RequestParam requestParam = buildRequestParam(request);
// 2. 获取请求头中的关键信息
String wechatpaySignature = request.getHeader("Wechatpay-Signature");
String wechatpayTimestamp = request.getHeader("Wechatpay-Timestamp");
String wechatpayNonce = request.getHeader("Wechatpay-Nonce");
String wechatpaySerial = request.getHeader("Wechatpay-Serial");
String wechatpaySignatureType = request.getHeader("Wechatpay-Signature-Type");
NotificationParser parser = new NotificationParser();
// 2. 解析并验证通知
log.info("回调头部信息:");
log.info("Wechatpay-Signature: " + wechatpaySignature);
log.info("Wechatpay-Timestamp: " + wechatpayTimestamp);
log.info("Wechatpay-Nonce: " + wechatpayNonce);
log.info("Wechatpay-Serial: " + wechatpaySerial);
log.info("Wechatpay-Signature-Type: " + wechatpaySignatureType);
// 3. 验证必要的请求头
if (StringUtils.isEmpty(wechatpaySignature) ||
StringUtils.isEmpty(wechatpayTimestamp) ||
StringUtils.isEmpty(wechatpayNonce) ||
StringUtils.isEmpty(wechatpaySerial)) {
result.put("code", "FAIL");
result.put("message", "缺少必要的微信支付头部信息");
return result;
}
// 4. 构建 RequestParam
RequestParam requestParam = new RequestParam.Builder()
.serialNumber(wechatpaySerial)
.nonce(wechatpayNonce)
.signature(wechatpaySignature)
.timestamp(wechatpayTimestamp)
.signType(wechatpaySignatureType)
.body(requestBody)
.build();
// 5. 初始化验证器 - 正确的方式
NotificationParser parser = new NotificationParser((NotificationConfig) WeChatPayUtil.getConfig());
// 6. 解析并验证通知
Transaction transaction = parser.parse(requestParam, Transaction.class);
System.out.println("解析支付通知成功:");
System.out.println("商户订单号: " + transaction.getOutTradeNo());
System.out.println("微信支付订单号: " + transaction.getTransactionId());
System.out.println("交易状态: " + transaction.getTradeState());
System.out.println("交易类型: " + transaction.getTradeType());
System.out.println("金额: " + transaction.getAmount().getTotal());
log.info("接收到微信支付回调:{}", JSONUtil.toJsonStr(transaction));
// 3. 处理业务逻辑
orderService.processPaymentResult(transaction);
// if (processResult) {
// // 4. 返回成功响应
// result.put("code", "SUCCESS");
// result.put("message", "成功");
// System.out.println("支付回调处理成功");
// } else {
// result.put("code", "FAIL");
// result.put("message", "处理失败");
// System.err.println("支付回调处理失败");
// }
// 7. 处理业务逻辑
//processPaymentResult(transaction, result);
} catch (Exception e) {
System.err.println("支付回调处理异常: " + e.getMessage());
} catch (ValidationException e) {
// logger.error("签名验证失败", e);
e.printStackTrace();
// 返回失败响应
result.put("code", "FAIL");
result.put("message", "签名验证失败");
} catch (Exception e) {
e.printStackTrace();
//logger.error("微信支付回调处理失败", e);
result.put("code", "FAIL");
result.put("message", "处理异常: " + e.getMessage());
}
return result;
// Map<String, String> result = new HashMap<>();
//
// try {
// // 1. 构建回调参数
// RequestParam requestParam = buildRequestParam(request);
//
//
//
//
// NotificationParser parser = new NotificationParser();
// // 2. 解析并验证通知
// Transaction transaction = parser.parse(requestParam, Transaction.class);
//
// log.info("接收到微信支付回调:{}", JSONUtil.toJsonStr( transaction));
//
// // 3. 处理业务逻辑
// orderService.processPaymentResult(transaction);
//
// //4. 返回成功响应
// result.put("code", "SUCCESS");
// result.put("message", "成功");
// } catch (Exception e) {
// log.error("支付回调处理异常: " + e.getMessage());
// e.printStackTrace();
// // 返回失败响应
// result.put("code", "FAIL");
// result.put("message", "处理异常: " + e.getMessage());
// }
// return result;
}
/**
* 从HttpServletRequest构建RequestParam
*/
private RequestParam buildRequestParam(HttpServletRequest request) throws Exception {
// 获取微信回调的头部信息
String wechatpaySerial = request.getHeader("Wechatpay-Serial");
String wechatpaySignature = request.getHeader("Wechatpay-Signature");
String wechatpayTimestamp = request.getHeader("Wechatpay-Timestamp");
String wechatpayNonce = request.getHeader("Wechatpay-Nonce");
String wechatpaySignatureType = request.getHeader("Wechatpay-Signature-Type");
System.out.println("回调头部信息:");
System.out.println("Wechatpay-Serial: " + wechatpaySerial);
System.out.println("Wechatpay-Timestamp: " + wechatpayTimestamp);
System.out.println("Wechatpay-Nonce: " + wechatpayNonce);
System.out.println("Wechatpay-Signature-Type: " + wechatpaySignatureType);
// 读取请求体
String body = getRequestBody(request);
System.out.println("回调请求体: " + body);
return new RequestParam.Builder()
.serialNumber(wechatpaySerial)
.nonce(wechatpayNonce)
.signature(wechatpaySignature)
.timestamp(wechatpayTimestamp)
.signType(wechatpaySignatureType)
.body(body)
.build();
}
/**
* 读取请求体内容
@@ -127,7 +168,7 @@ public class WechatPayNotifyController {
// */
// private boolean handleRefund(Order order, Transaction transaction) {
// // 实现退款逻辑
// System.out.println("处理退款: " + order.getOutTradeNo());
// log.info("处理退款: " + order.getOutTradeNo());
// return true;
// }
//
@@ -136,7 +177,7 @@ public class WechatPayNotifyController {
// */
// private boolean handleClosedPayment(Order order, Transaction transaction) {
// // 实现订单关闭逻辑
// System.out.println("处理订单关闭: " + order.getOutTradeNo());
// log.info("处理订单关闭: " + order.getOutTradeNo());
// return true;
// }
}

View File

@@ -55,6 +55,12 @@ public class ClientOrderInfoController extends BaseController
return orderInfoService.wechatPay(orderId);
}
// 查询支付结果
@GetMapping("/transactions")
public AjaxResult paymentCallback(@RequestParam("orderId") String orderId){
return orderInfoService.findTransactions(orderId);
}
/**
* 支付订单
*/

View File

@@ -0,0 +1,230 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.9.0
# 版权年份
copyrightYear: 2025
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置
logging:
level:
com.ruoyi: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://rm-t4ng7k83rzt5281yido.mysql.singapore.rds.aliyuncs.com:3306/musicpro?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: music
password: Q1w2e3r4
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 500MB
# 设置总上传的文件大小
max-request-size: 1000MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
# redis 配置
redis:
host: 116.204.124.80
# 端口默认为6379
port: 16379
# 数据库索引
database: 0
# 密码
password: Lwz19520416443@
# 地址
# host: 127.0.0.1
# # 端口默认为6379
# port: 6379
# # 数据库索引
# database: 0
# # 密码
# password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 1440
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
configuration:
auto-mapping-behavior: partial
map-underscore-to-camel-case: true
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
ali:
accessKeyId: LTAI5tAZPz1BecFgfPwFSnps
accessKeySecret: 9Qp2TeLMgjvhCwyjQuxSSIYaffzBpL
appId:
merchantPrivateKey:
merchantCertPath:
alipayCertPath:
alipayRootCertPath:
encryptKey:
notifyUrl:
umApp:
appAliKey: 204941627
appAliSecret: snxhb85RWiLAegYc20hEwTsOEIkZfIaS
androidSecret: nmabfppid2dfgqsxg4yecmppslpcrjeb
androidKey: 68cbcf86c261f2773322b918
# IOSKey: 68a99a66ec2b5b6f8825b8b1
IOSSecret: 48n5d5m8l6svar6srxag6uxovqpaifgp
# androidKey: 687b2df479267e0210b79b6f
IOSKey: 68ef6aa88560e34872ca7b41
#Q1w2e3r4
wechat:
appId: wx87084c0b6aa7aed6
merchantId: 1732990772
privateKeyPath: D:\musicpro\apiclient_key.pem
merchantCertPath: D:\musicpro\apiclient_cert.pem
wechatPayCertPath: D:\musicpro\pub_key.pem
publicKeyId: PUB_KEY_ID_0117329907722025112100111619002400
apiV3Key: ASSSUNTvttuiwqazuu12tnftANtfb004

View File

@@ -1,61 +1,3 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://rm-t4ng7k83rzt5281yido.mysql.singapore.rds.aliyuncs.com:3306/musicpro?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: music
password: Q1w2e3r4
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true

View File

@@ -0,0 +1,223 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.9.0
# 版权年份
copyrightYear: 2025
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置
logging:
level:
com.ruoyi: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://rm-t4ng7k83rzt5281yido.mysql.singapore.rds.aliyuncs.com:3306/musicpro?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: music
password: Q1w2e3r4
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 500MB
# 设置总上传的文件大小
max-request-size: 1000MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
# redis 配置
redis:
# 地址
host: 127.0.0.1
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# # 密码
# password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 1440
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
configuration:
auto-mapping-behavior: partial
map-underscore-to-camel-case: true
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
ali:
accessKeyId: LTAI5tAZPz1BecFgfPwFSnps
accessKeySecret: 9Qp2TeLMgjvhCwyjQuxSSIYaffzBpL
appId:
merchantPrivateKey:
merchantCertPath:
alipayCertPath:
alipayRootCertPath:
encryptKey:
notifyUrl:
umApp:
appAliKey: 204941627
appAliSecret: snxhb85RWiLAegYc20hEwTsOEIkZfIaS
androidSecret: nmabfppid2dfgqsxg4yecmppslpcrjeb
androidKey: 68cbcf86c261f2773322b918
# IOSKey: 68a99a66ec2b5b6f8825b8b1
IOSSecret: 48n5d5m8l6svar6srxag6uxovqpaifgp
# androidKey: 687b2df479267e0210b79b6f
IOSKey: 68ef6aa88560e34872ca7b41
#Q1w2e3r4
wechat:
appId: wx87084c0b6aa7aed6
merchantId: 1732990772
privateKeyPath: /home/cert/apiclient_key.pem
merchantCertPath: /home/cert/apiclient_cert.pem
wechatPayCertPath: /home/cert/pub_key.pem
publicKeyId: PUB_KEY_ID_0117329907722025112100111619002400
apiV3Key: ASSSUNTvttuiwqazuu12tnftANtfb004

View File

@@ -1,166 +1,4 @@
# 项目相关配置
ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.9.0
# 版权年份
copyrightYear: 2025
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: D:/ruoyi/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
captchaType: math
# 开发环境配置
server:
# 服务器的HTTP端口默认为8080
port: 8080
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# 连接数满后的排队数默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置
logging:
level:
com.ruoyi: debug
org.springframework: warn
# 用户配置
user:
password:
# 密码最大错误次数
maxRetryCount: 5
# 密码锁定时间默认10分钟
lockTime: 10
# Spring配置
spring:
# 资源信息
messages:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: druid
# 文件上传
servlet:
multipart:
# 单个文件大小
max-file-size: 500MB
# 设置总上传的文件大小
max-request-size: 1000MB
# 服务模块
devtools:
restart:
# 热部署开关
enabled: true
# redis 配置
redis:
# host: 116.204.124.80
# # 端口默认为6379
# port: 16379
# # 数据库索引
# database: 0
# # 密码
# password: Lwz19520416443@
# 地址
host: 127.0.0.1
# 端口默认为6379
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 连接超时时间
timeout: 10s
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 8
# 连接池的最大数据库连接数
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
encoding: UTF-8
active: dev
# token配置
token:
# 令牌自定义标识
header: Authorization
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 1440
# MyBatis配置
mybatis:
# 搜索指定包别名
typeAliasesPackage: com.ruoyi.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml
configuration:
auto-mapping-behavior: partial
map-underscore-to-camel-case: true
# PageHelper分页插件
pagehelper:
helperDialect: mysql
supportMethodsArguments: true
params: count=countSql
# Swagger配置
swagger:
# 是否开启swagger
enabled: true
# 请求前缀
pathMapping: /dev-api
# 防止XSS攻击
xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
ali:
accessKeyId: LTAI5tAZPz1BecFgfPwFSnps
accessKeySecret: 9Qp2TeLMgjvhCwyjQuxSSIYaffzBpL
umApp:
appAliKey: 204941627
appAliSecret: snxhb85RWiLAegYc20hEwTsOEIkZfIaS
androidSecret: nmabfppid2dfgqsxg4yecmppslpcrjeb
androidKey: 68cbcf86c261f2773322b918
# IOSKey: 68a99a66ec2b5b6f8825b8b1
IOSSecret: 48n5d5m8l6svar6srxag6uxovqpaifgp
# androidKey: 687b2df479267e0210b79b6f
IOSKey: 68ef6aa88560e34872ca7b41
#Q1w2e3r4
wechat:
appId: wx87084c0b6aa7aed6
merchantId: 1732990772
privateKeyPath: D:\musicpro\apiclient_key.pem
merchantCertPath: D:\musicpro\apiclient_cert.pem
wechatPayCertPath: D:\musicpro\pub_key.pem
publicKeyId: PUB_KEY_ID_0117329907722025112100111619002400
apiV3Key: ASSSUNTvttuiwqazuu12tnftANtfb004

View File

@@ -1,6 +1,7 @@
package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import lombok.Getter;
@@ -14,7 +15,7 @@ public class ShopUserResq {
private String username;
private String password;
private String phone;
private Long userId;
@@ -28,4 +29,6 @@ public class ShopUserResq {
private String deviceId;
private String token;
@Excel(name = "1 vip 2 非vip")
private Long vip;
}

View File

@@ -50,7 +50,7 @@ public class MusicUtil {
}
// 处理跨越日期的情况(结束时间早于开始时间)
if (startDate != null && endDate.before(startDate)) {
if (endDate.before(startDate)) {
// 当前时间 >= 开始时间 或 当前时间 <= 结束时间
return now.after(startDate) || now.before(endDate) || now.equals(startDate) || now.equals(endDate);
} else {

View File

@@ -135,9 +135,17 @@ public class SecurityConfig
// /client/index/getCategory
// /client/index/re/bind/music
// /client/index/re/music
// /client/index/getCategory
// /client/index/cate/music
// /client/consult/list
// /client/index/re/music
// /client/share/list
requests.antMatchers("/login", "/register","/client/shopLogin","/file/download/**", "/captchaImage",
"/client/getCode","/client/file/**","/call/back/**","/client/index/getBanner",
"/client/index/getCategory","/client/index/re/bind/music","/client/index/re/music","/client/version/getLastVersion").permitAll()
"/client/index/getCategory","/client/index/re/bind/music","/client/index/re/music",
"/client/version/getLastVersion","/client/search/list","/client/music/find","/client" +
"/index/getCategory","/client/index/cate/music/**","/client/consult/list",
"/client/index/re/music/**","/client/share/list").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()

View File

@@ -36,6 +36,19 @@
<version>0.2.17</version>
</dependency>
<!-- 微信支付V3 目前新版本-->
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.4.9</version>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-easysdk</artifactId>
<version>2.2.3</version>
</dependency>
</dependencies>
</project>

View File

@@ -59,4 +59,6 @@ public interface ProductMapper
* @return 结果
*/
public int deleteProductByIds(String[] ids);
Product selectProductByPageType(String packageType);
}

View File

@@ -138,4 +138,8 @@ public interface IOrderInfoService
AjaxResult wechatPay(String orderId);
AjaxResult processPaymentResult(Transaction transaction);
AjaxResult findTransactions(String transactionId);
AjaxResult processPaymentAliResult(String outTradeNo, String tradeNo);
}

View File

@@ -335,6 +335,10 @@ public class CShopUserServiceImpl implements ShopUserService {
return null;
}
}
if (!MusicUtil.getShopIsVip(member)){
shopUser.setVip(2L);
member.setVip(2L);
};
// 修改外设id
shopUserMapper.updateDeviceIdByPhone(shopUser);
return member;

View File

@@ -6,21 +6,23 @@ import com.ruoyi.common.core.domain.dto.PaymentRequest;
import com.ruoyi.common.core.domain.dto.RefundRequest;
import com.ruoyi.common.core.domain.entity.OrderInfo;
import com.ruoyi.common.core.domain.entity.PayStatusEnum;
import com.ruoyi.common.core.domain.entity.Product;
import com.ruoyi.common.core.domain.entity.ShopUser;
import com.ruoyi.common.core.domain.vo.OrderInfoVO;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.domain.vo.OrderInfoVO;
import com.ruoyi.common.enums.OrderStatus;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.OrderInfoMapper;
import com.ruoyi.system.mapper.ProductMapper;
import com.ruoyi.system.service.IOrderInfoService;
import com.ruoyi.system.service.ShopUserService;
import com.ruoyi.system.util.AppleyPay;
import com.ruoyi.system.util.PaymentUtil;
import com.ruoyi.system.util.WeChatPayUtil;
import com.wechat.pay.java.service.payments.app.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.payments.model.Transaction;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,6 +53,12 @@ public class OrderInfoServiceImpl implements IOrderInfoService
@Autowired
private WeChatPayUtil weChatPayUtil;
@Autowired
private ShopUserService shopUserService;
@Autowired
private ProductMapper productMapper;
/**
* 查询【请填写功能名称】
@@ -147,7 +155,8 @@ public class OrderInfoServiceImpl implements IOrderInfoService
orderInfo.setOrderId(System.currentTimeMillis()); // 使用时间戳作为订单号
orderInfo.setOrderName(request.getOrderName());
orderInfo.setUserId(loginUser.getUserId());
orderInfo.setAmount(new BigDecimal(request.getAmount()));
Product product = productMapper.selectProductByPageType(request.getPackageType());
orderInfo.setAmount(new BigDecimal("0.01"));
orderInfo.setPayType(request.getPayType());
orderInfo.setPackageType(request.getPackageType());
orderInfo.setDeviceType(request.getDeviceType());
@@ -391,6 +400,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
return AjaxResult.success("获取微信支付参数成功",result);
}
@Override
public AjaxResult processPaymentResult(Transaction transaction) {
try {
@@ -413,43 +423,46 @@ public class OrderInfoServiceImpl implements IOrderInfoService
return AjaxResult.success("订单已支付,跳过处理");
}
if ((OrderStatus.CREATED.getCode()).equals(order.getPayStatus())) {
//order.getAmount() 元转分
int amount = order.getAmount().multiply(new BigDecimal(100)).intValue();
//order.getAmount() 元转分
int amount = order.getAmount().multiply(new BigDecimal(100)).intValue();
// 3. 验证金额是否一致
if (amount != totalAmount) {
return AjaxResult.error("金额不一致");
}
// 3. 验证金额是否一致
if (amount != totalAmount) {
return AjaxResult.error("金额不一致");
// 4. 根据交易状态处理业务
if ("SUCCESS".equals(tradeState)) {
// 计算服务开始和结束时间
Date startTime = new Date();
// 支付成功
// 设置订单信息
order.setPayStatus(2L); // 2-已完成
order.setPayTime(DateUtils.getNowDate());
order.setStartTime(startTime);
order.setTradeNo(transactionId);
order.setCallbackContent(outTradeNo); // 保存交易ID
order.setCallTime(DateUtils.getNowDate());
order.setUpdateTime(DateUtils.getNowDate());
Date endTime = AppleyPay.calculateEndTime(startTime, order.getPackageType());
order.setEndTime(endTime);
// 更新用户VIP时间
shopUserService.updateShopUserVipTime(order.getUserId(), order.getPackageType());
orderInfoMapper.updateOrderInfo(order);
return AjaxResult.success();
} else if ("REFUND".equals(tradeState)) {
// 转入退款
//return handleRefund(order, transaction);
} else if ("CLOSED".equals(tradeState)) {
// 已关闭
//return handleClosedPayment(order, transaction);
} else {
// 其他状态
log.info("未知状态: " + tradeState);
// 仍然返回成功,避免微信重复通知
}
}
// 4. 根据交易状态处理业务
if ("SUCCESS".equals(tradeState)) {
// 计算服务开始和结束时间
Date startTime = new Date();
// 支付成功
// 设置订单信息
order.setPayStatus(2L); // 2-已完成
order.setPayTime(DateUtils.getNowDate());
order.setStartTime(startTime);
order.setTradeNo(transactionId);
order.setCallbackContent(outTradeNo); // 保存交易ID
order.setCallTime(DateUtils.getNowDate());
order.setUpdateTime(DateUtils.getNowDate());
Date endTime = AppleyPay.calculateEndTime(startTime, order.getPackageType());
order.setEndTime(endTime);
return AjaxResult.success();
} else if ("REFUND".equals(tradeState)) {
// 转入退款
//return handleRefund(order, transaction);
} else if ("CLOSED".equals(tradeState)) {
// 已关闭
//return handleClosedPayment(order, transaction);
} else {
// 其他状态
log.info("未知状态: " + tradeState);
// 仍然返回成功,避免微信重复通知
}
} catch (Exception e) {
log.error("处理订单异常: {}", e.getMessage());
e.printStackTrace();
@@ -459,6 +472,62 @@ public class OrderInfoServiceImpl implements IOrderInfoService
}
// 重试状态码
private static final int RETRY_CODES = 677;
@Override
public AjaxResult findTransactions(String orderId) {
OrderInfo orderInfo = orderInfoMapper.selectOrderByOrderId(orderId);
if(orderInfo == null){
return AjaxResult.error("未找到对应订单");
}
String transactionId = orderInfo.getTradeNo();
if(transactionId == null){
return new AjaxResult(RETRY_CODES,"未找到对应订单");
}
Transaction transaction = weChatPayUtil.queryOrder(transactionId);
if(transaction == null){
return new AjaxResult(RETRY_CODES,"未找到对应订单");
}
return AjaxResult.success( transaction);
}
@Override
public AjaxResult processPaymentAliResult(String outTradeNo, String tradeNo) {
// 1. 根据商户订单号查询本地订单
OrderInfo order = orderInfoMapper.selectOrderByOrderId(outTradeNo);
if (order == null) {
return AjaxResult.error("未找到对应订单");
}
// 2. 检查订单是否已经处理过(防止重复通知)
if ((OrderStatus.PAID.getCode()).equals(order.getPayStatus())) {
return AjaxResult.success("订单已支付,跳过处理");
}
if ((OrderStatus.CREATED.getCode()).equals(order.getPayStatus())) {
// 计算服务开始和结束时间
Date startTime = new Date();
// 支付成功
// 设置订单信息
order.setPayStatus(2L); // 2-已完成
order.setPayTime(DateUtils.getNowDate());
order.setStartTime(startTime);
order.setTradeNo(tradeNo);
order.setCallbackContent(outTradeNo); // 保存交易ID
order.setCallTime(DateUtils.getNowDate());
order.setUpdateTime(DateUtils.getNowDate());
Date endTime = AppleyPay.calculateEndTime(startTime, order.getPackageType());
order.setEndTime(endTime);
// 更新用户VIP时间
shopUserService.updateShopUserVipTime(order.getUserId(), order.getPackageType());
orderInfoMapper.updateOrderInfo(order);
return AjaxResult.success();
}
return AjaxResult.error("处理订单异常");
}
@Override
@Transactional
public AjaxResult confirmShipment(String orderId) {

View File

@@ -0,0 +1,60 @@
package com.ruoyi.system.util;
import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import com.alipay.easysdk.kernel.util.ResponseChecker;
import com.alipay.easysdk.payment.app.models.AlipayTradeAppPayResponse;
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
import com.ruoyi.common.core.domain.entity.OrderInfo;
/**
* 描述:
*
* @author MXP by 2025/11/25
*/
public class AliPayUtil {
public static void main(String[] args) throws Exception {
// 1. 设置参数(全局只需设置一次)
}
public String prepayWithRequestPayment(OrderInfo orderInfo){
Factory.setOptions(getOptions());
try {
AlipayTradeAppPayResponse response = Factory
.Payment
.App()
.pay(orderInfo.getOrderName(),
String.valueOf(orderInfo.getOrderId()),
String.valueOf(orderInfo.getAmount()));
return response.getBody() ;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static Config getOptions() {
Config config = new Config();
config.protocol = "https";
config.gatewayHost = "openapi.alipay.com";
config.signType = "RSA2";
config.appId = "<-- 请填写您的AppId例如2019091767145019 -->";
// 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
config.merchantPrivateKey = "<-- 请填写您的应用私钥例如MIIEvQIBADANB ... ... -->";
//注证书文件路径支持设置为文件系统中的路径或CLASS_PATH中的路径优先从文件系统中加载加载失败后会继续尝试从CLASS_PATH中加载
config.merchantCertPath = "<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->";
config.alipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->";
config.alipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->";
//注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
// config.alipayPublicKey = "<-- 请填写您的支付宝公钥例如MIIBIjANBg... -->";
//可设置异步通知接收服务地址(可选)
config.notifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址例如https://www.test.com/callback -->";
//可设置AES密钥调用AES加解密相关接口时需要可选
config.encryptKey = "<-- 请填写您的AES密钥例如aa4BtZ4tspm2wnXLb1ThQA== -->";
return config;
}
}

View File

@@ -2,6 +2,7 @@ package com.ruoyi.system.util;
import com.ruoyi.common.constant.WeChatConfig;
import com.ruoyi.common.core.domain.entity.OrderInfo;
import com.wechat.pay.contrib.apache.httpclient.auth.*;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAPublicKeyConfig;
import com.wechat.pay.java.core.util.PemUtil;
@@ -9,10 +10,17 @@ import com.wechat.pay.java.service.payments.app.AppServiceExtension;
import com.wechat.pay.java.service.payments.app.model.Amount;
import com.wechat.pay.java.service.payments.app.model.PrepayRequest;
import com.wechat.pay.java.service.payments.app.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.payments.app.model.QueryOrderByIdRequest;
import com.wechat.pay.java.service.payments.model.Transaction;
import org.springframework.stereotype.Component;
import java.io.ByteArrayInputStream;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.List;
/**
* 描述:
@@ -22,23 +30,9 @@ import java.security.cert.X509Certificate;
@Component
public class WeChatPayUtil {
public PrepayWithRequestPaymentResponse prepayWithRequestPayment(OrderInfo orderInfo){
public PrepayWithRequestPaymentResponse prepayWithRequestPayment(OrderInfo orderInfo) {
// 2. 加载商户证书并获取序列号
X509Certificate merchantCertificate = PemUtil.loadX509FromPath(WeChatConfig.MERCHANT_CERT_PATH);
String merchantSerialNumber = merchantCertificate.getSerialNumber().toString(16).toUpperCase();
Config config =
new RSAPublicKeyConfig.Builder()
.merchantId(WeChatConfig.MERCHANT_ID)
.privateKeyFromPath(WeChatConfig.PRIVATE_KEY_PATH)
.publicKeyFromPath(WeChatConfig.WECHAT_PAY_CERT_PATH)
.publicKeyId(WeChatConfig.PUBLIC_KEY_ID)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(WeChatConfig.API_V3_KEY)
.build();
AppServiceExtension service = new AppServiceExtension.Builder().config(config).build();
AppServiceExtension service = Options();
// 跟之前下单示例一样,填充预下单参数
PrepayRequest request = new PrepayRequest();
request.setAppid(WeChatConfig.APP_ID);
@@ -50,6 +44,7 @@ public class WeChatPayUtil {
Amount amount = new Amount();
// orderInfo.getAmount() 元转分
amount.setTotal(orderInfo.getAmount().multiply(new BigDecimal(100)).intValue());
//amount.setTotal(orderInfo.getAmount().multiply(new BigDecimal(100)).intValue());
amount.setCurrency("CNY");
request.setAmount(amount);
// response包含了调起支付所需的所有参数可直接用于前端调起支付
@@ -64,4 +59,50 @@ public class WeChatPayUtil {
}
// 查询支付结果
public Transaction queryOrder(String transactionId) {
AppServiceExtension service;
service = Options();
QueryOrderByIdRequest request = new QueryOrderByIdRequest();
request.setTransactionId(transactionId);
request.setMchid(WeChatConfig.MERCHANT_ID);
return service.queryOrderById(request);
}
public static AppServiceExtension Options() {
return new AppServiceExtension.Builder().config(getConfig()).build();
}
public static Config getConfig() {
X509Certificate merchantCertificate = PemUtil.loadX509FromPath(WeChatConfig.MERCHANT_CERT_PATH);
String merchantSerialNumber = merchantCertificate.getSerialNumber().toString(16).toUpperCase();
return new RSAPublicKeyConfig.Builder()
.merchantId(WeChatConfig.MERCHANT_ID)
.privateKeyFromPath(WeChatConfig.PRIVATE_KEY_PATH)
.publicKeyFromPath(WeChatConfig.WECHAT_PAY_CERT_PATH)
.publicKeyId(WeChatConfig.PUBLIC_KEY_ID)
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(WeChatConfig.API_V3_KEY)
.build();
}
/**
* 获取验证器(推荐方式)
*/
public static Verifier getVerifier() {
// 加载商户私钥
PrivateKey merchantPrivateKey = PemUtil.loadPrivateKeyFromPath(WeChatConfig.PRIVATE_KEY_PATH);
X509Certificate merchantCertificate = PemUtil.loadX509FromPath(WeChatConfig.MERCHANT_CERT_PATH);
String merchantSerialNumber = merchantCertificate.getSerialNumber().toString(16).toUpperCase();
// 创建自动更新平台证书的验证器
AutoUpdateCertificatesVerifier verifier = new AutoUpdateCertificatesVerifier(
new WechatPay2Credentials(WeChatConfig.MERCHANT_ID, new PrivateKeySigner(merchantSerialNumber, merchantPrivateKey)),
(WeChatConfig.API_V3_KEY).getBytes(StandardCharsets.UTF_8)
);
return verifier;
}
}

View File

@@ -122,4 +122,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="selectProductByPageType" resultMap="ProductResult">
select * from product where product_type = #{productType}
</select>
</mapper>

View File

@@ -260,7 +260,11 @@
</update>
<update id="updateDeviceIdByPhone">
update shop_user set device_id = #{deviceId} where shop_user.phone = #{phone}
update shop_user set device_id = #{deviceId}
<if test="vip != null">
,vip = #{vip}
</if>
where shop_user.phone = #{phone}
</update>
<select id="selectDeviceIdShopUserByUserIds" resultType="java.lang.String">