This commit is contained in:
2025-11-06 22:10:09 +08:00
parent 6653c2ca03
commit 42c6c8bc23
2 changed files with 270 additions and 10 deletions

View File

@@ -791,27 +791,27 @@ public class TencentDocController extends BaseController {
}
/**
* 从备注中提取手机号码
* 从文本中提取手机号码
* 支持11位手机号码可能包含空格、横线等分隔符
*
* @param remark 备注信息
* @param text 文本信息(可以是备注、状态等字段)
* @return 提取到的手机号码如果没有则返回null
*/
private String extractPhoneFromRemark(String remark) {
if (remark == null || remark.trim().isEmpty()) {
private String extractPhoneFromRemark(String text) {
if (text == null || text.trim().isEmpty()) {
return null;
}
// 移除所有空格、横线、括号等分隔符
String cleanedRemark = remark.replaceAll("[\\s\\-\\(\\)\\[\\]\\\\】]", "");
String cleanedText = text.replaceAll("[\\s\\-\\(\\)\\[\\]\\\\】]", "");
// 匹配11位手机号码1开头的11位数字
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("1[3-9]\\d{9}");
java.util.regex.Matcher matcher = pattern.matcher(cleanedRemark);
java.util.regex.Matcher matcher = pattern.matcher(cleanedText);
if (matcher.find()) {
String phone = matcher.group();
log.debug("备注中提取到手机号码: {}", phone);
log.debug("文本中提取到手机号码: {}", phone);
return phone;
}
@@ -1185,12 +1185,12 @@ public class TencentDocController extends BaseController {
if (order.getLogisticsLink() != null && !order.getLogisticsLink().trim().isEmpty()) {
String logisticsLink = order.getLogisticsLink().trim();
// 从备注中提取手机号码
// 从status字段中提取手机号码
String phone = null;
if (phoneColumn != null) {
phone = extractPhoneFromRemark(order.getRemark());
phone = extractPhoneFromRemark(order.getStatus());
if (phone != null) {
log.info("✓ 从备注中提取手机号码 - 单号: {}, 手机号: {}", orderNo, phone);
log.info("✓ 从status字段提取手机号码 - 单号: {}, 手机号: {}", orderNo, phone);
}
}