From a54769e07503bcecf516e8168527c841aa74dd83 Mon Sep 17 00:00:00 2001 From: todaywindy Date: Mon, 23 Jun 2025 10:31:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/addresmart/Address.php | 8 ++++ .../admin/addresmart/AppointmentParser.php | 39 +++++++++++++------ application/admin/controller/Order.php | 1 + public/assets/js/backend/order.js | 24 ++++++------ 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/application/admin/addresmart/Address.php b/application/admin/addresmart/Address.php index cb566ab..a186b62 100644 --- a/application/admin/addresmart/Address.php +++ b/application/admin/addresmart/Address.php @@ -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); diff --git a/application/admin/addresmart/AppointmentParser.php b/application/admin/addresmart/AppointmentParser.php index b328e43..5e1a19a 100644 --- a/application/admin/addresmart/AppointmentParser.php +++ b/application/admin/addresmart/AppointmentParser.php @@ -34,18 +34,26 @@ 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), - 'address' => $this->match('/地址:(.+)/u', $text), - 'date' => $date, - 'time' => $timeRange, + 'name' => $this->match('/姓名:(.+)/u', $text), + 'phone' => $phone, + 'ext' => $ext, + 'address' => $this->match('/地址:(.+)/u', $text), + 'date' => $date, + 'time' => $timeRange, 'datetime' => $datetime, - 'project' => $this->match('/商品名称:(.+)/u', $text), + 'project' => $this->match('/商品名称:(.+)/u', $text), ]; } + // --- Format B --- private function isFormatB(string $text): bool { @@ -64,14 +72,21 @@ 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), - 'address' => $this->match('/预约地址:(.+)/u', $text), - 'date' => $date, - 'time' => $timeRange, + 'name' => $this->match('/联系人:([^\n]+)/u', $text), + 'phone' => $phone, + 'ext' => $ext, + 'address' => $this->match('/预约地址:(.+)/u', $text), + 'date' => $date, + 'time' => $timeRange, 'datetime' => $datetime, - 'project' => $this->match('/预约项目:(.+)/u', $text), + 'project' => $this->match('/预约项目:(.+)/u', $text), ]; } diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index e5134b2..546be52 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -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']!=''){ diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index f363218..e77da2e 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -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); } - Toastr.info('识别成功'); + if (data.ext){ + Toastr.error('该客户电话为分机号,请输入客户真实号码!'); + + }else { + Toastr.info('识别成功'); + } return false; }); });