维修人员上报

This commit is contained in:
2025-03-19 10:43:16 +08:00
parent 8351799161
commit 71f1badc11
6 changed files with 516 additions and 22 deletions

View File

@ -4,6 +4,7 @@ namespace plugin\inspection\controller\api\auth;
use plugin\inspection\controller\api\Auth;
use plugin\inspection\model\InspectionRecord;
use plugin\ticket\model\TicketInspectionShare;
use plugin\ticket\model\TicketTicket;
class Ticket extends Auth
@ -12,15 +13,15 @@ class Ticket extends Auth
{
$record_id = $this->request->post('record_id');
$record = null;
if (!empty($record_id)) {
if (!empty($record_id) && $record_id != 'undefined') {
/** @var InspectionRecord $record */
$record = InspectionRecord::mk()->where('id', $record_id)->find();
if (empty($record)) {
$this->error('记录不存在');
}
}
$lat = $this->request->post('lat');
$lng = $this->request->post('lng');
$lat = $this->request->post('ticket_lat');
$lng = $this->request->post('ticket_lng');
$type_id = $this->request->post('type_id');
$title = $this->request->post('title');
$content = $this->request->post('content');
@ -29,33 +30,25 @@ class Ticket extends Auth
$imgs = $this->request->post('imgs');
$ticket_work_use = $this->request->post('ticket_work_use');
$data = [
'uid' => $this->staff->id,
'utype' => $this->staff->id,
'user_id' => $this->staff->id,
'type_id' => $type_id,
'title' => $title,
'content' => $content,
'contact_name' => $this->staff->name,
'contact_phone' => $this->staff->phone,
'imgs' => $imgs,
'ticket_region' => $ticket_region,
'ticket_address' => $ticket_address,
'lat' => $lat,
'lng' => $lng,
'imgs' => $imgs,
'status' => 1,
'state' => 0,
'ticket_lat' => $lat,
'ticket_lng' => $lng,
'contact_name' => $this->staff->name,
'contact_phone' => $this->staff->phone,
'status' => 0,
'work_days' => $ticket_work_use
];
if (!empty($record)) {
$ticket = $record->ticket()->save($data);
} else {
$ticket = TicketTicket::create($data);
$ticket = TicketInspectionShare::create($data);
}
$ticket->verify()->save([
'staff_id' => $this->staff->id,
'content' => $content,
'imgs' => $imgs,
'work_days' => $ticket_work_use
]);
$ticket->save();
$this->success("工单创建成功", $ticket);
}