]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-356] call site api
authorAlexander Smirnov <fredeom@mail.ru>
Mon, 3 Mar 2025 13:49:55 +0000 (16:49 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Mon, 3 Mar 2025 13:49:55 +0000 (16:49 +0300)
erp24/api2/controllers/BalanceController.php
erp24/api2/controllers/BonusController.php

index e595b35a2f95ff5aea58047458a7840441d5088a..ca6af9a18fb407987d154b82ee8d7d4e34be7bda 100644 (file)
@@ -35,4 +35,9 @@ class BalanceController extends BaseController {
 
         return $this->asJson($mess);
     }
+
+    public function actionTest() {
+        Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
+        return ['ok'];
+    }
 }
\ No newline at end of file
index 8168ee4a4a232a6d17b410cdeb8eb2fb22707fd7..881a05a62470458e0cc2043453232fb27558267c 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace app\controllers;
 
+use GuzzleHttp\Client;
 use DateTime;
 use DateTimeZone;
 use Yii;
@@ -1198,6 +1199,19 @@ class BonusController extends BaseController
         $mess["user_balans_actual"] = $user->balans;
         LogService::apiLogs(1, json_encode($mess, JSON_UNESCAPED_UNICODE));
       file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__ . ' OK ', FILE_APPEND);
+
+        $client = new Client();
+        try {
+            $client->post('https://api2.dev.erp-flowers.ru/balance/test', [
+                'phone' => $phone,
+                'balance' => $user->balans,
+                'created_at' => date('Y-m-d H:i:s'),
+            ]);
+        } catch (\Exception $e) {
+            LogService::apiErrorLog(json_encode(["error_id" => 7, "error" => "Ошибка отправки сообщения в Telegram: " .
+                $e->getMessage()], JSON_UNESCAPED_UNICODE));
+        }
+
         return $this->asJson($mess);
     }