审查视图

application/api/controller/Index.php 32.6 KB
王智 authored
1 2 3 4
<?php

namespace app\api\controller;
王智 authored
5
use think\console\input\Option;
王智 authored
6
use think\Db;
王智 authored
7 8 9
use app\common\controller\Api;

/**
王智 authored
10
 * 首页
王智 authored
11 12 13 14 15 16 17
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
王智 authored
18 19 20 21 22 23 24 25 26
     * @ApiTitle    (首页-报修单列表)
     * @ApiSummary  (报修单列表)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/ReportList)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiParams   (name="ids", type="int", required=true, description="报修单编号排序:1=是,0=否")
     * @ApiParams   (name="istime", type="int", required=true, description="根据时间排序:1=是,0=否")
     * @ApiParams   (name="status", type="int", required=true, description="审核状态:0=无,1=等待审核,2=审核通过,3=审核未通过")
     * @ApiParams   (name="zhandian", type="int", required=true, description="站点ID:0=无")
王智 authored
27
     * @ApiParams   (name="keywords", type="string", required=true, description="搜索关键字")
王智 authored
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
     * @ApiParams   (name="pages", type="int", required=true, description="页数")
     * @ApiParams   (name="rows", type="int", required=true, description="数据数量")
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": {
    "count": 总数,
    "list": [
    {
    "id": 1,
    "order_sn": "报修单编号",
    "type": 报修单状态:1=进行中,2=已完成,
    "repair_type": 维修状态:0=未接收,1=进行中,2=已完成,
    "status": 审核状态:0=不需要审核,1=等待审核,2=审核通过,3=审核未通过,
    "time": "2020-08-19"
    }
    ]
    }
    })
     */
    public function ReportList()
    {
        $param = $this->request->param();
        $user_id = $this->is_token($this->request->header());
        $user = Db::name('user')->where(['id' => $user_id])->find();
        $map = [];
        $map2 = [];
        $map3 = [];
王智 authored
58
        $map4 = [];
王智 authored
59 60 61 62 63 64 65 66 67
        if ($user['level'] == 5 || $user['level'] == 6) {
            $map['zhandian_id'] = ['eq', $user['zhandian_id']];
        }
        if ($param['status'] != 0) {
            $map2 ['status'] = ['eq', $param['status']];
        }
        if ($param['zhandian'] != 0) {
            $map3 ['zhandian_id'] = ['eq', $param['zhandian']];
        }
王智 authored
68 69 70 71 72
        if (!empty($param['keywords']) || $param['keywords'] != null || $param['keywords'] != '' || $param['keywords'] != "") {
            $map4 ['order_sn'] = ['LIKE', '%' . $param['keywords'] . '%'];
        }
        $arr = Db::name('baoxiudan')->where($map)->where($map2)->where($map3)->where($map4)->page($param['pages'], $param['rows'])->order('id desc')->select();
        $count = Db::name('baoxiudan')->where($map)->where($map2)->where($map3)->where($map4)->order('id desc')->select();
王智 authored
73 74 75 76 77 78 79 80 81 82 83 84 85 86
        if (empty($arr)) {
            $list = [
                'count' => 0,
                'list' => []
            ];
            $this->success('成功', $list);
            die;
        }
        foreach ($arr as $k => $v) {
            $list[$k]['id'] = $v['id'];   //报修单ID
            $list[$k]['order_sn'] = $v['order_sn'];   //订单编号
            $list[$k]['type'] = $v['type'];  //报修单状态
            $list[$k]['repair_type'] = $v['repair_type'];  //维修状态
            $list[$k]['status'] = $v['status'];  //审核状态
王智 authored
87
            $list[$k]['time'] = date('Y-m-d H:i:s', $v['createtime']);  //报修时间
王智 authored
88 89 90 91 92 93 94 95
//            $list[$k]['time'] = $v['createtime'];  //报修时间
        }
        if ($param['ids'] == 1) {
            array_multisort(array_column($list, 'id'), SORT_ASC, $list);
        }
        if ($param['istime'] == 1) {
            array_multisort(array_column($list, 'time'), SORT_ASC, $list);
        }
王智 authored
96 97
        if ($user['level'] == 5) {
            $bool = $this->time();
王智 authored
98
            if ($bool == 1) {
王智 authored
99 100 101 102 103 104 105
                $today = strtotime(date('Y-m-d', time()));
                $is_p = Db::name('month_talk')->where('user_id', $user)->where('createtime', 'GT', $today)->find();
                if (empty($is_p)) {
                    $bools = true;
                } else {
                    $bools = false;
                }
王智 authored
106
            } else {
王智 authored
107 108 109 110 111
                $bools = false;
            }
        } else {
            $bools = false;
        }
王智 authored
112
        $list = [
王智 authored
113
            'month' => $bools,
王智 authored
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
            'count' => count($count),
            'list' => $list
        ];
        $this->success('成功', $list);
    }


    /**
     * @ApiTitle    (首页-站点列表)
     * @ApiSummary  (站点列表)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/ZhanDianList)
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": [
    {
    "id": 1,
    "zhandian": "河北站"
    }
    ]
    })
     */
    public function ZhanDianList()
    {
        $arr = Db::name('zhandian')->select();
        if (empty($arr)) {
            $list = [];
        } else {
            foreach ($arr as $k => $v) {
                $list[$k]['id'] = $v['id'];
                $list[$k]['zhandian'] = $v['zhandian'];
            }
        }
        $this->success('成功', $list);
    }


    /**
     * @ApiTitle    (首页-填写报修单渲染)
     * @ApiSummary  (填写报修单渲染)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/InsertOrderList)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": {
    "name": "张三",
    "zhandian": "北京站",
    "xitong": [
    {
    "id": 1,
    "xitong": "监控系统",
    "bianhao": "JK"
    }
    ]
    }
    })
     */
    public function InsertOrderList()
    {
        $user_id = $this->is_token($this->request->header());
        $arr = Db::name('user')
            ->alias('u')
            ->where(['u.id' => $user_id])
            ->join('zhandian z', 'z.id=u.zhandian_id')
            ->field('u.name,z.zhandian')
            ->find();
        if (empty($arr)) {
            $this->error('内部错误,请联系微信官方');
        }
        $xitong = Db::name('xitong')->select();
        if (empty($xitong)) {
            $xi = [];
        } else {
            $xi = $xitong;
        }
        $list = [
            'name' => $arr['name'],
            'zhandian' => $arr['zhandian'],
            'xitong' => $xi
        ];
        $this->success('成功', $list);
    }


    /**
     * @ApiTitle    (首页-填写报修单)
     * @ApiSummary  (填写报修单)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/InsertOrder)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="title", type=string, required=true, description="报修内容")
     * @ApiHeaders  (name="address", type=string, required=true, description="报修地点")
     * @ApiHeaders  (name="colum", type=string, required=true, description="故障设备名称")
     * @ApiHeaders  (name="system", type=string, required=true, description="所属系统ID")
     * @ApiHeaders  (name="up_time", type=string, required=true, description="上报时间:linux时间戳")
     * @ApiHeaders  (name="con", type=string, required=true, description="故障现象")
     * @ApiHeaders  (name="images", type=string, required=true, description="照片多个,分割")
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": {
    "name": "张三",
    "zhandian": "北京站"
    }
    })
     */
    public function InsertOrder()
    {
        $user_id = $this->is_token($this->request->header());
        $param = $this->request->param();
王智 authored
233
        if ($param['title'] == null || $param['title'] == '' || $param['title'] == "" || empty($param['title'])) {
王智 authored
234 235
            $this->error('报修内容不能为空', 0);
        }
王智 authored
236
        if ($param['address'] == null || $param['address'] == '' || $param['address'] == "" || empty($param['address'])) {
王智 authored
237 238
            $this->error('报修地点不能为空', 0);
        }
王智 authored
239
        if ($param['colum'] == null || $param['colum'] == '' || $param['colum'] == "" || empty($param['colum'])) {
王智 authored
240 241
            $this->error('故障设备名称不能为空', 0);
        }
王智 authored
242
        if ($param['con'] == null || $param['con'] == '' || $param['con'] == "" || empty($param['con'])) {
王智 authored
243 244
            $this->error('故障现象不能为空', 0);
        }
王智 authored
245 246 247
        if ($param['system'] == 0) {
            $this->error('所属系统不能为空', 0);
        }
王智 authored
248 249 250 251 252 253 254 255 256 257 258 259
        //站点编号
        $prc = Db::name('user')
            ->alias('u')
            ->where(['u.id' => $user_id])
            ->join('zhandian z', 'z.id=u.zhandian_id')
            ->field('z.prc,u.name,z.id')
            ->find();
        //年份
        $year = date('Y');
        //系统
        $xitong = Db::name('xitong')->where(['id' => $param['system']])->value('bianhao');
        //号码
王智 authored
260
        $order_sn = Db::name('baoxiudan')->order('id desc')->limit(1)->where('order_sn', 'like', '%' . $xitong . '%')->value('order_sn');
王智 authored
261
        $arr = explode('-', $order_sn);
王智 authored
262
        if (empty($arr[3])) {
王智 authored
263 264
            $num = '001';
        } else {
王智 authored
265 266
            $str = $arr[3] + 1;
            $num = str_pad($str, 3, '0', STR_PAD_LEFT);
王智 authored
267
        }
王智 authored
268
        $up_time = substr($param['up_time'], 0, 10);
王智 authored
269 270 271 272 273 274 275 276 277
        $data = [
            'createtime' => time(),
            'updatetime' => time(),
            'user_id' => $user_id,
            'order_sn' => $prc['prc'] . '-' . $year . '-' . $xitong . '-' . $num,
            'title' => $param['title'],
            'address' => $param['address'],
            'colum' => $param['colum'],
            'system' => $param['system'],
王智 authored
278
            'time' => $up_time,
王智 authored
279 280 281 282
            'zhandian_id' => $prc['id'],
            'people_name' => $prc['name'],
            'colum_con' => $param['con'],
            'images' => $param['images'],
王智 authored
283
            'king_type' => 0,
王智 authored
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
            'type' => 1,
            'repair_type' => 0,
            'price' => 0,
            'status' => 0,
            'is_genghuan' => 2
        ];
        $res = Db::name('baoxiudan')->insert($data);
        if ($res) {
            $this->success('提交成功', 1);
        } else {
            $this->error('提交失败', 0);
        }
    }


    /**
     * @ApiTitle    (首页-报修单详情)
     * @ApiSummary  (报修单详情)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/OrderContent)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": {
    "level": 用户等级,
    "repair_type": 维修状态:0=未接收,1=进行中,2=已完成,
    "type": 报修单状态:1=进行中,2=已完成,
    "is_weixiu": 非维修人员查看为0,维修人员查看详情时,1=分配到当前用户,2=否,
王智 authored
316
    "is_me":"是否是自己报修单 1=是0=否",
王智 authored
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334
    "title": "报修内容",
    "address": "地点",
    "colum": "故障设备名称",
    "system": "所属系统",
    "time": "上报时间",
    "people_name": "上报人",
    "zhandian": "站点名称",
    "colum_con": "故障现象",
    "images": [
    "照片"
    ],
    "is_genghuan": 是否需要更换设备:1=是,2=否,
    "IsTalk": 是否可以评价 1=是,0=否,
    "price": 设备价格:0=不需要更换设备,1=2000以下,2=2000-10000元,3=10000元以上,
    "status": 审核状态:0=不需要审核,1=等待审核,2=审核通过,3=审核未通过,
    "weixiu": 维修情况,
    "jidian": 机电负责人意见,
    "holder": 分管领导意见,
王智 authored
335
    "fuzeren" : //维修负责人意见
王智 authored
336
    "zaicishenhe": [ //再次审核内容
王智 authored
337
    'king_type';  //KingType
王智 authored
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
    {
    "con": "内容",
    "images": [
    "图片"
    ]
    }
    ]
    }
    })
     */
    public function OrderContent()
    {
        $user_id = $this->is_token($this->request->header());
        $id = input('id');
        $level = Db::name('user')->where('id', $user_id)->value('level');
        $arr = Db::name('baoxiudan')->where(['id' => $id])->find();
王智 authored
354 355 356 357 358 359 360 361
        if (empty($arr['redio_user_id'])) {
            $redio_user = '';
        } else {
            $redio_user = Db::name('user')->where('id', $arr['redio_user_id'])->value('name');
            if (empty($redio_user)) {
                $redio_user = '';
            }
        }
王智 authored
362
        $xitong = Db::name('xitong')->where(['id' => $arr['system']])->value('xitong');
王智 authored
363 364 365
        $zhandian = Db::name('zhandian')
            ->where(['id' => $arr['zhandian_id']])
            ->value('zhandian');
王智 authored
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383

        if (strstr($arr['images'], ',')) {
            $avatars = explode(',', $arr['images']);
        } else {
            $avatars = explode(' ', $arr['images']);
        }
        foreach ($avatars as $k => $v) {
            $images[$k] = cdnurl($v);
        }
        $is_weixiu = 0;
        if ($level == 4) {
            if ($arr['redio_user_id'] == $user_id) {
                $is_weixiu = 1;
            } else {
                $is_weixiu = 2;
            }
        }
        if ($level == 5) {
王智 authored
384
            if ($arr['type'] == 2) {
王智 authored
385
                if (empty($arr['talk_con'])) {
王智 authored
386
                    $Is_talk = 1;
王智 authored
387
                } else {
王智 authored
388 389
                    $Is_talk = 0;
                }
王智 authored
390
            } else {
王智 authored
391 392 393 394 395 396 397 398 399 400 401 402 403 404
                $Is_talk = 0;
            }
        } else {
            $Is_talk = 0;
        }
        $zcsq = Db::name('answer')->order('id desc')->where(['order_id' => $id])->select();
        if (!empty($zcsq)) {
            foreach ($zcsq as $k => $v) {
                $shenhe[$k]['con'] = $v['con'];
                $shenhe[$k]['images'] = $this->images($v['images']);
            }
        } else {
            $shenhe = [];
        }
王智 authored
405 406 407 408 409 410
        $is_me = Db::name('baoxiudan')->where(['user_id' => $user_id])->where(['id' => $id])->find();
        if (!empty($is_me)) {
            $is_me2222 = 1;
        } else {
            $is_me2222 = 0;
        }
王智 authored
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428

        //
        if (empty($arr['redio_time']) || $arr['redio_time'] == null || $arr['redio_time'] == '' || $arr['redio_time'] == "") {
            $redio_time = '';
        } else {
            $redio_time = date('Y-m-d H:i:s', $arr['redio_time']);
        }
        if (empty($arr['ok_time']) || $arr['ok_time'] == null || $arr['ok_time'] == '' || $arr['ok_time'] == "") {
            $ok_time = '';
        } else {
            $ok_time = date('Y-m-d H:i:s', $arr['ok_time']);
        }
        if (empty($arr['yuji']) || $arr['yuji'] == null || $arr['yuji'] == '' || $arr['yuji'] == "") {
            $yuji = '';

        } else {
            $yuji = date('Y-m-d H:i:s', $arr['yuji']);
        }
王智 authored
429 430 431 432 433
        $list = [
            'level' => $level, //用户等级
            'repair_type' => $arr['repair_type'], //维修状态:0=未接收,1=进行中,2=已完成
            'type' => $arr['type'], //报修单状态:1=进行中,2=已完成
            'is_weixiu' => $is_weixiu, //非维修人员查看为0,维修人员查看详情时,1=分配到当前用户,2=否
王智 authored
434
            'is_me' => $is_me2222,  //是否是自己报修单 1=是0=否
王智 authored
435 436 437 438 439 440
            'title' => $arr['title'], //报修内容
            'address' => $arr['address'], //地点
            'colum' => $arr['colum'], //故障设备名称
            'system' => $xitong, //所属系统
            'time' => date('Y-m-d H:i:s', $arr['time']), //上报时间
            'people_name' => $arr['people_name'], //上报人
王智 authored
441
            'redio_user' => $redio_user, //维修人
王智 authored
442 443 444 445 446 447 448 449 450 451
            'zhandian' => $zhandian, //站点名称
            'colum_con' => $arr['colum_con'], //故障现象
            'images' => $images, //照片
            'is_genghuan' => $arr['is_genghuan'], //是否需要更换设备:1=是,2=否
            'IsTalk' => $Is_talk, //是否可以评价 1=是,0=否
            'price' => $arr['price'], //设备价格:0=不需要更换设备,1=2000以下,2=2000-10000元,3=10000元以上
            'status' => $arr['status'], //审核状态:0=不需要审核,1=等待审核,2=审核通过,3=审核未通过
            'weixiu' => $arr['weixiu'],//维修情况
            'jidian' => $arr['jidian'], //机电负责人意见
            'holder' => $arr['holder'], //分管领导意见
王智 authored
452
            'fuzeren' => $arr['fuzeren'], //维修负责人意见
王智 authored
453
            'zaicishenhe' => $shenhe, //再次审核内容
王智 authored
454
            'king_type' => $arr['king_type'], //KingType
王智 authored
455 456 457
            'redio_time' => $redio_time, //维修时间
            'ok_time' => $ok_time, //修复时间
            'yuji' => $yuji, //预计修复时间
王智 authored
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
        ];
        $this->success('成功', $list);
    }


    /**
     * @ApiTitle    (首页-维修成员列表)
     * @ApiSummary  (维修成员列表)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/PeopleList)
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": [
    {
    "id": 用户ID,
    "name": "姓名"
    }
    ]
    })
     */
    public function PeopleList()
    {
        $arr = Db::name('user')->where(['level' => 4])->order('id desc')->select();
        if (empty($arr)) {
            $list = [];
        } else {
            foreach ($arr as $k => $v) {
                $list[$k]['id'] = $v['id'];
                $list[$k]['name'] = $v['name'];
            }
        }
        $this->success('成功', $list);
    }


    /**
     * @ApiTitle    (首页-再次提交审核)
     * @ApiSummary  (再次提交审核)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/TiJiaoStatus)
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="con", type=int, required=true, description="文本")
     * @ApiHeaders  (name="images", type=int, required=true, description="图片 多张,拼接")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function TiJiaoStatus()
    {
        $param = $this->request->param();
        $data = [
            'order_id' => $param['id'],
            'con' => $param['con'],
            'images' => $param['images']
        ];
        $res = Db::name('answer')->insert($data);
王智 authored
521
        Db::name('baoxiudan')->where(['id' => $param['id']])->update(['status' => 1]);
王智 authored
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
        if ($res) {
            $this->success('提交成功', 1);
        } else {
            $this->error('提交失败', 0);
        }
    }


    /**
     * @ApiTitle    (首页-分配维修员)
     * @ApiSummary  (分配维修员)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/FenPei)
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="user_id", type=int, required=true, description="维修人员用户ID")
     * @ApiHeaders  (name="start_time", type=int, required=true, description="维修时间 linux时间戳")
     * @ApiHeaders  (name="end_time", type=int, required=true, description="修复时间 linux时间戳")
     * @ApiHeaders  (name="con", type=int, required=true, description="修复内容")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function FenPei()
    {
        $param = $this->request->param();
        $data = [
            'redio_user_id' => $param['user_id'],
王智 authored
553 554
            'redio_time' => $param['start_time'] / 1000,
            'ok_time' => $param['end_time'] / 1000,
王智 authored
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
            'redio_con' => $param['con']
        ];
        $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update($data);
        if ($res) {
            $this->success('分配成功', 1);
        } else {
            $this->error('分配失败', 0);
        }
    }


    /**
     * @ApiTitle    (首页-维修成员报修单操作)
     * @ApiSummary  (维修成员报修单操作)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/OrderPlay)
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
王智 authored
572
     * @ApiHeaders  (name="type", type=int, required=true, description="设备价格:0=不需要更换设备,1=需要更换设备")
王智 authored
573
     * @ApiHeaders  (name="con", type=int, required=true, description="维修情况")
王智 authored
574
     * @ApiHeaders  (name="time", type=int, required=true, description="时间戳")
王智 authored
575 576 577 578 579 580 581 582 583 584 585
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function OrderPlay()
    {
        $param = $this->request->param();
王智 authored
586
        if ($param['type'] == 2) {
王智 authored
587
            $is_genghuan = 2;
王智 authored
588
            $status = 0;
王智 authored
589
        } else {
王智 authored
590
            $is_genghuan = 1;
王智 authored
591
            $status = 1;
王智 authored
592 593 594 595 596
        }
        $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update(
            [
                'is_genghuan' => $is_genghuan,
                'price' => $param['type'],
王智 authored
597
                'status' => $status,
王智 authored
598
                'repair_type' => 1,
王智 authored
599
                'yuji' => $param['time'] / 1000
王智 authored
600 601 602
            ]
        );
        if ($res) {
王智 authored
603
            $this->success('成功', $status);
王智 authored
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
        } else {
            $this->error('失败', 0);
        }
    }


    /**
     * @ApiTitle    (首页-维修负责人报修单操作)
     * @ApiSummary  (维修负责人报修单操作)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/OrderPlayKing)
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="type", type=int, required=true, description="设备价格:1=2000以下,2=2000-10000元,3=10000元以上")
     * @ApiHeaders  (name="con", type=int, required=true, description="维修情况")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function OrderPlayKing()
    {
        $param = $this->request->param();
王智 authored
629 630
        if ($param['type'] == 1) {
            $status = 2;
王智 authored
631 632 633 634 635 636 637
            $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update(
                [
                    'price' => $param['type'],
                    'status' => $status,
                    'king_type' => 1,
                ]
            );
王智 authored
638 639 640 641
        }
        if ($param['type'] == 2) {
            $status = 1;
            $fuzeren = $param['con'];
王智 authored
642 643 644 645 646 647 648 649
            $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update(
                [
                    'price' => $param['type'],
                    'status' => $status,
                    'fuzeren' => $fuzeren,
                    'king_type' => 1,
                ]
            );
王智 authored
650 651 652 653
        }
        if ($param['type'] == 3) {
            $status = 1;
            $fuzeren = $param['con'];
王智 authored
654 655 656 657 658 659 660 661
            $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update(
                [
                    'price' => $param['type'],
                    'status' => $status,
                    'fuzeren' => $fuzeren,
                    'king_type' => 1,
                ]
            );
王智 authored
662
        }
王智 authored
663 664
        if ($res) {
            $this->success('成功', 1);
王智 authored
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739
        } else {
            $this->error('失败', 0);
        }
    }


    /**
     * @ApiTitle    (首页-审核)
     * @ApiSummary  (审核)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/Status)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="type", type=int, required=true, description="审核状态:2=通过,3=不通过")
     * @ApiHeaders  (name="con", type=string, required=true, description="意见")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function Status()
    {
        $param = $this->request->param();
        $user_id = $this->is_token($this->request->header());
        $level = Db::name('user')->where(['id' => $user_id])->value('level');
        if ($level == 1 || $level == 2) {
            if ($level == 1) {
                Db::name('baoxiudan')->where(['id' => $param['id']])->update(
                    [
                        'holder' => $param['con']
                    ]
                );
            }
            if ($level == 2) {
                Db::name('baoxiudan')->where(['id' => $param['id']])->update(
                    [
                        'jidian' => $param['con']
                    ]
                );
            }
        } else {
            $this->error('内部错误,您没有权限,90111', 0);
            die;
        }
        $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update(
            [
                'status' => $param['type']
            ]
        );
        if ($res) {
            $this->success('成功', 1);
        } else {
            $this->error('失败', 0);
        }
    }

    /**
     * @ApiTitle    (首页-维修情况添加)
     * @ApiSummary  (维修情况添加)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/WeiXiuQ)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="con", type=string, required=true, description="维修情况)
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
王智 authored
740
     */
