This commit is contained in:
2025-03-23 13:21:35 +08:00
parent b173667c49
commit b6ff9b1a6e
10 changed files with 863 additions and 345 deletions

View File

@ -93,7 +93,7 @@ class InspectionShare extends Controller
'lat' => $share->ticket_lat,
'lng' => $share->ticket_lng,
'imgs' => $share->imgs,
'status' => -1, // 先审核
'status' => 0, // 先审核
]);
$ticket->source = $share;
$ticket->save();

View File

@ -148,6 +148,15 @@ class Ticket 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 move()
{
$this->title = "工单分配";
@ -170,19 +179,12 @@ class Ticket extends Controller
// 外部
$ticket->state = 2;
}
if ($ticket->fz_user_id) {
$staff = InspectionStaff::query()->find($ticket->fz_user_id);
$staff->messages()->save([
'title' => "您有新的工单待处理",
'content' => "您有新的工单待处理,请及时处理。",
]);
}
$ticket->status = 1;
$ticket->save();
$this->success('工单分配成功!');
} else {
$this->dept_list = TicketDept::query()->scope('avail')->select();
$this->user_list = InspectionStaff::query()->select();
$this->user_list = SystemUser::query()->select();
$this->fetch();
}
}

View File

@ -2,10 +2,18 @@
namespace plugin\ticket\controller;
use plugin\inspection\model\InspectionStaff;
use plugin\ticket\model\ApprovalInstance;
use plugin\ticket\model\ApprovalProcess;
use plugin\ticket\model\ApprovalStep;
use plugin\ticket\model\TicketReply;
use plugin\ticket\model\TicketTicket;
use plugin\ticket\model\TicketTicketInter;
use plugin\ticket\model\TicketType;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
use think\admin\model\SystemUser;
use think\exception\HttpResponseException;
/**
* 内部工单管理
@ -32,23 +40,17 @@ class TicketInter extends Controller
$query->like(['title|content|contact_name|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->append(['imgs_arr', 'source_type_name', 'status_text', 'type_name']);
$query->append(['imgs_arr', 'source_type_name', 'type_name', 'last_reply'])->with(['user_shares', 'views', 'repairs', 'verifys', 'view_process', 'repair_process', 'verify_process']);
});
}
public function my()
public function _form_filter(&$data)
{
$this->title = '我的工单';
$this->user_id = $this->request->session('user')['id'];
TicketTicketInter::mQuery()->layTable(function () {
}, function (QueryHelper $query) {
$query->like(['title|content|contact_name|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->append(['imgs_arr', 'source_type_name', 'status_text', 'type_name']);
$query->where(['current_admin_id' => $this->user_id]);
});
if ($this->request->isPost()) {
$data['user_id'] = 0;
}
ApprovalInstance::query()->where('oid', '=', $data['id'])->delete();
$data['status'] = -1;
}
/**
@ -61,8 +63,493 @@ class TicketInter extends Controller
{
$this->title = '工单详情';
['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']);
$this->vo = TicketTicketInter::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'status_text', 'type_name', 'last_reply'])->find($id);
$this->vo = TicketTicketInter::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($id);
$this->ticket = $this->vo;
$process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty();
$instance = ApprovalInstance::query()->with(['steps.approver', 'logs'])->where('process_id', '=', $process->id)->where('oid', '=', $id)->findOrEmpty();
$this->instance = $instance;
if ($instance->isEmpty()) {
$this->step_index = -1;
} else {
$this->step_index = $instance->current_step;
}
$this->fetch();
}
public function reply()
{
$this->title = '回复工单';
[
'ticket_id'=>$ticket_id,
'id'=>$id
] = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
'id.require'=>'请指定回复ID!'
]);
$this->vo = TicketTicket::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($ticket_id);
TicketReply::mForm('reply');
}
public function _reply_form_filter(&$data)
{
if ($this->request->isPost()) {
$this->_applyFormToken();
$data['type'] = 1;
$adminInfo = $this->request->session('user');
$data['user_id'] = $adminInfo['id'];
$data['username'] = $adminInfo['nickname'];
$data['contact'] = $adminInfo['contact_phone'];
}
}
/**
* 审核页面
* @auth true
* @menu true
*/
public function approve()
{
$this->title = '审核流程';
[
'id'=>$id
] = $this->_vali([
'id.require'=>'请指定回复ID!'
]);
$this->vo = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($id);
$process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty();
if ($process->isEmpty()) {
$this->error('未找到可用的审核流程');
}
$this->process = $process;
$instance = ApprovalInstance::query()->with(['steps', 'logs'])->where('process_id', '=', $process->id)->where('oid', '=', $id)->findOrEmpty();
$this->instance = $instance;
if ($instance->isEmpty()) {
$this->step_index = -1;
$this->current_step = $process->steps[0];
} else {
$this->step_index = $instance->current_step;
if (sizeof($instance->steps) <= ($instance->current_step + 1)) {
$this->current_step = ['approver_type' => 0];
} else {
$this->current_step = $instance->steps[$instance->current_step + 1];
}
}
$this->users = SystemUser::query()->field('id,username,nickname')->select();
$this->fetch();
}
/**
* @return void
* @throws \Exception
* 审核提交
* @auth true
* @menu true
*/
public function create_approval()
{
$data = $this->_vali([
'id.require'=>'请指定工单ID!',
'title.default'=>'工单审核',
'content.default'=>'',
]);
$process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty();
if ($process->isEmpty()) {
$this->error('未找到可用的审核流程');
}
$adminInfo = $this->request->session('user');
ApprovalInstance::mk()->startTrans();
try {
$instance = ApprovalInstance::create([
'process_id' => $process->id,
'oid' => $data['id'],
'title' => $data['title'],
'content' => $data['content'],
'status' => 0,
'current_step' => 0,
'create_time' => date('Y-m-d H:i:s'),
'create_by' => $adminInfo['id'],
'create_name' => $adminInfo['username'],
]);
foreach ($process->steps as $index => $step) {
$approver_id = $step['approver_id'] ?? 0;
if ($index == 0) {
if ($step['approver_type'] == 3) {
$approve_data = $this->_vali([
'approver_id.require' => '请指定审核人!',
]);
$approver_id = $approve_data['approver_id'];
}
}
ApprovalStep::create([
'instance_id' => $instance->id,
'step_number' => $index,
'approver_type' => $step['approver_type'],
'approver_id' => $approver_id,
'status' => 0,
]);
}
ApprovalInstance::mk()->commit();
} catch (HttpResponseException $e) {
ApprovalInstance::mk()->rollback();
throw $e;
} catch (\Exception $e) {
ApprovalInstance::mk()->rollback();
// $this->error("创建失败");
throw $e;
}
$this->success('创建成功!');
}
public function view_process_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$process = ApprovalProcess::where('type', '=', 'HSSH')->order('id', 'asc')->findOrEmpty();
if ($process->isEmpty()) {
$this->error('未找到可用的审核流程');
}
$adminInfo = $this->request->session('user');
$ticket = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$instance_data = $this->_vali([
'title.default'=>'核验工单审核',
'content.default'=>'',
]);
ApprovalInstance::mk()->startTrans();
try {
$instance = ApprovalInstance::create([
'process_id' => $process->id,
'oid' => $ticket->id,
'title' => $instance_data['title'],
'content' => $instance_data['content'],
'status' => 0,
'current_step' => 0,
'create_time' => date('Y-m-d H:i:s'),
'create_by' => $adminInfo['id'],
'create_name' => $adminInfo['username'],
]);
foreach ($process->steps as $index => $step) {
$approver_id = $step['approver_id'] ?? 0;
if ($index == 0) {
if ($step['approver_type'] == 3) {
$approve_data = $this->_vali([
'approver_id.require' => '请指定审核人!',
]);
$approver_id = $approve_data['approver_id'];
}
}
ApprovalStep::create([
'instance_id' => $instance->id,
'step_number' => $index,
'approver_type' => $step['approver_type'],
'approver_id' => $approver_id,
'status' => 0,
]);
}
$ticket->view_pid = $instance->id;
$ticket->save();
ApprovalInstance::mk()->commit();
} catch (HttpResponseException $e) {
ApprovalInstance::mk()->rollback();
throw $e;
} catch (\Exception $e) {
ApprovalInstance::mk()->rollback();
$this->error("创建失败");
}
$this->success('创建成功!');
} else {
$this->vo = $ticket;
$this->process = $process;
$this->step_index = -1;
$this->current_step = $process->steps[0];
$this->users = SystemUser::query()->field('id,username,nickname')->select();
$this->fetch();
}
}
public function view_ticket_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$ticket = TicketTicket::query()->with(['view_process'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
$staffs = InspectionStaff::query()->field('id,name,phone')->select();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$instance_data = $this->_vali([
'staff_id.require'=>'请指定维修人员!',
]);
$view = $ticket->views()->save([
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_by'=>$adminInfo['id'],
]);
$this->success('创建成功!', $view);
} else {
$this->vo = $ticket;
$this->staffs = $staffs;
$this->fetch();
}
}
public function repair_process_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$process = ApprovalProcess::where('type', '=', 'WXSH')->order('id', 'asc')->findOrEmpty();
if ($process->isEmpty()) {
$this->error('未找到可用的审核流程');
}
$adminInfo = $this->request->session('user');
$ticket = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$instance_data = $this->_vali([
'title.default'=>'核验工单审核',
'content.default'=>'',
]);
ApprovalInstance::mk()->startTrans();
try {
$instance = ApprovalInstance::create([
'process_id' => $process->id,
'oid' => $ticket->id,
'title' => $instance_data['title'],
'content' => $instance_data['content'],
'status' => 0,
'current_step' => 0,
'create_time' => date('Y-m-d H:i:s'),
'create_by' => $adminInfo['id'],
'create_name' => $adminInfo['username'],
]);
foreach ($process->steps as $index => $step) {
$approver_id = $step['approver_id'] ?? 0;
if ($index == 0) {
if ($step['approver_type'] == 3) {
$approve_data = $this->_vali([
'approver_id.require' => '请指定审核人!',
]);
$approver_id = $approve_data['approver_id'];
}
}
ApprovalStep::create([
'instance_id' => $instance->id,
'step_number' => $index,
'approver_type' => $step['approver_type'],
'approver_id' => $approver_id,
'status' => 0,
]);
}
$ticket->repair_pid = $instance->id;
$ticket->save();
ApprovalInstance::mk()->commit();
} catch (HttpResponseException $e) {
ApprovalInstance::mk()->rollback();
throw $e;
} catch (\Exception $e) {
ApprovalInstance::mk()->rollback();
$this->error("创建失败");
}
$this->success('创建成功!');
} else {
$this->vo = $ticket;
$this->process = $process;
$this->step_index = -1;
$this->current_step = $process->steps[0];
$this->users = SystemUser::query()->field('id,username,nickname')->select();
$this->fetch();
}
}
public function repair_ticket_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$ticket = TicketTicket::query()->with(['repair_process'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
$staffs = InspectionStaff::query()->field('id,name,phone')->select();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$instance_data = $this->_vali([
'staff_id.require'=>'请指定维修人员!',
]);
$view = $ticket->repairs()->save([
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_by'=>$adminInfo['id'],
]);
$this->success('创建成功!', $view);
} else {
$this->vo = $ticket;
$this->staffs = $staffs;
$this->fetch();
}
}
public function verify_process_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$process = ApprovalProcess::where('type', '=', 'YSSH')->order('id', 'asc')->findOrEmpty();
if ($process->isEmpty()) {
$this->error('未找到可用的审核流程');
}
$adminInfo = $this->request->session('user');
$ticket = TicketTicket::query()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$instance_data = $this->_vali([
'title.default'=>'核验工单审核',
'content.default'=>'',
]);
ApprovalInstance::mk()->startTrans();
try {
$instance = ApprovalInstance::create([
'process_id' => $process->id,
'oid' => $ticket->id,
'title' => $instance_data['title'],
'content' => $instance_data['content'],
'status' => 0,
'current_step' => 0,
'create_time' => date('Y-m-d H:i:s'),
'create_by' => $adminInfo['id'],
'create_name' => $adminInfo['username'],
]);
foreach ($process->steps as $index => $step) {
$approver_id = $step['approver_id'] ?? 0;
if ($index == 0) {
if ($step['approver_type'] == 3) {
$approve_data = $this->_vali([
'approver_id.require' => '请指定审核人!',
]);
$approver_id = $approve_data['approver_id'];
}
}
ApprovalStep::create([
'instance_id' => $instance->id,
'step_number' => $index,
'approver_type' => $step['approver_type'],
'approver_id' => $approver_id,
'status' => 0,
]);
}
$ticket->verify_pid = $instance->id;
$ticket->save();
ApprovalInstance::mk()->commit();
} catch (HttpResponseException $e) {
ApprovalInstance::mk()->rollback();
throw $e;
} catch (\Exception $e) {
ApprovalInstance::mk()->rollback();
$this->error("创建失败");
}
$this->success('创建成功!');
} else {
$this->vo = $ticket;
$this->process = $process;
$this->step_index = -1;
$this->current_step = $process->steps[0];
$this->users = SystemUser::query()->field('id,username,nickname')->select();
$this->fetch();
}
}
public function verify_ticket_create()
{
$data = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
]);
$ticket = TicketTicket::query()->with(['repair_process'])->append(['imgs_arr', 'type_name'])->where('id', '=', $data['ticket_id'])->findOrEmpty();
$staffs = InspectionStaff::query()->field('id,name,phone')->select();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$instance_data = $this->_vali([
'staff_id.require'=>'请指定维修人员!',
]);
$view = $ticket->verifys()->save([
'staff_id'=>$instance_data['staff_id'],
'status'=>0,
'create_by'=>$adminInfo['id'],
]);
$this->success('创建成功!', $view);
} else {
$this->vo = $ticket;
$this->staffs = $staffs;
$this->fetch();
}
}
public function my() {
$this->title = '待我审核';
$this->type_list = TicketType::getList();
$this->user_id = $this->request->session('user')['id'];
TicketTicket::mQuery()->layTable(function () {
}, function (QueryHelper $query) {
$query->like(['title|content|contact_name|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->whereIn("id", ApprovalStep::query()->where(['approver_id' => $this->user_id, 'status' => 0, 'approver_type' => 1, 'instance.status' => 0])->field("oid")->select())
->append(['imgs_arr', 'source_type_name', 'type_name', 'last_reply'])->with('approval');
});
}
public function comment()
{
$data = $this->_vali([
'id.require'=>'请指定工单ID!',
]);
$ticket = TicketTicketInter::query()->with(['user_shares'])->where('id', '=', $data['id'])->findOrEmpty();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if (!$ticket->user_shares || sizeof($ticket->user_shares) == 0) {
$this->error("该工单无需评论");
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$comment_data = $this->_vali([
'content.require'=>'请输入评论内容!',
]);
TicketTicket::mk()->startTrans();
try {
foreach ($ticket->user_shares as $share) {
$share->logs()->save([
'op_name' => $adminInfo["username"],
'content' => $comment_data['content'],
'result' => "后台用户反馈",
]);
}
TicketTicket::mk()->commit();
} catch (\Exception $e) {
TicketTicket::mk()->rollback();
$this->error("保存失败");
}
} else {
$this->vo = $ticket;
$this->ticket = $ticket;
$this->fetch();
}
}
}

View File

@ -2,11 +2,19 @@
namespace plugin\ticket\controller;
use PhpOffice\PhpSpreadsheet\IOFactory;
use plugin\inspection\model\InspectionStaff;
use plugin\ticket\model\ApprovalInstance;
use plugin\ticket\model\ApprovalProcess;
use plugin\ticket\model\ApprovalStep;
use plugin\ticket\model\TicketReply;
use plugin\ticket\model\TicketTicket;
use plugin\ticket\model\TicketTicketOuter;
use plugin\ticket\model\TicketType;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
use think\admin\model\SystemUser;
use think\exception\HttpResponseException;
/**
* 外部工单管理
@ -33,22 +41,7 @@ class TicketOuter extends Controller
$query->like(['title|content|contact_name|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->append(['imgs_arr', 'source_type_name', 'status_text', 'type_name', 'last_reply']);
});
}
public function my()
{
$this->title = '我的工单';
$this->user_id = $this->request->session('user')['id'];
TicketTicketOuter::mQuery()->layTable(function () {
}, function (QueryHelper $query) {
$query->like(['title|content|contact_name|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->append(['imgs_arr', 'source_type_name', 'status_text', 'type_name']);
$query->where(['current_admin_id' => $this->user_id]);
$query->append(['imgs_arr', 'source_type_name', 'type_name', 'last_reply'])->with(['user_shares', 'views', 'repairs', 'verifys', 'view_process', 'repair_process', 'verify_process']);
});
}
@ -62,7 +55,148 @@ class TicketOuter extends Controller
{
$this->title = '工单详情';
['id' => $id] = $this->_vali(['id.require' => '请指定工单ID!']);
$this->vo = TicketTicketOuter::mk()->with(['user', 'type', 'reply'])->append(['imgs_arr', 'status_text', 'type_name', 'last_reply'])->find($id);
$this->vo = TicketTicketOuter::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($id);
$this->ticket = $this->vo;
$process = ApprovalProcess::where('type', '=', 'GDSH')->order('id', 'asc')->findOrEmpty();
$instance = ApprovalInstance::query()->with(['steps.approver', 'logs'])->where('process_id', '=', $process->id)->where('oid', '=', $id)->findOrEmpty();
$this->instance = $instance;
if ($instance->isEmpty()) {
$this->step_index = -1;
} else {
$this->step_index = $instance->current_step;
}
$this->fetch();
}
public function reply()
{
$this->title = '回复工单';
[
'ticket_id'=>$ticket_id,
'id'=>$id
] = $this->_vali([
'ticket_id.require'=>'请指定工单ID!',
'id.require'=>'请指定回复ID!'
]);
$this->vo = TicketTicket::mk()->with(['user', 'type'])->append(['imgs_arr', 'type_name'])->find($ticket_id);
TicketReply::mForm('reply');
}
public function _reply_form_filter(&$data)
{
if ($this->request->isPost()) {
$this->_applyFormToken();
$data['type'] = 1;
$adminInfo = $this->request->session('user');
$data['user_id'] = $adminInfo['id'];
$data['username'] = $adminInfo['nickname'];
$data['contact'] = $adminInfo['contact_phone'];
}
}
public function my() {
$this->title = '待我审核';
$this->type_list = TicketType::getList();
$this->user_id = $this->request->session('user')['id'];
TicketTicket::mQuery()->layTable(function () {
}, function (QueryHelper $query) {
$query->like(['title|content|contact_name|ticket_address|contact_phone#keyword'])
->dateBetween(['create_at'])
->equal(['status', 'type_id']);
$query->whereIn("id", ApprovalStep::query()->where(['approver_id' => $this->user_id, 'status' => 0, 'approver_type' => 1, 'instance.status' => 0])->field("oid")->select())
->append(['imgs_arr', 'source_type_name', 'type_name', 'last_reply'])->with('approval');
});
}
/**
* @return void
* @auth true
*/
public function import() {
$file = $this->app->request->post('file');
if (!$file) {
// 创建一个临时Excel模板用于下载
$this->redirect('/static/excel/ticket_import_template.xlsx');
};
$file = '.' . str_replace($this->app->request->domain(), '', $file);
//表格字段对应
$fields = [
'A' => 'title',
'B' => 'type_id',
'C' => 'content',
'D' => 'contact_name',
'E' => 'contact_phone',
'F' => 'contact_address',
'G' => 'ticket_address',
];
//加载文件
$spreadsheet = IOFactory::load($file);
$sheet = $spreadsheet->getActiveSheet(); // 获取表格
$highestRow = $sheet->getHighestRow(); // 取得总行数
$sheetData = [];
for ($row = 2; $row <= $highestRow; $row++) { // $row表示从第几行开始读取
foreach ($fields as $cell => $field) {
$value = $sheet->getCell($cell . $row)->getValue();
$value = trim($value);
$sheetData[$row][$field] = $value;
}
}
$sheetData = array_values($sheetData);
foreach ($sheetData as $key => $value) {
if (!empty($value['type_id'])) {
$type = TicketType::query()->where(['id' => $value['type_id']])->find();
if (empty($type)) {
$this->error('工单类型【'.$value['type_id'].'】不存在');
} else {
$sheetData[$key]['type_id'] = $type['id'];
}
}
$sheetData[$key]['create_at'] = date('Y-m-d H:i:s');
$sheetData[$key]['user_id'] = $this->request->session('user')['id'];
$sheetData[$key]['status'] = 0;
}
TicketTicket::mk()->saveAll($sheetData);
$this->success("成功");
}
public function comment()
{
$data = $this->_vali([
'id.require'=>'请指定工单ID!',
]);
$ticket = TicketTicket::query()->with(['user_shares'])->where('id', '=', $data['id'])->findOrEmpty();
if ($ticket->isEmpty()) {
$this->error('未找到工单信息');
}
if (!$ticket->user_shares || sizeof($ticket->user_shares) == 0) {
$this->error("该工单无需评论");
}
if ($this->request->isPost()) {
$adminInfo = $this->request->session('user');
$comment_data = $this->_vali([
'content.require'=>'请输入评论内容!',
]);
TicketTicket::mk()->startTrans();
try {
foreach ($ticket->user_shares as $share) {
$share->logs()->save([
'op_name' => $adminInfo["username"],
'content' => $comment_data['content'],
'result' => "后台用户反馈",
]);
}
TicketTicket::mk()->commit();
} catch (\Exception $e) {
TicketTicket::mk()->rollback();
$this->error("保存失败");
}
} else {
$this->vo = $ticket;
$this->ticket = $ticket;
$this->fetch();
}
}
}

View File

@ -97,7 +97,7 @@ class UserShare extends Controller
'lat' => $share->ticket_lat,
'lng' => $share->ticket_lng,
'imgs' => $share->imgs,
'status' => -1,
'status' => 0,
]);
$ticket->source = $share;
$ticket->save();