<?php

namespace app\api\controller;



use app\api\logic\ReturnWorkLogic;
use app\api\validate\ReturnWorkValidate;

class ReturnWorkController extends BaseApiController
{
    public function lists()
    {
        $params['user_id'] = $this->userId;
        $result = ReturnWorkLogic::lists($params);
        return $this->data($result);
    }

    public function repairInfo()
    {
        $params = (new ReturnWorkValidate())->goCheck('detail', [
            'user_id' => $this->userId,
        ]);
        $result = ReturnWorkLogic::detail($params);
        return $this->data($result);
    }

    public function confirmFinish()
    {
        $params =  (new ReturnWorkValidate())->post()->goCheck('confirmFinish', [
            'user_id' => $this->userId,
        ]);
        $result = ReturnWorkLogic::confirmFinish($params);
        if (false === $result) {
            return $this->fail(ReturnWorkLogic::getError());
        }
        return $this->success('已确认服务完成', [], 1, 1);
    }

    public function getWorkStatus()
    {
        $params = (new ReturnWorkValidate())->goCheck('detail',[
            'user_id' => $this->userId,
        ]);
        $result = ReturnWorkLogic::detail($params);
        if (empty($result)) {
            return $this->fail('返修单不存在');
        }
        return $this->success('', ['return_work_status'=>$result['return_work_status']], 1, 1);
    }
}