1
This commit is contained in:
@@ -821,16 +821,34 @@ private String handleTF(String input) {
|
||||
int nameLineIndex = 0;
|
||||
boolean isNewFormat = false;
|
||||
|
||||
// 检查是否是新格式(第一行包含"拼多多"后跟订单号)
|
||||
// 检查是否是新格式(第一行包含"拼多多")
|
||||
if (lines.length > 0) {
|
||||
String firstLine = lines[0].trim();
|
||||
// 匹配格式:拼多多数字-数字(如:拼多多251102-457567158704072)
|
||||
|
||||
// 格式1:拼多多数字-数字(一行格式,如:拼多多251102-457567158704072)
|
||||
Pattern orderNoPattern = Pattern.compile("拼多多(\\d+-\\d+)");
|
||||
Matcher matcher = orderNoPattern.matcher(firstLine);
|
||||
if (matcher.find()) {
|
||||
thirdPartyOrderNo = matcher.group(1); // 提取订单号部分(不含"拼多多")
|
||||
isNewFormat = true;
|
||||
nameLineIndex = 1; // 新格式下,姓名在第二行
|
||||
}
|
||||
// 格式2:第一行是"拼多多",第二行是订单号(多行格式)
|
||||
else if (firstLine.equals("拼多多") && lines.length > 1) {
|
||||
String secondLine = lines.length > 1 ? lines[1].trim() : "";
|
||||
// 检查第二行是否是订单号格式(数字-数字)
|
||||
Pattern orderNoPattern2 = Pattern.compile("^(\\d+-\\d+)$");
|
||||
Matcher matcher2 = orderNoPattern2.matcher(secondLine);
|
||||
if (matcher2.find()) {
|
||||
thirdPartyOrderNo = matcher2.group(1); // 提取订单号
|
||||
isNewFormat = true;
|
||||
nameLineIndex = 2; // 多行格式下,姓名在第三行
|
||||
} else {
|
||||
// 旧格式:移除"拼多多"前缀(如果有)
|
||||
String data = input.replaceFirst("^拼多多\\s*[\r\n]+", "").trim();
|
||||
lines = data.split("\r?\n");
|
||||
nameLineIndex = 0;
|
||||
}
|
||||
} else {
|
||||
// 旧格式:移除"拼多多"前缀(如果有)
|
||||
String data = input.replaceFirst("^拼多多\\s*[\r\n]+", "").trim();
|
||||
@@ -840,11 +858,15 @@ private String handleTF(String input) {
|
||||
}
|
||||
|
||||
// 检查行数
|
||||
int requiredLines = isNewFormat ? 5 : 4;
|
||||
// 如果第三方单号在第二行(多行格式),需要6行;如果在第一行(一行格式),需要5行
|
||||
int requiredLines = isNewFormat ? (nameLineIndex == 2 ? 6 : 5) : 4;
|
||||
if (lines.length < requiredLines) {
|
||||
return "拼多多格式错误,需要" + requiredLines + "行数据:" + (isNewFormat ?
|
||||
"\n1. 拼多多订单号\n2. 姓名[编号]\n3. 电话\n4. 地址[编号]\n5. 型号" :
|
||||
"\n1. 🕒 姓名[编号]\n2. 电话\n3. 地址[编号]\n4. 型号");
|
||||
String formatDesc = isNewFormat ?
|
||||
(nameLineIndex == 2 ?
|
||||
"\n1. 拼多多\n2. 订单号\n3. 姓名[编号]\n4. 电话\n5. 地址[编号]\n6. 型号" :
|
||||
"\n1. 拼多多订单号\n2. 姓名[编号]\n3. 电话\n4. 地址[编号]\n5. 型号") :
|
||||
"\n1. 🕒 姓名[编号]\n2. 电话\n3. 地址[编号]\n4. 型号";
|
||||
return "拼多多格式错误,需要" + requiredLines + "行数据:" + formatDesc;
|
||||
}
|
||||
|
||||
// 解析姓名行
|
||||
@@ -900,16 +922,13 @@ private String handleTF(String input) {
|
||||
// 获取转链链接
|
||||
String jf = productJdConfigService.getJdUrlByProductModel(modelNumber);
|
||||
|
||||
// 构建分销标记:如果有第三方单号,则包含在括号中
|
||||
// 构建分销标记:只保存 PDD,不包含第三方单号
|
||||
String distributionMark = "PDD";
|
||||
if (thirdPartyOrderNo != null && !thirdPartyOrderNo.isEmpty()) {
|
||||
distributionMark = "PDD(" + thirdPartyOrderNo + ")";
|
||||
}
|
||||
|
||||
// 构建"生"指令格式
|
||||
StringBuilder sheng = new StringBuilder();
|
||||
sheng.append("生\n")
|
||||
.append(distributionMark) // 分销标记:拼多多(包含第三方单号)
|
||||
.append(distributionMark) // 分销标记:PDD
|
||||
.append("\n")
|
||||
.append(modelNumber)
|
||||
.append("\n")
|
||||
|
||||
Reference in New Issue
Block a user