From f2718c0f9124434349f9db55b703f8cf74030099 Mon Sep 17 00:00:00 2001 From: fomichev Date: Mon, 19 May 2025 17:03:19 +0300 Subject: [PATCH] =?utf8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7=D0=B0?= =?utf8?q?=D1=86=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=BE?= =?utf8?q?=D0=B2=20=D0=B8=20=D1=86=D0=B8=D0=BA=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/StorePlanService.php | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index 5ce67ab9..366491f7 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -829,24 +829,29 @@ class StorePlanService $matrixTypesIds = StorePlanService::getActiveMatrixTypes(); $storesForecasts = []; + $priceDictionary = []; + $priceModel = BouquetCompositionPrice::find() + ->select(['bouquet_id', 'region_id', 'price']) + ->asArray() + ->all(); + foreach ($priceModel as $price) { + $priceDictionary[$price['bouquet_id']][$price['region_id']]['price'] = $price['price']; + } if ($matrixTypesIds) { foreach ($matrixTypesIds as $matrixTypeId) { $bouquetsArray = StorePlanService::getBouqetsByDate($month, $year, $matrixTypeId); + $bouquetsArray = StorePlanService::getBouqetsByDate(5, 2025, 2); $forecasts = ArrayHelper::getColumn($bouquetsArray, 'bouquetForecast'); - var_dump($bouquetsArray); die(); + $ids = ArrayHelper::getColumn($bouquetsArray, 'id'); + + //var_dump($ids); die(); foreach ($forecasts as $forecastArray) { if (is_array($forecastArray)) { foreach ($forecastArray as $fc) { $bouquetPrice = 0; - if (isset($storesParams[$fc["type_sales_id"]])) { - $priceModel = BouquetCompositionPrice::find() - ->where(['bouquet_id' => $fc['bouquet_id']]) - ->andWhere(['region_id' => $storesParams[$fc["type_sales_id"]]]) - ->one(); - if ($priceModel !== null) { - $bouquetPrice = $priceModel->price; - } + if (isset($storesParams[$fc["type_sales_id"]]) &&$priceDictionary[$fc['bouquet_id']][$storesParams[$fc["type_sales_id"]]] !== null) { + $bouquetPrice = $priceDictionary[$fc['bouquet_id']][$storesParams[$fc["type_sales_id"]]]['price']; } $storesForecasts[] = array_merge($fc, [ 'matrixTypeId' => $matrixTypeId, @@ -860,7 +865,7 @@ class StorePlanService $resultData = []; $detailData = []; - //var_dump($storesParams);die(); + //var_dump($storesForecasts);die(); foreach ($storesForecasts as $storeForecast) { $products = ArrayHelper::toArray(BouquetCompositionProducts::getCompositionProducts($storeForecast['bouquet_id'])); $productGuids = array_filter(array_column($products, 'product_guid')); -- 2.39.5