This commit is contained in:
todaywindy 2025-06-23 10:31:49 +08:00
parent 6f1678b1d9
commit a54769e075
4 changed files with 49 additions and 23 deletions

View File

@ -30,6 +30,7 @@ class Address
'addr' => $result['address'],
'name' => $result['name'],
'mobile' => $result['phone'],
'ext' => $result['ext'],
'plan_time' => $result['datetime'],
];
}else{
@ -39,6 +40,12 @@ class Address
} else {
$re['addr'] = $string;
}
$text = $re['mobile'];
preg_match('/.*?(\d{11})[^\d]{0,5}(\d{3,5})?/u', $text, $phoneMatches);
$phone = $phoneMatches[1] ?? null;
$ext = $phoneMatches[2] ?? null;
$re['mobile'] = $phone;
$re['ext'] = $ext;
$type = self::extractServiceTypes($string,$titles)[0] ?? '';
}
@ -109,6 +116,7 @@ class Address
}
preg_match('/\d{6}/', $string, $match);
// dd($match);
if ($match && $match[0]) {
$compose['postcode'] = $match[0];
$string = str_replace($match[0], '', $string);

View File

@ -34,9 +34,16 @@ class AppointmentParser
$timeRange = $this->match('/时间:([\d:]+)~[\d:]+/', $text);
$datetime = $date && $timeRange ? "$date $timeRange" : null;
// 提取电话号码和分机号
$phoneMatches = [];
preg_match('/电话:.*?(\d{11})[^\d]{0,5}(\d{3,5})?/u', $text, $phoneMatches);
$phone = $phoneMatches[1] ?? null;
$ext = $phoneMatches[2] ?? null;
return [
'name' => $this->match('/姓名:(.+)/u', $text),
'phone' => $this->match('/电话:(\d{11})/', $text),
'phone' => $phone,
'ext' => $ext,
'address' => $this->match('/地址:(.+)/u', $text),
'date' => $date,
'time' => $timeRange,
@ -46,6 +53,7 @@ class AppointmentParser
}
// --- Format B ---
private function isFormatB(string $text): bool
{
@ -64,9 +72,16 @@ class AppointmentParser
$timeRange = $this->match('/预约时间:\d{4}-\d{2}-\d{2} ([\d:]+)-[\d:]+/', $text);
$datetime = $date && $timeRange ? "$date $timeRange" : null;
// 提取电话号码和分机号
$phoneMatches = [];
preg_match('/联系电话:.*?(\d{11})(?:\D{0,5}(\d{3,5}))?/u', $text, $phoneMatches);
$phone = $phoneMatches[1] ?? null;
$ext = $phoneMatches[2] ?? null;
return [
'name' => $this->match('/联系人:([^\n]+)/u', $text),
'phone' => $this->match('/联系电话:.*?(\d{11})/', $text),
'phone' => $phone,
'ext' => $ext,
'address' => $this->match('/预约地址:(.+)/u', $text),
'date' => $date,
'time' => $timeRange,

View File

@ -442,6 +442,7 @@ class Order extends Backend
$data['item']['item'] = $this->findElementByValue($this->itemsformattedTree, $data['item']['id'] ?? null);
}
preg_match('/\b(1[3-9]\d{9})\b/',$data['mobile'],$match);
// dd($data);
$data['mobile'] = $match[0] ?? $data['mobile'];
if ($data['addr'] && $data['addr']!=''){

View File

@ -35,7 +35,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
客户昵称: ${data.customer}
客户电话: ${data.tel}
客户地址: ${data.address}
下单金额: ${data.receive_type === 1 ? '已收定金 ' + formatNumber(data.online_amount) : '已收全款 ' + formatNumber(data.online_amount)}
${data.receive_type === 1 ? '已收定金' : '已收全款'}
下单金额: ¥${formatNumber(data.online_amount)}
订单备注: ${data.remark || '无'}
预约时间: ${data.plan_time || '无'}
`;
@ -45,7 +46,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
客户昵称: ${data.customer}
客户电话: ${data.tel}
客户地址: ${data.address}
下单金额: ${data.receive_type === 1 ? '已收定金 ' + formatNumber(data.online_amount) : '已收全款 ' + formatNumber(data.online_amount)}
${data.receive_type === 1 ? '已收定金' : '已收全款'}
下单金额: ¥${formatNumber(data.online_amount)}
优惠活动: ${data.coupon?.description || '无'}
订单备注: ${data.remark ||'无'}
预约时间: ${data.plan_time || '无'}
@ -550,9 +552,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
if (data.mobile !== '') {
$('#c-tel').val(data.mobile);
}
if (data.name !== '') {
$('#c-customer').val(data.name);
}
// if (data.name !== '') {
// $('#c-customer').val(data.name);
// }
if (data.item.id !== 0) {
$('#item_id_value').val(data.item.id);
$('#item_id').val(data.item.item);
@ -560,11 +562,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
if (data.idn) {
$('#c-source-id').val(data.idn);
}
// $city.citypicker({
// province: data.province,
// city: data.city,
// district: data.region
// });
if (data.area_id) {
$("#area_id").val(data.area_id);
}
@ -584,7 +581,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
$("#c-address").val(data.addr);
$("#area_name").val(data.addr);
}
if (data.ext){
Toastr.error('该客户电话为分机号,请输入客户真实号码!');
}else {
Toastr.info('识别成功');
}
return false;
});
});