public function getRateInfo($employeeSelectStoreId, $employeeGroupId, $dateFrom, $dateTo): array
{
- $query = RateStoreCategory::find()
- ->select(['category_id'])
- ->andWhere(['<=', 'date_from', $dateFrom])
- ->andWhere(['>=', 'date_to', $dateFrom])
- ->andWhere(['<=', 'date_from', $dateTo])
- ->andWhere(['>=', 'date_to', $dateTo])
- ->andWhere(['store_id'=> $employeeSelectStoreId]);
+ $rateInfo = [];
+ if ($dateFrom <= '2024-01-01') {
+ $query = RateStoreCategory::find()
+ ->select(['category_id'])
+ ->andWhere(['<=', 'date_from', $dateFrom])
+ ->andWhere(['>=', 'date_to', $dateFrom])
+ ->andWhere(['<=', 'date_from', $dateTo])
+ ->andWhere(['>=', 'date_to', $dateTo])
+ ->andWhere(['store_id' => $employeeSelectStoreId]);
$action = $query->createCommand()->getRawSql();
- $storeCategoryId = $query->asArray()->scalar();
+ $storeCategoryId = $query->asArray()->scalar();
- $rateDict = RateDict::find()
- ->indexBy('id')
- ->asArray()
- ->all();
+ $rateDict = RateDict::find()
+ ->indexBy('id')
+ ->asArray()
+ ->all();
- $normaSmena = RateCategoryAdminGroup::find()
- ->andWhere(['admin_group_id'=> $employeeGroupId])
- ->andWhere(['category_id'=> $storeCategoryId])
- ->asArray()
- ->one();
+ $normaSmena = RateCategoryAdminGroup::find()
+ ->andWhere(['admin_group_id' => $employeeGroupId])
+ ->andWhere(['category_id' => $storeCategoryId])
+ ->asArray()
+ ->one();
- if (!empty($normaSmena)) {
- $rate = (new NormaSmenaService())->getFormattedNormaSmena($normaSmena);
- }
+ if (!empty($normaSmena)) {
+ $rate = (new NormaSmenaService())->getFormattedNormaSmena($normaSmena);
+ }
- $rateInfo = [];
- if (!empty($rate)) {
- foreach ($rate as $key => $item) {
- $rateInfo[] = [
- 'id' => $key,
- 'name' => $rateDict[$key]['name'],
- 'condition' => $item,
- 'value' => $rateDict[$key]['value'],
- 'game_value' => $rateDict[$key]['game_value'],
- ];
+ if (!empty($rate)) {
+ foreach ($rate as $key => $item) {
+ $rateInfo[] = [
+ 'id' => $key,
+ 'name' => $rateDict[$key]['name'],
+ 'condition' => $item,
+ 'value' => $rateDict[$key]['value'],
+ 'game_value' => $rateDict[$key]['game_value'],
+ ];
+ }
}
}