价保
This commit is contained in:
@@ -7,8 +7,7 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.loggerger;
|
|
||||||
import org.slf4j.loggergerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
@@ -75,12 +74,15 @@ public class OrderUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理价保逻辑
|
// 处理价保逻辑
|
||||||
BigDecimal newProPriceAmount = Optional.ofNullable(orderRow.getProPriceAmount()).map(BigDecimal::new).orElse(BigDecimal.ZERO);
|
BigDecimal newProPriceAmount = Optional.ofNullable(orderRow.getProPriceAmount())
|
||||||
|
.map(BigDecimal::new)
|
||||||
|
.orElse(BigDecimal.ZERO);
|
||||||
|
|
||||||
if (BigDecimal.ZERO.compareTo(newProPriceAmount) < 0) {
|
if (BigDecimal.ZERO.compareTo(newProPriceAmount) < 0) {
|
||||||
String oldProPriceAmountStr = getFromRedis(ORDER_ROW_JB_KEY + orderRow.getId());
|
String oldProPriceAmountStr = getFromRedis(ORDER_ROW_JB_KEY + orderRow.getId());
|
||||||
BigDecimal oldProPriceAmount = oldProPriceAmountStr == null ? BigDecimal.ZERO : new BigDecimal(oldProPriceAmountStr);
|
BigDecimal oldProPriceAmount = oldProPriceAmountStr == null ?
|
||||||
|
BigDecimal.ZERO : new BigDecimal(oldProPriceAmountStr);
|
||||||
|
|
||||||
if (newProPriceAmount.compareTo(oldProPriceAmount) != 0) {
|
if (newProPriceAmount.compareTo(oldProPriceAmount) != 0) {
|
||||||
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
||||||
@@ -89,12 +91,13 @@ public class OrderUtil {
|
|||||||
String alertMsg = "[Broken][Broken][Broken] 价保提醒 [Broken][Broken][Broken] " + newProPriceAmount + "\n" + content;
|
String alertMsg = "[Broken][Broken][Broken] 价保提醒 [Broken][Broken][Broken] " + newProPriceAmount + "\n" + content;
|
||||||
wxUtil.sendTextMessage(wxId, alertMsg, 1, wxId, true);
|
wxUtil.sendTextMessage(wxId, alertMsg, 1, wxId, true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 不管是否变动都写入 Redis,用于下次比较
|
// 只有发生变动后才更新 Redis
|
||||||
redisTemplate.opsForValue().set(ORDER_ROW_JB_KEY + orderRow.getId(), newProPriceAmount.toString());
|
redisTemplate.opsForValue().set(ORDER_ROW_JB_KEY + orderRow.getId(), newProPriceAmount.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("处理订单微信通知失败: {}", e.getMessage(), e);
|
logger.error("处理订单微信通知失败: {}", e.getMessage(), e);
|
||||||
// 可加入重试机制或上报监控
|
// 可加入重试机制或上报监控
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Leo
|
* @author Leo
|
||||||
@@ -81,7 +82,7 @@ public class WXUtil {
|
|||||||
private final MessageProducerService messageProducerService;
|
private final MessageProducerService messageProducerService;
|
||||||
public int sendTimes = 0;
|
public int sendTimes = 0;
|
||||||
private Environment env;
|
private Environment env;
|
||||||
|
private static boolean restartNoticeSent = false;
|
||||||
@Autowired
|
@Autowired
|
||||||
public WXUtil(Environment env, WxtsUtil wxTsUtil, @Lazy MessageProducerService messageProducerService) {
|
public WXUtil(Environment env, WxtsUtil wxTsUtil, @Lazy MessageProducerService messageProducerService) {
|
||||||
this.messageProducerService = messageProducerService;
|
this.messageProducerService = messageProducerService;
|
||||||
@@ -124,6 +125,9 @@ public class WXUtil {
|
|||||||
|
|
||||||
// 初始化超级管理员
|
// 初始化超级管理员
|
||||||
public void initSuperAdmins() {
|
public void initSuperAdmins() {
|
||||||
|
if (restartNoticeSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
SuperAdmin admin1 = new SuperAdmin("wxid_ytpc72mdoskt22", "凡", "2014264913", "98e21c89ae5610240ec3f5f575f86a59", "3dcb6b23a1104639ac433fd07adb6dfb");
|
SuperAdmin admin1 = new SuperAdmin("wxid_ytpc72mdoskt22", "凡", "2014264913", "98e21c89ae5610240ec3f5f575f86a59", "3dcb6b23a1104639ac433fd07adb6dfb");
|
||||||
super_admins.put(admin1.getWxid() + admin1.getUnionId(), admin1);
|
super_admins.put(admin1.getWxid() + admin1.getUnionId(), admin1);
|
||||||
jdidToWxidMap.put(admin1.getUnionId(), admin1.getWxid());
|
jdidToWxidMap.put(admin1.getUnionId(), admin1.getWxid());
|
||||||
@@ -211,11 +215,20 @@ public class WXUtil {
|
|||||||
// 舵手群(48621589056@chatroom):"曲莉亚@河南慧推电子商务有限公司、齐学法@河南慧推电子商务有限公司"为企业微信用户,<_wc_custom_link_ href="https://weixin.qq.com/cgi-bin/newreadtemplate?t=work_wechat/about_group">了解更多</_wc_custom_link_>。
|
// 舵手群(48621589056@chatroom):"曲莉亚@河南慧推电子商务有限公司、齐学法@河南慧推电子商务有限公司"为企业微信用户,<_wc_custom_link_ href="https://weixin.qq.com/cgi-bin/newreadtemplate?t=work_wechat/about_group">了解更多</_wc_custom_link_>。
|
||||||
chatRoom_xb.put("48621589056@chatroom", "舵手");
|
chatRoom_xb.put("48621589056@chatroom", "舵手");
|
||||||
|
|
||||||
//发送通知到微信
|
String messageContent = "Jarvis 重启完成 [亲亲][亲亲][亲亲] ";
|
||||||
|
String fromWxid = default_bot_wxid; // 来源为机器人自身
|
||||||
|
|
||||||
super_admins.forEach((wxid, superAdmin) -> {
|
super_admins.forEach((wxid, superAdmin) -> {
|
||||||
sendTextMessage(wxid, "Jarvis 重启完成 [亲亲][亲亲][亲亲] ", 1, wxid, false);
|
try {
|
||||||
|
// 异步发送,不影响启动流程
|
||||||
|
CompletableFuture.runAsync(() -> sendTextMessage(wxid.substring(0, 19), messageContent, 1, fromWxid, false));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("发送重启通知失败,目标 wxid: {}", wxid, e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
restartNoticeSent = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取微信列表
|
// 获取微信列表
|
||||||
|
|||||||
17
src/main/java/cn/van/business/util/test.java
Normal file
17
src/main/java/cn/van/business/util/test.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package cn.van.business.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Leo
|
||||||
|
* @version 1.0
|
||||||
|
* @create 2025/5/17 00:05
|
||||||
|
* @description:
|
||||||
|
*/
|
||||||
|
public class test {
|
||||||
|
public static class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String str = "wxid_cfmrk2upjtf322";
|
||||||
|
int length = str.length();
|
||||||
|
System.out.println("字符串长度是: " + length); // 输出:15
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user