<?php

namespace app\workerapi\controller;

use app\common\logic\MasterWorkerExamineLogic;
use app\common\model\dict\DictData;
use app\workerapi\lists\MasterWorkerLists;
use app\workerapi\lists\ServiceWorkLists;
use app\workerapi\lists\TeamServiceWorkLists;
use app\workerapi\logic\LoginLogic;
use app\workerapi\logic\MasterWorkerInfoLogic;
use app\workerapi\logic\MasterWorkerLogic;
use app\workerapi\logic\MasterWorkerTeamLogic;
use app\workerapi\validate\BankAccountValidate;
use app\workerapi\validate\MasterWokerInfoValidate;
use app\workerapi\validate\MasterWokerTeamValidate;
use app\workerapi\validate\MasterWokerValidate;

class MasterWorkerTeamController extends BaseApiController
{
    public array $notNeedLogin = [''];

    /**
     * 获取团队信息
     * @return \think\response\Json
     */
    public function getTeamInfo()
    {
        $result = MasterWorkerTeamLogic::getDetail($this->userId);
        return $this->data($result);
    }

    /**
     * 团队成员列表展示和分配
     * @return \think\response\Json
     */
    public function getMemberList()
    {
        return $this->dataLists(new MasterWorkerLists());
    }

    /**
     * 添加团队成员
     * @return \think\response\Json
     */
    public function addTeamMember()
    {
        $params = (new MasterWokerTeamValidate())->post()->goCheck('add');
        /*$res = LoginLogic::confirmMobile($params);
        if(!$res){
            return $this->fail(LoginLogic::getError());
        }*/
        $result = MasterWorkerTeamLogic::addTeamMember($params,$this->userId);
        if($result === false){
            return $this->fail(MasterWorkerTeamLogic::getError());
        }
        return $this->success('', [], 1, 1);
    }

    /**
     * 分配工单给团队成员
     * @return \think\response\Json
     */
    public function allocation()
    {
        $params = (new MasterWokerTeamValidate())->post()->goCheck('allocation');
        $result = MasterWorkerTeamLogic::allocation($params,$this->userInfo);
        if($result === false){
            return $this->fail(MasterWorkerTeamLogic::getError());
        }
        return $this->success('', [], 1, 1);
    }
    /**
     * 团队工单状态统计
     * @return \think\response\Json
     */
    public function getTeamWorkCount()
    {
        $result = MasterWorkerTeamLogic::MemberWorkStatistics($this->userInfo);
        return $this->data($result);
    }

    /**
     * 团队工单查询
     * @return \think\response\Json
     */
    public function getTeamWorkLists()
    {
        return $this->dataLists(new TeamServiceWorkLists());
    }

}