<?php
declare (strict_types = 1);

namespace app\controller;

use app\BaseController;
use think\facade\Request;
use app\model\TransferLogModel;

/**
 * 转账记录控制器
 */
class TransferLog extends BaseController
{
    /**
     * 获取转账记录列表
     */
    public function list()
    {
        $userInfo = $this->request->userInfo;
        
        // 获取查询参数
        $page = Request::get('page', 1, 'intval');
        $limit = Request::get('limit', 20, 'intval');
        
        // 筛选条件
        $filters = [
            // 时间筛选
            'start_time' => Request::get('start_time', '', 'trim'),
            'end_time' => Request::get('end_time', '', 'trim'),
            // 平台ID筛选
            'uname' => Request::get('uname', '', 'trim'),
            // 玩家ID筛选
            'player_id' => Request::get('user_id', '', 'trim'), 
            // 平台昵称
            'nickname' => Request::get('nickname', '', 'trim'),            
            // 状态筛选
            'status' => Request::get('status', ''),
            // 转账流水号筛选
            'tx_id' => Request::get('tx_id', '', 'trim'),
        ];
        
        try {
            $result = TransferLogModel::getTransferLogs($userInfo['merchant_id'], $page, $limit, $filters);
            return json_success($result, '获取成功');
        } catch (\Exception $e) {
            return json_error([], '获取转账记录失败：' . $e->getMessage());
        }
    }

}