1
This commit is contained in:
@@ -79,17 +79,17 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
// TF/H/生/拼多多 生成类指令
|
||||
else if (input.startsWith("TF")) {
|
||||
result = Collections.singletonList(handleTF(input));
|
||||
result = Collections.singletonList(handleTF(input, forceGenerate));
|
||||
} else if (input.startsWith("H")) {
|
||||
result = Collections.singletonList(handleH(input));
|
||||
result = Collections.singletonList(handleH(input, forceGenerate));
|
||||
} else if (input.startsWith("W")) {
|
||||
result = Collections.singletonList(handleW(input));
|
||||
result = Collections.singletonList(handleW(input, forceGenerate));
|
||||
} else if (input.startsWith("生")) {
|
||||
result = Collections.singletonList(handleSheng(input));
|
||||
result = Collections.singletonList(handleSheng(input, forceGenerate));
|
||||
} else if (isPDDWCommand(input)) {
|
||||
result = Collections.singletonList(handlePDDW(input));
|
||||
result = Collections.singletonList(handlePDDW(input, forceGenerate));
|
||||
} else if (input.equals("拼多多") || input.startsWith("拼多多\n") || input.startsWith("拼多多\r\n") || isPDDFormat(input)) {
|
||||
result = Collections.singletonList(handlePDD(input));
|
||||
result = Collections.singletonList(handlePDD(input, forceGenerate));
|
||||
} else if (input.startsWith("录单") || input.startsWith("慢单") || input.startsWith("慢搜") || input.startsWith("慢查") || input.startsWith("单")) {
|
||||
result = handleRecordLikeMulti(input, forceGenerate);
|
||||
} else if (input.startsWith("转链") || input.startsWith("文案") || input.startsWith("转")) {
|
||||
@@ -646,6 +646,10 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
|
||||
private String handleTF(String input) {
|
||||
return handleTF(input, false);
|
||||
}
|
||||
|
||||
private String handleTF(String input, boolean forceGenerate) {
|
||||
String body = input.replaceFirst("^TF\\s*", "");
|
||||
body = body.replaceAll("[啊阿]", "");
|
||||
String[] lines = body.split("\\r?\\n+");
|
||||
@@ -729,7 +733,7 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
StringBuilder order = new StringBuilder();
|
||||
order.append("生"+phone).append("\n").append(fenxiaoInfo).append("\n").append(modelNumber).append("\n").append(jf).append("\n").append(quantityStr).append("\n").append(address);
|
||||
// 传递第三方单号给 generateOrderText,以便在生成订单文本时正确提取
|
||||
outputs.add(generateOrderText(order.toString(), thirdPartyOrderNo));
|
||||
outputs.add(generateOrderText(order.toString(), thirdPartyOrderNo, forceGenerate));
|
||||
} else {
|
||||
outputs.add("TF 指令格式:TF\t分销信息\t分销信息\t分销信息\t型号\t数量\t姓名\t电话\t地址 ;也支持多行,每行一条数据");
|
||||
}
|
||||
@@ -740,14 +744,26 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
|
||||
|
||||
private String handleH(String input) {
|
||||
return handleHLike(input, "H", "H");
|
||||
return handleH(input, false);
|
||||
}
|
||||
|
||||
private String handleH(String input, boolean forceGenerate) {
|
||||
return handleHLike(input, "H", "H", forceGenerate);
|
||||
}
|
||||
|
||||
private String handleW(String input) {
|
||||
return handleHLike(input, "W", "W");
|
||||
return handleW(input, false);
|
||||
}
|
||||
|
||||
private String handleW(String input, boolean forceGenerate) {
|
||||
return handleHLike(input, "W", "W", forceGenerate);
|
||||
}
|
||||
|
||||
private String handleHLike(String input, String commandKeyword, String distributionMark) {
|
||||
return handleHLike(input, commandKeyword, distributionMark, false);
|
||||
}
|
||||
|
||||
private String handleHLike(String input, String commandKeyword, String distributionMark, boolean forceGenerate) {
|
||||
String cleaned = input.replaceFirst("^" + Pattern.quote(commandKeyword), "");
|
||||
if (cleaned.startsWith("\n")) {
|
||||
cleaned = cleaned.substring(1);
|
||||
@@ -774,10 +790,14 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
StringBuilder sheng = new StringBuilder();
|
||||
sheng.append("生\n").append(distributionMark).append("\n").append(modelNumber).append("\n").append(jfLink != null ? jfLink : "").append("\n")
|
||||
.append("1\n").append(name).append(fullAddress);
|
||||
return generateOrderText(sheng.toString());
|
||||
return generateOrderText(sheng.toString(), null, forceGenerate);
|
||||
}
|
||||
|
||||
private String handleSheng(String input) {
|
||||
return handleSheng(input, false);
|
||||
}
|
||||
|
||||
private String handleSheng(String input, boolean forceGenerate) {
|
||||
// 输入格式:
|
||||
// 生\n分销标记\n型号\n转链链接\n数量\n地址
|
||||
String[] split = input.split("\n");
|
||||
@@ -797,7 +817,7 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
split[3] = link;
|
||||
split[5] = sanitizeAddress(split[5]);
|
||||
return generateOrderText(String.join("\n", split));
|
||||
return generateOrderText(String.join("\n", split), null, forceGenerate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -835,14 +855,26 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
|
||||
private String handlePDD(String input) {
|
||||
return handlePDDWithMark(input, "拼多多", "PDD");
|
||||
return handlePDD(input, false);
|
||||
}
|
||||
|
||||
private String handlePDD(String input, boolean forceGenerate) {
|
||||
return handlePDDWithMark(input, "拼多多", "PDD", forceGenerate);
|
||||
}
|
||||
|
||||
private String handlePDDW(String input) {
|
||||
return handlePDDWithMark(input, "拼多多 W", "PDD-W");
|
||||
return handlePDDW(input, false);
|
||||
}
|
||||
|
||||
private String handlePDDW(String input, boolean forceGenerate) {
|
||||
return handlePDDWithMark(input, "拼多多 W", "PDD-W", forceGenerate);
|
||||
}
|
||||
|
||||
private String handlePDDWithMark(String input, String commandKeyword, String distributionMark) {
|
||||
return handlePDDWithMark(input, commandKeyword, distributionMark, false);
|
||||
}
|
||||
|
||||
private String handlePDDWithMark(String input, String commandKeyword, String distributionMark, boolean forceGenerate) {
|
||||
// 拼多多新格式:
|
||||
// <指令>251102-457567158704072
|
||||
// 赵政委[6947]
|
||||
@@ -986,7 +1018,7 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
.append(fullAddress.toString());
|
||||
|
||||
// 传递第三方单号给 generateOrderText
|
||||
return generateOrderText(sheng.toString(), thirdPartyOrderNo);
|
||||
return generateOrderText(sheng.toString(), thirdPartyOrderNo, forceGenerate);
|
||||
}
|
||||
|
||||
private boolean shouldAutoFillLink(String distributionMark) {
|
||||
@@ -1030,10 +1062,14 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
}
|
||||
|
||||
private String generateOrderText(String shengInput) {
|
||||
return generateOrderText(shengInput, null);
|
||||
return generateOrderText(shengInput, null, false);
|
||||
}
|
||||
|
||||
private String generateOrderText(String shengInput, String providedThirdPartyOrderNo) {
|
||||
return generateOrderText(shengInput, providedThirdPartyOrderNo, false);
|
||||
}
|
||||
|
||||
private String generateOrderText(String shengInput, String providedThirdPartyOrderNo, boolean forceGenerate) {
|
||||
String[] split = shengInput.split("\n");
|
||||
// 第一行可能是 生 或 生{备注}
|
||||
String head = split[0].trim();
|
||||
@@ -1073,12 +1109,15 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
String existed = stringRedisTemplate.opsForValue().get(addressKey);
|
||||
if (existed != null) {
|
||||
if (!(existed.contains("李波") || existed.contains("吴胜硕") || existed.contains("小硕硕"))) {
|
||||
String warn = "[炸弹] [炸弹] [炸弹] 此地址已经存在,请勿重复生成订单 [炸弹] [炸弹] [炸弹] ";
|
||||
StringBuilder warnOut = new StringBuilder();
|
||||
warnOut.append(warn).append("\n");
|
||||
return warnOut.toString().trim();
|
||||
// 如果强制生成,跳过地址重复检查
|
||||
if (!forceGenerate) {
|
||||
// 返回特殊错误码,前端会识别并弹出验证码
|
||||
return "ERROR_CODE:ADDRESS_DUPLICATE\n此地址已经存在,请勿重复生成订单";
|
||||
}
|
||||
// forceGenerate为true时,跳过地址重复检查,继续执行
|
||||
}
|
||||
}
|
||||
// 只有在不强制生成或地址不存在时才设置Redis(强制生成时也更新Redis记录)
|
||||
stringRedisTemplate.opsForValue().set(addressKey, address, 1, TimeUnit.DAYS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user