From 3ec08279fe0ba342db890e0d3aa18f542c717ff0 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 1 Dec 2024 15:53:17 +0800 Subject: [PATCH] UserShare --- .../src/controller/UserShare.php | 25 ++++++++++++++++++- .../src/model/TicketTicket.php | 23 +++++++++++++---- .../src/view/user_share/detail.html | 11 ++++---- .../src/view/user_share/index.html | 8 +++++- 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/plugs/think-plugs-ticket/src/controller/UserShare.php b/plugs/think-plugs-ticket/src/controller/UserShare.php index a013325..1ac4326 100644 --- a/plugs/think-plugs-ticket/src/controller/UserShare.php +++ b/plugs/think-plugs-ticket/src/controller/UserShare.php @@ -80,14 +80,36 @@ class UserShare extends Controller 'type_id.require' => '类型不能为空', 'user_id.require' => '请选择处理人员', ]); + $ticket = TicketTicket::mk()->create([ + 'source_type' => 1, + 'type_id' => $data['type_id'], + 'user_type' => 'user', + 'user_id' => $userShare->user_id, + 'current_admin_id' => $data['user_id'], + 'title' => $userShare->title, + 'content' => $userShare->content, + 'ticket_region' => $userShare->ticket_region, + 'ticket_address' => $userShare->ticket_address, + 'contact_name' => $userShare->contact_name, + 'contact_phone' => $userShare->contact_phone, + 'lat' => $userShare->lat, + 'lng' => $userShare->lng, + 'imgs' => $userShare->imgs, + 'status' => 0, + ]); + $ticket->source = $userShare; + $ticket->save(); + $ticket_id = $ticket->id; break; case 'exist': $data = $this->_vali([ 'ticket_id.require' => '请选择处理工单', ]); - $ticket_id = $data['ticket_id']; $ticket = TicketTicket::mk()->where(['id' => $data['ticket_id']])->findOrEmpty(); if ($ticket->isEmpty()) $this->error('工单不存在!'); + $ticket_id = $data['ticket_id']; + $ticket->source = $userShare; + $ticket->save(); break; default: $this->error('参数错误'); @@ -98,5 +120,6 @@ class UserShare extends Controller UserPointService::addUserPoint($userShare->user_id, $basic_data['point_aware'], '用户随手拍奖励积分'); $userShare->status = 1; $userShare->save(); + $this->success('处理成功!'); } } \ No newline at end of file diff --git a/plugs/think-plugs-ticket/src/model/TicketTicket.php b/plugs/think-plugs-ticket/src/model/TicketTicket.php index 78c0edd..1bc0473 100644 --- a/plugs/think-plugs-ticket/src/model/TicketTicket.php +++ b/plugs/think-plugs-ticket/src/model/TicketTicket.php @@ -22,11 +22,6 @@ class TicketTicket extends Model return $this->hasMany(TicketReply::class, 'ticket_id')->order("create_at", 'asc'); } - public function source() - { - return $this->morphTo(); - } - public function getImgsArrAttr($value, $data) { return str2arr($data['imgs'] ?: '', '|'); @@ -37,6 +32,24 @@ class TicketTicket extends Model return $this->reply()->order('create_at', 'desc')->find(); } + public function getSourceTypeNameAttr($value, $data) + { + if (!empty($this->getSourceTypeList()[$data['source_type']])) { + return $this->getSourceTypeList()[$data['source_type']]; + } else { + return '未知'; + } + } + + public function getSourceTypeList() + { + return [ + 0 => '其他', + 1 => '用户随手拍', + 2 => '工单', + ]; + } + public function getTypeNameAttr($value, $data) { $type = $this->type()->find(); diff --git a/plugs/think-plugs-ticket/src/view/user_share/detail.html b/plugs/think-plugs-ticket/src/view/user_share/detail.html index 45788d6..bf869a9 100644 --- a/plugs/think-plugs-ticket/src/view/user_share/detail.html +++ b/plugs/think-plugs-ticket/src/view/user_share/detail.html @@ -113,11 +113,11 @@