];
}
- $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year']);
+ $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year'], null, $filters['week']);
var_dump($forecast);die();
foreach ($result as $productId => &$productData) {
return $pricesMap;
}
- public function getWeeklyBouquetProductsForecast($month, $year, $storeId = null)
+ public function getWeeklyBouquetProductsForecast($month, $year, $storeId = null, $weekNumber = null)
{
$matrixGroups = ArrayHelper::map(
MatrixBouquetForecast::find()->select(['group'])->distinct()->asArray()->all(),
'group',
'group'
);
+
$date = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-01';
+
$result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId, $matrixGroups);
$weekShares = $this->getHistoricalSpeciesShareByWeek($date);
$flatData = $result['flatData'];
}
foreach ($weekIndex[$key] as $weekShare) {
+ if ($weekNumber !== null && (int)$weekShare['week'] !== (int)$weekNumber) {
+ continue; // фильтрация по неделе
+ }
+
$weeklyForecasts[] = [
'store_id' => $item['store_id'],
'category' => $item['category'],
];
}
}
- return $weeklyForecasts;
+ return $weeklyForecasts;
}
-
}
\ No newline at end of file