From d53e80de92b1e32c9560d3b32edd1ff6480e98fe Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Fri, 22 Aug 2025 16:05:27 +0300 Subject: [PATCH] =?utf8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?utf8?q?=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 30 ++++++++++------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index d69cccc7..7fffe9ee 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -1023,27 +1023,23 @@ class DataController extends BaseController } if (!empty($result['stores'])) { - $products1cStores = Products1c::find() - ->andWhere(['tip' => 'city_store']) - ->indexBy('id') - ->asArray() - ->column(); - $products1cTerminals = Products1c::find() - ->andWhere(['tip' => 'terminals']) - ->indexBy('id') + $products1cByTip = Products1c::find() + ->select(['id', 'tip']) + ->andWhere(['tip' => ['kkms', 'terminals', 'city_store']]) + ->groupBy(['tip', 'id']) ->asArray() - ->column(); + ->all(); + $products1cByTipMap = []; + foreach ($products1cByTip as $item) { + $products1cByTipMap[$item['tip']][] = $item['id']; + } $existTerminals = Terminals::find() ->indexBy('id') ->asArray() ->column(); - $products1cKkms = Products1c::find() - ->andWhere(['tip' => 'kkms']) - ->indexBy('id') - ->asArray() - ->column(); + foreach ($result['stores'] as $gi => $arr) { - if (!in_array($arr["id"], $products1cStores)) { + if (!in_array($arr["id"], $products1cByTipMap['city_store'])) { $products1c = new Products1c; $products1c->id = $arr["id"]; $products1c->tip = 'city_store'; @@ -1058,7 +1054,7 @@ class DataController extends BaseController if ($arr["terminals"]) { $k = 0; foreach ($arr["terminals"] as $gi2 => $arr2) { - if (!in_array($arr2['id'], $products1cTerminals)) { + if (!in_array($arr2['id'], $products1cByTipMap['terminals'])) { $products1c2 = new Products1c; $products1c2->id = $arr2['id']; $products1c2->tip = 'terminals'; @@ -1090,7 +1086,7 @@ class DataController extends BaseController if ($arr['kkms']) { foreach ($arr["kkms"] as $gi2 => $arr2) { - if (!in_array($arr2['id'], $products1cKkms)) { + if (!in_array($arr2['id'], $products1cByTipMap['kkms'])) { $products1c3 = new Products1c; $products1c3->id = $arr2["id"]; $products1c3->tip = 'kkms'; -- 2.39.5