王智 authored
741
    public function WeiXiuQ()
王智 authored
742
    {
王智 authored
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757
        $param = $this->request->param();
        $user_id = $this->is_token($this->request->header());
        $level = Db::name('user')->where(['id' => $user_id])->value('level');
        if ($level != 4) {
            $this->error('身份错误', 0);
        }
        $data = [
            'weixiu' => $param['con']
        ];
        $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update($data);
        if ($res) {
            $this->success('成功', 1);
        } else {
            $this->error('失败', 0);
        }
王智 authored
758
    }
王智 authored
759 760 761 762 763 764 765 766 767


    /**
     * @ApiTitle    (首页-维修完成)
     * @ApiSummary  (维修完成)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/WeiXiuAn)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
王智 authored
768
     * @ApiHeaders  (name="con", type=int, required=true, description="维修情况")
王智 authored
769 770 771 772 773 774 775 776 777 778 779
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function WeiXiuAn()
    {
        $id = input('id');
王智 authored
780
        $con = input('con');
王智 authored
781 782 783 784 785
        $user_id = $this->is_token($this->request->header());
        $is_weixiu = Db::name('baoxiudan')->where(['id' => $id])->where(['redio_user_id' => $user_id])->find();
        if (empty($is_weixiu)) {
            $this->error('内部错误', 0);
        }
王智 authored
786
        $res = Db::name('baoxiudan')->where(['id' => $id])->update(['repair_type' => 2, 'weixiu' => $con]);
王智 authored
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
        if ($res) {
            $this->success('成功', 1);
        } else {
            $this->error('失败', 0);
        }
    }


    /**
     * @ApiTitle    (首页-验收)
     * @ApiSummary  (审核)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/YanShou)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="type", type=int, required=true, description="1=验收已完成,2=验收未完成")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data":{
    }
    })
     */
    public function YanShou()
    {
        $id = input('id');
        $type = input('type');
        $user_id = $this->is_token($this->request->header());
        $is_weixiu = Db::name('baoxiudan')->where(['id' => $id])->where(['user_id' => $user_id])->find();
        if (empty($is_weixiu)) {
            $this->error('内部错误', 0);
        }
        if ($type == 1) {
            $res = Db::name('baoxiudan')->where(['id' => $id])->update(['type' => 2]);
        } else {
            $res = Db::name('baoxiudan')->where(['id' => $id])->update(['repair_type' => 1]);
        }
        if ($res) {
            $this->success('成功', 1);
        } else {
            $this->error('失败', 0);
        }
    }
