From 5db49435aea74542b856c570eafc322e729314b1 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 12:42:41 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../AutoPlannogrammaController.php | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index addc9b76..86b297bc 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -205,35 +205,34 @@ class AutoPlannogrammaController extends BaseController ], ], ]; - - - foreach ($result as $productId => &$productData) { + + foreach ($result as &$productData) { foreach ($productData['values'] as &$value) { $storeId = $value['store_id']; $quantity = $value['quantity']; $value['title'] = []; - if (!isset($forecast[$storeId]) || !isset($forecast[$storeId][$productId])) { - continue; - } - foreach (['offline', 'marketplace', 'online'] as $channel) { - if (isset($forecast[$storeId][$productId][$channel]) && is_array($forecast[$storeId][$productId][$channel])) { - // Суммируем все коэффициенты по группам для данного канала - $coefSum = 0; - foreach ($forecast[$storeId][$productId][$channel] as $coef) { - if (is_numeric($coef)) { - $coefSum += $coef; - } - } - if ($coefSum > 0) { - $value['title'][$channel] = round($quantity * $coefSum, 2); - } + // Если по этому магазину и каналу есть просто share — умножаем + if (isset($forecast[$storeId][$channel]['share'])) { + $share = $forecast[$storeId][$channel]['share']; + $value['title'][$channel] = round($quantity * $share, 2); + } + + // Если по этому магазину и каналу есть список с продуктами — просто копируем + if ( + isset($forecast[$storeId][$channel]) && + is_array($forecast[$storeId][$channel]) && + !isset($forecast[$storeId][$channel]['share']) // чтобы не дублировать + ) { + $value['title'][$channel] = $forecast[$storeId][$channel]; } } } } + + return array_values($result); } -- 2.39.5