From e7f312ec5068ce10ed07d1bd18616d5865b07e9d Mon Sep 17 00:00:00 2001 From: Van0313 <60689272+Van0313@users.noreply.github.com> Date: Sat, 26 Apr 2025 12:11:55 +0800 Subject: [PATCH] bug fix --- .../java/cn/van/business/util/JDUtil.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/cn/van/business/util/JDUtil.java b/src/main/java/cn/van/business/util/JDUtil.java index 2e269d5..f294003 100644 --- a/src/main/java/cn/van/business/util/JDUtil.java +++ b/src/main/java/cn/van/business/util/JDUtil.java @@ -1531,25 +1531,28 @@ public class JDUtil { num = Integer.parseInt(split[2]); } catch (NumberFormatException ignored) { } - if (s != null) { - count = Integer.parseInt(s) + num; // 递增计数器 + for (int i = 0; i < num; i++){ + if (s != null) { + count = Integer.parseInt(s) + 1; // 递增计数器 + } + + // 将新的计数器值保存回 Redis + redisTemplate.opsForValue().set(redisKey, String.valueOf(count), 1, TimeUnit.DAYS); + + // 生成订单号 + String orderID = today + String.format("%03d", count); // 格式化为 3 位数字,不足补零 + + // 替换模板中的占位符 + temp = temp.replace("{单号}", orderID); + temp = temp.replace("{地址}", split[3]); + temp = temp.replace("{型号}", split[1]); + temp = temp.replaceAll("[|]", ""); + + + // 发送订单信息到微信 + wxUtil.sendTextMessage(fromWxid, temp, 1, fromWxid, true); } - // 将新的计数器值保存回 Redis - redisTemplate.opsForValue().set(redisKey, String.valueOf(count), 1, TimeUnit.DAYS); - - // 生成订单号 - String orderID = today + String.format("%03d", count); // 格式化为 3 位数字,不足补零 - - // 替换模板中的占位符 - temp = temp.replace("{单号}", orderID); - temp = temp.replace("{地址}", split[3]); - temp = temp.replace("{型号}", split[1]); - temp = temp.replaceAll("[|]", ""); - - - // 发送订单信息到微信 - wxUtil.sendTextMessage(fromWxid, temp, 1, fromWxid, true); } catch (Exception e) { logger.error("生成订单号时发生异常 - 用户: {}, 日期: {}", fromWxid, today, e);