diff --git a/packages/bydauto/src/Commands/BYDAutoCommand.php b/packages/bydauto/src/Commands/BYDAutoCommand.php index e878a6c..0f9c068 100644 --- a/packages/bydauto/src/Commands/BYDAutoCommand.php +++ b/packages/bydauto/src/Commands/BYDAutoCommand.php @@ -43,47 +43,44 @@ public function action_init() } // 漏发试驾数据 - public function action_push_missing() - { - $items = Testdrive::query() - ->where('date_updated', '>', '2024-11-21 09:06:00') - ->get(); - - $contacts = Contact::query() - ->where('status', Contact::STATUS_PUBLISHED) - ->orderBy('id') - ->get(); - - $count = $contacts->count(); - $offset = cache()->get('push2contact:offset', 0); - $sendList = []; - - foreach ($items as $item) { - if ($this->isDirtyName($item->name)) { - info("试驾数据 {$item->id} 姓名异常 {$item->name}"); - $this->info("试驾数据 {$item->id} 姓名异常 {$item->name}"); - $item->update(['status' => Testdrive::STATUS_REJECTED]); - continue; - } - $contact = $contacts[$offset]; - $item->update(['status' => Testdrive::STATUS_PUBLISHED, 'contact_id' => $contact->id, 'contact_info' => $contact->toArray()]); - if (!isset($sendList[$contact->id])) { - $sendList[$contact->id] = [$item]; - } else { - $sendList[$contact->id][] = $item; - } - $offset = ($offset + 1) % $count; - } - cache()->forever('push2contact:offset', $offset); - // 开始发送 - foreach ($sendList as $contactId => $items) { - $contact = $contacts->firstWhere('id', $contactId); - $this->info("发送试驾数据给联系人 {$contact->id} 总数 " . count($items)); - info("发送试驾数据给联系人 {$contact->id} 总数 " . count($items)); - $contact->notify(new TestdirveNotification($items)); - } - return Command::SUCCESS; - } + // public function action_push_missing() + // { + // $items = Testdrive::query() + // ->where('date_updated', '>', '2024-11-21 09:06:00') + // ->get(); + // $contacts = Contact::query() + // ->where('status', Contact::STATUS_PUBLISHED) + // ->orderBy('id') + // ->get(); + // $count = $contacts->count(); + // $offset = cache()->get('push2contact:offset', 0); + // $sendList = []; + // foreach ($items as $item) { + // if ($this->isDirtyName($item->name)) { + // info("试驾数据 {$item->id} 姓名异常 {$item->name}"); + // $this->info("试驾数据 {$item->id} 姓名异常 {$item->name}"); + // $item->update(['status' => Testdrive::STATUS_REJECTED]); + // continue; + // } + // $contact = $contacts[$offset]; + // $item->update(['status' => Testdrive::STATUS_PUBLISHED, 'contact_id' => $contact->id, 'contact_info' => $contact->toArray()]); + // if (!isset($sendList[$contact->id])) { + // $sendList[$contact->id] = [$item]; + // } else { + // $sendList[$contact->id][] = $item; + // } + // $offset = ($offset + 1) % $count; + // } + // cache()->forever('push2contact:offset', $offset); + // // 开始发送 + // foreach ($sendList as $contactId => $items) { + // $contact = $contacts->firstWhere('id', $contactId); + // $this->info("发送试驾数据给联系人 {$contact->id} 总数 " . count($items)); + // info("发送试驾数据给联系人 {$contact->id} 总数 " . count($items)); + // $contact->notify(new TestdirveNotification($items)); + // } + // return Command::SUCCESS; + // } // 同步试驾数据给到经销商联系人 按顺序每个联系人分配一个试驾数据 public function action_push2contact()