From 212639ee574f65f7831a82b9c5d4b758e5588217 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Fri, 4 Jul 2025 19:41:18 +0300 Subject: [PATCH] =?utf8?q?[BC-278]=20=D0=9E=D1=82=D0=BF=D1=80=D0=B0=D0=B2?= =?utf8?q?=D0=BA=D0=B0=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D1=8F=20=D0=B2=20=D0=A2=D0=B5=D0=BB=D0=B5=D0=B3=D1=80=D0=B0?= =?utf8?q?=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/jobs/SendTelegramPromoMessageJob.php | 7 +-- erp24/services/TelegramService.php | 70 +++++++++++++--------- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/erp24/jobs/SendTelegramPromoMessageJob.php b/erp24/jobs/SendTelegramPromoMessageJob.php index 67331bea..7177eb53 100644 --- a/erp24/jobs/SendTelegramPromoMessageJob.php +++ b/erp24/jobs/SendTelegramPromoMessageJob.php @@ -39,12 +39,9 @@ class SendTelegramPromoMessageJob extends \yii\base\BaseObject implements JobInt if ($result == "OK") { try { -// $result = TelegramService::saveSentMessageToDB($this->messageData); - //TODO - перенос сюда обновления статусов записей когорт - if ($result) { + + if (1) { Yii::warning("Сообщение успешно сохранено для пользователя с ID {$chatId} телефон {$phone}", 'telegram'); - } else { - Yii::warning("Сообщение не удалось сохранить для пользователя с ID {$chatId} телефон {$phone}", 'telegram'); } } catch (\Exception $e) { diff --git a/erp24/services/TelegramService.php b/erp24/services/TelegramService.php index 9058136e..1eb4afd4 100644 --- a/erp24/services/TelegramService.php +++ b/erp24/services/TelegramService.php @@ -203,23 +203,11 @@ class TelegramService Только 7 дней: Скидка 20% на три стильных букета из нашей летней коллекции!'; - $pic1Path = curl_file_create( - __DIR__ . '/../web/images/pic_1.jpg', - 'image/jpg', - 'pic_1.jpg' - ); + $pic1Path =__DIR__ . '/../web/images/pic_1.jpg'; - $pic2Path = curl_file_create( - __DIR__ . '/../web/images/pic_2.jpg', - 'image/jpg', - 'pic_2.jpg' - ); + $pic2Path = __DIR__ . '/../web/images/pic_2.jpg'; - $pic3Path = curl_file_create( - __DIR__ . '/../web/images/pic_3.jpg', - 'image/jpg', - 'pic_3.jpg' - ); + $pic3Path = __DIR__ . '/../web/images/pic_3.jpg'; $result = 'false'; @@ -228,19 +216,47 @@ class TelegramService $buttons = self::getTgShortButtons($chatId); $client = new Client(); + + $media = [ + [ + 'type' => 'photo', + 'media' => 'attach://pic_1.jpg', + 'caption' => $text, + ], + [ + 'type' => 'photo', + 'media' => 'attach://pic_2.jpg', + ], + [ + 'type' => 'photo', + 'media' => 'attach://pic_3.jpg', + ] + ]; + try { - $response1 = $client->post($apiURL1, [ - 'json' => [ - 'chat_id' => $chatId, - 'media' => json_encode([ - ['type' => 'photo', 'media' => 'attach://pic_1.jpg', "caption" => $text], - ['type' => 'photo', 'media' => 'attach://pic_2.jpg' ], - ['type' => 'photo', 'media' => 'attach://pic_3.jpg' ], - ]), - 'pic_1.jpg' => $pic1Path, - 'pic_2.jpg' => $pic2Path, - 'pic_3.jpg' => $pic3Path, - ], + $response1 = $client->post($apiURL1,[ + 'multipart' => [ + [ + 'name' => 'chat_id', + 'contents' => $chatId + ], + [ + 'name' => 'media', + 'contents' => json_encode($media) + ], + [ + 'name' => 'pic_1.jpg', + 'contents' => fopen($pic1Path, 'r') + ], + [ + 'name' => 'pic_2.jpg', + 'contents' => fopen($pic2Path, 'r') + ], + [ + 'name' => 'pic_3.jpg', + 'contents' => fopen($pic3Path, 'r') + ], + ] ]); if ($response1->getStatusCode() !== 200) { -- 2.39.5