| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?phpnamespace App\Services;//战绩相关服务use App\Models\RoomUser;class RecordService{    public function getList($chatId, $firstName, $messageId = null, $page = 1, $limit = 4)    {        $list = RoomUser::where('status', 4)            ->where('member_id', $chatId)            ->with('room:room_id,game_name,base_score,participants,rounds')            ->forPage($page, $limit)            ->orderBy('updated_at', 'desc')            ->get();        $count = RoomUser::where('status', 4)            ->where('member_id', $chatId)            ->count();        $test = "👤 {$firstName}  战绩记录\n\n";        foreach ($list as $item) {            $test .= "游戏:{$item->room->game_name}   {$item->room->participants}人   {$item->room->rounds}局   房间号:{$item->room_id}\n";            $test .= "底分:{$item->room->base_score} USDT\n";            $test .= "得分:{$item->score}\n";            $temp = floatval($item->real_score);            $test .= "盈亏:{$temp} USDT\n";            $temp = floatval($item->brokerage);            if ($temp > 0) $test .= "抽佣:{$temp} USDT\n";            $test .= "日期:{$item->updated_at}\n";            $test .= "-----------------------------------------\n";        }        if ($page > 1) {            $keyboard[] = [                ['text' => "👆上一页", 'callback_data' => "recordNextPage@@" . ($page - 1)]            ];        }        $allPage = ceil($count / $limit);        if ($allPage > $page) {            if ($page > 1) {                $keyboard[count($keyboard) - 1][] = ['text' => "👇下一页", 'callback_data' => "recordNextPage@@" . ($page + 1)];            } else {                $keyboard[] = [                    ['text' => "👇下一页", 'callback_data' => "recordNextPage@@" . ($page + 1)]                ];            }        }        $keyboard[] = [            ['text' => "返回", 'callback_data' => "message@@close"]        ];        return [            'chat_id' => $chatId,            'text' => $test,            'message_id' => $messageId,            'reply_markup' => json_encode(['inline_keyboard' => $keyboard]),        ];    }}
 |