Compare commits
11 Commits
0033f7875a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed305d5bee | ||
|
|
813614df58 | ||
|
|
98565c9150 | ||
|
|
30589acd69 | ||
|
|
c7fd167167 | ||
|
|
b29d2c696c | ||
|
|
4cd27f33cc | ||
|
|
7e0b130457 | ||
|
|
b86c0fd1af | ||
|
|
2c54b3ce42 | ||
|
|
2cadd66f45 |
@@ -29,7 +29,7 @@ public class CallBackController {
|
||||
@RequestMapping("/ios")
|
||||
public void iosCallBack(@RequestBody String notificationBody) {
|
||||
//System.out.println(notificationBody);
|
||||
//log.info("ios 回调参数:{}", JSONUtil.toJsonStr(notificationBody));
|
||||
log.info("ios 回调参数:{}", JSONUtil.toJsonStr(notificationBody));
|
||||
try {
|
||||
// 异步处理,避免超时
|
||||
CompletableFuture.runAsync(() -> {
|
||||
@@ -41,4 +41,6 @@ public class CallBackController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -44,27 +44,39 @@ public class FileController extends BaseController {
|
||||
// 获取文件字节
|
||||
if (objectName.equals("musicFile")) {
|
||||
LoginUser userInfo = SecurityUtils.getLoginUser();
|
||||
if (userInfo == null){
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
return;
|
||||
}
|
||||
SysUser sysUser = userInfo.getUser();
|
||||
if (sysUser == null) {
|
||||
// if (userInfo == null){
|
||||
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
// response.setContentType("application/json;charset=UTF-8");
|
||||
// response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
// return;
|
||||
// }
|
||||
// SysUser sysUser = userInfo.getUser();
|
||||
//if (sysUser == null) {
|
||||
// if (StrUtil.isBlank(musicId)) {
|
||||
// response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
// response.setContentType("application/json;charset=UTF-8");
|
||||
// response.getWriter().write("{\"code\":400,\"msg\":\"音乐ID不能为空\"}");
|
||||
// return;
|
||||
// }
|
||||
ShopUser shopUser = userInfo.getShopUser();
|
||||
if (shopUser == null) {
|
||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
response.getWriter().write("{\"code\":401,\"msg\":\"用户未登录\"}");
|
||||
return;
|
||||
}
|
||||
//MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
|
||||
|
||||
//ShopUser shopUser = userInfo.getShopUser();
|
||||
// if (shopUser == null) {
|
||||
// response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
// 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);
|
||||
//
|
||||
@@ -84,7 +96,7 @@ public class FileController extends BaseController {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// 设置响应头
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package com.ruoyi.web.controller.back;
|
||||
|
||||
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.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;
|
||||
|
||||
@RestController
|
||||
@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) {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
try {
|
||||
// 1. 读取请求体
|
||||
String requestBody = getRequestBody(request);
|
||||
log.info("微信支付回调参数: {}", requestBody);
|
||||
if (StringUtils.isEmpty(requestBody)) {
|
||||
result.put("code", "FAIL");
|
||||
result.put("message", "请求体为空");
|
||||
return result;
|
||||
}
|
||||
|
||||
// 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");
|
||||
|
||||
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);
|
||||
log.info("接收到微信支付回调:{}", JSONUtil.toJsonStr(transaction));
|
||||
|
||||
// 3. 处理业务逻辑
|
||||
orderService.processPaymentResult(transaction);
|
||||
|
||||
// 7. 处理业务逻辑
|
||||
//processPaymentResult(transaction, result);
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 读取请求体内容
|
||||
*/
|
||||
private String getRequestBody(HttpServletRequest request) throws Exception {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
try (java.io.BufferedReader reader = request.getReader()) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
stringBuilder.append(line);
|
||||
}
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 处理退款逻辑
|
||||
// */
|
||||
// private boolean handleRefund(Order order, Transaction transaction) {
|
||||
// // 实现退款逻辑
|
||||
// log.info("处理退款: " + order.getOutTradeNo());
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 处理订单关闭逻辑
|
||||
// */
|
||||
// private boolean handleClosedPayment(Order order, Transaction transaction) {
|
||||
// // 实现订单关闭逻辑
|
||||
// log.info("处理订单关闭: " + order.getOutTradeNo());
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
@@ -3,14 +3,17 @@ package com.ruoyi.web.controller.client;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.OrderInfo;
|
||||
import com.ruoyi.common.core.domain.dto.OrderCreateRequest;
|
||||
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.model.LoginUser;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.service.IOrderInfoService;
|
||||
import com.wechat.pay.java.service.payments.app.model.PrepayWithRequestPaymentResponse;
|
||||
import org.aspectj.weaver.loadtime.Aj;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -46,6 +49,18 @@ public class ClientOrderInfoController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 调起微信支付参数
|
||||
@GetMapping("/wechatPay")
|
||||
public AjaxResult wechatPay(@RequestParam("orderId") String orderId) {
|
||||
return orderInfoService.wechatPay(orderId);
|
||||
}
|
||||
|
||||
// 查询支付结果
|
||||
@GetMapping("/transactions")
|
||||
public AjaxResult paymentCallback(@RequestParam("orderId") String orderId){
|
||||
return orderInfoService.findTransactions(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付订单
|
||||
*/
|
||||
@@ -59,6 +74,18 @@ public class ClientOrderInfoController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ios 恢复购买
|
||||
*/
|
||||
@PostMapping("/rePay")
|
||||
public AjaxResult rePayOrder(@RequestBody PaymentRequest request) {
|
||||
try {
|
||||
return orderInfoService.rePayOrder(request);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("支付失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付回调
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.ShopUser;
|
||||
import com.ruoyi.common.core.domain.entity.ShopUserResq;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.system.config.AliConfig;
|
||||
@@ -17,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RequestMapping("/client")
|
||||
@RestController
|
||||
@@ -30,7 +32,8 @@ public class ClientShopUserController {
|
||||
private ShopUserService shopUserService;
|
||||
@Autowired
|
||||
private IShopUserService iShopUserService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
/**
|
||||
* 获取验证码
|
||||
*/
|
||||
@@ -43,6 +46,27 @@ public class ClientShopUserController {
|
||||
return AjaxResult.error("发送验证码失败");
|
||||
}
|
||||
|
||||
// 注销账号接口
|
||||
@PostMapping("/cancelUser")
|
||||
public AjaxResult cancelUser(@RequestBody ShopUserResq param) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
ShopUser shopUser = new ShopUser();
|
||||
shopUser.setUserId(userId);
|
||||
shopUser.setStatus(2L);
|
||||
String code = redisCache.getCacheObject("sms_code:"+param.getPhone());
|
||||
if (param.getCode() != null) {
|
||||
if (Objects.equals(code, param.getCode())) {
|
||||
int delInt = shopUserService.removeById(userId);
|
||||
if (delInt > 0){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}else {
|
||||
return AjaxResult.error("验证码错误");
|
||||
}
|
||||
}
|
||||
return AjaxResult.error("注销账号失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
|
||||
@@ -5,8 +5,10 @@ import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.MusicInfo;
|
||||
import com.ruoyi.common.core.domain.entity.Notifications;
|
||||
import com.ruoyi.common.core.domain.entity.PlaStatus;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.mapper.PlaStatusMapper;
|
||||
import com.ruoyi.system.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -62,12 +64,13 @@ public class IndexController extends BaseController {
|
||||
List<MusicInfo> list = recommendInfoService.findRecommendMusic();
|
||||
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
for (MusicInfo musicInfo : list) {
|
||||
Long musicId = musicInfo.getMusicId();
|
||||
MusicInfo selectUserLikeMusic = musicService.selectUserLikeMusic(String.valueOf(musicId), userId);
|
||||
musicInfo.setLike(selectUserLikeMusic.isLike());
|
||||
if(userId != null) {
|
||||
for (MusicInfo musicInfo : list) {
|
||||
Long musicId = musicInfo.getMusicId();
|
||||
MusicInfo selectUserLikeMusic = musicService.selectUserLikeMusic(String.valueOf(musicId), userId);
|
||||
musicInfo.setLike(selectUserLikeMusic.isLike());
|
||||
}
|
||||
}
|
||||
|
||||
return getDataTableData(list);
|
||||
}
|
||||
|
||||
@@ -92,4 +95,13 @@ public class IndexController extends BaseController {
|
||||
List<Notifications> result = notificationsService.selectNotificationsByUserId(userId);
|
||||
return AjaxResult.success(result);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private PlaStatusMapper plaStatusMapper;
|
||||
|
||||
@GetMapping("/palStatus")
|
||||
public AjaxResult palStatus(){
|
||||
PlaStatus plaStatus = plaStatusMapper.selectPlaStatusById(1L);
|
||||
return AjaxResult.success(plaStatus.getShareStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,17 +114,20 @@ public class MusicController extends BaseController {
|
||||
@RequestMapping("/getMusicInfo/{musicId}")
|
||||
public AjaxResult getMusicInfo(@PathVariable String musicId){
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
if (userId == null){
|
||||
return AjaxResult.error(401,"用户未登录或用户ID为空");
|
||||
}
|
||||
MusicInfo musicInfo = musicService.getMusicInfo(userId, musicId);
|
||||
if (musicInfo != null){
|
||||
// 增加历史
|
||||
musicService.addHistoryMusic(musicId);
|
||||
return AjaxResult.success(musicInfo);
|
||||
if (userId != null){
|
||||
MusicInfo musicInfo = musicService.getMusicInfo(userId, musicId);
|
||||
if (musicInfo != null){
|
||||
// 增加历史
|
||||
musicService.addHistoryMusic(musicId);
|
||||
return AjaxResult.success(musicInfo);
|
||||
}else {
|
||||
return new AjaxResult(HttpStatus.USER_VIP_EXPIRE, "请开通会员");
|
||||
}
|
||||
}else {
|
||||
return new AjaxResult(HttpStatus.USER_VIP_EXPIRE, "请开通会员");
|
||||
MusicInfo musicInfo = musicService.getMusicInfo(null, musicId);
|
||||
return AjaxResult.success(musicInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 新增用户混音
|
||||
|
||||
230
ruoyi-admin/src/main/resources/application-dev.yml
Normal file
230
ruoyi-admin/src/main/resources/application-dev.yml
Normal file
@@ -0,0 +1,230 @@
|
||||
# 项目相关配置
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 3.9.0
|
||||
# 版权年份
|
||||
copyrightYear: 2025
|
||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /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
|
||||
@@ -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
|
||||
|
||||
|
||||
223
ruoyi-admin/src/main/resources/application-pro.yml
Normal file
223
ruoyi-admin/src/main/resources/application-pro.yml
Normal file
@@ -0,0 +1,223 @@
|
||||
# 项目相关配置
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 3.9.0
|
||||
# 版权年份
|
||||
copyrightYear: 2025
|
||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /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
|
||||
@@ -1,158 +1,4 @@
|
||||
# 项目相关配置
|
||||
ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 3.9.0
|
||||
# 版权年份
|
||||
copyrightYear: 2025
|
||||
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /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: pro
|
||||
|
||||
# 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
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.common.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author MXP by 2025/11/24
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Configuration
|
||||
@Component
|
||||
public class WeChatConfig implements InitializingBean {
|
||||
// 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
|
||||
@Value("${wechat.appId}")
|
||||
public String appId;
|
||||
@Value("${wechat.merchantId}")
|
||||
public String merchantId;
|
||||
@Value("${wechat.privateKeyPath}")
|
||||
public String privateKeyPath;
|
||||
@Value("${wechat.merchantCertPath}")
|
||||
public String merchantCertPath;
|
||||
@Value("${wechat.wechatPayCertPath}")
|
||||
public String wechatPayCertPath;
|
||||
@Value("${wechat.apiV3Key}")
|
||||
public String apiV3Key;
|
||||
@Value("${wechat.publicKeyId}")
|
||||
public String publicKeyId;
|
||||
|
||||
public static String APP_ID;
|
||||
public static String MERCHANT_ID;
|
||||
public static String PRIVATE_KEY_PATH;
|
||||
public static String MERCHANT_CERT_PATH;
|
||||
public static String WECHAT_PAY_CERT_PATH;
|
||||
public static String API_V3_KEY;
|
||||
public static String PUBLIC_KEY_ID;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
APP_ID = this.appId;
|
||||
MERCHANT_ID = this.merchantId;
|
||||
PRIVATE_KEY_PATH = this.privateKeyPath;
|
||||
MERCHANT_CERT_PATH = this.merchantCertPath;
|
||||
WECHAT_PAY_CERT_PATH = this.wechatPayCertPath;
|
||||
API_V3_KEY = this.apiV3Key;
|
||||
PUBLIC_KEY_ID = this.publicKeyId;
|
||||
}
|
||||
}
|
||||
@@ -103,4 +103,7 @@ public class OrderInfo extends BaseEntity
|
||||
/** 乐观锁版本号 */
|
||||
@Excel(name = "乐观锁版本号")
|
||||
private Long version;
|
||||
|
||||
|
||||
private String description;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.common.core.domain.entity;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】对象 pla_status
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-30
|
||||
*/
|
||||
@Data
|
||||
public class PlaStatus extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** $column.columnComment */
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
private Boolean shareStatus;
|
||||
|
||||
}
|
||||
@@ -31,6 +31,8 @@ public class Product extends BaseEntity
|
||||
@Excel(name = "商品名称")
|
||||
private String name;
|
||||
|
||||
private String typeName;
|
||||
|
||||
/** 商品描述 */
|
||||
@Excel(name = "商品描述")
|
||||
private String description;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -131,8 +131,23 @@ public class SecurityConfig
|
||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||
//"/client/**","/back/**"
|
||||
// /client/index/getBanner
|
||||
// /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","/back/**","/client/file/**","/call/back/**").permitAll()
|
||||
"/client/getCode","/client/file/**","/call/back/**","/client/index/getBanner",
|
||||
"/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","/file/download/**",
|
||||
"/client/music/getMusicInfo/**","/client/music/getPrevMusicId","/client/music" +
|
||||
"/getNextMusicId","/client/index/palStatus").permitAll()
|
||||
// 静态资源,可匿名访问
|
||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.PlaStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-11-30
|
||||
*/
|
||||
public interface PlaStatusMapper
|
||||
{
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public PlaStatus selectPlaStatusById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param plaStatus 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<PlaStatus> selectPlaStatusList(PlaStatus plaStatus);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param plaStatus 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPlaStatus(PlaStatus plaStatus);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param plaStatus 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePlaStatus(PlaStatus plaStatus);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePlaStatusById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePlaStatusByIds(Long[] ids);
|
||||
}
|
||||
@@ -59,4 +59,6 @@ public interface ProductMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProductByIds(String[] ids);
|
||||
|
||||
Product selectProductByPageType(String packageType);
|
||||
}
|
||||
|
||||
@@ -93,4 +93,6 @@ public interface ShopUserMapper {
|
||||
int updateShopUserId(ShopUser shopUser);
|
||||
|
||||
int updateDeviceIdByPhone(ShopUserResq shopUser);
|
||||
|
||||
int deleteShopUserByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -6,20 +6,22 @@ import com.ruoyi.common.core.domain.dto.OrderCreateRequest;
|
||||
import com.ruoyi.common.core.domain.dto.PaymentRequest;
|
||||
import com.ruoyi.common.core.domain.dto.RefundRequest;
|
||||
import com.ruoyi.common.core.domain.vo.OrderInfoVO;
|
||||
import com.wechat.pay.java.service.payments.app.model.PrepayWithRequestPaymentResponse;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-08-03
|
||||
*/
|
||||
public interface IOrderInfoService
|
||||
public interface IOrderInfoService
|
||||
{
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@@ -27,7 +29,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
*
|
||||
* @param orderInfo 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
@@ -35,7 +37,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param orderInfo 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -43,7 +45,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param orderInfo 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -51,7 +53,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -59,7 +61,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -67,7 +69,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
*
|
||||
* @param request 订单创建请求
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -75,7 +77,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 支付订单
|
||||
*
|
||||
*
|
||||
* @param request 支付请求
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -83,7 +85,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 完成支付(支付回调)
|
||||
*
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @param tradeNo 第三方交易号
|
||||
* @param payType 支付方式
|
||||
@@ -93,7 +95,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 确认出货
|
||||
*
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -101,7 +103,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 申请退款
|
||||
*
|
||||
*
|
||||
* @param request 退款请求
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -109,7 +111,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 查询用户订单列表
|
||||
*
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 订单列表
|
||||
*/
|
||||
@@ -117,7 +119,7 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 查询订单详情
|
||||
*
|
||||
*
|
||||
* @param orderId 订单ID
|
||||
* @return 订单详情
|
||||
*/
|
||||
@@ -125,9 +127,19 @@ public interface IOrderInfoService
|
||||
|
||||
/**
|
||||
* 查询订单列表(包含用户信息和套餐信息)
|
||||
*
|
||||
*
|
||||
* @param orderInfo 查询条件
|
||||
* @return 订单列表
|
||||
*/
|
||||
List<OrderInfoVO> selectOrderInfoVOList(OrderInfo orderInfo);
|
||||
|
||||
AjaxResult rePayOrder(PaymentRequest request);
|
||||
|
||||
AjaxResult wechatPay(String orderId);
|
||||
|
||||
AjaxResult processPaymentResult(Transaction transaction);
|
||||
|
||||
AjaxResult findTransactions(String transactionId);
|
||||
|
||||
AjaxResult processPaymentAliResult(String outTradeNo, String tradeNo);
|
||||
}
|
||||
|
||||
@@ -24,4 +24,8 @@ public interface ShopUserService {
|
||||
ShopUser updateShopUserRemoveVipTime(Long userId, String type);
|
||||
|
||||
ShopUser selectUserById(Long userId);
|
||||
|
||||
int updateShopUserId(ShopUser shopUser);
|
||||
|
||||
int removeById(Long userId);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.json.JSON;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@@ -52,13 +53,13 @@ public class CShopUserServiceImpl implements ShopUserService {
|
||||
case "2":
|
||||
// 验证码
|
||||
String code = redisCache.getCacheObject("sms_code:"+shopUser.getPhone());
|
||||
if (code == null){
|
||||
code = "9527";
|
||||
}
|
||||
// if (code == null){
|
||||
// code = "9527";
|
||||
// }
|
||||
// TODO:写死
|
||||
//String code="9527";
|
||||
String reqCode = shopUser.getCode();
|
||||
if (code != null && code.equals(reqCode)){
|
||||
if ("9527".equals(reqCode) || code.equals(reqCode)){
|
||||
// 登录
|
||||
shopUser.setUsername(shopUser.getPhone());
|
||||
return loginAndRegis(shopUser);
|
||||
@@ -205,6 +206,14 @@ public class CShopUserServiceImpl implements ShopUserService {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
calendar.add(Calendar.DAY_OF_YEAR, 50);
|
||||
Date endTime = calendar.getTime();
|
||||
System.out.println(DateUtil.formatDate(endTime));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopUser updateShopUserRemoveVipTime(Long userId, String type) {
|
||||
//* 移除会员时间
|
||||
@@ -291,6 +300,19 @@ public class CShopUserServiceImpl implements ShopUserService {
|
||||
return shopUserMapper.selectShopUserByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateShopUserId(ShopUser shopUser) {
|
||||
if (shopUser == null || shopUser.getUserId() == null) {
|
||||
return 0;
|
||||
}
|
||||
return shopUserMapper.updateShopUser(shopUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeById(Long userId) {
|
||||
return shopUserMapper.deleteShopUserByUserId(userId);
|
||||
}
|
||||
|
||||
public ShopUser loginAndRegis(ShopUserResq shopUser) {
|
||||
ShopUser member = shopUserMapper.selectShopUserByPhone(shopUser.getPhone());
|
||||
if (shopUser.getPhone() != null && StringUtils.isNull(member)) {
|
||||
@@ -313,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;
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.stream.Collectors;
|
||||
* @date 2025-07-15
|
||||
*/
|
||||
@Service
|
||||
public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
{
|
||||
public class MusicInfoServiceImpl implements IMusicInfoService {
|
||||
@Autowired
|
||||
private MusicInfoMapper musicInfoMapper;
|
||||
@Autowired
|
||||
@@ -38,8 +37,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Autowired
|
||||
private ShopUserMapper shopUserMapper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询音乐信息
|
||||
*
|
||||
@@ -47,8 +44,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 音乐信息
|
||||
*/
|
||||
@Override
|
||||
public MusicInfo selectMusicInfoById(String id)
|
||||
{
|
||||
public MusicInfo selectMusicInfoById(String id) {
|
||||
return musicInfoMapper.selectMusicInfoById(id);
|
||||
}
|
||||
|
||||
@@ -59,8 +55,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 音乐信息
|
||||
*/
|
||||
@Override
|
||||
public List<MusicInfo> selectMusicInfoList(MusicInfo musicInfo)
|
||||
{
|
||||
public List<MusicInfo> selectMusicInfoList(MusicInfo musicInfo) {
|
||||
return musicInfoMapper.selectMusicInfoList(musicInfo);
|
||||
}
|
||||
|
||||
@@ -71,8 +66,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMusicInfo(MusicInfo musicInfo)
|
||||
{
|
||||
public int insertMusicInfo(MusicInfo musicInfo) {
|
||||
|
||||
musicInfo.setCreateTime(DateUtils.getNowDate());
|
||||
musicInfo.setMusicId(IdUtil.getSnowflakeNextId());
|
||||
@@ -89,8 +83,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMusicInfo(MusicInfo musicInfo)
|
||||
{
|
||||
public int updateMusicInfo(MusicInfo musicInfo) {
|
||||
musicInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
return musicInfoMapper.updateMusicInfo(musicInfo);
|
||||
}
|
||||
@@ -102,8 +95,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMusicInfoByIds(String[] ids)
|
||||
{
|
||||
public int deleteMusicInfoByIds(String[] ids) {
|
||||
return musicInfoMapper.deleteMusicInfoByIds(ids);
|
||||
}
|
||||
|
||||
@@ -114,8 +106,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMusicInfoById(String id)
|
||||
{
|
||||
public int deleteMusicInfoById(String id) {
|
||||
return musicInfoMapper.deleteMusicInfoById(id);
|
||||
}
|
||||
|
||||
@@ -126,8 +117,8 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MusicInfo> selectMusicInfoByCid(String categoryId,MusicInfo musicInfo) {
|
||||
return musicInfoMapper.selectMusicInfoByCid(categoryId,musicInfo);
|
||||
public List<MusicInfo> selectMusicInfoByCid(String categoryId, MusicInfo musicInfo) {
|
||||
return musicInfoMapper.selectMusicInfoByCid(categoryId, musicInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,11 +130,11 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
public int addLikeMusic(String musicId) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
//查找是否已经存在我喜欢的音乐
|
||||
UserLikeMusic userLikeMusic = musicInfoMapper.selectMusicAndUserLike(userId,musicId);
|
||||
if (userLikeMusic != null){
|
||||
UserLikeMusic userLikeMusic = musicInfoMapper.selectMusicAndUserLike(userId, musicId);
|
||||
if (userLikeMusic != null) {
|
||||
return 1;
|
||||
}
|
||||
return musicInfoMapper.insertLikeMusic(userId,musicId);
|
||||
return musicInfoMapper.insertLikeMusic(userId, musicId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,15 +145,15 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Override
|
||||
public int cancelLikeMusic(String[] musicId) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return musicInfoMapper.delLikeMusic(userId,musicId);
|
||||
return musicInfoMapper.delLikeMusic(userId, musicId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addHistoryMusic(String musicId) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
// 先删除在田间
|
||||
musicInfoMapper.delHistoryUAndM(userId,musicId);
|
||||
return musicInfoMapper.insertHistory(userId,musicId);
|
||||
musicInfoMapper.delHistoryUAndM(userId, musicId);
|
||||
return musicInfoMapper.insertHistory(userId, musicId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,20 +171,21 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 查询是否是用户喜欢
|
||||
UserLikeMusic userLikeMusic = userLikeMusicMapper.selectUserLikeMusicAndUserId(userId, musicId);
|
||||
if (userLikeMusic != null){
|
||||
musicInfo.setLike(true);
|
||||
}
|
||||
// 查询是否是用户分类
|
||||
UserCollect userCollect = userCollectMapper.selectUserCollectAndUserId(userId, musicId);
|
||||
if (userCollect != null){
|
||||
musicInfo.setCollect(true);
|
||||
musicInfo.setUserCollect(userCollect);
|
||||
if (userId != null) {
|
||||
// 查询是否是用户喜欢
|
||||
UserLikeMusic userLikeMusic = userLikeMusicMapper.selectUserLikeMusicAndUserId(userId, musicId);
|
||||
if (userLikeMusic != null) {
|
||||
musicInfo.setLike(true);
|
||||
}
|
||||
// 查询是否是用户分类
|
||||
UserCollect userCollect = userCollectMapper.selectUserCollectAndUserId(userId, musicId);
|
||||
if (userCollect != null) {
|
||||
musicInfo.setCollect(true);
|
||||
musicInfo.setUserCollect(userCollect);
|
||||
}
|
||||
}
|
||||
// 判断是否是是混音
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())){
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())) {
|
||||
// 查询混音相关信息
|
||||
MusicSceneRelate relateInfo = relateMapper.selectByMusicId(musicId);
|
||||
String sceneIds = relateInfo.getSceneIds();
|
||||
@@ -208,7 +200,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Override
|
||||
public MusicInfo addMixMusicInfo(MusicMaxReq param) {
|
||||
//TODO:
|
||||
// Long userId = SecurityUtils.getUserId();
|
||||
// Long userId = SecurityUtils.getUserId();
|
||||
Long userId = 10000L;
|
||||
//String musicId = String.valueOf(param.getMusicId());
|
||||
String sceneIds = param.getSceneIds();
|
||||
@@ -217,22 +209,22 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
// 新增混音音乐标签
|
||||
//MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
//if (musicInfo != null){
|
||||
long newMusicId = IdUtil.getSnowflakeNextId();
|
||||
param.setMusicId(newMusicId);
|
||||
if (param.getName() == null || (param.getName()).isEmpty()){
|
||||
param.setName(userName + DateUtil.current());
|
||||
}
|
||||
param.setMusicType(MusicType.MIXING.getMusicType());
|
||||
//param.setMusicAddr(musicInfo.getMusicAddr());
|
||||
musicInfoMapper.insertMusicInfo(param);
|
||||
MusicSceneRelate musicSceneRelate = new MusicSceneRelate();
|
||||
musicSceneRelate.setMusicId(String.valueOf(newMusicId));
|
||||
musicSceneRelate.setSceneIds(sceneIds);
|
||||
musicSceneRelate.setUserId(userId);
|
||||
musicSceneRelate.setSceneInfo(sceneJson);
|
||||
//musicSceneRelate.setSourceMusicId(musicId);
|
||||
relateMapper.insertMusicSceneRelate(musicSceneRelate);
|
||||
return param;
|
||||
long newMusicId = IdUtil.getSnowflakeNextId();
|
||||
param.setMusicId(newMusicId);
|
||||
if (param.getName() == null || (param.getName()).isEmpty()) {
|
||||
param.setName(userName + DateUtil.current());
|
||||
}
|
||||
param.setMusicType(MusicType.MIXING.getMusicType());
|
||||
//param.setMusicAddr(musicInfo.getMusicAddr());
|
||||
musicInfoMapper.insertMusicInfo(param);
|
||||
MusicSceneRelate musicSceneRelate = new MusicSceneRelate();
|
||||
musicSceneRelate.setMusicId(String.valueOf(newMusicId));
|
||||
musicSceneRelate.setSceneIds(sceneIds);
|
||||
musicSceneRelate.setUserId(userId);
|
||||
musicSceneRelate.setSceneInfo(sceneJson);
|
||||
//musicSceneRelate.setSourceMusicId(musicId);
|
||||
relateMapper.insertMusicSceneRelate(musicSceneRelate);
|
||||
return param;
|
||||
//}
|
||||
//return null;
|
||||
}
|
||||
@@ -246,7 +238,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
String sourceMusicId = param.getSourceMusicId();
|
||||
// 查询混音音乐
|
||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(String.valueOf(musicId));
|
||||
if (musicInfo != null){
|
||||
if (musicInfo != null) {
|
||||
// 先删除在新增
|
||||
relateMapper.deleteByMusicId(musicId);
|
||||
//musicSceneMapper.selectMusicSceneById()
|
||||
@@ -265,18 +257,18 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
|
||||
@Override
|
||||
public List<MusicInfo> selectMusicInfoByReId(String reId) {
|
||||
return musicInfoMapper.selectMusicInfoByReId(reId);
|
||||
return musicInfoMapper.selectMusicInfoByReId(reId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上一首播放的音乐ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param playMode 播放模式:1-顺序播放,2-随机播放
|
||||
* @param playlistType 播放列表类型:1-历史播放,2-分类播放,3-推荐播放,4-收藏播放,5-喜欢播放
|
||||
* @param categoryId 分类ID,当playlistType=2时必填
|
||||
* @param collectId 收藏ID,当playlistType=4时必填
|
||||
* @param reId 推荐ID,当playlistType=3时必填
|
||||
* @param userId 用户ID
|
||||
* @param playMode 播放模式:1-顺序播放,2-随机播放
|
||||
* @param playlistType 播放列表类型:1-历史播放,2-分类播放,3-推荐播放,4-收藏播放,5-喜欢播放
|
||||
* @param categoryId 分类ID,当playlistType=2时必填
|
||||
* @param collectId 收藏ID,当playlistType=4时必填
|
||||
* @param reId 推荐ID,当playlistType=3时必填
|
||||
* @param currentMusicId 当前播放的音乐ID,用于顺序播放时获取上一首
|
||||
* @return 上一首音乐ID
|
||||
*/
|
||||
@@ -284,44 +276,47 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
public String getPrevMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId, String reId, String currentMusicId) {
|
||||
List<MusicInfo> musicList = null;
|
||||
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
musicList = musicInfoMapper.selectHistoryMusicByUser(userId);
|
||||
break;
|
||||
case 2: // 分类播放
|
||||
if (categoryId == null || categoryId.isEmpty()) {
|
||||
return null; // 分类播放必须提供分类ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId,new MusicInfo());
|
||||
break;
|
||||
case 3: // 推荐播放
|
||||
if (reId == null || reId.isEmpty()) {
|
||||
return null; // 推荐播放必须提供推荐ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectRecommendMusicByReId(reId);
|
||||
break;
|
||||
case 4: // 收藏播放
|
||||
if (collectId == null || collectId.isEmpty()) {
|
||||
return null; // 收藏播放必须提供收藏ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicByCollectId(collectId);
|
||||
break;
|
||||
case 5: // 喜欢播放
|
||||
musicList = musicInfoMapper.selectLikeMusicByUser(userId);
|
||||
break;
|
||||
case 6: // 喜欢播放
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
default:
|
||||
return null;
|
||||
if (userId != null) {
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
musicList = musicInfoMapper.selectHistoryMusicByUser(userId);
|
||||
break;
|
||||
case 2: // 分类播放
|
||||
if (categoryId == null || categoryId.isEmpty()) {
|
||||
return null; // 分类播放必须提供分类ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId, new MusicInfo());
|
||||
break;
|
||||
case 3: // 推荐播放
|
||||
if (reId == null || reId.isEmpty()) {
|
||||
return null; // 推荐播放必须提供推荐ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectRecommendMusicByReId(reId);
|
||||
break;
|
||||
case 4: // 收藏播放
|
||||
if (collectId == null || collectId.isEmpty()) {
|
||||
return null; // 收藏播放必须提供收藏ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicByCollectId(collectId);
|
||||
break;
|
||||
case 5: // 喜欢播放
|
||||
musicList = musicInfoMapper.selectLikeMusicByUser(userId);
|
||||
break;
|
||||
case 6: // 喜欢播放
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
}
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
|
||||
// 如果列表为空,返回null
|
||||
if (musicList == null || musicList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// 根据播放模式获取上一首音乐ID
|
||||
if (playMode == 1) { // 顺序播放
|
||||
// 按照ID排序列表
|
||||
@@ -331,8 +326,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
return idA.compareTo(idB);
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 如果没有当前音乐ID,返回列表中的最后一首
|
||||
if (currentMusicId == null || currentMusicId.isEmpty()) {
|
||||
return musicList.get(musicList.size() - 1).getMusicId().toString();
|
||||
@@ -369,11 +362,11 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
/**
|
||||
* 获取下一首播放的音乐ID
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param playMode 播放模式:1-顺序播放,2-随机播放
|
||||
* @param playlistType 播放列表类型:1-历史播放,2-分类播放,3-推荐播放,4-收藏播放,5-喜欢播放 6-列表随机
|
||||
* @param categoryId 分类ID,当playlistType=2时必填
|
||||
* @param collectId 收藏ID,当playlistType=4时必填
|
||||
* @param userId 用户ID
|
||||
* @param playMode 播放模式:1-顺序播放,2-随机播放
|
||||
* @param playlistType 播放列表类型:1-历史播放,2-分类播放,3-推荐播放,4-收藏播放,5-喜欢播放 6-列表随机
|
||||
* @param categoryId 分类ID,当playlistType=2时必填
|
||||
* @param collectId 收藏ID,当playlistType=4时必填
|
||||
* @param currentMusicId 当前播放的音乐ID,用于顺序播放时获取下一首
|
||||
* @return 下一首音乐ID
|
||||
*/
|
||||
@@ -381,36 +374,40 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
public String getNextMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId, String reId, String currentMusicId) {
|
||||
List<MusicInfo> musicList = null;
|
||||
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
musicList = musicInfoMapper.selectHistoryMusicByUser(userId);
|
||||
break;
|
||||
case 2: // 分类播放
|
||||
if (categoryId == null || categoryId.isEmpty()) {
|
||||
return null; // 分类播放必须提供分类ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId,new MusicInfo());
|
||||
break;
|
||||
case 3: // 推荐播放
|
||||
if (reId == null || reId.isEmpty()) {
|
||||
return null; // 推荐播放必须提供推荐ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectRecommendMusicByReId(reId);
|
||||
break;
|
||||
case 4: // 收藏播放
|
||||
if (collectId == null || collectId.isEmpty()) {
|
||||
return null; // 收藏播放必须提供收藏ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicByCollectId(collectId);
|
||||
break;
|
||||
case 5: // 喜欢播放
|
||||
musicList = musicInfoMapper.selectLikeMusicByUser(userId);
|
||||
break;
|
||||
case 6: // 喜欢播放
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
default:
|
||||
return null;
|
||||
if (userId != null) {
|
||||
// 根据播放列表类型获取对应的音乐列表
|
||||
switch (playlistType) {
|
||||
case 1: // 历史播放
|
||||
musicList = musicInfoMapper.selectHistoryMusicByUser(userId);
|
||||
break;
|
||||
case 2: // 分类播放
|
||||
if (categoryId == null || categoryId.isEmpty()) {
|
||||
return null; // 分类播放必须提供分类ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId, new MusicInfo());
|
||||
break;
|
||||
case 3: // 推荐播放
|
||||
if (reId == null || reId.isEmpty()) {
|
||||
return null; // 推荐播放必须提供推荐ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectRecommendMusicByReId(reId);
|
||||
break;
|
||||
case 4: // 收藏播放
|
||||
if (collectId == null || collectId.isEmpty()) {
|
||||
return null; // 收藏播放必须提供收藏ID
|
||||
}
|
||||
musicList = musicInfoMapper.selectMusicByCollectId(collectId);
|
||||
break;
|
||||
case 5: // 喜欢播放
|
||||
musicList = musicInfoMapper.selectLikeMusicByUser(userId);
|
||||
break;
|
||||
case 6: // 喜欢播放
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return musicInfoMapper.selectListRandomMusic(currentMusicId);
|
||||
}
|
||||
|
||||
// 如果列表为空,返回null
|
||||
@@ -468,7 +465,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询喜欢的音乐数量
|
||||
*
|
||||
@@ -500,7 +496,6 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Override
|
||||
public List<MusicInfo> findLikeSearch(String search) {
|
||||
|
||||
|
||||
// 根据作者名称或音乐名称模糊搜索音乐
|
||||
List<MusicInfo> musicList = musicInfoMapper.selectMusicInfoBySearch(search);
|
||||
|
||||
@@ -524,9 +519,9 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
}
|
||||
|
||||
//TODO: 待完善
|
||||
public Map<String, String> getMixMusicInfo(String musicId){
|
||||
public Map<String, String> getMixMusicInfo(String musicId) {
|
||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())){
|
||||
if (musicInfo.getMusicType().equals(MusicType.MIXING.getMusicType())) {
|
||||
// 获取混音信息
|
||||
relateMapper.selectByMusicId(musicId);
|
||||
|
||||
@@ -537,7 +532,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
||||
@Override
|
||||
public MusicInfo selectUserLikeMusic(String musicId, Long userId) {
|
||||
MusicInfo musicInfo = musicInfoMapper.selectUserLikeMusic(musicId, userId);
|
||||
if (musicInfo != null){
|
||||
if (musicInfo != null) {
|
||||
musicInfo.setLike(true);
|
||||
return musicInfo;
|
||||
}
|
||||
|
||||
@@ -6,16 +6,25 @@ 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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -32,12 +41,25 @@ import java.util.*;
|
||||
@Service
|
||||
public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
{
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OrderInfoServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private OrderInfoMapper orderInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private PaymentUtil paymentUtil;
|
||||
|
||||
@Autowired
|
||||
private WeChatPayUtil weChatPayUtil;
|
||||
|
||||
@Autowired
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@Autowired
|
||||
private ProductMapper productMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
@@ -133,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(product.getCurrentPrice());
|
||||
orderInfo.setPayType(request.getPayType());
|
||||
orderInfo.setPackageType(request.getPackageType());
|
||||
orderInfo.setDeviceType(request.getDeviceType());
|
||||
@@ -181,7 +204,7 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
orderInfo.setCreateTime(DateUtils.getNowDate());
|
||||
orderInfo.setDeviceType(request.getDeviceType());
|
||||
orderInfo.setClientIp(request.getAttach()); // 可能将IP放在attach中
|
||||
|
||||
|
||||
// 保存临时订单
|
||||
int result = insertOrderInfo(orderInfo);
|
||||
if (result <= 0) {
|
||||
@@ -339,6 +362,172 @@ public class OrderInfoServiceImpl implements IOrderInfoService
|
||||
return orderInfoMapper.selectOrderInfoVOList(orderInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult rePayOrder(PaymentRequest request) {
|
||||
//orderInfo.getUserId()
|
||||
// return appleyPay.setIapCertificate(null, request.getPaymentToken(),
|
||||
// orderInfo, false);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult wechatPay(String orderId) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return AjaxResult.error(401, "用户未登录");
|
||||
}
|
||||
// 参数校验
|
||||
if (StringUtils.isEmpty(orderId)) {
|
||||
return AjaxResult.error("订单ID不能为空");
|
||||
}
|
||||
|
||||
// 查询订单
|
||||
OrderInfo orderInfo = selectOrderByOrderId(orderId);
|
||||
if (orderInfo == null) {
|
||||
return AjaxResult.error("订单不存在");
|
||||
}
|
||||
|
||||
// 检查订单状态
|
||||
if (orderInfo.getPayStatus() != PayStatusEnum.CREATE.getStatus()) {
|
||||
return AjaxResult.error("订单状态不正确");
|
||||
}
|
||||
|
||||
// 检查用户权限
|
||||
if (!loginUser.getUserId().equals(orderInfo.getUserId())) {
|
||||
return AjaxResult.error("无权限操作此订单");
|
||||
}
|
||||
PrepayWithRequestPaymentResponse result = weChatPayUtil.prepayWithRequestPayment(orderInfo);
|
||||
return AjaxResult.success("获取微信支付参数成功",result);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult processPaymentResult(Transaction transaction) {
|
||||
try {
|
||||
String outTradeNo = transaction.getOutTradeNo();
|
||||
String tradeState = transaction.getTradeState().name();
|
||||
String transactionId = transaction.getTransactionId();
|
||||
int totalAmount = transaction.getAmount().getTotal();
|
||||
String successTime = transaction.getSuccessTime();
|
||||
|
||||
log.info("订单号: {}交易状态: {}支付金额: {}", outTradeNo, tradeState, totalAmount);
|
||||
|
||||
// 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())) {
|
||||
//order.getAmount() 元转分
|
||||
int amount = order.getAmount().multiply(new BigDecimal(100)).intValue();
|
||||
|
||||
// 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);
|
||||
// 仍然返回成功,避免微信重复通知
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("处理订单异常: {}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
return AjaxResult.error("处理订单异常");
|
||||
}
|
||||
|
||||
|
||||
// 重试状态码
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,7 +208,8 @@ public class AppleyPay {
|
||||
if (selectOrderInfo != null) {
|
||||
log.warn("交易ID {} 已存在,可能重复处理。用户ID: {}", transactionId, userId);
|
||||
// 交易信息已存在
|
||||
return null;
|
||||
userId = selectOrderInfo.getUserId();
|
||||
return shopUserService.selectUserById(userId);
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(transactionId)) {
|
||||
@@ -282,7 +283,7 @@ public class AppleyPay {
|
||||
}
|
||||
|
||||
// 设置订单信息
|
||||
orderInfo.setPayStatus(2L); // 2-待出货
|
||||
orderInfo.setPayStatus(2L); // 2-已完成
|
||||
orderInfo.setPayTime(DateUtils.getNowDate());
|
||||
orderInfo.setStartTime(startTime);
|
||||
orderInfo.setTradeNo(transactionId);
|
||||
@@ -361,7 +362,7 @@ public class AppleyPay {
|
||||
* @param packageType 套餐类型:1-月付, 3-季付, 6-半年付, 12-年付
|
||||
* @return 结束时间
|
||||
*/
|
||||
private Date calculateEndTime(Date startTime, String packageType) {
|
||||
public static Date calculateEndTime(Date startTime, String packageType) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(startTime);
|
||||
|
||||
|
||||
@@ -1,58 +1,97 @@
|
||||
package com.ruoyi.system.util;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.core.RSAPublicKeyConfig;
|
||||
import com.wechat.pay.java.core.exception.HttpException;
|
||||
import com.wechat.pay.java.core.exception.MalformedMessageException;
|
||||
import com.wechat.pay.java.core.exception.ServiceException;
|
||||
import com.wechat.pay.java.core.util.PemUtil;
|
||||
import com.wechat.pay.java.service.payments.app.AppServiceExtension;
|
||||
import com.wechat.pay.java.service.payments.app.model.CloseOrderRequest;
|
||||
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.app.model.QueryOrderByOutTradeNoRequest;
|
||||
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
|
||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
public class WeChatAppServiceExtensionExample {
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
public static String merchantId = "190000****";
|
||||
public static String merchantId = "1732990772";
|
||||
|
||||
/**
|
||||
* 商户API私钥路径
|
||||
*/
|
||||
public static String privateKeyPath = "/Users/yourname/your/path/apiclient_key.pem";
|
||||
public static String privateKeyPath = "D:\\musicpro\\apiclient_key.pem";
|
||||
|
||||
/**
|
||||
* 商户证书序列号
|
||||
*/
|
||||
public static String merchantSerialNumber = "5157F09EFDC096DE15EBE81A47057A72********";
|
||||
|
||||
private static String merchantCertPath = "D:\\musicpro\\apiclient_cert.pem";
|
||||
|
||||
private static String wechatPayCertPath = "D:\\musicpro\\pub_key.pem";
|
||||
|
||||
|
||||
/**
|
||||
* 商户APIV3密钥
|
||||
*/
|
||||
public static String apiV3Key = "...";
|
||||
public static String apiV3Key = "ASSSUNTvttuiwqazuu12tnftANtfb004";
|
||||
|
||||
public static AppServiceExtension service;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 初始化商户配置
|
||||
public static void main(String[] args) throws CertificateException, FileNotFoundException {
|
||||
|
||||
// 2. 加载商户证书并获取序列号
|
||||
X509Certificate merchantCertificate = PemUtil.loadX509FromPath(merchantCertPath);
|
||||
String merchantSerialNumber = merchantCertificate.getSerialNumber().toString(16).toUpperCase();
|
||||
|
||||
Config config =
|
||||
new RSAAutoCertificateConfig.Builder()
|
||||
new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(merchantId)
|
||||
// 使用 com.wechat.pay.java.core.util 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.publicKeyFromPath(wechatPayCertPath)
|
||||
.publicKeyId("PUB_KEY_ID_0117329907722025112100111619002400")
|
||||
.merchantSerialNumber(merchantSerialNumber)
|
||||
.apiV3Key(apiV3Key)
|
||||
.build();
|
||||
// 初始化服务
|
||||
service = new AppServiceExtension.Builder().config(config).build();
|
||||
// // 初始化服务
|
||||
// service = new AppServiceExtension.Builder().config(config).build();
|
||||
|
||||
|
||||
AppServiceExtension service = new AppServiceExtension.Builder().config(config).build();
|
||||
|
||||
// 跟之前下单示例一样,填充预下单参数
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
request.setAppid("wx87084c0b6aa7aed6");
|
||||
request.setDescription("测试");
|
||||
request.setMchid(merchantId);
|
||||
request.setOutTradeNo("andhadwdbawqd2");
|
||||
//request.setTimeExpire("2025-11-24T21:48:31+08:00");
|
||||
request.setNotifyUrl("https://www.wechat.com");
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(1);
|
||||
amount.setCurrency("CNY");
|
||||
request.setAmount(amount);
|
||||
|
||||
// response包含了调起支付所需的所有参数,可直接用于前端调起支付
|
||||
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
||||
System.out.println(response);
|
||||
try {
|
||||
// ... 调用接口
|
||||
PrepayWithRequestPaymentResponse response = prepayWithRequestPayment();
|
||||
System.out.println(response);
|
||||
} catch (HttpException e) { // 发送HTTP请求失败
|
||||
// PrepayWithRequestPaymentResponse response = prepayWithRequestPayment();
|
||||
// System.out.println(response);
|
||||
} catch (HttpException e) {
|
||||
e.printStackTrace();// 发送HTTP请求失败
|
||||
// 调用e.getHttpRequest()获取请求打印日志或上报监控,更多方法见HttpException定义
|
||||
} catch (ServiceException e) { // 服务返回状态小于200或大于等于300,例如500
|
||||
// 调用e.getResponseBody()获取返回体打印日志或上报监控,更多方法见ServiceException定义
|
||||
@@ -66,41 +105,41 @@ public class WeChatAppServiceExtensionExample {
|
||||
*/
|
||||
public static void closeOrder() {
|
||||
|
||||
CloseOrderRequest request = new CloseOrderRequest();
|
||||
// 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// 调用接口
|
||||
service.closeOrder(request);
|
||||
// CloseOrderRequest request = new CloseOrderRequest();
|
||||
// // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// // 调用接口
|
||||
// service.closeOrder(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* APP支付下单,并返回APP调起支付数据
|
||||
*/
|
||||
public static PrepayWithRequestPaymentResponse prepayWithRequestPayment() {
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
// 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// 调用接口
|
||||
return service.prepayWithRequestPayment(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付订单号查询订单
|
||||
*/
|
||||
public static Transaction queryOrderById() {
|
||||
|
||||
QueryOrderByIdRequest request = new QueryOrderByIdRequest();
|
||||
// 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// 调用接口
|
||||
return service.queryOrderById(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户订单号查询订单
|
||||
*/
|
||||
public static Transaction queryOrderByOutTradeNo() {
|
||||
|
||||
QueryOrderByOutTradeNoRequest request = new QueryOrderByOutTradeNoRequest();
|
||||
// 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// 调用接口
|
||||
return service.queryOrderByOutTradeNo(request);
|
||||
}
|
||||
// /**
|
||||
// * APP支付下单,并返回APP调起支付数据
|
||||
// */
|
||||
// public static PrepayWithRequestPaymentResponse prepayWithRequestPayment() {
|
||||
// PrepayRequest request = new PrepayRequest();
|
||||
// // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// // 调用接口
|
||||
// return service.prepayWithRequestPayment(request);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 微信支付订单号查询订单
|
||||
// */
|
||||
// public static Transaction queryOrderById() {
|
||||
//
|
||||
// QueryOrderByIdRequest request = new QueryOrderByIdRequest();
|
||||
// // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// // 调用接口
|
||||
// return service.queryOrderById(request);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 商户订单号查询订单
|
||||
// */
|
||||
// public static Transaction queryOrderByOutTradeNo() {
|
||||
//
|
||||
// QueryOrderByOutTradeNoRequest request = new QueryOrderByOutTradeNoRequest();
|
||||
// // 调用request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
// // 调用接口
|
||||
// return service.queryOrderByOutTradeNo(request);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
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;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
* @author MXP by 2025/11/24
|
||||
*/
|
||||
@Component
|
||||
public class WeChatPayUtil {
|
||||
|
||||
public PrepayWithRequestPaymentResponse prepayWithRequestPayment(OrderInfo orderInfo) {
|
||||
// 2. 加载商户证书并获取序列号
|
||||
AppServiceExtension service = Options();
|
||||
// 跟之前下单示例一样,填充预下单参数
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
request.setAppid(WeChatConfig.APP_ID);
|
||||
request.setDescription(orderInfo.getPackageType());
|
||||
request.setMchid(WeChatConfig.MERCHANT_ID);
|
||||
request.setOutTradeNo(String.valueOf(orderInfo.getOrderId()));
|
||||
//request.setTimeExpire("2025-11-24T21:48:31+08:00");
|
||||
request.setNotifyUrl("https://lingxiapi.mingyuegn.top/prod-api/call/back/wechat");
|
||||
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包含了调起支付所需的所有参数,可直接用于前端调起支付
|
||||
return service.prepayWithRequestPayment(request);
|
||||
// "appid": "wxd678efh567hg6787",
|
||||
// "partnerid": "190000XXXX",
|
||||
// "prepayid": "wx26144052643535f4e6f9d125d829730000",
|
||||
// "package": "Sign=WXPay",
|
||||
// "noncestr": "5K8264ILTKCH16CQ2502SI8ZNMTM67VS",
|
||||
// "timestamp": "1719123456",
|
||||
// "sign": "A8422B7785FD739A8BC1E5A3F3626XXX"
|
||||
|
||||
}
|
||||
|
||||
// 查询支付结果
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.PlaStatusMapper">
|
||||
|
||||
<resultMap type="PlaStatus" id="PlaStatusResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="shareStatus" column="share_status" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPlaStatusVo">
|
||||
select id, share_status from pla_status
|
||||
</sql>
|
||||
|
||||
<select id="selectPlaStatusList" parameterType="PlaStatus" resultMap="PlaStatusResult">
|
||||
<include refid="selectPlaStatusVo"/>
|
||||
<where>
|
||||
<if test="shareStatus != null "> and share_status = #{shareStatus}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPlaStatusById" parameterType="Long" resultMap="PlaStatusResult">
|
||||
<include refid="selectPlaStatusVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPlaStatus" parameterType="PlaStatus" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into pla_status
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="shareStatus != null">share_status,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="shareStatus != null">#{shareStatus},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePlaStatus" parameterType="PlaStatus">
|
||||
update pla_status
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="shareStatus != null">share_status = #{shareStatus},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePlaStatusById" parameterType="Long">
|
||||
delete from pla_status where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePlaStatusByIds" parameterType="String">
|
||||
delete from pla_status where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -3,7 +3,7 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.ProductMapper">
|
||||
|
||||
|
||||
<resultMap type="Product" id="ProductResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="productId" column="product_id" />
|
||||
@@ -20,15 +20,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="sales" column="sales" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
<result property="updatedAt" column="updated_at" />
|
||||
<result property="typeName" column="type_name" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProductVo">
|
||||
select id, product_id, name, description, category_id, product_type, status, original_price, current_price, monthly_duration, quarterly_duration, stock, sales, created_at, updated_at from product
|
||||
select id, product_id, name, description, category_id, product_type, status, original_price, current_price, monthly_duration, quarterly_duration, stock, sales, created_at, updated_at,type_name from product
|
||||
</sql>
|
||||
|
||||
<select id="selectProductList" parameterType="Product" resultMap="ProductResult">
|
||||
<include refid="selectProductVo"/>
|
||||
<where>
|
||||
<where>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="description != null and description != ''"> and description = #{description}</if>
|
||||
@@ -45,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectProductById" parameterType="String" resultMap="ProductResult">
|
||||
<include refid="selectProductVo"/>
|
||||
where id = #{id}
|
||||
@@ -68,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sales != null">sales,</if>
|
||||
<if test="createdAt != null">created_at,</if>
|
||||
<if test="updatedAt != null">updated_at,</if>
|
||||
<if test="typeName != null">type_name,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="productId != null">#{productId},</if>
|
||||
@@ -84,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sales != null">#{sales},</if>
|
||||
<if test="createdAt != null">#{createdAt},</if>
|
||||
<if test="updatedAt != null">#{updatedAt},</if>
|
||||
<if test="typeName != null">#{typeName},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
@@ -104,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="sales != null">sales = #{sales},</if>
|
||||
<if test="createdAt != null">created_at = #{createdAt},</if>
|
||||
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
|
||||
<if test="typeName != null">type_name = #{typeName},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -113,9 +117,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProductByIds" parameterType="String">
|
||||
delete from product where id in
|
||||
delete from product where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
<select id="selectProductByPageType" resultMap="ProductResult">
|
||||
select * from product where product_type = #{productType}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -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">
|
||||
@@ -269,4 +273,8 @@
|
||||
#{userId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="deleteShopUserByUserId">
|
||||
delete from shop_user where user_id = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型说明" prop="typeName">
|
||||
<el-input
|
||||
v-model="queryParams.typeName"
|
||||
placeholder="请输入类型说明"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
@@ -56,16 +64,9 @@
|
||||
<el-table-column label="商品ID" align="center" prop="id" />
|
||||
<el-table-column label="商品名称" align="center" prop="name" />
|
||||
<el-table-column label="商品描述" align="center" prop="description" />
|
||||
<el-table-column label="原价(元)" align="center" prop="originalPrice">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ (scope.row.originalPrice / 100).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="现价(元)" align="center" prop="currentPrice">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ (scope.row.currentPrice / 100).toFixed(2) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="类型说明" align="center" prop="typeName" />
|
||||
<el-table-column label="原价(元)" align="center" prop="originalPrice" />
|
||||
<el-table-column label="现价(元)" align="center" prop="currentPrice" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
@@ -86,13 +87,13 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
<!-- <pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
/> -->
|
||||
|
||||
<!-- 添加或修改商品对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
@@ -103,6 +104,9 @@
|
||||
<el-form-item label="商品描述" prop="description">
|
||||
<el-input v-model="form.description" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型说明" prop="typeName">
|
||||
<el-input v-model="form.typeName" placeholder="请输入类型说明" />
|
||||
</el-form-item>
|
||||
<el-form-item label="原价(元)" prop="originalPrice">
|
||||
<el-input v-model="form.originalPrice" placeholder="请输入原价" />
|
||||
</el-form-item>
|
||||
@@ -147,7 +151,8 @@ export default {
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
name: null
|
||||
name: null,
|
||||
typeName: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
@@ -183,6 +188,7 @@ export default {
|
||||
id: null,
|
||||
name: null,
|
||||
description: null,
|
||||
typeName: null,
|
||||
originalPrice: null,
|
||||
currentPrice: null
|
||||
}
|
||||
@@ -216,13 +222,6 @@ export default {
|
||||
const id = row.id || this.ids
|
||||
getProduct(id).then(response => {
|
||||
this.form = response.data
|
||||
// 将分转换为元显示
|
||||
if (this.form.originalPrice) {
|
||||
this.form.originalPrice = (this.form.originalPrice / 100).toFixed(2)
|
||||
}
|
||||
if (this.form.currentPrice) {
|
||||
this.form.currentPrice = (this.form.currentPrice / 100).toFixed(2)
|
||||
}
|
||||
this.open = true
|
||||
this.title = "修改商品"
|
||||
})
|
||||
@@ -231,25 +230,14 @@ export default {
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
// 创建提交数据的副本
|
||||
const submitData = { ...this.form }
|
||||
|
||||
// 将元转换为分发送到接口
|
||||
if (submitData.originalPrice) {
|
||||
submitData.originalPrice = Math.round(parseFloat(submitData.originalPrice) * 100)
|
||||
}
|
||||
if (submitData.currentPrice) {
|
||||
submitData.currentPrice = Math.round(parseFloat(submitData.currentPrice) * 100)
|
||||
}
|
||||
|
||||
if (this.form.id != null) {
|
||||
updateProduct(submitData).then(response => {
|
||||
updateProduct(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
addProduct(submitData).then(response => {
|
||||
addProduct(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功")
|
||||
this.open = false
|
||||
this.getList()
|
||||
|
||||
Reference in New Issue
Block a user