From 079fee766eb77d384d2a10d82267189306706e4b Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 12:19:25 +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 | 74 ++++++++++++++++--- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index 505369a6..b5dbd86f 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -152,25 +152,81 @@ class AutoPlannogrammaController extends BaseController $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year'], null, $filters['week']); + $forecast = [ + 2 => [ + 'offline' => [ + 'share' => 0.6, + ], + 'c5743ee5-9832-11ef-84ea-ac1f6b1b7573' => [ + 'offline' => [ + 'дополнительная_букеты' => 1.93, + 'доп_Хризантема' => 2.17, + ], + 'marketplace' => [ + 'дополнительная_букеты' => 0.97, + 'доп_Хризантема' => 0.72, + ], + 'online' => [ + 'дополнительная_букеты' => 1.93, + 'доп_Хризантема' => 2.17, + ], + ], + '0fb4e768-8191-11ef-84ea-ac1f6b1b7573' => [ + 'offline' => [ + 'дополнительная_букеты' => 0.83, + 'дополнительная_композиция' => 0.63, + 'основная_розовая' => 3.34, + 'основная_красно-белая' => 1.46, + 'основная_красная' => 8.76, + 'основная_бело-зеленая' => 0.83, + ], + 'marketplace' => [ + 'дополнительная_букеты' => 0.42, + 'дополнительная_композиция' => 0.21, + 'основная_розовая' => 1.67, + 'основная_красно-белая' => 0.83, + 'основная_красная' => 4.59, + 'основная_бело-зеленая' => 0.42, + ], + 'online' => [ + 'дополнительная_букеты' => 0.83, + 'дополнительная_композиция' => 0.63, + 'основная_розовая' => 3.34, + 'основная_красно-белая' => 1.46, + 'основная_красная' => 8.76, + 'основная_бело-зеленая' => 0.83, + ], + ], + 'marketplace' => [ + 'share' => 0.2, + ], + 'online' => [ + 'share' => 0.2, + ], + ], + ]; + + foreach ($result as $productId => &$productData) { foreach ($productData['values'] as &$value) { $storeId = $value['store_id']; + $group = $value['group']; + $quantity = $value['quantity']; $value['title'] = []; - if (isset($forecast[$storeId][$productId])) { - $forecastData = $forecast[$storeId][$productId]; - $quantity = $value['quantity']; - - foreach ($forecastData as $type => $groups) { - if (isset($groups['share'])) { - $calculated = round($quantity * $groups['share'], 2); - $value['title'][$type] = $calculated; - } + foreach (['offline', 'marketplace', 'online'] as $channel) { + if ( + isset($forecast[$storeId][$channel][$group]) && + is_numeric($forecast[$storeId][$channel][$group]) + ) { + $coef = $forecast[$storeId][$channel][$group]; + $value['title'][$channel] = round($quantity * $coef, 2); } } } } + return array_values($result); } -- 2.39.5