王智 authored
831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860


    /**
     * @ApiTitle    (首页-添加评价)
     * @ApiSummary  (添加评价)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/AddTalk)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="id", type=int, required=true, description="报修单ID")
     * @ApiHeaders  (name="weixiu_star", type=int, required=true, description="维修服务")
     * @ApiHeaders  (name="taidu_star", type=int, required=true, description="维修态度")
     * @ApiHeaders  (name="talk_num", type=int, required=true, description="评价分数")
     * @ApiHeaders  (name="talk_con", type=int, required=true, description="评价内容")
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": {
    }
    })
     */
    public function AddTalk()
    {
        $param = $this->request->param();
        if ($param['talk_num'] < 1 || $param['talk_num'] > 100) {
            $this->error('评价分数错误', 0);
        }
        $data = [
            'fuwu' => $param['weixiu_star'],
王智 authored
861
            'taiudu' => $param['taidu_star'],
王智 authored
862 863
            'talk_up' => $param['talk_num'],
            'talk_con' => $param['talk_con']
王智 authored
864 865 866 867 868 869 870 871
        ];
        $res = Db::name('baoxiudan')->where(['id' => $param['id']])->update($data);
        if ($res) {
            $this->success('成功', 1);
        } else {
            $this->error('失败', 0);
        }
    }
