refactor: 重构规范部分代码、邮件队列增加失败重试、去除多个支付方式、更新依赖

This commit is contained in:
xboard
2024-04-10 00:51:03 +08:00
parent ec63e05575
commit 4c6c7182e2
50 changed files with 421 additions and 1005 deletions
@@ -17,14 +17,15 @@ class PaymentController extends Controller
try {
$paymentService = new PaymentService($method, null, $uuid);
$verify = $paymentService->notify($request->input());
if (!$verify) return $this->fail([422,'verify error']);
if (!$verify)
return $this->fail([422, 'verify error']);
if (!$this->handle($verify['trade_no'], $verify['callback_no'])) {
return $this->fail([400,'handle error']);
return $this->fail([400, 'handle error']);
}
return (isset($verify['custom_result']) ? $verify['custom_result'] : 'success');
} catch (\Exception $e) {
\Log::error($e);
return $this->fail([500,'fail']);
return $this->fail([500, 'fail']);
}
}
@@ -32,9 +33,10 @@ class PaymentController extends Controller
{
$order = Order::where('trade_no', $tradeNo)->first();
if (!$order) {
return $this->fail([400202,'order is not found']);
return $this->fail([400202, 'order is not found']);
}
if ($order->status !== 0) return true;
if ($order->status !== Order::STATUS_PENDING)
return true;
$orderService = new OrderService($order);
if (!$orderService->paid($callbackNo)) {
return false;
@@ -13,24 +13,23 @@ class TelegramController extends Controller
protected $commands = [];
protected $telegramService;
public function __construct(Request $request)
public function __construct(TelegramService $telegramService)
{
if ($request->input('access_token') !== md5(admin_setting('telegram_bot_token'))) {
throw new ApiException('access_token is error', 401);
}
$this->telegramService = new TelegramService();
$this->telegramService = $telegramService;
}
public function webhook(Request $request)
{
if ($request->input('access_token') !== md5(admin_setting('telegram_bot_token'))) {
throw new ApiException('access_token is error', 401);
}
$data = json_decode(get_request_content(),true);
$this->formatMessage($data);
$this->formatChatJoinRequest($data);
$this->handle();
}
public function handle()
private function handle()
{
if (!$this->msg) return;
$msg = $this->msg;
@@ -68,7 +67,7 @@ class TelegramController extends Controller
}
}
public function getBotName()
private function getBotName()
{
$response = $this->telegramService->getMe();
return $response->result->username;