From 6bb2dcff970c0f39d43292dfa3c9447a47b51d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=82=E7=8F=82?= Date: Mon, 9 Dec 2024 15:08:52 +0800 Subject: [PATCH] dev --- .../bydauto/src/Commands/BYDAutoCommand.php | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/packages/bydauto/src/Commands/BYDAutoCommand.php b/packages/bydauto/src/Commands/BYDAutoCommand.php index 13c1937..62cc0a8 100644 --- a/packages/bydauto/src/Commands/BYDAutoCommand.php +++ b/packages/bydauto/src/Commands/BYDAutoCommand.php @@ -31,7 +31,7 @@ public function action_data_fix() { $source = ['alipromote:108600010', 'alipromote:108600017']; $items = Testdrive::query()->whereIn('source', $source)->get(); - foreach($items as $item) { + foreach ($items as $item) { $propertyList = $item->rawdata['property_list']; $name = collect($propertyList)->firstWhere('key', '姓名'); $item->name = $name['value'] ?? ''; @@ -107,31 +107,40 @@ public function action_push2contact() ->pluck('mobile') ->toArray(); - // 需要发送的试驾数据 - $items = Testdrive::query() + // // 需要发送的试驾数据 + // $items = Testdrive::query() + // ->whereNotNull('source') + // ->where('status', Testdrive::STATUS_DRAFT) + // ->orderBy('id') + // ->get(); + + $num = $this->ask('ID 正序取出', 100); + $items1 = Testdrive::query() ->whereNotNull('source') ->where('status', Testdrive::STATUS_DRAFT) ->orderBy('id') + ->take($num) ->get(); + $num = $this->ask('ID 倒叙取出', 100); + $items2 = Testdrive::query() + ->whereNotNull('source') + ->where('status', Testdrive::STATUS_DRAFT) + ->orderBy('id', 'desc') + ->take($num) + ->get(); + + $items = $items1->merge($items2); // 根据手机号码去除重 $items = $items->unique('mobile'); - // 根据已发送的手机号码去重 - $items = $items->filter(function ($item) use ($sendItems) { - return !in_array($item->mobile, $sendItems); - }); + $items = $items->filter(fn($item) => !in_array($item->mobile, $sendItems)); - $items = $items->sortBy('id')->take(80); - - $confirm = $this->confirm("共有 {$items->count()} 条数据,是否继续?"); + $confirm = $this->confirm("共有 {$items->count()} 条数据(已去重),是否继续?"); if (!$confirm) return Command::SUCCESS; // 联系人 - $contacts = Contact::query() - ->where('status', Contact::STATUS_PUBLISHED) - ->orderBy('id') - ->get(); + $contacts = Contact::query()->where('status', Contact::STATUS_PUBLISHED)->orderBy('id')->get(); $count = $contacts->count(); $offset = cache()->get('push2contact:offset', 0);