This commit is contained in:
parent
3793130ce5
commit
54f77de5cf
@ -71,6 +71,10 @@ public function action_push2contact()
|
|||||||
|
|
||||||
$count = $contacts->count();
|
$count = $contacts->count();
|
||||||
$offset = cache()->get('push2contact:offset', 0);
|
$offset = cache()->get('push2contact:offset', 0);
|
||||||
|
|
||||||
|
$sendList = [];
|
||||||
|
|
||||||
|
// 分配数据
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if (mb_strlen($item->name) > 6) {
|
if (mb_strlen($item->name) > 6) {
|
||||||
info("试驾数据 {$item->id} 姓名异常 {$item->name}");
|
info("试驾数据 {$item->id} 姓名异常 {$item->name}");
|
||||||
@ -79,22 +83,22 @@ public function action_push2contact()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$contact = $contacts[$offset];
|
$contact = $contacts[$offset];
|
||||||
// $contact->notify(new TestdirveNotification($item));
|
if (!isset($sendList[$contact->id])) {
|
||||||
$item->update(['status' => Testdrive::STATUS_PUBLISHED]);
|
$sendList[$contact->id] = [$item];
|
||||||
Activity::create([
|
} else {
|
||||||
'name' => '试驾通知',
|
$sendList[$contact->id][] = $item;
|
||||||
'content' => ['testdrive' => $item->id, 'contact' => $contact->id],
|
}
|
||||||
'related_id' => $contact->id,
|
// info("分配试驾数据 {$item->id} 给联系人 {$contact->id}");
|
||||||
'related_type' => Contact::class,
|
// $this->info("分配试驾数据 {$item->id} 给联系人 {$contact->id}");
|
||||||
]);
|
|
||||||
|
|
||||||
info("分配试驾数据 {$item->id} 给联系人 {$contact->id}");
|
|
||||||
$this->info("分配试驾数据 {$item->id} 给联系人 {$contact->id}");
|
|
||||||
|
|
||||||
$offset = ($offset + 1) % $count;
|
$offset = ($offset + 1) % $count;
|
||||||
}
|
}
|
||||||
cache()->forever('push2contact:offset', $offset);
|
cache()->forever('push2contact:offset', $offset);
|
||||||
|
|
||||||
|
// 开始发送
|
||||||
|
foreach ($sendList as $contactId => $items) {
|
||||||
|
$contact = $contacts->find($contactId);
|
||||||
|
$this->info("发送试驾数据给联系人 {$contact->id} 总数 " . count($items));
|
||||||
|
}
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user