From 9e79113b0155c4cfe5daaf8e12650c11a05193ee Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 6 Jun 2025 13:24:44 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C?= =?utf8?q?=D1=8E=20=D0=B8=20=D0=BE=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?utf8?q?=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/CategoryPlanController.php | 2 +- erp24/services/StorePlanService.php | 30 ++++++----- .../views/category-plan/show-history-data.php | 53 ++++++++++--------- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index d5989dc7..b2b52b9d 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -364,7 +364,7 @@ class CategoryPlanController extends Controller { } } } - // var_dump($weightedResults); die(); + return $this->render('show-history-data', [ 'result' => $result, 'weighted' => $weightedResults, diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index d660a6d3..185ba93a 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -854,7 +854,6 @@ class StorePlanService ->all(); $dur = (hrtime(true) - $t1) / 1e6; Yii::warning( "Query {$storeId}: {$dur} ms\n"); - //var_dump($similarProductIds, $storeId, $startDate, $endDate);die(); $t2 = hrtime(true); $salesValues = []; foreach ($similarProductIds as $id) { @@ -920,9 +919,24 @@ class StorePlanService $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year); $monthEnd = sprintf('%04d-%02d-%02d', $year, $month, $daysInMonth); + $region = CityStoreParams::find() + ->where(['store_id' => $storeId]) + ->one()->address_region; + + if (!$region) { + // определяем регион по городу + $cityId = CityStore::find()->select('city_id')->where(['id' => $storeId])->scalar(); + if ($cityId == 1) { + $region = BouquetComposition::REGION_MSK; + } else { + $region = BouquetComposition::REGION_NN; + } + } + $priceRecords = PricesDynamic::find() ->where(['product_id' => $productId]) ->andWhere(['<=', 'date_from', $monthEnd]) + ->andWhere(['region_id' => $region]) ->andWhere([ 'or', ['>=', 'date_to', $monthStart], @@ -930,15 +944,6 @@ class StorePlanService ])->all(); - if (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1342) { - $region = BouquetComposition::REGION_NN; - } elseif (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1) { - $region = BouquetComposition::REGION_MSK; - } else { - $region = null; - } - //$priceRecords->andWhere(['or',['region_id' => $region],['region_id' => null]]) - //->all(); if (!empty($priceRecords)) { $totalPrice = 0; @@ -1136,11 +1141,9 @@ class StorePlanService if ($matrixTypesIds) { foreach ($matrixTypesIds as $matrixTypeId) { $bouquetsArray = StorePlanService::getBouqetsByDate($month, $year, $matrixTypeId); - $bouquetsArray = StorePlanService::getBouqetsByDate(5, 2025, 2); $forecasts = ArrayHelper::getColumn($bouquetsArray, 'bouquetForecast'); $ids = ArrayHelper::getColumn($bouquetsArray, 'id'); - //var_dump($ids); die(); foreach ($forecasts as $forecastArray) { if (is_array($forecastArray)) { foreach ($forecastArray as $fc) { @@ -1160,7 +1163,6 @@ class StorePlanService $resultData = []; $detailData = []; - //var_dump($storesForecasts);die(); foreach ($storesForecasts as $storeForecast) { $products = ArrayHelper::toArray(BouquetCompositionProducts::getCompositionProducts($storeForecast['bouquet_id'])); $productGuids = array_filter(array_column($products, 'product_guid')); @@ -1178,7 +1180,7 @@ class StorePlanService foreach ($products as $product) { $productModel = Products1cNomenclature::find()->where(['id' => $product['product_guid']])->one(); $species = ($productModel !== null) ? $productModel->species : 'Неизвестно'; - $basePrice = isset($pricesData[$product['product_guid']]) ? $pricesData[$product['product_guid']] : 0; + $basePrice = $pricesData[$product['product_guid']] ?? 0; $rawCalculation = $basePrice * $product['count'] * $storeForecast["type_sales_value"]; $productCost = round($rawCalculation * BouquetCompositionPrice::SURCHARGE_ASSEMBLY, 2); diff --git a/erp24/views/category-plan/show-history-data.php b/erp24/views/category-plan/show-history-data.php index fc030f30..60a06e53 100644 --- a/erp24/views/category-plan/show-history-data.php +++ b/erp24/views/category-plan/show-history-data.php @@ -24,31 +24,36 @@ use yii_app\records\Products1c; 'post', ]); ?> - - field($model, 'storeId') - ->dropDownList($storeList, ['prompt' => 'Выберите магазин']) - ->label('Магазин') ?> - - field($model, 'month') - ->dropDownList($monthsList, ['prompt' => 'Выберите месяц']) - ->label('Месяц') ?> - - field($model, 'category') - ->dropDownList($categoryList, ['prompt' => 'Выберите категорию']) - ->label('Категория') ?> - - field($model, 'subcategory') - ->dropDownList($subcategoryList, ['prompt' => 'Выберите подкатегорию']) - ->label('Подкатегория') ?> - - field($model, 'species') - ->dropDownList($speciesList, ['prompt' => 'Выберите вид товара']) - ->label('Вид товара') ?> - -
- 'btn btn-primary']) ?> +
+
+ field($model, 'storeId') + ->dropDownList($storeList, ['prompt' => 'Выберите магазин']) + ->label('Магазин') ?> +
+
+ field($model, 'month') + ->dropDownList($monthsList, ['prompt' => 'Выберите месяц']) + ->label('Месяц') ?> +
+
+ field($model, 'category') + ->dropDownList($categoryList, ['prompt' => 'Выберите категорию']) + ->label('Категория') ?> +
+
+ field($model, 'subcategory') + ->dropDownList($subcategoryList, ['prompt' => 'Выберите подкатегорию']) + ->label('Подкатегория') ?> +
+
+ field($model, 'species') + ->dropDownList($speciesList, ['prompt' => 'Выберите вид товара']) + ->label('Вид товара') ?> +
+
+ 'btn btn-primary']) ?> +
-