You've already forked guangan
维修人员上报
This commit is contained in:
125
plugs/think-plugs-ticket/src/controller/InspectionShare.php
Normal file
125
plugs/think-plugs-ticket/src/controller/InspectionShare.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\ticket\controller;
|
||||
|
||||
use plugin\ticket\model\TicketCommonReply;
|
||||
use plugin\ticket\model\TicketInspectionShare;
|
||||
use plugin\ticket\model\TicketTicket;
|
||||
use plugin\ticket\model\TicketType;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\model\SystemUser;
|
||||
|
||||
/**
|
||||
* 维修人员上报
|
||||
*/
|
||||
class InspectionShare extends Controller
|
||||
{
|
||||
/**
|
||||
* 维修人员上报列表
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '维修人员上报';
|
||||
$this->type_list = TicketType::getList();
|
||||
TicketInspectionShare::mQuery()->layTable(function () {
|
||||
|
||||
}, function (QueryHelper $query) {
|
||||
$query->like(['title|content|ticket_address|contact_phone#keyword'])
|
||||
->dateBetween(['create_at'])
|
||||
->equal(['status', 'type_id']);
|
||||
$query->append(['imgs_arr', 'type_name']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 维修人员上报详情
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @return void
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$this->title = '维修人员上报详情';
|
||||
$where = $this->_vali([
|
||||
'id.require' => '维修人员上报ID不能为空',
|
||||
]);
|
||||
$this->vo = TicketInspectionShare::mk()->where($where)->with(['linked_ticket'])->findOrEmpty();
|
||||
if ($this->vo->isEmpty()) $this->error('维修人员上报不存在!');
|
||||
if (!$this->vo->linked_ticket_id) {
|
||||
$this->ticket_list = TicketTicket::mk()->scope(['avail'])->select();
|
||||
} else {
|
||||
$this->ticket_list = [];
|
||||
}
|
||||
$this->type_list = TicketType::getList();
|
||||
$this->user_list = SystemUser::query()->select();
|
||||
$this->common_reply_list = TicketCommonReply::query()->scope(['avail'])->select();
|
||||
$this->fetch('detail');
|
||||
}
|
||||
|
||||
public function link()
|
||||
{
|
||||
$basic_data = $this->_vali([
|
||||
'id.require' => '维修人员上报ID不能为空',
|
||||
'_type.require' => '类型不能为空',
|
||||
'content.require' => '请简要填写说明!',
|
||||
]);
|
||||
$share = TicketInspectionShare::mk()->where(['id' => $basic_data['id']])->findOrEmpty();
|
||||
if ($share->isEmpty()) $this->error('维修人员上报不存在!');
|
||||
if ($share->status !== 0) $this->error('维修人员上报已处理!');
|
||||
$ticket_id = null;
|
||||
switch ($basic_data['_type']) {
|
||||
case 'new':
|
||||
$data = $this->_vali([
|
||||
'type_id.require' => '类型不能为空',
|
||||
'user_id.require' => '请选择处理人员',
|
||||
]);
|
||||
$ticket = TicketTicket::mk()->create([
|
||||
'source_type' => 2,
|
||||
'type_id' => $data['type_id'],
|
||||
'user_type' => 'staff',
|
||||
'user_id' => $share->user_id,
|
||||
'current_admin_id' => $data['user_id'],
|
||||
'title' => $share->title,
|
||||
'content' => $share->content,
|
||||
'ticket_region' => $share->ticket_region,
|
||||
'ticket_address' => $share->ticket_address,
|
||||
'contact_name' => $share->contact_name,
|
||||
'contact_phone' => $share->contact_phone,
|
||||
'lat' => $share->lat,
|
||||
'lng' => $share->lng,
|
||||
'imgs' => $share->imgs,
|
||||
'status' => 0,
|
||||
]);
|
||||
$ticket->source = $share;
|
||||
$ticket->save();
|
||||
$ticket_id = $ticket->id;
|
||||
break;
|
||||
case 'exist':
|
||||
$data = $this->_vali([
|
||||
'ticket_id.require' => '请选择处理工单',
|
||||
]);
|
||||
$ticket = TicketTicket::mk()->where(['id' => $data['ticket_id']])->findOrEmpty();
|
||||
if ($ticket->isEmpty()) $this->error('工单不存在!');
|
||||
$ticket_id = $data['ticket_id'];
|
||||
$ticket->source = $share;
|
||||
$ticket->save();
|
||||
break;
|
||||
case 'skip':
|
||||
break;
|
||||
default:
|
||||
$this->error('参数错误');
|
||||
}
|
||||
$share->linked_ticket_id = $ticket_id;
|
||||
$share->status = 1;
|
||||
$share->content = $basic_data['content'];
|
||||
$share->save();
|
||||
$this->success('处理成功!');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user