From: fomichev Date: Thu, 15 May 2025 17:29:38 +0000 (+0300) Subject: Расчет цели букета выбор магазина X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=501295bbbd04230ae60136ec6503d80c4c4c040b;p=erp24_rep%2Fyii-erp24%2F.git Расчет цели букета выбор магазина --- diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index a31e736f..d7694441 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -307,12 +307,14 @@ class BouquetController extends Controller $post = $request->post(); $month = $post['DynamicModel']['month'] ?? 5; $year = $post['DynamicModel']['year'] ?? 2025; + $storeId = $post['DynamicModel']['storeId'] ?? 2; $model = DynamicModel::validateData( - ['month' => $month, 'year' => $year], + ['month' => $month, 'year' => $year, 'storeId' => $storeId], [ - [['month', 'year'], 'required'], + [['month', 'year', 'storeId'], 'required'], ['month', 'integer', 'min' => 1, 'max' => 12], + ['storeId', 'integer', 'min' => 1, 'max' => 100], ['year', 'integer', 'min' => 2000, 'max' => 2100], ] ); @@ -320,12 +322,14 @@ class BouquetController extends Controller if ($request->isPost && $model->validate()) { $month = $model->month; $year = $model->year; + $storeId = $model->storeId; } else { $model->month = $month; $model->year = $year; + $model->storeId = $storeId; } - $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, 2); + $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId); //var_dump($result); die(); $stores = CityStore::find() ->select(['id', 'name']) diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index 650f13d1..e14f6bd2 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -964,7 +964,7 @@ class StorePlanService foreach ($components as $productId => $count) { $products[] = [ 'product_guid' => $productId, - 'count' => (int)$count, + 'count' => (float)$count, ]; } } @@ -988,11 +988,21 @@ class StorePlanService } foreach ($storesParams as $storeId => $regionId) { + if (!$regionId) { + if (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1342) { + $regionId = 52; + } elseif (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1) { + $regionId = 77; + } else { + $regionId = null; + } + } + $pricesData = ArrayHelper::map( PricesDynamic::find() ->where(['product_id' => $productGuids]) ->andWhere(['active' => 1]) - ->andWhere(['region_id' => $regionId]) + ->andWhere(['or', ['region_id' => $regionId], ['region_id' => null]]) ->select(['price', 'product_id']) ->asArray() ->all(), diff --git a/erp24/views/bouquet/month-goal-forecast.php b/erp24/views/bouquet/month-goal-forecast.php index c9b91dc4..227cf122 100644 --- a/erp24/views/bouquet/month-goal-forecast.php +++ b/erp24/views/bouquet/month-goal-forecast.php @@ -26,12 +26,13 @@ $saleTypesLabels = [
Url::to(['bouquet/month-goal']), + 'action' => Url::to(['bouquet/month-goal-forecast']), 'method' => 'post', ]); ?> field($model, 'month')->input('number')->label('Месяц') ?> field($model, 'year')->input('number')->label('Год') ?> + field($model, 'storeId')->dropDownList($storesMap)->label('Магазин') ?>
'btn btn-primary']) ?> @@ -76,9 +77,9 @@ $saleTypesLabels = [ $sum = array_sum($salesTypes); return [ 'species' => $species, - 'offline' => $salesTypes[1] ?? 0, - 'online' => $salesTypes[2] ?? 0, - 'marketplace' => $salesTypes[3] ?? 0, + 'offline' => $salesTypes['offline'] ?? 0, + 'online' => $salesTypes['online'] ?? 0, + 'marketplace' => $salesTypes['marketplace'] ?? 0, 'sum' => $sum, ]; }, array_keys($speciesData), $speciesData),