This commit is contained in:
Van0313
2025-04-27 16:58:00 +08:00
parent c6f64218db
commit d55eacd0b1

View File

@@ -96,7 +96,7 @@ public class JDUtil {
* <p> * <p>
* 订单号: * 订单号:
*/ */
private static final String WENAN_D = "单:\n" + "{单号} \n" + "分销标记(标记用,勿改):{分销标记}\n" + "型号:\n" + "{型号}" + "\n" + "链接:\n" +"{链接}"+ "\n" + "下单付款:\n" + "\n" + "后返金额:\n" + "\n" + "地址:\n" + "{地址}" + "\n" + "物流链接:\n" + "\n" + "订单号:\n" + "\n" + "下单人:\n" + "\n"; private static final String WENAN_D = "单:\n" + "{单号} \n" + "分销标记(标记用,勿改):{分销标记}\n" + "型号:\n" + "{型号}" + "\n" + "链接:\n" + "{链接}" + "\n" + "下单付款:\n" + "\n" + "后返金额:\n" + "\n" + "地址:\n" + "{地址}" + "\n" + "物流链接:\n" + "\n" + "订单号:\n" + "\n" + "下单人:\n" + "\n";
final WXUtil wxUtil; final WXUtil wxUtil;
private final StringRedisTemplate redisTemplate; private final StringRedisTemplate redisTemplate;
@@ -1556,11 +1556,12 @@ public class JDUtil {
// 今天的日期 // 今天的日期
String today = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd ")); String today = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd "));
String redisKey = "order_count:" + today; String redisKey = "order_count:" + today;
Integer count = 1; Integer count;
try { try {
// 从 Redis 获取当前日期的订单计数器 // 从 Redis 获取当前日期的订单计数器
String s = redisTemplate.opsForValue().get(redisKey); String s = redisTemplate.opsForValue().get(redisKey);
count = s != null ? Integer.parseInt(s) : 1;
Integer num = 1; Integer num = 1;
try { try {
num = Integer.valueOf(split[4].trim()); num = Integer.valueOf(split[4].trim());
@@ -1569,7 +1570,7 @@ public class JDUtil {
} }
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
if (s != null) { if (s != null) {
count = num + 1; // 递增计数器 count++; // 递增计数器
} }
// 将新的计数器值保存回 Redis // 将新的计数器值保存回 Redis
@@ -1597,7 +1598,7 @@ public class JDUtil {
} }
} }
public void sendOrderToWxByOrderP(String order, String fromWxid) { public void sendOrderToWxByOrderP(String order, String fromWxid) {
// 检查是否命中“评”指令 // 检查是否命中“评”指令
if ("".equals(order)) { if ("".equals(order)) {
// 初始化用户交互状态 // 初始化用户交互状态
@@ -1624,12 +1625,12 @@ public void sendOrderToWxByOrderP(String order, String fromWxid) {
// 如果未命中“评”指令,检查是否在生成评论流程中 // 如果未命中“评”指令,检查是否在生成评论流程中
handleCommentInteraction(fromWxid, order); handleCommentInteraction(fromWxid, order);
} }
} }
/** /**
* 处理生成评论流程中的用户交互 * 处理生成评论流程中的用户交互
*/ */
private void handleCommentInteraction(String fromWxid, String message) { private void handleCommentInteraction(String fromWxid, String message) {
String key = INTERACTION_STATE_PREFIX + fromWxid; String key = INTERACTION_STATE_PREFIX + fromWxid;
UserInteractionState state = loadOrCreateState(key); UserInteractionState state = loadOrCreateState(key);
@@ -1659,12 +1660,12 @@ private void handleCommentInteraction(String fromWxid, String message) {
} finally { } finally {
saveState(key, state); saveState(key, state);
} }
} }
/** /**
* 生成评论内容 * 生成评论内容
*/ */
private void generateComment(String fromWxid, String productType) { private void generateComment(String fromWxid, String productType) {
// 这里可以调用缓存或AI生成文案目前先返回固定模板 // 这里可以调用缓存或AI生成文案目前先返回固定模板
String commentTemplate = "这是一条关于%s的评论\n" + String commentTemplate = "这是一条关于%s的评论\n" +
"1. 性能非常出色,使用体验极佳。\n" + "1. 性能非常出色,使用体验极佳。\n" +
@@ -1677,8 +1678,7 @@ private void generateComment(String fromWxid, String productType) {
// 重置状态 // 重置状态
resetState(fromWxid, loadOrCreateState(INTERACTION_STATE_PREFIX + fromWxid)); resetState(fromWxid, loadOrCreateState(INTERACTION_STATE_PREFIX + fromWxid));
} }
// 定义一个内部类来存储用户交互状态 // 定义一个内部类来存储用户交互状态