<?php

namespace App\Services\Gteam;

use App\Models\Gteam\EnterModel;
use App\Models\User\UserModel;
use App\Services\Log\NoticeLogService;
use PocketBE\MsyPush\Jobs\RegistEventJob;

class NoticeService
{


    private $gametype = [
        "cj_wx" => [
            "game" => "cj",
            "area" => "wx",
        ],
        "cj_qq" => [
            "game" => "cj",
            "area" => "qq",
        ],
        "wz_wx" => [
            "game" => "wz",
            "area" => "wx",
        ],
        "wz_qq" => [
            "game" => "wz",
            "area" => "qq",
        ],
    ];

    private $activity_type = [
        "cj_qq" => "一起吃鸡",
        "cj_wx" => "一起吃鸡",
        "wz_qq" => "一起打王者",
        "wz_wx" => "一起打王者",
    ];


    /**
     * 邀请好友助力成功-提高成功率
     * @param $to_uid
     * @param $friend_uid
     * @param $enter_id
     * @return bool
     */
    public function inviteToScore($to_uid, $friend_uid, $enter_id)
    {
        $title = "开黑-邀请好友助力提高成功率";
        $user = UserModel::find($to_uid);
        $friend_user = UserModel::find($friend_uid);
        $enter = EnterModel::find($enter_id);
        $payload = [
            'to_user' => $user->getAuth(),
            'friend_user' => $friend_user->toArray(),
            'enter' => $enter->toArray(),
        ];
        dispatch(new RegistEventJob(10301, $payload))->onQueue("{push}");
    }


    /**
     * 开黑帮助好友助力
     * @param $to_uid
     * @param $friend_uid
     * @param $enter_id
     * @return bool
     * @throws \App\Exceptions\AlertException
     * @throws \App\Exceptions\ApiException
     */
    public function helpToScore($to_uid, $friend_uid, $enter_id)
    {
        $title = "开黑-帮助好友助力";
        $user = UserModel::find($to_uid);
        $friend_user = UserModel::find($friend_uid);
        $enter = EnterModel::find($enter_id);
        $payload = [
            'to_user' => $user->getAuth(),
            'friend_user' => $friend_user->toArray(),
            'enter' => $enter->toArray(),
        ];
        dispatch(new RegistEventJob(10302, $payload))->onQueue("{push}");
    }


    /**
     * 开黑匹配成功
     * @param  int  $enter_id
     * @param $friend_uid
     * @return bool
     * @throws \Exception
     */
    public function matchSuccess(int $to_uid, int $friend_uid, int $enter_id)
    {
        $title = "开黑-匹配成功通知";
        $uuid = uuid();
        $noticeLog = new NoticeLogService();

        $user = UserModel::find($to_uid);
        $friend_user = UserModel::find($friend_uid);
        $enter = EnterModel::find($enter_id);
        $payload = [
            'to_user' => $user->getAuth(),
            'friend_user' => $friend_user->toArray(),
            'enter' => $enter->toArray(),
        ];
        dispatch(new RegistEventJob(10303, $payload))->onQueue("{push}");
    }


    /**
     * 开黑-匹配失败通知
     * @param $to_uid
     * @param $enter_id
     * @return bool
     */
    public function matchFail($to_uid, $enter_id)
    {
        $title = "开黑-匹配失败通知";

        $user = UserModel::find($to_uid);
        $enter = EnterModel::find($enter_id);
        $payload = [
            'to_user' => $user->getAuth(),
            'user' => $user->toArray(),
            'enter' => $enter->toArray(),
        ];
        dispatch(new RegistEventJob(10304, $payload))->onQueue("{push}");
    }
}
