class StorePlanService
{
+ const SURCHARGE_ASSEMBLY = 1.15; // Коэффициент наценки за сборку - 15%
/**
* @param int $month
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;
}
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(),
$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;
}
$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));
$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][] = [