From de463423ef3f847b8c7b5128884af9d54f3e9426 Mon Sep 17 00:00:00 2001 From: fomichev Date: Wed, 26 Feb 2025 15:29:00 +0300 Subject: [PATCH] =?utf8?q?=D0=9B=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?utf8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=20=D1=84=D0=B0=D0=B9=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/.gitignore | 3 +- .../controllers/NotificationController.php | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/erp24/.gitignore b/erp24/.gitignore index c25408fc..8943eaed 100644 --- a/erp24/.gitignore +++ b/erp24/.gitignore @@ -40,4 +40,5 @@ tests/_support/_generated /data/* /runtime/* /api2/runtime/* -/api2/json/* \ No newline at end of file +/api2/json/* +/media/notification/* \ No newline at end of file diff --git a/erp24/media/controllers/NotificationController.php b/erp24/media/controllers/NotificationController.php index b36e951d..9c5ef109 100644 --- a/erp24/media/controllers/NotificationController.php +++ b/erp24/media/controllers/NotificationController.php @@ -22,6 +22,9 @@ use yii_app\services\MarketplaceService; class NotificationController extends Controller { + const OUT_DIR = + //"/www/media/notification"; + "/var/www/erp24/media/notification"; public function actionTest() { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; @@ -66,11 +69,21 @@ class NotificationController extends Controller */ $rawBody = Yii::$app->request->getRawBody(); + file_put_contents( + self::OUT_DIR . '/notifications.json', + PHP_EOL . date('Y-m-d H:i:s') . ' ' . $rawBody, + FILE_APPEND + ); try { $data = Json::decode($rawBody); } catch (\Exception $e) { Yii::error("Ошибка декодирования JSON: " . $e->getMessage()); Yii::$app->response->statusCode = 400; + file_put_contents( + self::OUT_DIR . '/notification_error.txt', + PHP_EOL . date("d.m.Y H:i:s", time()) . " " . $e->getMessage() . $e->getLine(), + FILE_APPEND + ); return $this->asJson([ 'error' => [ 'type' => 'WRONG_EVENT_FORMAT', @@ -285,6 +298,11 @@ class NotificationController extends Controller $returnedAt = $orderReturnData['returnedAt']; } catch (\Exception $e) { Yii::$app->response->statusCode = 400; + file_put_contents( + self::OUT_DIR . '/notification_error.txt', + PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . $e->getLine(), + FILE_APPEND + ); return $this->asJson([ 'error' => [ 'type' => 'WRONG_EVENT_FORMAT', @@ -339,6 +357,11 @@ class NotificationController extends Controller default: Yii::info("Неизвестный тип события: {$eventType}"); + file_put_contents( + self::OUT_DIR . '/notification_error.txt', + PHP_EOL . date("d.m.Y H:i:s", time()) . " Неизвестный тип события: {$eventType}", + FILE_APPEND + ); return $this->asJson([ 'success' => true, 'message' => 'Unknown event ignored' @@ -346,6 +369,11 @@ class NotificationController extends Controller } } catch (\Exception $e) { Yii::error("Error processing event {$eventType}: " . $e->getMessage()); + file_put_contents( + self::OUT_DIR . '/notification_error.txt', + PHP_EOL . date("d.m.Y H:i:s", time()) . $e->getMessage() . $e->getLine(), + FILE_APPEND + ); Yii::$app->response->statusCode = 500; return $this->asJson([ 'error' => [ -- 2.39.5