<?php

namespace app\api_broker\controller;

use app\api_broker\extend\Basic;
use app\api_broker\service\ReportService;

/**
 * Created by PhpStorm.
 * User : zw
 * Date : 2018/1/24
 * Time : 14:24
 * Intro:
 */
class Report extends Basic
{
    private $service_;

    public function __construct($request = null)
    {
        parent::__construct($request);
        $this->service_ = new ReportService();

    }

    /**
     * 报备
     * @return \think\Response
     */
    public function report()
    {
        /*   $params = $this->params;
           if (!isset($params['report_agent_id']) || !isset($params['report_store_id']) || !isset($params['user_id']) ||
               !isset($params['house_ids']) || !isset($params['vehicle']) ) {
               return $this->response("101", "请求参数错误");
           }*/

        $params = array(
            "report_agent_id"  => 1,//报备经纪人id
            "report_store_id"  => 1,//门店id
            "user_id"          => 1,//用户id
            "house_ids"        => "1,2,3",//楼盘id
            "vehicle"          => 10,//交通工具
            "intro"            => "123123123",//备注
            "predict_see_time" => date("Y-m-d H:i:s", time()),//预计到看时间
        );
        //todo 检查经纪人状态 basic类做

        //todo 验证用户id是否正常

        $agent_id         = $params["report_agent_id"];
        $store_id         = $params["report_store_id"];
        $user_id          = $params["user_id"];
        $house_ids        = $params["house_ids"];
        $vehicle          = $params["vehicle"];
        $intro            = $params["intro"];
        $predict_see_time = $params["predict_see_time"];

        $is_ok = $this->service_->verifyReport($agent_id, $store_id, $user_id, $house_ids, $vehicle, $intro, $predict_see_time);
        if($is_ok > 0){
            return $this->response("200","request success",[]);
        }else{
            return $this->response("101","save exception");
        }


    }

    /**
     * 根据报备的编号进场
     * @return \think\Response
     */
    public function marchInByOrderId()
    {
        return $this->response();
    }
}