<?php

namespace App\Http\Controllers\Share;

use App\Managers\SharePairManager;
use App\Services\Share\GteamService;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Core\Auth;
use App\Services\Share\FlowerService;
use App\Services\Share\LockService;

class ShareController extends Controller
{
    public function ing()
    {
        $uid = Auth::auth();
        // 72小时
        $ps = new SharePairManager();
        $pairdata = $ps->inglist($uid);
        // 解锁卡片任务
        $ls = new LockService();
        $lockdata = $ls->inglist($uid);
        // 小fa分享
        $fs = new FlowerService();
        $flowerdata = $fs->ing($uid);
        // 开黑任务
        $gs = new GteamService();
        $gteamdata = $gs->inglist($uid);
        $data = array();
        foreach ($pairdata as $tmp) {
            $data[] = $tmp;
        }
        foreach ($lockdata as $tmp) {
            $data[] = $tmp;
        }
        foreach ($flowerdata as $tmp) {
            $data[] = $tmp;
        }
        foreach ($gteamdata as $tmp) {
            $data[] = $tmp;
        }
        usort($data, function ($a, $b) {
            if ($a['expired_at'] > $b['expired_at']) {
                return false;
            } else {
                return true;
            }
        });
        return array(
            'code' => 200,
            'message' => 'success',
            'data' => $data
        );
    }
}
