Compare commits

..

2 Commits

Author SHA1 Message Date
Van0313
e7f312ec50 bug fix 2025-04-26 12:11:55 +08:00
Van0313
2b15a40f75 bug fix 2025-04-26 12:11:08 +08:00

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;
@@ -1507,6 +1507,16 @@ public class JDUtil {
} }
public void sendOrderToWxByOrderD(String order, String fromWxid) { public void sendOrderToWxByOrderD(String order, String fromWxid) {
if (order == null || order.trim().isEmpty()) {
wxUtil.sendTextMessage(fromWxid, "输入格式为:\n 单\n型号\n数量\n地址", 1, fromWxid, false);
return;
}
String[] split = order.split("\n");
if (split.length != 3) {
wxUtil.sendTextMessage(fromWxid, "输入格式为:\n 单\n型号\n数量\n地址", 1, fromWxid, false);
return;
}
String temp = WENAN_D; String temp = WENAN_D;
// 今天的日期 // 今天的日期
String today = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd ")); String today = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd "));
@@ -1516,6 +1526,12 @@ public class JDUtil {
try { try {
// 从 Redis 获取当前日期的订单计数器 // 从 Redis 获取当前日期的订单计数器
String s = redisTemplate.opsForValue().get(redisKey); String s = redisTemplate.opsForValue().get(redisKey);
int num = 1;
try {
num = Integer.parseInt(split[2]);
} catch (NumberFormatException ignored) {
}
for (int i = 0; i < num; i++){
if (s != null) { if (s != null) {
count = Integer.parseInt(s) + 1; // 递增计数器 count = Integer.parseInt(s) + 1; // 递增计数器
} }
@@ -1528,12 +1544,15 @@ public class JDUtil {
// 替换模板中的占位符 // 替换模板中的占位符
temp = temp.replace("{单号}", orderID); temp = temp.replace("{单号}", orderID);
temp = temp.replace("{地址}", order); temp = temp.replace("{地址}", split[3]);
temp = temp.replace("{型号}", split[1]);
temp = temp.replaceAll("[|]", ""); temp = temp.replaceAll("[|]", "");
// 发送订单信息到微信 // 发送订单信息到微信
wxUtil.sendTextMessage(fromWxid, temp, 1, fromWxid, true); wxUtil.sendTextMessage(fromWxid, temp, 1, fromWxid, true);
}
} catch (Exception e) { } catch (Exception e) {
logger.error("生成订单号时发生异常 - 用户: {}, 日期: {}", fromWxid, today, e); logger.error("生成订单号时发生异常 - 用户: {}, 日期: {}", fromWxid, today, e);