1
This commit is contained in:
@@ -416,13 +416,19 @@ public class InstructionServiceImpl implements IInstructionService {
|
||||
static {
|
||||
/*
|
||||
|
||||
13243039070
|
||||
15639125541
|
||||
13103996539
|
||||
15514755615
|
||||
17746927935
|
||||
13140433517
|
||||
17746921532
|
||||
15514786055
|
||||
*/
|
||||
|
||||
phoneWithTF.add("13243039070");
|
||||
phoneWithTF.add("15639125541");
|
||||
|
||||
phoneWithTF.add("13103996539");
|
||||
phoneWithTF.add("15514755615");
|
||||
phoneWithTF.add("17746927935");
|
||||
phoneWithTF.add("13140433517");
|
||||
phoneWithTF.add("17746921532");
|
||||
phoneWithTF.add("15514786055");
|
||||
|
||||
}
|
||||
|
||||
@@ -471,9 +477,65 @@ private String handleTF(String input) {
|
||||
|
||||
// 提取电话(第7个字段)
|
||||
String phone = parts[6];
|
||||
//从phoneWithTF随机拿一个出来
|
||||
if ("13243039070".equals(phone)) {
|
||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||
//每天至多从phoneWithTF中进行一次替换
|
||||
if ("13243039070".equals(phone) || "17530176250".equals(phone)) {
|
||||
String today = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
String phoneUsageKey = "phone_usage:" + today;
|
||||
|
||||
if (stringRedisTemplate != null) {
|
||||
try {
|
||||
// 获取今天已经使用过的号码
|
||||
String usedPhone = stringRedisTemplate.opsForValue().get(phoneUsageKey);
|
||||
|
||||
if (usedPhone != null) {
|
||||
// 今天已经替换过了,使用已记录的号码
|
||||
phone = usedPhone;
|
||||
} else {
|
||||
// 今天还没有替换过,从列表中选择一个可用的号码
|
||||
// 获取最近使用过的所有号码(保留7天)
|
||||
String usedPhonesKey = "used_phones_history";
|
||||
Set<String> usedPhones = stringRedisTemplate.opsForSet().members(usedPhonesKey);
|
||||
|
||||
// 找出还没使用过的号码
|
||||
List<String> availablePhones = new ArrayList<>();
|
||||
for (String p : phoneWithTF) {
|
||||
if (usedPhones == null || !usedPhones.contains(p)) {
|
||||
availablePhones.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (!availablePhones.isEmpty()) {
|
||||
// 随机选择一个可用的号码
|
||||
phone = availablePhones.get(new Random().nextInt(availablePhones.size()));
|
||||
} else {
|
||||
// 所有号码都用过了,使用备用号码(轮换使用)
|
||||
String lastBackupKey = "last_backup_phone";
|
||||
String lastBackup = stringRedisTemplate.opsForValue().get(lastBackupKey);
|
||||
if ("15639125541".equals(lastBackup)) {
|
||||
phone = "13243039070";
|
||||
} else {
|
||||
phone = "15639125541";
|
||||
}
|
||||
stringRedisTemplate.opsForValue().set(lastBackupKey, phone);
|
||||
// 清空历史记录,重新开始
|
||||
stringRedisTemplate.delete(usedPhonesKey);
|
||||
}
|
||||
|
||||
// 记录今天使用的号码(24小时过期)
|
||||
stringRedisTemplate.opsForValue().set(phoneUsageKey, phone, 1, TimeUnit.DAYS);
|
||||
// 添加到历史记录(不过期,手动管理)
|
||||
if (availablePhones.contains(phone)) {
|
||||
stringRedisTemplate.opsForSet().add(usedPhonesKey, phone);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Redis操作失败,使用随机号码作为降级方案
|
||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||
}
|
||||
} else {
|
||||
// Redis不可用,使用随机号码
|
||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||
}
|
||||
}
|
||||
|
||||
// 构建地址:姓名+电话+地址信息
|
||||
@@ -500,7 +562,7 @@ private String handleTF(String input) {
|
||||
String jf = productJdConfigService.getJdUrlByProductModel(modelNumber);
|
||||
|
||||
StringBuilder order = new StringBuilder();
|
||||
order.append("生").append("\n").append(fenxiaoInfo).append("\n").append(modelNumber).append("\n").append(jf).append("\n").append(quantityStr).append("\n").append(address);
|
||||
order.append("生"+phone).append("\n").append(fenxiaoInfo).append("\n").append(modelNumber).append("\n").append(jf).append("\n").append(quantityStr).append("\n").append(address);
|
||||
outputs.add(generateOrderText(order.toString()));
|
||||
} else {
|
||||
outputs.add("TF 指令格式:TF\t分销信息\t分销信息\t分销信息\t型号\t数量\t姓名\t电话\t地址 ;也支持多行,每行一条数据");
|
||||
|
||||
Reference in New Issue
Block a user