From 7858ae894c398f2f9248ac898b2ff200fa36225d Mon Sep 17 00:00:00 2001
From: longz <longzhaoz@qq.com>
Date: 星期三, 29 七月 2026 18:42:15 +0800
Subject: [PATCH] 各类修复
---
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/FavoritePriceDropTask.java | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/FavoritePriceDropTask.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/FavoritePriceDropTask.java
index 0d19882..ea0af40 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/FavoritePriceDropTask.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/task/FavoritePriceDropTask.java
@@ -92,12 +92,16 @@
}
TAppUser user = appUserService.getById(favorite.getAppUserId());
if (user == null || !StringUtils.hasText(user.getWxOpenid())) {
+ log.info("收藏站点降价提醒未发送,用户openid为空,userId={}, siteId={}",
+ favorite.getAppUserId(), favorite.getSiteId());
continue;
}
if (sendSubscribeMessage(user.getWxOpenid(), favorite, price)) {
favorite.setNotifyEnabled(false);
favorite.setLastNotifiedPrice(price.getCurrentPrice());
favoriteService.updateById(favorite);
+ log.info("收藏站点降价提醒发送成功,userId={}, siteId={}, currentPrice={}",
+ favorite.getAppUserId(), favorite.getSiteId(), price.getCurrentPrice());
}
}
} catch (InterruptedException e) {
@@ -112,16 +116,13 @@
}
private boolean sendSubscribeMessage(String openId, TAppUserSiteFavorite favorite, FavoriteSitePriceVO price) {
- BigDecimal decrease = favorite.getFavoritePrice().subtract(price.getCurrentPrice());
JSONObject body = new JSONObject();
body.put("touser", openId);
body.put("template_id", templateId);
body.put("page", page + "?siteId=" + favorite.getSiteId());
JSONObject data = new JSONObject();
data.put("thing1", value(limit(price.getSiteName(), 20)));
- data.put("amount2", value(favorite.getFavoritePrice().setScale(4, BigDecimal.ROUND_HALF_UP).toPlainString()));
- data.put("amount3", value(price.getCurrentPrice().setScale(4, BigDecimal.ROUND_HALF_UP).toPlainString()));
- data.put("amount4", value(decrease.setScale(4, BigDecimal.ROUND_HALF_UP).toPlainString()));
+ data.put("amount4", value(formatAmount(price.getCurrentPrice())));
body.put("data", data);
String accessToken = new WxAppletTools(wxRestTemplate, wxConfig, redisService).getAccessToken("");
String result = HttpUtils.post(SEND_URL + accessToken, body.toJSONString());
@@ -140,6 +141,10 @@
return item;
}
+ private String formatAmount(BigDecimal amount) {
+ return amount.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "元";
+ }
+
private String limit(String value, int length) {
if (!StringUtils.hasText(value) || value.length() <= length) {
return value;
--
Gitblit v1.7.1