notify($request->input()); if (!$verify) return $this->fail([422,'verify error']); if (!$this->handle($verify['trade_no'], $verify['callback_no'])) { return $this->fail([400,'handle error']); } return(isset($verify['custom_result']) ? $verify['custom_result'] : 'success'); } catch (\Exception $e) { return $this->fail([500,'fail']); } } private function handle($tradeNo, $callbackNo) { $order = Order::where('trade_no', $tradeNo)->first(); if (!$order) { return $this->fail([400202,'order is not found']); } if ($order->status !== 0) return true; $orderService = new OrderService($order); if (!$orderService->paid($callbackNo)) { return false; } $telegramService = new TelegramService(); $message = sprintf( "💰成功收款%s元\n———————————————\n订单号:%s", $order->total_amount / 100, $order->trade_no ); $telegramService->sendMessageWithAdmin($message); return true; } }