<?php

namespace App\Http\Controllers\Share;

use App\Managers\SharePairManager;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Core\Auth;

class PairController extends Controller
{
    /**
     * 获取邀请详情
     * @param  int  $list_id
     * @return array
     * @deprecated Share/PairGet
     */
    public function get(int $list_id)
    {
        $ps = new SharePairManager();
        $data = $ps->get($list_id);
        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    /**
     * 匹配成功率分享完成列表
     * @param  Request  $request
     * @return array
     * @throws \Tymon\JWTAuth\Exceptions\JWTException
     */
    public function scorelist(Request $request)
    {
        $uid = Auth::auth();
        $page = $request->get('page') ?? 1;
        $pages = array(
            'limit' => 20,
            'page' => $page
        );
        $ps = new SharePairManager();
        $data = $ps->scorelist($uid, $pages);
        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }

    /**
     * 退费分享完成列表
     * @param  Request  $request
     * @return array
     * @throws \Tymon\JWTAuth\Exceptions\JWTException
     */
    public function refundlist(Request $request)
    {
        $uid = Auth::auth();
        $page = $request->get('page') ?? 1;
        $pages = array(
            'limit' => 20,
            'page' => $page
        );
        $ps = new SharePairManager();
        $data = $ps->refundlist($uid, $pages);
        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }
}
