|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\api;
|
|
|
|
|
|
|
|
use App\Constants\StepStatus;
|
|
use App\Constants\StepStatus;
|
|
|
use App\Constants\Util;
|
|
use App\Constants\Util;
|
|
|
|
|
+use App\Services\LogService;
|
|
|
use App\Services\PublicService;
|
|
use App\Services\PublicService;
|
|
|
use App\Services\QianBaoWithdrawService;
|
|
use App\Services\QianBaoWithdrawService;
|
|
|
use App\Services\SanJinRechargeService;
|
|
use App\Services\SanJinRechargeService;
|
|
@@ -38,19 +39,12 @@ class TelegramWebHook extends BaseController
|
|
|
parent::__construct();
|
|
parent::__construct();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @throws TelegramSDKException
|
|
|
|
|
+ */
|
|
|
public function handle(Request $request): JsonResponse
|
|
public function handle(Request $request): JsonResponse
|
|
|
{
|
|
{
|
|
|
- try {
|
|
|
|
|
- $telegram = new Api(config('services.telegram.token'));
|
|
|
|
|
- } catch (TelegramSDKException $e) {
|
|
|
|
|
- return response()->json(['status' => 'ok']);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $telegram = new Api(config('services.telegram.token'));
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
$update = $telegram->getWebhookUpdate(); // 获取更新数据
|
|
$update = $telegram->getWebhookUpdate(); // 获取更新数据
|
|
@@ -88,15 +82,13 @@ class TelegramWebHook extends BaseController
|
|
|
}//
|
|
}//
|
|
|
catch (Exception $e) {
|
|
catch (Exception $e) {
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
- $json = json_encode(['line' => $e->getLine(), 'message' => $e->getMessage()]);
|
|
|
|
|
- Log::error('Telegram 处理消息异常: ');
|
|
|
|
|
- Log::error($json);
|
|
|
|
|
|
|
+ LogService::error($e);
|
|
|
$telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
|
|
$telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
|
|
|
}
|
|
}
|
|
|
} //
|
|
} //
|
|
|
else {
|
|
else {
|
|
|
$update = $request->all();
|
|
$update = $request->all();
|
|
|
- if (isset($update['message'])) {
|
|
|
|
|
|
|
+ if (isset($update['message'])) {
|
|
|
$message = $update['message'];
|
|
$message = $update['message'];
|
|
|
$chatId = $message['chat']['id'];
|
|
$chatId = $message['chat']['id'];
|
|
|
$messageId = $message['message_id'];
|
|
$messageId = $message['message_id'];
|
|
@@ -120,9 +112,7 @@ class TelegramWebHook extends BaseController
|
|
|
}//
|
|
}//
|
|
|
catch (Exception $e) {
|
|
catch (Exception $e) {
|
|
|
DB::rollBack();
|
|
DB::rollBack();
|
|
|
- $json = json_encode(['line' => $e->getLine(), 'message' => $e->getMessage()]);
|
|
|
|
|
- Log::error('Telegram 处理消息异常: ');
|
|
|
|
|
- Log::error($json);
|
|
|
|
|
|
|
+ LogService::error($e);
|
|
|
$telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
|
|
$telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -131,11 +121,7 @@ class TelegramWebHook extends BaseController
|
|
|
} //
|
|
} //
|
|
|
catch (Exception $e) {
|
|
catch (Exception $e) {
|
|
|
if (!empty($chatId)) {
|
|
if (!empty($chatId)) {
|
|
|
- try {
|
|
|
|
|
- $telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
|
|
|
|
|
- } catch (TelegramSDKException $e) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $telegram->sendMessage(['chat_id' => $chatId, 'text' => '‼️‼️系统发生了错误,请联系客服']);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return response()->json(['status' => 'ok']);
|
|
return response()->json(['status' => 'ok']);
|