微信支付部分

This commit is contained in:
menxipeng
2025-11-26 22:40:03 +08:00
parent 30589acd69
commit 98565c9150
12 changed files with 500 additions and 231 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

@@ -57,8 +57,8 @@ public class ClientOrderInfoController extends BaseController
// 查询支付结果
@GetMapping("/transactions")
public AjaxResult paymentCallback(@RequestParam("transactionId") String transactionId){
return orderInfoService.findTransactions(transactionId);
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

@@ -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

@@ -8,8 +8,8 @@ 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;
@@ -23,7 +23,6 @@ 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;
@@ -157,7 +156,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
orderInfo.setOrderName(request.getOrderName());
orderInfo.setUserId(loginUser.getUserId());
Product product = productMapper.selectProductByPageType(request.getPackageType());
orderInfo.setAmount(product.getCurrentPrice());
orderInfo.setAmount(new BigDecimal("0.01"));
orderInfo.setPayType(request.getPayType());
orderInfo.setPackageType(request.getPackageType());
orderInfo.setDeviceType(request.getDeviceType());
@@ -472,9 +471,25 @@ public class OrderInfoServiceImpl implements IOrderInfoService
return AjaxResult.error("处理订单异常");
}
// 重试状态码
private static final int RETRY_CODES = 677;
@Override
public AjaxResult findTransactions(String transactionId) {
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);
}

View File

@@ -44,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包含了调起支付所需的所有参数可直接用于前端调起支付

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">