]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Разметка констант
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 19 May 2025 09:38:26 +0000 (12:38 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 19 May 2025 09:38:26 +0000 (12:38 +0300)
erp24/services/StorePlanService.php

index 155c7c2d0d021f95f0c1813d8711d1109e8b982b..afa1015927b5edf68579a5ee12d48ca17c06848a 100755 (executable)
@@ -26,6 +26,7 @@ use yii_app\records\WriteOffsErp;
 
 class StorePlanService
 {
+    const SURCHARGE_ASSEMBLY = 1.15; // Коэффициент наценки за сборку - 15%
 
     /**
      * @param int $month
@@ -637,9 +638,9 @@ class StorePlanService
 
 
         if (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1342) {
-            $region = 52;
+            $region = BouquetComposition::REGION_NN;
         } elseif (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1) {
-            $region = 77;
+            $region = BouquetComposition::REGION_MSK;
         } else {
             $region = null;
         }
@@ -869,7 +870,7 @@ class StorePlanService
                 PricesDynamic::find()
                     ->where(['product_id' => $productGuids])
                     ->andWhere(['active' => 1])
-                    ->andWhere(['region_id' => $storesParams[$storeForecast["type_sales_id"]] ?? 52])
+                    ->andWhere(['region_id' => $storesParams[$storeForecast["type_sales_id"]] ?? BouquetComposition::REGION_NN])
                     ->select(['price', 'product_id'])
                     ->asArray()
                     ->all(),
@@ -881,7 +882,7 @@ class StorePlanService
                 $species = ($productModel !== null) ? $productModel->species : 'Неизвестно';
                 $basePrice = isset($pricesData[$product['product_guid']]) ? $pricesData[$product['product_guid']] : 0;
                 $rawCalculation = $basePrice * $product['count'] * $storeForecast["type_sales_value"];
-                $productCost = round($rawCalculation * 1.15, 2);
+                $productCost = round($rawCalculation * self::SURCHARGE_ASSEMBLY, 2);
 
                 if (!isset($resultData[$storeForecast["type_sales_id"]][$species][$storeForecast["type_sales"]])) {
                     $resultData[$storeForecast["type_sales_id"]][$species][$storeForecast["type_sales"]] = 0;
@@ -1005,9 +1006,9 @@ class StorePlanService
                         }
 
                         $regionId = $params['address_region'] ?: match ($storeCities[$sid] ?? null) {
-                            1342 => 52,
-                            1    => 77,
-                            default => 52,
+                            1342 => BouquetComposition::REGION_NN,
+                            1    => BouquetComposition::REGION_MSK,
+                            default => BouquetComposition::REGION_NN,
                         };
 
                         $priceKey = $regionId . ':' . md5(implode(',', $productGuids));
@@ -1030,7 +1031,7 @@ class StorePlanService
                             $species = $speciesCache[$guid]['species'] ?? 'Неизвестно';
                             $price = $prices[$guid] ?? 0;
                             $raw = $price * $product['count'] * $typeSalesValue;
-                            $cost = round($raw * 1.15, 2);
+                            $cost = round($raw * self::SURCHARGE_ASSEMBLY, 2);
 
                             $resultData[$sid][$species][$typeSales] = ($resultData[$sid][$species][$typeSales] ?? 0) + $cost;
                             $debugData[$sid][$species][$typeSales][] = [