$matrixTypesIds = StorePlanService::getActiveMatrixTypes();
$storesForecasts = [];
+ $priceDictionary = [];
+ $priceModel = BouquetCompositionPrice::find()
+ ->select(['bouquet_id', 'region_id', 'price'])
+ ->asArray()
+ ->all();
+ foreach ($priceModel as $price) {
+ $priceDictionary[$price['bouquet_id']][$price['region_id']]['price'] = $price['price'];
+ }
if ($matrixTypesIds) {
foreach ($matrixTypesIds as $matrixTypeId) {
$bouquetsArray = StorePlanService::getBouqetsByDate($month, $year, $matrixTypeId);
+ $bouquetsArray = StorePlanService::getBouqetsByDate(5, 2025, 2);
$forecasts = ArrayHelper::getColumn($bouquetsArray, 'bouquetForecast');
- var_dump($bouquetsArray); die();
+ $ids = ArrayHelper::getColumn($bouquetsArray, 'id');
+
+ //var_dump($ids); die();
foreach ($forecasts as $forecastArray) {
if (is_array($forecastArray)) {
foreach ($forecastArray as $fc) {
$bouquetPrice = 0;
- if (isset($storesParams[$fc["type_sales_id"]])) {
- $priceModel = BouquetCompositionPrice::find()
- ->where(['bouquet_id' => $fc['bouquet_id']])
- ->andWhere(['region_id' => $storesParams[$fc["type_sales_id"]]])
- ->one();
- if ($priceModel !== null) {
- $bouquetPrice = $priceModel->price;
- }
+ if (isset($storesParams[$fc["type_sales_id"]]) &&$priceDictionary[$fc['bouquet_id']][$storesParams[$fc["type_sales_id"]]] !== null) {
+ $bouquetPrice = $priceDictionary[$fc['bouquet_id']][$storesParams[$fc["type_sales_id"]]]['price'];
}
$storesForecasts[] = array_merge($fc, [
'matrixTypeId' => $matrixTypeId,
$resultData = [];
$detailData = [];
- //var_dump($storesParams);die();
+ //var_dump($storesForecasts);die();
foreach ($storesForecasts as $storeForecast) {
$products = ArrayHelper::toArray(BouquetCompositionProducts::getCompositionProducts($storeForecast['bouquet_id']));
$productGuids = array_filter(array_column($products, 'product_guid'));