From 3793130ce5b832222b2bbf950a0ac182cd349886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=82=E7=8F=82?= Date: Fri, 15 Nov 2024 16:44:35 +0800 Subject: [PATCH] init --- packages/bydauto/src/Commands/BYDAutoCommand.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/bydauto/src/Commands/BYDAutoCommand.php b/packages/bydauto/src/Commands/BYDAutoCommand.php index 16edaf7..0d18618 100644 --- a/packages/bydauto/src/Commands/BYDAutoCommand.php +++ b/packages/bydauto/src/Commands/BYDAutoCommand.php @@ -45,13 +45,25 @@ public function action_init() // 同步试驾数据给到经销商联系人 按顺序每个联系人分配一个试驾数据 public function action_push2contact() { + // 所有已发送的试驾数据 + $sendItems = Testdrive::query() + ->where('status', Testdrive::STATUS_PUBLISHED) + ->pluck('mobile') + ->toArray(); + + // 需要发送的试驾数据 $items = Testdrive::query() ->whereNotNull('source') ->where('status', Testdrive::STATUS_DRAFT) ->orderBy('id') ->get(); - $items = $items->unique('mobile'); + // 根据手机号码去除重 + $items = $items->filter(function ($item) use ($sendItems) { + return !in_array($item->mobile, $sendItems); + }); + + // 联系人 $contacts = Contact::query() ->where('status', Contact::STATUS_PUBLISHED) ->orderBy('id')