]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Расчет цели букета выбор магазина
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 15 May 2025 17:29:38 +0000 (20:29 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 15 May 2025 17:29:38 +0000 (20:29 +0300)
erp24/controllers/BouquetController.php
erp24/services/StorePlanService.php
erp24/views/bouquet/month-goal-forecast.php

index a31e736f491cf62d0552d7e5be50155ab06795a1..d76944417af49272840405141debaf594973b5f9 100644 (file)
@@ -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'])
index 650f13d1af8adcad228cd94d6e6bb1c58c8444cd..e14f6bd2014fb0cceebda42eb1974b32db05e299 100755 (executable)
@@ -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(),
index c9b91dc46a9c63d141cb19abe73b62418618fdb3..227cf122901e3bbfc784b8844dbbf2627a54e5a1 100644 (file)
@@ -26,12 +26,13 @@ $saleTypesLabels = [
     <div class="month-goal-form col-4">
 
         <?php $form = ActiveForm::begin([
-            'action' => Url::to(['bouquet/month-goal']),
+            'action' => Url::to(['bouquet/month-goal-forecast']),
             'method' => 'post',
         ]); ?>
 
         <?= $form->field($model, 'month')->input('number')->label('Месяц') ?>
         <?= $form->field($model, 'year')->input('number')->label('Год') ?>
+        <?= $form->field($model, 'storeId')->dropDownList($storesMap)->label('Магазин') ?>
 
         <div class="form-group">
             <?= Html::submitButton('Показать', ['class' => '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),