From 9f8dbd442dc77bdfdf6796bc51aa9dd2837768ec Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Tue, 27 Jan 2026 12:48:09 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=20=D1=80=D0=B5=D0=B2=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/MarketplaceController.php | 58 ++++++++++---------- erp24/services/OrderControlReportService.php | 10 ++-- 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/erp24/commands/MarketplaceController.php b/erp24/commands/MarketplaceController.php index 0962267a..e3ce4618 100644 --- a/erp24/commands/MarketplaceController.php +++ b/erp24/commands/MarketplaceController.php @@ -445,38 +445,40 @@ class MarketplaceController extends Controller $result->totalIssues > 0 ? BaseConsole::FG_RED : BaseConsole::FG_GREEN); $this->stdout("Сохранено состояний: {$result->statesSaved}\n", BaseConsole::FG_CYAN); - // Статус отправки - $this->stdout("\nОтправка уведомлений:\n", BaseConsole::FG_YELLOW); + // Статус отправки (только если есть проблемы) + if ($result->hasIssues()) { + $this->stdout("\nОтправка уведомлений:\n", BaseConsole::FG_YELLOW); - if ($asyncMode) { - // Асинхронный режим — задачи поставлены в очередь - if ($result->telegramSent) { - $this->stdout(" Telegram: ✅ поставлено в очередь\n", BaseConsole::FG_GREEN); - } else { - $errorMsg = $result->telegramError ?? 'не удалось поставить в очередь'; - $this->stdout(" Telegram: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); - } + if ($asyncMode) { + // Асинхронный режим — задачи поставлены в очередь + if ($result->telegramSent) { + $this->stdout(" Telegram: ✅ поставлено в очередь\n", BaseConsole::FG_GREEN); + } else { + $errorMsg = $result->telegramError ?? 'не удалось поставить в очередь'; + $this->stdout(" Telegram: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); + } - if ($result->emailSent) { - $this->stdout(" Email: ✅ поставлено в очередь\n", BaseConsole::FG_GREEN); - } else { - $errorMsg = $result->emailError ?? 'не удалось поставить в очередь'; - $this->stdout(" Email: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); - } - } else { - // Синхронный режим — отправлено сразу - if ($result->telegramSent) { - $this->stdout(" Telegram: ✅ отправлено\n", BaseConsole::FG_GREEN); + if ($result->emailSent) { + $this->stdout(" Email: ✅ поставлено в очередь\n", BaseConsole::FG_GREEN); + } else { + $errorMsg = $result->emailError ?? 'не удалось поставить в очередь'; + $this->stdout(" Email: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); + } } else { - $errorMsg = $result->telegramError ?? 'неизвестная ошибка'; - $this->stdout(" Telegram: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); - } + // Синхронный режим — отправлено сразу + if ($result->telegramSent) { + $this->stdout(" Telegram: ✅ отправлено\n", BaseConsole::FG_GREEN); + } else { + $errorMsg = $result->telegramError ?? 'неизвестная ошибка'; + $this->stdout(" Telegram: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); + } - if ($result->emailSent) { - $this->stdout(" Email: ✅ отправлено\n", BaseConsole::FG_GREEN); - } else { - $errorMsg = $result->emailError ?? 'неизвестная ошибка'; - $this->stdout(" Email: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); + if ($result->emailSent) { + $this->stdout(" Email: ✅ отправлено\n", BaseConsole::FG_GREEN); + } else { + $errorMsg = $result->emailError ?? 'неизвестная ошибка'; + $this->stdout(" Email: ❌ ошибка - {$errorMsg}\n", BaseConsole::FG_RED); + } } } diff --git a/erp24/services/OrderControlReportService.php b/erp24/services/OrderControlReportService.php index 967b8e78..ba595358 100644 --- a/erp24/services/OrderControlReportService.php +++ b/erp24/services/OrderControlReportService.php @@ -243,8 +243,6 @@ class OrderControlReportService // Помечаем отправленные $this->markIssuesAsNotified($issuesToSave); } else { - $result->telegramSent = true; - $result->emailSent = true; $this->logInfo('Нет проблемных заказов, уведомления не требуются'); } @@ -324,7 +322,9 @@ class OrderControlReportService ->leftJoin(['mosub' => 'marketplace_order_status_types'], 'mosub.id = mo.substatus_id') ->where(['mo.fake' => 0]) ->andWhere(['not', ['mo.status_processing_1c' => null]]) - ->andWhere(['in', new Expression('mo.status_processing_1c::integer'), $rmkCourierIds]) + ->andWhere(new Expression( + 'CAST(mo.status_processing_1c AS integer) IN (' . implode(',', array_map('intval', $rmkCourierIds)) . ')' + )) ->andWhere(['>=', 'mo.updated_at', $startDateStr]) ->andWhere(['<=', 'mo.updated_at', $endDateStr]) ->andWhere([ @@ -639,7 +639,9 @@ class OrderControlReportService ->andWhere(['<=', 'mo.updated_at', $endDateStr]) ->andWhere(['most.code' => MarketplaceOrderStatusTypes::CANSELLED_CODE]) ->andWhere(['not', ['mo.status_processing_1c' => null]]) - ->andWhere(['in', new Expression('mo.status_processing_1c::integer'), $rmkCancelIds]) + ->andWhere(new Expression( + 'CAST(mo.status_processing_1c AS integer) IN (' . implode(',', array_map('intval', $rmkCancelIds)) . ')' + )) ->andWhere(new Expression('COALESCE(mo.cancelled_order_sent, 0) = 0')) ->orderBy(['cs.name' => SORT_ASC, 'mo.creation_date' => SORT_DESC]) ->all(); -- 2.39.5