<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Http\Controllers\Core\Auth;
use App\Services\User\SignService;
use Illuminate\Http\Request;

/**
 * Class SignController
 * @package App\Http\Controllers\User
 */
class SignController extends Controller
{
    /**
     * 今日签到情况
     */
    public function today()
    {
        $uid = Auth::auth();

        $ss = new SignService();
        $data = $ss->today($uid);

        return response([
            'code' => 200,
            'message' => 'success',
            'data' => $data
        ]);
    }

    /**
     * 签到
     * @throws \App\Exceptions\AlertException
     */
    public function sign(Request $request)
    {
        $uid = Auth::auth();
        $platform = $request->header('platform');

        $signService = new SignService();
        $signService->sign($uid, $platform);

        return response([
            'code' => 200,
            'message' => 'success'
        ]);
    }

    /**
     * 领取小花奖励
     * @throws \App\Exceptions\AlertException
     */
    public function rewardFlower()
    {
        $uid = Auth::auth();

        $signService = new SignService();
        $flower = $signService->rewardFlower($uid);

        return response([
            'code' => 200,
            'message' => 'success',
            'data' => compact("flower")
        ]);
    }

    /**
     * 领取人气值奖励
     * @throws \App\Exceptions\AlertException
     */
    public function rewardPopularity()
    {
        $uid = Auth::auth();

        $signService = new SignService();
        $popularity = $signService->rewardPopularity($uid);

        return response([
            'code' => 200,
            'message' => 'success',
            'data' => compact("popularity")
        ]);
    }


    /**
     * 领取解锁次数
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
     * @throws \App\Exceptions\AlertException
     * @throws \Tymon\JWTAuth\Exceptions\JWTException
     */
    public function rewardUnLookCard()
    {
        $uid = Auth::auth();

        $signService = new SignService();
        $signService->rewardUnLookCard($uid);

        return response([
            'code' => 200,
            'message' => 'OK'
        ]);
    }


    /**
     * 领取72h卡券满减券
     * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
     * @throws \App\Exceptions\AlertException
     * @throws \Tymon\JWTAuth\Exceptions\JWTException
     */
    public function rewardCouponSuperVip()
    {
        $uid = Auth::auth();

        $signService = new SignService();
        $couponSuperVip = $signService->rewardCouponSuperVip($uid);

        return response([
            'code' => 200,
            'message' => 'success',
            'data' => compact("couponSuperVip")
        ]);
    }

    /**
     * 72小时折扣券
     * @throws \App\Exceptions\AlertException
     */
    public function rewardCoupon72Dis()
    {
        $uid = Auth::auth();

        $signService = new SignService();
        $coupon72dis = $signService->rewardCoupon72Dis($uid);

        return response([
            'code' => 200,
            'message' => 'success',
            'data' => compact("coupon72dis")
        ]);
    }

    /**
     * 72h报名入场券
     * @throws \App\Exceptions\AlertException
     */
    public function rewardCoupon72Pair()
    {
        $uid = Auth::auth();

        $signService = new SignService();
        $coupon72pair = $signService->rewardCoupon72Pair($uid);

        return response([
            'code' => 200,
            'message' => 'success',
            'data' => compact("coupon72pair")
        ]);
    }
}
