<?php

namespace App\Services\Complain;

use App\Http\Controllers\Miniprogram\Core;
use App\Models\ComplaintModel;
use App\Models\User\UserModel;
use App\Services\Log\NoticeLogService;
use App\Services\NoticeService\Channels\WeChatTemplateChannel;
use App\Services\QQMiniApp\Template;
use PocketBE\MsyPush\Jobs\RegistEventJob;

class NoticeService
{

    /**
     * 回复举报者
     * @param  ComplaintModel  $complaint
     */
    public function reply(ComplaintModel $complaint)
    {
        $to_uid = $complaint->uid;
        $user = UserModel::find($to_uid);
        $payload = [
            'to_user' => $user->getAuth(),
            'complaint' => $complaint->toArray(),
            'meta' => [
                'date' => date('Y-m-d'),
            ],
        ];
        dispatch(new RegistEventJob(10501, $payload))->onQueue("{push}");
    }


    /**
     * 拉黑被举报者通知
     * @param  ComplaintModel  $complaint
     */
    public function defriendNoticeBeuser(ComplaintModel $complaint)
    {
        $to_uid = $complaint->be_uid;
        $user = UserModel::find($to_uid);
        $payload = [
            'to_user' => $user->getAuth(),
            'complaint' => $complaint->toArray(),
            'meta' => [
                'date' => date('Y-m-d'),
            ],
        ];
        dispatch(new RegistEventJob(10502, $payload))->onQueue("{push}");
    }


    /**
     * 拉黑通知举报者
     * @param  ComplaintModel  $complaint
     */
    public function defriendNotice(ComplaintModel $complaint)
    {
        $to_uid = $complaint->uid;
        $user = UserModel::find($to_uid);
        $payload = [
            'to_user' => $user->getAuth(),
            'complaint' => $complaint->toArray(),
            'meta' => [
                'date' => date('Y-m-d'),
            ],
        ];
        dispatch(new RegistEventJob(10503, $payload))->onQueue("{push}");
    }


    /**
     * 举报-删除被举报者字段通知
     * @param  ComplaintModel  $complaint
     */
    public function erasingNotice(ComplaintModel $complaint)
    {
        $to_uid = $complaint->be_uid;
        $user = UserModel::find($to_uid);
        $payload = [
            'to_user' => $user->getAuth(),
            'complaint' => $complaint->toArray(),
            'meta' => [
                'date' => date('Y-m-d'),
            ],
        ];
        dispatch(new RegistEventJob(10504, $payload))->onQueue("{push}");
    }
}
