From 00106c3110f977a51c8a28c20e43e9029a5ee859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=82=E7=8F=82?= Date: Fri, 15 Nov 2024 18:11:25 +0800 Subject: [PATCH] init --- packages/bydauto/src/Commands/BYDAutoCommand.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/bydauto/src/Commands/BYDAutoCommand.php b/packages/bydauto/src/Commands/BYDAutoCommand.php index b66dc19..99e5f7b 100644 --- a/packages/bydauto/src/Commands/BYDAutoCommand.php +++ b/packages/bydauto/src/Commands/BYDAutoCommand.php @@ -63,6 +63,11 @@ public function action_push2contact() return !in_array($item->mobile, $sendItems); }); + // 去除中文名字长度大于3的数据 + // $items = $items->filter(function ($item) { + // return !$this->filterDirtyName($item->name); + // }); + // 联系人 $contacts = Contact::query() ->where('status', Contact::STATUS_PUBLISHED) @@ -76,7 +81,7 @@ public function action_push2contact() // 分配数据 foreach ($items as $item) { - if (mb_strlen($item->name) > 6) { + if (mb_strlen($item->name) >= 6) { info("试驾数据 {$item->id} 姓名异常 {$item->name}"); $this->info("试驾数据 {$item->id} 姓名异常 {$item->name}"); $item->update(['status' => Testdrive::STATUS_REJECTED]); @@ -137,4 +142,12 @@ public function action_contact_add() $this->info('Contact added'); } + + protected function filterDirtyName($str, $max = 3) + { + if (!preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)) { + return false; + } + return mb_strlen($str) > $max; + } }