From: fomichev Date: Wed, 30 Apr 2025 09:12:38 +0000 (+0300) Subject: Выносим запрос за цикл X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d6945b06cd5255cb8506a7bb9570fbf10c3b75e6;p=erp24_rep%2Fyii-erp24%2F.git Выносим запрос за цикл --- diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index 1fed5bf9..da539c27 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -1093,12 +1093,19 @@ class CronController extends Controller $kogortPhones, array_column($kogortStopListPhones, 'phone') ); + $users = Users::find()->select(['phone', 'name'])->where(['phone' => $phonesArray])->asArray()->all(); + $usersNames = ArrayHelper::map($users, 'phone', 'name'); foreach ($phonesArray as $phone) { + if (isset($usersNames[$phone]) && !empty(trim($usersNames[$phone ])) ) { + $name = $usersNames[$phone]; + } else { + $name = 'Клиент'; + } $api = new LPTrackerApi(); $response = $api->post('lead', [ 'contact' => [ 'project_id' => LPTrackerApi::SERVICE, - 'name' => Users::find()->where(['phone' => $phone])->name ?? 'Клиент', + 'name' => $name, 'details' => [ [ 'type' => 'phone',