<?php
namespace app\workerapi\controller;

use app\workerapi\lists\IssueWorkLists;
use app\workerapi\logic\IssueWorkLogic;
use app\workerapi\validate\IssueWorkValidate;

/**
 * 投诉工单系统
 */
class IssueWorkController extends BaseApiController
{
    /**
     * 投诉工单列表
     *
     * @return \think\response\Json
     */
    public function issueWorkList()
    {
        return $this->dataLists(new IssueWorkLists());
    }

    /**
     * 投诉工单详情
     * @return \think\response\Json
     */
    public function detail()
    {
        $params = (new IssueWorkValidate())->goCheck('detail',[
            'user_id' => $this->userId,
        ]);
        $result = IssueWorkLogic::detail($params);
        if (false === $result) {
            return $this->fail(IssueWorkLogic::getError());
        }
        return $this->data($result);
    }

    /**
     * 投诉单提交申述申请
     * @return \think\response\Json
     */
    public function submitApproval()
    {
        $params = (new IssueWorkValidate())->post()->goCheck('approval', [
            'user_id' => $this->userId,
            'user_info' => $this->userInfo
        ]);
        $result = IssueWorkLogic::submitApproval($params);
        if (false === $result) {
            return $this->fail(IssueWorkLogic::getError());
        }
        return $this->success('已提交申述', [], 1, 1);
    }
}