From 42f8a62d085dc6f7a3af2c197db2e3c8d2f6a406 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 1 Jul 2025 17:04:29 +0300 Subject: [PATCH] =?utf8?q?ERP-433=20=D0=9E=D1=82=D1=87=D0=B5=D1=82=20?= =?utf8?q?=D0=BF=D0=BE=20=D0=BE=D1=81=D1=82=D0=B0=D1=82=D0=BA=D0=B0=D0=BC?= =?utf8?q?=20=D0=B1=D1=83=D0=BA=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B4=D0=BB?= =?utf8?q?=D1=8F=20=D0=9C=D0=9F=20=D0=B8=20=D0=BF=D1=80=D0=B8=D1=87=D0=B8?= =?utf8?q?=D0=BD=D0=B0=D0=BC,=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BB=D0=BE?= =?utf8?q?=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=BD=D0=B5=20=D0=BF=D1=80=D0=BE?= =?utf8?q?=D1=85=D0=BE=D0=B4=D0=B8=D1=82.=20=D0=92=D0=BE=D0=B7=D0=BC=D0=BE?= =?utf8?q?=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D1=80=D1=83=D1=87=D0=BD?= =?utf8?q?=D0=BE=D0=B9=20=D0=B2=D1=8B=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8?= =?utf8?q?=20=D0=B8=D0=B7=20ERP=20=D0=B2=20Excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/actions/marketplace/ReportAction.php | 42 ++++++++++++++-------- erp24/services/MarketplaceService.php | 11 ------ erp24/views/marketplace/report.php | 16 ++++++++- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/erp24/actions/marketplace/ReportAction.php b/erp24/actions/marketplace/ReportAction.php index 7e9ffd98..8a48bde5 100644 --- a/erp24/actions/marketplace/ReportAction.php +++ b/erp24/actions/marketplace/ReportAction.php @@ -24,24 +24,36 @@ class ReportAction extends Action ]) ->select('p1n.id'); - $productsRaw = Products1c::find() + $products = Products1c::find() + ->alias('p1n') + ->leftJoin('prices p', 'p.product_id = p1n.id') + ->leftJoin('matrix_erp_property mep', 'mep.guid = p1n.id') + ->select([ + 'p1n.id', + 'p1n.name', + 'p1n.articule', + new \yii\db\Expression(" + CASE + WHEN mep.id IS NULL AND p.price IS NULL THEN + 'Не имеет состава букета в MatrixErpProperty и нет цена' + WHEN mep.id IS NULL THEN + 'Не имеет состава букета в MatrixErpProperty' + WHEN p.price IS NULL THEN + 'Нет цены' + ELSE NULL + END AS reason + "), + new \yii\db\Expression(" + CASE + WHEN mep.id IS NULL OR p.price IS NULL THEN FALSE + ELSE TRUE + END AS is_valid + ") + ]) ->where(['in', 'parent_id', $subQuery]) - ->limit(10) + ->asArray() ->all(); - $marketplaceService = new MarketplaceService(); - - $products = []; - - foreach ($productsRaw as $product) { - $check = $marketplaceService->checkProducts($product, true); - $products[] = [ - 'id' => $product->id, - 'name' => $product->name, - 'articule' => $product->articule, - 'checkResult' => $check !== false ? 'true' : 'false', - ]; - } $dataProvider = new ArrayDataProvider([ 'allModels' => $products, diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index e309da99..7bc8b269 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -486,19 +486,8 @@ class MarketplaceService return false; } - $price = MarketplaceService::getProductPrice($product->id); - if ($price == 0) { - if ($isView) { - $message = "У товара {$product->id} отсутствует цена и он будет исключен из фида."; - Yii::error($message, __METHOD__); - InfoLogService::setInfoLog(__FILE__, __LINE__, $message, 'Zero price error'); - } - return false; - } - return [ 'properties' => $properties, - 'price' => $price, ]; } diff --git a/erp24/views/marketplace/report.php b/erp24/views/marketplace/report.php index a3fedd2c..4195a3e9 100644 --- a/erp24/views/marketplace/report.php +++ b/erp24/views/marketplace/report.php @@ -20,7 +20,21 @@ $this->params['breadcrumbs'][] = $this->title; 'name', 'articule', 'id', - 'checkResult', + [ + 'attribute' => 'is_valid', + 'label' => 'Активен ли букет на МП?', + 'value' => function ($model) { + return $model->is_valid ? 'Да' : 'Нет'; + } + ], + [ + 'attribute' => 'reason', + 'label' => 'Причина не активности', + 'value' => function ($model) { + return $model->reason; + } + ], + 'reason', ], ]); ?> -- 2.39.5