王智 authored
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902


    /**
     * @ApiTitle    (首页-添加月评价)
     * @ApiSummary  (添加月评价)
     * @ApiMethod (POST)
     * @ApiRoute    (/api/Index/AddMonthTalk)
     * @ApiHeaders  (name="authorization", type=string, required=true, description="请求的Token")
     * @ApiHeaders  (name="weixiu_star", type=int, required=true, description="维修服务")
     * @ApiHeaders  (name="taidu_star", type=int, required=true, description="维修态度")
     * @ApiHeaders  (name="talk_num", type=int, required=true, description="评价分数")
     * @ApiHeaders  (name="talk_con", type=int, required=true, description="评价内容")
     * @ApiReturnParams   (name="code", type="integer", required=true,  sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturn   ({
    "code":"1",
    "msg": "返回成功",
    "data": {
    }
    })
     */
    public function AddMonthTalk()
    {
        $user_id = $this->is_token($this->request->header());
        $param = $this->request->param();
        $data = [
            'createtime' => time(),
            'weixiu_star' => $param['weixiu_star'],
            'taidu_star' => $param['taidu_star'],
            'talk_num' => $param['talk_num'],
            'talk_con' => $param['talk_con'],
王智 authored
903
            'user_id' => $user_id
王智 authored
904 905 906 907 908 909 910 911 912 913
        ];
        $res = Db::name('month_talk')->insert($data);
        if ($res) {
            $this->success('成功', 1);
        } else {
            $this->error('失败', 0);
        }
    }

王智 authored
914
}