1
This commit is contained in:
@@ -653,64 +653,64 @@ private String handleTF(String input) {
|
|||||||
// 提取电话(第7个字段)
|
// 提取电话(第7个字段)
|
||||||
String phone = parts[6];
|
String phone = parts[6];
|
||||||
//每天可以使用 phoneWithTF 中的多个不同号码,每个号码只用一次
|
//每天可以使用 phoneWithTF 中的多个不同号码,每个号码只用一次
|
||||||
if ("13243039070".equals(phone) || "17530176250".equals(phone)) {
|
// if ("13243039070".equals(phone) || "17530176250".equals(phone)) {
|
||||||
String today = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
// String today = new java.text.SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
String usedPhonesKey = "phone_used_today:" + today;
|
// String usedPhonesKey = "phone_used_today:" + today;
|
||||||
|
|
||||||
if (stringRedisTemplate != null) {
|
// if (stringRedisTemplate != null) {
|
||||||
try {
|
// try {
|
||||||
// 获取今天已经使用过的号码集合
|
// // 获取今天已经使用过的号码集合
|
||||||
Set<String> usedPhonesToday = stringRedisTemplate.opsForSet().members(usedPhonesKey);
|
// Set<String> usedPhonesToday = stringRedisTemplate.opsForSet().members(usedPhonesKey);
|
||||||
|
|
||||||
// 找出今天还没使用过的号码
|
// // 找出今天还没使用过的号码
|
||||||
List<String> availablePhones = new ArrayList<>();
|
// List<String> availablePhones = new ArrayList<>();
|
||||||
for (String p : phoneWithTF) {
|
// for (String p : phoneWithTF) {
|
||||||
if (usedPhonesToday == null || !usedPhonesToday.contains(p)) {
|
// if (usedPhonesToday == null || !usedPhonesToday.contains(p)) {
|
||||||
availablePhones.add(p);
|
// availablePhones.add(p);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!availablePhones.isEmpty()) {
|
// if (!availablePhones.isEmpty()) {
|
||||||
// 随机选择一个今天还没用过的号码
|
// // 随机选择一个今天还没用过的号码
|
||||||
phone = availablePhones.get(new Random().nextInt(availablePhones.size()));
|
// phone = availablePhones.get(new Random().nextInt(availablePhones.size()));
|
||||||
// 记录今天使用的号码(24小时后自动过期)
|
// // 记录今天使用的号码(24小时后自动过期)
|
||||||
stringRedisTemplate.opsForSet().add(usedPhonesKey, phone);
|
// stringRedisTemplate.opsForSet().add(usedPhonesKey, phone);
|
||||||
stringRedisTemplate.expire(usedPhonesKey, 1, TimeUnit.DAYS);
|
// stringRedisTemplate.expire(usedPhonesKey, 1, TimeUnit.DAYS);
|
||||||
} else {
|
// } else {
|
||||||
// phoneWithTF 中的号码今天都用完了,使用备用号码(轮换使用)
|
// // phoneWithTF 中的号码今天都用完了,使用备用号码(轮换使用)
|
||||||
String backupUsedKey = "backup_phone_used_today:" + today;
|
// String backupUsedKey = "backup_phone_used_today:" + today;
|
||||||
Set<String> backupUsedToday = stringRedisTemplate.opsForSet().members(backupUsedKey);
|
// Set<String> backupUsedToday = stringRedisTemplate.opsForSet().members(backupUsedKey);
|
||||||
|
|
||||||
// 检查两个备用号码哪个还没用过
|
// // 检查两个备用号码哪个还没用过
|
||||||
if (backupUsedToday == null || !backupUsedToday.contains("15639125541")) {
|
// if (backupUsedToday == null || !backupUsedToday.contains("15639125541")) {
|
||||||
phone = "15639125541";
|
// phone = "15639125541";
|
||||||
} else if (!backupUsedToday.contains("13243039070")) {
|
// } else if (!backupUsedToday.contains("13243039070")) {
|
||||||
phone = "13243039070";
|
// phone = "13243039070";
|
||||||
} else {
|
// } else {
|
||||||
// 两个备用号码今天都用过了,继续轮换使用
|
// // 两个备用号码今天都用过了,继续轮换使用
|
||||||
String lastBackupKey = "last_backup_phone:" + today;
|
// String lastBackupKey = "last_backup_phone:" + today;
|
||||||
String lastBackup = stringRedisTemplate.opsForValue().get(lastBackupKey);
|
// String lastBackup = stringRedisTemplate.opsForValue().get(lastBackupKey);
|
||||||
if ("15639125541".equals(lastBackup)) {
|
// if ("15639125541".equals(lastBackup)) {
|
||||||
phone = "13243039070";
|
// phone = "13243039070";
|
||||||
} else {
|
// } else {
|
||||||
phone = "15639125541";
|
// phone = "15639125541";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 记录今天使用的备用号码
|
// // 记录今天使用的备用号码
|
||||||
stringRedisTemplate.opsForSet().add(backupUsedKey, phone);
|
// stringRedisTemplate.opsForSet().add(backupUsedKey, phone);
|
||||||
stringRedisTemplate.expire(backupUsedKey, 1, TimeUnit.DAYS);
|
// stringRedisTemplate.expire(backupUsedKey, 1, TimeUnit.DAYS);
|
||||||
stringRedisTemplate.opsForValue().set("last_backup_phone:" + today, phone, 1, TimeUnit.DAYS);
|
// stringRedisTemplate.opsForValue().set("last_backup_phone:" + today, phone, 1, TimeUnit.DAYS);
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// Redis操作失败,使用随机号码作为降级方案
|
// // Redis操作失败,使用随机号码作为降级方案
|
||||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
// phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
// Redis不可用,使用随机号码
|
// // Redis不可用,使用随机号码
|
||||||
phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
// phone = phoneWithTF.get(new Random().nextInt(phoneWithTF.size()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 构建地址:姓名+电话+地址信息
|
// 构建地址:姓名+电话+地址信息
|
||||||
StringBuilder address = new StringBuilder();
|
StringBuilder address = new StringBuilder();
|
||||||
|
|||||||
Reference in New Issue
Block a user