->all();
$dur = (hrtime(true) - $t1) / 1e6;
Yii::warning( "Query {$storeId}: {$dur} ms\n");
- //var_dump($similarProductIds, $storeId, $startDate, $endDate);die();
$t2 = hrtime(true);
$salesValues = [];
foreach ($similarProductIds as $id) {
$daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$monthEnd = sprintf('%04d-%02d-%02d', $year, $month, $daysInMonth);
+ $region = CityStoreParams::find()
+ ->where(['store_id' => $storeId])
+ ->one()->address_region;
+
+ if (!$region) {
+ // определяем регион по городу
+ $cityId = CityStore::find()->select('city_id')->where(['id' => $storeId])->scalar();
+ if ($cityId == 1) {
+ $region = BouquetComposition::REGION_MSK;
+ } else {
+ $region = BouquetComposition::REGION_NN;
+ }
+ }
+
$priceRecords = PricesDynamic::find()
->where(['product_id' => $productId])
->andWhere(['<=', 'date_from', $monthEnd])
+ ->andWhere(['region_id' => $region])
->andWhere([
'or',
['>=', 'date_to', $monthStart],
])->all();
- if (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1342) {
- $region = BouquetComposition::REGION_NN;
- } elseif (CityStore::find()->where(['id' => $storeId])->one()->city_id == 1) {
- $region = BouquetComposition::REGION_MSK;
- } else {
- $region = null;
- }
- //$priceRecords->andWhere(['or',['region_id' => $region],['region_id' => null]])
- //->all();
if (!empty($priceRecords)) {
$totalPrice = 0;
if ($matrixTypesIds) {
foreach ($matrixTypesIds as $matrixTypeId) {
$bouquetsArray = StorePlanService::getBouqetsByDate($month, $year, $matrixTypeId);
- $bouquetsArray = StorePlanService::getBouqetsByDate(5, 2025, 2);
$forecasts = ArrayHelper::getColumn($bouquetsArray, 'bouquetForecast');
$ids = ArrayHelper::getColumn($bouquetsArray, 'id');
- //var_dump($ids); die();
foreach ($forecasts as $forecastArray) {
if (is_array($forecastArray)) {
foreach ($forecastArray as $fc) {
$resultData = [];
$detailData = [];
- //var_dump($storesForecasts);die();
foreach ($storesForecasts as $storeForecast) {
$products = ArrayHelper::toArray(BouquetCompositionProducts::getCompositionProducts($storeForecast['bouquet_id']));
$productGuids = array_filter(array_column($products, 'product_guid'));
foreach ($products as $product) {
$productModel = Products1cNomenclature::find()->where(['id' => $product['product_guid']])->one();
$species = ($productModel !== null) ? $productModel->species : 'Неизвестно';
- $basePrice = isset($pricesData[$product['product_guid']]) ? $pricesData[$product['product_guid']] : 0;
+ $basePrice = $pricesData[$product['product_guid']] ?? 0;
$rawCalculation = $basePrice * $product['count'] * $storeForecast["type_sales_value"];
$productCost = round($rawCalculation * BouquetCompositionPrice::SURCHARGE_ASSEMBLY, 2);
<?php $form = ActiveForm::begin([
'method' => 'post',
]); ?>
-
- <?= $form->field($model, 'storeId')
- ->dropDownList($storeList, ['prompt' => 'Выберите магазин'])
- ->label('Магазин') ?>
-
- <?= $form->field($model, 'month')
- ->dropDownList($monthsList, ['prompt' => 'Выберите месяц'])
- ->label('Месяц') ?>
-
- <?= $form->field($model, 'category')
- ->dropDownList($categoryList, ['prompt' => 'Выберите категорию'])
- ->label('Категория') ?>
-
- <?= $form->field($model, 'subcategory')
- ->dropDownList($subcategoryList, ['prompt' => 'Выберите подкатегорию'])
- ->label('Подкатегория') ?>
-
- <?= $form->field($model, 'species')
- ->dropDownList($speciesList, ['prompt' => 'Выберите вид товара'])
- ->label('Вид товара') ?>
-
- <div class="form-group">
- <?= Html::submitButton('Отправить', ['class' => 'btn btn-primary']) ?>
+ <div class="row p-3">
+ <div class="col-md">
+ <?= $form->field($model, 'storeId')
+ ->dropDownList($storeList, ['prompt' => 'Выберите магазин'])
+ ->label('Магазин') ?>
+ </div>
+ <div class="col-md">
+ <?= $form->field($model, 'month')
+ ->dropDownList($monthsList, ['prompt' => 'Выберите месяц'])
+ ->label('Месяц') ?>
+ </div>
+ <div class="col-md">
+ <?= $form->field($model, 'category')
+ ->dropDownList($categoryList, ['prompt' => 'Выберите категорию'])
+ ->label('Категория') ?>
+ </div>
+ <div class="col-md">
+ <?= $form->field($model, 'subcategory')
+ ->dropDownList($subcategoryList, ['prompt' => 'Выберите подкатегорию'])
+ ->label('Подкатегория') ?>
+ </div>
+ <div class="col-md">
+ <?= $form->field($model, 'species')
+ ->dropDownList($speciesList, ['prompt' => 'Выберите вид товара'])
+ ->label('Вид товара') ?>
+ </div>
+ <div class="form-group col-md">
+ <?= Html::submitButton('Отправить', ['class' => 'btn btn-primary']) ?>
+ </div>
</div>
-
<?php ActiveForm::end(); ?>
<?php