This commit is contained in:
Van0313
2025-04-26 12:11:08 +08:00
parent d6110a2d4b
commit 2b15a40f75

View File

@@ -96,7 +96,7 @@ public class JDUtil {
* <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;
private final StringRedisTemplate redisTemplate;
@@ -1507,6 +1507,16 @@ public class JDUtil {
}
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 today = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd "));
@@ -1516,8 +1526,13 @@ public class JDUtil {
try {
// 从 Redis 获取当前日期的订单计数器
String s = redisTemplate.opsForValue().get(redisKey);
int num = 1;
try {
num = Integer.parseInt(split[2]);
} catch (NumberFormatException ignored) {
}
if (s != null) {
count = Integer.parseInt(s) + 1; // 递增计数器
count = Integer.parseInt(s) + num; // 递增计数器
}
// 将新的计数器值保存回 Redis
@@ -1528,7 +1543,8 @@ public class JDUtil {
// 替换模板中的占位符
temp = temp.replace("{单号}", orderID);
temp = temp.replace("{地址}", order);
temp = temp.replace("{地址}", split[3]);
temp = temp.replace("{型号}", split[1]);
temp = temp.replaceAll("[|]", "");