This commit is contained in:
611
plugins/addon/example/controller/TicketController.php
Normal file
611
plugins/addon/example/controller/TicketController.php
Normal file
@@ -0,0 +1,611 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller;
|
||||
|
||||
use addon\idcsmart_ticket\logic\IdcsmartTicketLogic;
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketModel;
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketReplyModel;
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketTypeModel;
|
||||
use addon\idcsmart_ticket\validate\TicketValidate;
|
||||
use app\event\controller\PluginAdminBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单(后台)
|
||||
* @desc 工单(后台)
|
||||
* @use addon\idcsmart_ticket\controller\TicketController
|
||||
*/
|
||||
class TicketController extends PluginAdminBaseController
|
||||
{
|
||||
private $validate=null;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->validate = new TicketValidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 设置
|
||||
* @desc 设置
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/config
|
||||
* @method get
|
||||
* @return int refresh_time - 刷新时间
|
||||
* @return int ticket_notice_open - 是否开启工单通知,1是默认,0否
|
||||
* @return string ticket_notice_description - 工单通知描述
|
||||
* @return int ticket_type_id - 工单部门ID
|
||||
* @return int downstream_delivery - 下游传递
|
||||
* @return int ticket_close_switch - 自动关闭工单开关 1开启,0关闭
|
||||
* @return int ticket_close_hour - 已回复状态的工单超过x小时后关闭
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
$config = IdcsmartTicketLogic::getDefaultConfig();
|
||||
return json([
|
||||
'status' => 200,
|
||||
'msg' => lang_plugins('success_message'),
|
||||
'data' => [
|
||||
'refresh_time' => $config['refresh_time']??3,
|
||||
'ticket_notice_open' => $config['ticket_notice_open']??1,
|
||||
'ticket_notice_description' => !empty($config['ticket_notice_description'])?htmlspecialchars_decode($config['ticket_notice_description']):"",
|
||||
'ticket_type_id' => $config['ticket_type_id']??0,
|
||||
'downstream_delivery' => $config['downstream_delivery']??0,
|
||||
'ticket_close_switch' => $config['ticket_close_switch']??0,
|
||||
'ticket_close_hour' => $config['ticket_close_hour']??0,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 设置
|
||||
* @desc 设置
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/config
|
||||
* @method POST
|
||||
* @param int refresh_time - 刷新时间
|
||||
* @param int ticket_notice_open - 是否开启工单通知,1是默认,0否
|
||||
* @param string ticket_notice_description - 工单通知描述
|
||||
* @param int ticket_type_id - 工单部门ID
|
||||
* @param int downstream_delivery - 下游传递
|
||||
* @param int ticket_close_switch - 自动关闭工单开关 1开启,0关闭
|
||||
* @param int ticket_close_hour - 已回复状态的工单超过x小时后关闭
|
||||
*/
|
||||
public function setConfig()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$result = (new IdcsmartTicketLogic())->setConfig($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-24
|
||||
* @title 工单部门
|
||||
* @desc 工单部门
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/department
|
||||
* @method GET
|
||||
* @return array list - 工单部门列表
|
||||
* @return int list[].id - 工单部门ID
|
||||
* @return string list[].name - 工单部门名称
|
||||
*/
|
||||
public function department()
|
||||
{
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->typeDepartment();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 工单列表
|
||||
* @desc 工单列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket
|
||||
* @method GET
|
||||
* @param string keywords - 关键字
|
||||
* @param array status - 状态搜索,数组(/console/v1/ticket/status get获取状态列表)
|
||||
* @param int ticket_type_id - 工单类型搜索(/console/v1/ticket/type get获取类型列表)
|
||||
* @param int client_id - 用户搜索(客户列表接口获取)
|
||||
* @param int admin_id - 跟进人搜索(管理员列表获取)
|
||||
* @param int page - 页数
|
||||
* @param int limit - 每页条数
|
||||
* @return array list - 工单列表
|
||||
* @return int list[].id - ID
|
||||
* @return string list[].ticket_num - 工单号
|
||||
* @return string list[].title - 标题
|
||||
* @return string list[].name - 类型
|
||||
* @return int list[].post_time - 提交时间
|
||||
* @return string list[].client_id - 用户ID
|
||||
* @return string list[].username - 客户名称
|
||||
* @return array list[].hosts - 关联产品,数组
|
||||
* @return array list[].host_ids - 关联产品ID,数组(作跳转使用)
|
||||
* @return int list[].last_reply_time - 最近回复时间
|
||||
* @return string list[].status - 状态
|
||||
* @return string list[].color - 状态颜色
|
||||
* @return string list[].admin_name - 跟进人,为null时显示-
|
||||
* @return int list[].ticket_internal - 是否有内部工单插件:1是(显示新建内部工单按钮),0否
|
||||
* @return int list[].client_level - 客户等级客户ID
|
||||
* @return int list[].last_time - 最近操作时间
|
||||
* @return int list[].downstream_delivery - 是否下游传递
|
||||
* @return int list[].upstream_ticket_id - 大于0时,为上游工单ID,显示[向上传递]
|
||||
* @return int count - 工单总数
|
||||
*/
|
||||
public function ticketList()
|
||||
{
|
||||
$param = array_merge($this->request->param(),['page'=>$this->request->page,'limit'=>$this->request->limit,'sort'=>$this->request->sort]);
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->ticketList($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 接收工单
|
||||
* @desc 接收工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/receive
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function receive()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->receiveTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 已解决工单
|
||||
* @desc 已解决工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/resolved
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function resolved()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->resolvedTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 工单详情
|
||||
* @desc 工单详情
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id
|
||||
* @method GET
|
||||
* @param int id - 工单ID required
|
||||
* @return object ticket - 工单详情
|
||||
* @return int ticket.id - 工单ID
|
||||
* @return int ticket.client_id - 用户ID
|
||||
* @return string ticket.title - 工单标题
|
||||
* @return string ticket.title - 工单标题
|
||||
* @return string ticket.priority - 内容
|
||||
* @return int ticket.ticket_type_id - 类型ID
|
||||
* @return string ticket.status - 状态:Pending待接受,Handling处理中,Reply待回复,Replied已回复,Resolved已解决,Closed已关闭
|
||||
* @return int ticket.create_time - 创建时间
|
||||
* @return array ticket.attachment - 工单附件,数组,返回所有附件
|
||||
* @return int ticket.last_reply_time - 工单最后回复时间
|
||||
* @return string ticket.username - 用户名
|
||||
* @return array ticket.host_ids - 关联产品ID,数组
|
||||
* @return int ticket.can_operate - 是否可操作
|
||||
* @return int ticket.upstream_ticket_id - 上游工单ID
|
||||
* @return int ticket.delivery_status - 传递状态:1已开启传递,0已关闭传递
|
||||
* @return int ticket.delivery_operate - 传递操作:0不显示按钮,1发起传递,2开启传递,3终止传递
|
||||
* @return array ticket.replies - 沟通记录,数组
|
||||
* @return int ticket.replies[].id - 回复ID,注意:有一个回复ID为0,是工单内容默认填充,这里不能修改
|
||||
* @return string ticket.replies[].content - 内容
|
||||
* @return array ticket.replies[].attachment - 附件访问地址,数组
|
||||
* @return int ticket.replies[].create_time - 时间
|
||||
* @return string ticket.replies[].type - 类型:Client用户回复,Admin管理员回复
|
||||
* @return string ticket.replies[].client_name - 用户名,type==Client时用此值
|
||||
* @return string ticket.replies[].admin_name - 管理员名,type==Admin时用此值
|
||||
* @return string ticket.forwards[].nickname - 管理员名
|
||||
* @return string ticket.forwards[].forward_nickname - 转入理员名
|
||||
* @return string ticket.forwards[].notes - 备注
|
||||
* @return string ticket.forwards[].ticket_type_name - 转入部门名
|
||||
* @return int ticket.forwards[].create_time - 时间
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->indexTicket(intval($param['id']));
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-22
|
||||
* @title 回复工单
|
||||
* @desc 回复工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/reply
|
||||
* @method POST
|
||||
* @param int id - 工单ID required
|
||||
* @param string content - 回复内容,不超过3000个字符 required
|
||||
* @param array attachment - 附件,数组(后台调admin/v1/upload(前台调console/v1/upload)上传文件,取返回值save_name)
|
||||
* @return int ticket_reply_id - 回复ID
|
||||
*/
|
||||
public function reply()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('reply')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->replyTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-07-22
|
||||
* @title 工单附件下载
|
||||
* @desc 工单附件下载
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/download
|
||||
* @method POST
|
||||
* @param string name - 附件名称 required
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
return $IdcsmartTicketModel->download($param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-21
|
||||
* @title 转内部工单
|
||||
* @desc 转内部工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/convert
|
||||
* @method POST
|
||||
* @param int ticket_id - 工单ID(转内部工单时需要传此参数)
|
||||
* @param string title - 内部工单标题 required
|
||||
* @param int ticket_type_id - 内部工单类型ID(调admin/v1/ticket/internal/type获取列表) required
|
||||
* @param string priority - 紧急程度:medium一般,high紧急 required
|
||||
* @param int client_id - 关联用户
|
||||
* @param int admin_role_id - 指定部门 required
|
||||
* @param int admin_id - 管理员ID
|
||||
* @param array host_ids - 关联产品ID,数组(/admin/v1/host?client_id= 获取所选客户的产品列表,取产品ID)
|
||||
* @param string content - 问题描述
|
||||
* @param array attachment - 附件,数组(后台调admin/v1/upload(前台调console/v1/upload)上传文件,取返回值save_name)
|
||||
*/
|
||||
public function convert()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->convert($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 内部工单类型列表
|
||||
* @desc 内部工单类型列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/internal/type
|
||||
* @method GET
|
||||
* @return array list - 工单类型列表
|
||||
* @return int list[].id - 工单类型ID
|
||||
* @return int list[].name - 工单类型名称
|
||||
* @return int list[].role_name - 默认接受部门
|
||||
*/
|
||||
public function ticketInternalType()
|
||||
{
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->ticketInternalType();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 创建工单
|
||||
* @desc 创建工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket
|
||||
* @method POST
|
||||
* @param int client_id - 用户ID required
|
||||
* @param string title - 工单标题 required
|
||||
* @param int ticket_type_id - 工单类型ID required
|
||||
* @param array host_ids - 关联产品ID,数组(id从)
|
||||
* @param string content - 问题描述
|
||||
* @param array attachment - 附件,数组(后台调admin/v1/upload(前台调console/v1/upload)上传文件,取返回值save_name)
|
||||
* @param string notes - 备注
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('create_admin')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->createTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 转交工单
|
||||
* @desc 转交工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/forward
|
||||
* @method POST
|
||||
* @param int admin_id - 管理员ID required
|
||||
* @param int notes - 备注 required
|
||||
* @param int ticket_type_id - 部门ID required
|
||||
*/
|
||||
public function forward()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('forward')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->forward($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 修改工单状态
|
||||
* @desc 修改工单状态
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/status
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
* @param int status - 状态ID required
|
||||
* @param int ticket_type_id - 工单类型ID
|
||||
* @param array host_ids - 产品ID,数组
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('update_status')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->status($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 修改工单回复
|
||||
* @desc 修改工单回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/reply/:id
|
||||
* @method PUT
|
||||
* @param int id - 工单回复ID required
|
||||
* @param int content - 内容 required
|
||||
*/
|
||||
public function ticketReplyUpdate()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketReplyModel = new IdcsmartTicketReplyModel();
|
||||
|
||||
$result = $IdcsmartTicketReplyModel->ticketReplyUpdate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 删除工单回复
|
||||
* @desc 删除工单回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/reply/:id
|
||||
* @method DELETE
|
||||
* @param int id - 工单回复ID required
|
||||
*/
|
||||
public function ticketReplyDelete()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketReplyModel = new IdcsmartTicketReplyModel();
|
||||
|
||||
$result = $IdcsmartTicketReplyModel->ticketReplyDelete($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 工单日志
|
||||
* @desc 工单日志
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/log
|
||||
* @method GET
|
||||
* @param int page - 页数
|
||||
* @param int limit - 每页条数
|
||||
* @return array list -
|
||||
* @return int list[].id - ID
|
||||
* @return int list[].create_time - 记录时间
|
||||
* @return int list[].description - 描述
|
||||
*/
|
||||
public function ticketLog()
|
||||
{
|
||||
$param = array_merge($this->request->param(),['page'=>$this->request->page,'limit'=>$this->request->limit,'sort'=>$this->request->sort]);
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->ticketLog($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-09-23
|
||||
* @title 修改工单内容
|
||||
* @desc 修改工单内容
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/content
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
* @param int content - 内容 required
|
||||
*/
|
||||
public function updateContent()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->updateContent($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 手动发起传递
|
||||
* @desc 手动发起传递
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/delivery/manual
|
||||
* @method POST
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function manualDelivery()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->manualDelivery($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 终止传递
|
||||
* @desc 终止传递
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/delivery/terminate
|
||||
* @method POST
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function terminateDelivery()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->terminateDelivery($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 启动传递
|
||||
* @desc 启动传递
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:id/delivery/active
|
||||
* @method POST
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function activeDelivery()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$IdcsmartTicketModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketModel->activeDelivery($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
}
|
||||
242
plugins/addon/example/controller/TicketDeliveryController.php
Normal file
242
plugins/addon/example/controller/TicketDeliveryController.php
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller;
|
||||
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketDeliveryModel;
|
||||
use addon\idcsmart_ticket\validate\TicketDeliveryValidate;
|
||||
use app\common\model\UpstreamProductModel;
|
||||
use app\event\controller\PluginAdminBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单自动向上传递规则(后台)
|
||||
* @desc 工单自动向上传递规则(后台)
|
||||
* @use addon\idcsmart_ticket\controller\TicketDeliveryController
|
||||
*/
|
||||
class TicketDeliveryController extends PluginAdminBaseController
|
||||
{
|
||||
private $validate=null;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->validate = new TicketDeliveryValidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-13
|
||||
* @title 工单传递供应商商品列表
|
||||
* @desc 工单传递供应商商品列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/supplier/product
|
||||
* @method GET
|
||||
* @return array list - 工单传递供应商商品列表
|
||||
* @return int list[].supplier_name - 供应商名称
|
||||
* @return array list[].group - 分组
|
||||
* @return string list[].group[].product_group_name - 分组名称
|
||||
* @return array list[].group[].products - 商品
|
||||
* @return int list[].group[].products[].product_id - 商品ID
|
||||
* @return int list[].group[].products[].supplier_id - 供应商ID
|
||||
* @return int list[].group[].products[].product_group_id - 商品分组ID
|
||||
* @return string list[].group[].products[].product_name - 商品名称
|
||||
* @return string list[].group[].products[].product_group_name - 分组名称
|
||||
* @return string list[].group[].products[].supplier_name - 供应商名称
|
||||
*/
|
||||
public function supplierProductList()
|
||||
{
|
||||
$UpstreamProductModel = new UpstreamProductModel();
|
||||
|
||||
$products = $UpstreamProductModel->alias('up')
|
||||
->field('up.product_id,up.supplier_id,p.product_group_id,p.name product_name,
|
||||
pg.name product_group_name,s.name supplier_name')
|
||||
->leftJoin('supplier s','up.supplier_id=s.id')
|
||||
->leftJoin('product p','up.product_id=p.id')
|
||||
->leftJoin('product_group pg','p.product_group_id=pg.id')
|
||||
->where('p.product_group_id','>',0)
|
||||
->group('up.product_id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$filter = [];
|
||||
|
||||
foreach ($products as $product){
|
||||
if (!isset($filter[$product['supplier_id']])){
|
||||
$filter[$product['supplier_id']] = [];
|
||||
$filter[$product['supplier_id']][] = $product;
|
||||
}else{
|
||||
$filter[$product['supplier_id']][] = $product;
|
||||
}
|
||||
}
|
||||
|
||||
$filter2 = [];
|
||||
|
||||
foreach ($filter as $key=>$value){
|
||||
if (!empty($value)){
|
||||
$group = [];
|
||||
|
||||
foreach ($value as $item){
|
||||
if (!isset($group[$item['product_group_id']])){
|
||||
$group[$item['product_group_id']] = [];
|
||||
$group[$item['product_group_id']][] = $item;
|
||||
}else{
|
||||
$group[$item['product_group_id']][] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
$groupFilter = [];
|
||||
|
||||
foreach ($group as $key2=>$value2){
|
||||
if (!empty($value2)){
|
||||
$groupFilter[] = [
|
||||
'product_group_name' => $value2[0]['product_group_name'],
|
||||
'products' => $value2
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$filter2[] = [
|
||||
'supplier_name' => $value[0]['supplier_name'],
|
||||
'group' => $groupFilter
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return json([
|
||||
'status' => 200,
|
||||
'msg' => lang_plugins('success_message'),
|
||||
'data' => [
|
||||
'list' => $filter2
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-13
|
||||
* @title 工单传递规则列表
|
||||
* @desc 工单传递规则列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/delivery
|
||||
* @method GET
|
||||
* @return array list - 工单传递规则列表
|
||||
* @return int list[].id - 规则ID
|
||||
* @return int list[].product_name - 商品名称
|
||||
* @return int list[].type_name - 类型名称
|
||||
* @return int list[].blocked_words - 屏蔽词,逗号分隔
|
||||
*/
|
||||
public function ticketDeliveryList()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketDeliveryModel = new IdcsmartTicketDeliveryModel();
|
||||
|
||||
$IdcsmartTicketDeliveryModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketDeliveryModel->ticketDeliveryList($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-13
|
||||
* @title 工单传递规则详情
|
||||
* @desc 工单传递规则详情
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/delivery/:id
|
||||
* @method GET
|
||||
* @param int id - 工单传递规则ID required
|
||||
* @return object ticket_delivery - 工单传递规则详情
|
||||
* @return int ticket_delivery.product_id - 商品ID
|
||||
* @return string ticket_delivery.ticket_type_id - 类型ID
|
||||
* @return string ticket_delivery.blocked_words - 屏蔽词,逗号分隔
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketDeliveryModel = new IdcsmartTicketDeliveryModel();
|
||||
|
||||
$result = $IdcsmartTicketDeliveryModel->indexTicketDelivery(intval($param['id']));
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-13
|
||||
* @title 创建工单传递规则
|
||||
* @desc 创建工单传递规则
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/delivery
|
||||
* @method POST
|
||||
* @param int ticket_type_id - 工单类型ID required
|
||||
* @param array product_ids - 商品ID数组 required
|
||||
* @param string blocked_words - 屏蔽词
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('create')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketDeliveryModel = new IdcsmartTicketDeliveryModel();
|
||||
|
||||
$result = $IdcsmartTicketDeliveryModel->createTicketDelivery($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-13
|
||||
* @title 编辑工单传递规则
|
||||
* @desc 编辑工单传递规则
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/delivery/:id
|
||||
* @method PUT
|
||||
* @param int id - 工单传递规则ID required
|
||||
* @param int product_id - 商品ID required
|
||||
* @param int ticket_type_id - 类型ID required
|
||||
* @param string blocked_words - 屏蔽词
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('update')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketDeliveryModel = new IdcsmartTicketDeliveryModel();
|
||||
|
||||
$result = $IdcsmartTicketDeliveryModel->updateTicketDelivery($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-13
|
||||
* @title 删除工单传递规则
|
||||
* @desc 删除工单传递规则
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/delivery/:id
|
||||
* @method DELETE
|
||||
* @param int id - 工单传递规则ID required
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketDeliveryModel = new IdcsmartTicketDeliveryModel();
|
||||
|
||||
$result = $IdcsmartTicketDeliveryModel->deleteTicketDelivery(intval($param['id']));
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
}
|
||||
135
plugins/addon/example/controller/TicketNotesController.php
Normal file
135
plugins/addon/example/controller/TicketNotesController.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller;
|
||||
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketNotesModel;
|
||||
use app\event\controller\PluginAdminBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单备注(后台)
|
||||
* @desc 工单备注(后台)
|
||||
* @use addon\idcsmart_ticket\controller\TicketNotesController
|
||||
*/
|
||||
class TicketNotesController extends PluginAdminBaseController
|
||||
{
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单备注列表
|
||||
* @desc 工单备注列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/notes
|
||||
* @method GET
|
||||
* @param int ticket_id - 工单ID
|
||||
* @return array list - 工单备注列表
|
||||
* @return int list[].id - ID
|
||||
* @return string list[].content - 工单备注
|
||||
* @return int list[].create_time - 创建时间
|
||||
* @return int list[].update_time - 更新时间
|
||||
* @return string list[].name - 管理员名称
|
||||
*/
|
||||
public function ticketNotesList()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketNotesModel = new IdcsmartTicketNotesModel();
|
||||
|
||||
$result = $IdcsmartTicketNotesModel->ticketNotesList($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单备注详情
|
||||
* @desc 工单备注详情
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:ticket_id/notes/:id
|
||||
* @method GET
|
||||
* @param int id - 工单备注ID
|
||||
* @return int id - ID
|
||||
* @return string content - 工单备注
|
||||
* @return int create_time - 创建时间
|
||||
* @return int update_time - 更新时间
|
||||
* @return string name - 管理员名称
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketNotesModel = new IdcsmartTicketNotesModel();
|
||||
|
||||
$result = $IdcsmartTicketNotesModel->ticketNotesIndex($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 创建工单备注
|
||||
* @desc 创建工单备注
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:ticket_id/notes
|
||||
* @method POST
|
||||
* @param int ticket_id - 工单ID
|
||||
* @param string content - 工单备注
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketNotesModel = new IdcsmartTicketNotesModel();
|
||||
|
||||
$result = $IdcsmartTicketNotesModel->ticketNotesCreate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 编辑工单备注
|
||||
* @desc 编辑工单备注
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:ticket_id/notes/:id
|
||||
* @method PUT
|
||||
* @param int ticket_id - 工单ID
|
||||
* @param int id - 工单备注ID
|
||||
* @param string content - 工单备注
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketNotesModel = new IdcsmartTicketNotesModel();
|
||||
|
||||
$result = $IdcsmartTicketNotesModel->ticketNotesUpdate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 删除工单备注
|
||||
* @desc 删除工单备注
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/:ticket_id/notes/:id
|
||||
* @method DELETE
|
||||
* @param int ticket_id - 工单ID
|
||||
* @param int id - 工单备注ID
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketNotesModel = new IdcsmartTicketNotesModel();
|
||||
|
||||
$result = $IdcsmartTicketNotesModel->ticketNotesDelete($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
123
plugins/addon/example/controller/TicketPrereplyController.php
Normal file
123
plugins/addon/example/controller/TicketPrereplyController.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller;
|
||||
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketPrereplyModel;
|
||||
use app\event\controller\PluginAdminBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单预设回复(后台)
|
||||
* @desc 工单预设回复(后台)
|
||||
* @use addon\idcsmart_ticket\controller\TicketPrereplyController
|
||||
*/
|
||||
class TicketPrereplyController extends PluginAdminBaseController
|
||||
{
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单预设回复列表
|
||||
* @desc 工单预设回复列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/prereply
|
||||
* @method GET
|
||||
* @return array list - 工单预设回复列表
|
||||
* @return int list[].id - ID
|
||||
* @return string list[].content - 内容
|
||||
*/
|
||||
public function ticketPrereplyList()
|
||||
{
|
||||
$IdcsmartTicketPrereplyModel = new IdcsmartTicketPrereplyModel();
|
||||
|
||||
$result = $IdcsmartTicketPrereplyModel->ticketPrereplyList();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单预设回复详情
|
||||
* @desc 工单预设回复详情
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/prereply/:id
|
||||
* @method GET
|
||||
* @param int id - 工单预设回复ID
|
||||
* @return int id - ID
|
||||
* @return string content - 内容
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketPrereplyModel = new IdcsmartTicketPrereplyModel();
|
||||
|
||||
$result = $IdcsmartTicketPrereplyModel->ticketPrereplyIndex($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 创建工单预设回复
|
||||
* @desc 创建工单预设回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/prereply
|
||||
* @method POST
|
||||
* @param string content - 内容
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketPrereplyModel = new IdcsmartTicketPrereplyModel();
|
||||
|
||||
$result = $IdcsmartTicketPrereplyModel->ticketPrereplyCreate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 编辑工单预设回复
|
||||
* @desc 编辑工单预设回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/prereply/:id
|
||||
* @method PUT
|
||||
* @param int id - 工单预设回复ID
|
||||
* @param string content - 内容
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketPrereplyModel = new IdcsmartTicketPrereplyModel();
|
||||
|
||||
$result = $IdcsmartTicketPrereplyModel->ticketPrereplyUpdate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 删除工单预设回复
|
||||
* @desc 删除工单预设回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/prereply/:id
|
||||
* @method DELETE
|
||||
* @param int id - 工单预设回复ID
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketPrereplyModel = new IdcsmartTicketPrereplyModel();
|
||||
|
||||
$result = $IdcsmartTicketPrereplyModel->ticketPrereplyDelete($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
151
plugins/addon/example/controller/TicketStatusController.php
Normal file
151
plugins/addon/example/controller/TicketStatusController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller;
|
||||
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketStatusModel;
|
||||
use addon\idcsmart_ticket\validate\TicketStatusValidate;
|
||||
use app\event\controller\PluginAdminBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单状态(后台)
|
||||
* @desc 工单状态(后台)
|
||||
* @use addon\idcsmart_ticket\controller\TicketStatusController
|
||||
*/
|
||||
class TicketStatusController extends PluginAdminBaseController
|
||||
{
|
||||
private $validate=null;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->validate = new TicketStatusValidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单状态列表
|
||||
* @desc 工单状态列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/status
|
||||
* @method GET
|
||||
* @return array list - 工单状态列表
|
||||
* @return int list[].id - ID
|
||||
* @return string list[].name - 工单状态
|
||||
* @return string list[].color - 状态颜色
|
||||
* @return int list[].status - 完结状态:1完结,0未完结
|
||||
* @return int list[].default - 是否默认状态:0否,1是,默认状态无法修改删除
|
||||
*/
|
||||
public function ticketStatusList()
|
||||
{
|
||||
$IdcsmartTicketStatusModel = new IdcsmartTicketStatusModel();
|
||||
|
||||
$result = $IdcsmartTicketStatusModel->ticketStatusList();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单状态详情
|
||||
* @desc 工单状态详情
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/status/:id
|
||||
* @method GET
|
||||
* @param int id - 工单状态ID
|
||||
* @return int id - ID
|
||||
* @return string name - 工单状态
|
||||
* @return string color - 状态颜色
|
||||
* @return int status - 完结状态:1完结,0未完结
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketStatusModel = new IdcsmartTicketStatusModel();
|
||||
|
||||
$result = $IdcsmartTicketStatusModel->ticketStatusIndex($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 创建工单状态
|
||||
* @desc 创建工单状态
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/status
|
||||
* @method POST
|
||||
* @param string name - 工单状态ID
|
||||
* @param string color - 状态颜色
|
||||
* @param int status - 完结状态:1完结,0未完结
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('create')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketStatusModel = new IdcsmartTicketStatusModel();
|
||||
|
||||
$result = $IdcsmartTicketStatusModel->ticketStatusCreate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 编辑工单状态
|
||||
* @desc 编辑工单状态
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/status/:id
|
||||
* @method PUT
|
||||
* @param int id - 工单状态ID
|
||||
* @param string name - 工单状态ID
|
||||
* @param string color - 状态颜色
|
||||
* @param int status - 完结状态:1完结,0未完结
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('update')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketStatusModel = new IdcsmartTicketStatusModel();
|
||||
|
||||
$result = $IdcsmartTicketStatusModel->ticketStatusUpdate($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 删除工单状态
|
||||
* @desc 删除工单状态
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/status/:id
|
||||
* @method DELETE
|
||||
* @param int id - 工单状态ID
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketStatusModel = new IdcsmartTicketStatusModel();
|
||||
|
||||
$result = $IdcsmartTicketStatusModel->ticketStatusDelete($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
152
plugins/addon/example/controller/TicketTypeController.php
Normal file
152
plugins/addon/example/controller/TicketTypeController.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller;
|
||||
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketTypeModel;
|
||||
use addon\idcsmart_ticket\validate\TicketTypeValidate;
|
||||
use app\event\controller\PluginAdminBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单类型(后台)
|
||||
* @desc 工单类型(后台)
|
||||
* @use addon\idcsmart_ticket\controller\TicketTypeController
|
||||
*/
|
||||
class TicketTypeController extends PluginAdminBaseController
|
||||
{
|
||||
private $validate=null;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->validate = new TicketTypeValidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 工单部门列表
|
||||
* @desc 工单部门列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/type
|
||||
* @method GET
|
||||
* @return array list - 工单部门列表
|
||||
* @return int list[].id - 工单部门ID
|
||||
* @return int list[].name - 工单部门名称
|
||||
* @return int list[].admin[].id - 管理员ID
|
||||
* @return string list[].admin[].name - 管理员名称
|
||||
*/
|
||||
public function ticketTypeList()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$IdcsmartTicketTypeModel->isAdmin = true;
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->typeTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 工单部门详情
|
||||
* @desc 工单部门详情
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/type/:id
|
||||
* @method GET
|
||||
* @param int id - 工单部门ID required
|
||||
* @return object ticket_type - 工单部门详情
|
||||
* @return int ticket_type.id - 工单部门ID
|
||||
* @return string ticket_type.name - 工单部门名称
|
||||
* @return int admin[].id - 管理员ID
|
||||
* @return string admin[].name - 管理员名称
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->indexTicketType(intval($param['id']));
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 创建工单部门
|
||||
* @desc 创建工单部门
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/type
|
||||
* @method POST
|
||||
* @param string name - 工单部门名称 required
|
||||
* @param array admin_id - 管理员ID required
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('create')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->createTicketType($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 编辑工单部门
|
||||
* @desc 编辑工单部门
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/type/:id
|
||||
* @method PUT
|
||||
* @param int id - 工单部门ID required
|
||||
* @param string name - 工单部门名称 required
|
||||
* @param array admin_id - 管理员ID required
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('update')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->updateTicketType($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 删除工单部门
|
||||
* @desc 删除工单部门
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /admin/v1/ticket/type/:id
|
||||
* @method DELETE
|
||||
* @param int id - 工单部门ID required
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->deleteTicketType(intval($param['id']));
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
}
|
||||
471
plugins/addon/example/controller/clientarea/TicketController.php
Normal file
471
plugins/addon/example/controller/clientarea/TicketController.php
Normal file
@@ -0,0 +1,471 @@
|
||||
<?php
|
||||
namespace addon\idcsmart_ticket\controller\clientarea;
|
||||
|
||||
use addon\idcsmart_ticket\logic\IdcsmartTicketLogic;
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketModel;
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketStatusModel;
|
||||
use addon\idcsmart_ticket\model\IdcsmartTicketTypeModel;
|
||||
use addon\idcsmart_ticket\validate\TicketValidate;
|
||||
use app\event\controller\PluginBaseController;
|
||||
|
||||
/**
|
||||
* @title 工单(会员中心)
|
||||
* @desc 工单(会员中心)
|
||||
* @use addon\idcsmart_ticket\controller\clientarea\TicketController
|
||||
*/
|
||||
class TicketController extends PluginBaseController
|
||||
{
|
||||
private $validate=null;
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
$this->validate = new TicketValidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-21
|
||||
* @title 工单状态列表
|
||||
* @desc 工单状态列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/status
|
||||
* @method GET
|
||||
* @return array list - 工单状态列表
|
||||
* @return int list[].id - ID
|
||||
* @return string list[].name - 工单状态
|
||||
* @return string list[].color - 状态颜色
|
||||
* @return int list[].status - 完结状态:1完结,0未完结
|
||||
* @return int list[].default - 是否默认状态:0否,1是,默认状态无法修改删除
|
||||
*/
|
||||
public function ticketStatusList()
|
||||
{
|
||||
$IdcsmartTicketStatusModel = new IdcsmartTicketStatusModel();
|
||||
|
||||
$result = $IdcsmartTicketStatusModel->ticketStatusList();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-20
|
||||
* @title 工单列表
|
||||
* @desc 工单列表
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket
|
||||
* @method GET
|
||||
* @param string keywords - 关键字
|
||||
* @param int status - 状态搜索(/console/v1/ticket/status get获取状态列表)
|
||||
* @param int ticket_type_id - 工单类型搜索(/console/v1/ticket/type get获取类型列表)
|
||||
* @param int client_id - 客户ID
|
||||
* @param int admin_id - 管理员ID
|
||||
* @param int host_id - 产品ID
|
||||
* @param int page - 页数
|
||||
* @param int limit - 每页条数
|
||||
* @return array list - 工单列表
|
||||
* @return int list[].id - ID
|
||||
* @return string list[].ticket_num - 工单号
|
||||
* @return string list[].title - 标题
|
||||
* @return string list[].name - 类型
|
||||
* @return int list[].post_time - 提交时间
|
||||
* @return int list[].last_reply_time - 最近回复时间
|
||||
* @return string list[].status - 状态
|
||||
* @return string list[].color - 状态颜色
|
||||
* @return string list[].last_urge_time - 上次催单时间戳(0代表未催单)
|
||||
* @return int count - 工单总数
|
||||
*/
|
||||
public function ticketList()
|
||||
{
|
||||
$param = array_merge($this->request->param(),['page'=>$this->request->page,'limit'=>$this->request->limit,'sort'=>$this->request->sort]);
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->ticketList($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 工单统计
|
||||
* @desc 工单统计
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/statistic
|
||||
* @method GET
|
||||
* @return int 1 - 待接单数量
|
||||
* @return int 2 - 待回复数量
|
||||
* @return int 3 - 已回复数量
|
||||
* @return int 5 - 处理中数量
|
||||
*/
|
||||
public function statistic()
|
||||
{
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->statisticTicket();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-20
|
||||
* @title 查看工单
|
||||
* @desc 查看工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id
|
||||
* @method GET
|
||||
* @param int id - 工单ID required
|
||||
* @return object ticket - 工单详情
|
||||
* @return int ticket.client_id - 用户ID
|
||||
* @return int ticket.id - 工单ID
|
||||
* @return string ticket.title - 工单标题
|
||||
* @return string ticket.content - 内容
|
||||
* @return int ticket.ticket_type_id - 类型ID
|
||||
* @return string ticket.status - 状态,直接显示,结合color
|
||||
* @return string ticket.color - 状态颜色
|
||||
* @return int ticket.create_time - 创建时间
|
||||
* @return array ticket.attachment - 工单附件,数组,返回所有附件(附件以^符号分割,取最后一个值获取文件原名)
|
||||
* @return int ticket.last_reply_time - 工单最后回复时间
|
||||
* @return string ticket.username - 用户名
|
||||
* @return array ticket.host_ids - 关联产品ID,数组
|
||||
* @return int ticket.can_operate - 是否可操作
|
||||
* @return array ticket.replies - 沟通记录,数组
|
||||
* @return string ticket.replies[].content - 内容
|
||||
* @return array ticket.replies[].attachment - 附件访问地址,数组
|
||||
* @return int ticket.replies[].create_time - 时间
|
||||
* @return string ticket.replies[].type - 类型:Client用户回复,Admin管理员回复
|
||||
* @return string ticket.replies[].client_name - 用户名,type==Client时用此值
|
||||
* @return string ticket.replies[].admin_name - 管理员名,type==Admin时用此值
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->indexTicket(intval($param['id']));
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-20
|
||||
* @title 创建工单
|
||||
* @desc 创建工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket
|
||||
* @method POST
|
||||
* @param string title - 工单标题 required
|
||||
* @param int ticket_type_id - 工单类型ID,/console/v1/ticket/type接口获取 required
|
||||
* @param array host_ids - 关联产品ID,数组(id从产品列表接口获取)
|
||||
* @param string content - 问题描述
|
||||
* @param array attachment - 附件,数组(后台调admin/v1/upload(前台调console/v1/upload)上传文件,取返回值save_name)
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('create')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->createTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 回复工单
|
||||
* @desc 回复工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/reply
|
||||
* @method POST
|
||||
* @param int id - 工单ID required
|
||||
* @param string content - 回复内容,不超过3000个字符 required
|
||||
* @param array attachment - 附件,数组(后台调admin/v1/upload(前台调console/v1/upload)上传文件,取返回值save_name)
|
||||
* @return int ticket_reply_id - 回复ID
|
||||
*/
|
||||
public function reply()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
//参数验证
|
||||
if (!$this->validate->scene('reply')->check($param)){
|
||||
return json(['status' => 400 , 'msg' => lang_plugins($this->validate->getError())]);
|
||||
}
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->replyTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 催单
|
||||
* @desc 催单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/urge
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function urge()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->urgeTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 关闭工单
|
||||
* @desc 关闭工单
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/close
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->closeTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-10-24
|
||||
* @title 工单部门
|
||||
* @desc 工单部门
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/department
|
||||
* @method GET
|
||||
* @return array list - 工单部门列表
|
||||
* @return int list[].id - 工单部门ID
|
||||
* @return string list[].name - 工单部门名称
|
||||
*/
|
||||
public function department()
|
||||
{
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->typeDepartment();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-06-21
|
||||
* @title 工单部门
|
||||
* @desc 工单部门
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/type
|
||||
* @method GET
|
||||
* @return array list - 工单类型列表
|
||||
* @return int list[].id - 工单部门ID
|
||||
* @return string list[].name - 工单部门名称
|
||||
*/
|
||||
public function type()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketTypeModel = new IdcsmartTicketTypeModel();
|
||||
|
||||
$result = $IdcsmartTicketTypeModel->typeTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2022-07-22
|
||||
* @title 工单附件下载
|
||||
* @desc 工单附件下载
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/download
|
||||
* @method POST
|
||||
* @param string name - 附件名称 required
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
return $IdcsmartTicketModel->download($param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-01-22
|
||||
* @title 工单通知设置
|
||||
* @desc 工单通知设置
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/config
|
||||
* @method GET
|
||||
* @return int ticket_notice_open - 是否开启工单通知,1是默认,0否
|
||||
* @return string ticket_notice_description - 工单通知描述
|
||||
*/
|
||||
public function ticketConfig()
|
||||
{
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->ticketConfig();
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/* 以下接口为API调用 */
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 工单处理中
|
||||
* @desc 工单处理中
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/processing
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function processing()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->processing($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 工单终止传递
|
||||
* @desc 工单终止传递
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/terminate
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
*/
|
||||
public function terminate()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->terminateTicket($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 更新工单状态
|
||||
* @desc 更新工单状态
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/status
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
* @param int status - 工单状态 required
|
||||
*/
|
||||
public function updateStatus()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->updateStatus($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 更新工单回复
|
||||
* @desc 更新工单回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/reply
|
||||
* @method PUT
|
||||
* @param int id - 工单ID required
|
||||
* @param int ticket_reply_id - 工单回复ID required
|
||||
* @param int content - 工单回复内容 required
|
||||
*/
|
||||
public function updateReply()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->updateReply($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 删除工单回复
|
||||
* @desc 删除工单回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/reply
|
||||
* @method DELETE
|
||||
* @param int id - 工单ID required
|
||||
* @param int ticket_reply_id - 工单回复ID required
|
||||
*/
|
||||
public function deleteReply()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->deleteReply($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 2024-06-18
|
||||
* @title 创建工单回复
|
||||
* @desc 创建工单回复
|
||||
* @author wyh
|
||||
* @version v1
|
||||
* @url /console/v1/ticket/:id/reply
|
||||
* @method POST
|
||||
* @param int id - 工单ID required
|
||||
* @param int upstream_ticket_reply_id - 上游工单回复ID required
|
||||
* @param string content - 工单回复内容 required
|
||||
* @param array attachment - 附件
|
||||
*/
|
||||
public function createReply()
|
||||
{
|
||||
$param = $this->request->param();
|
||||
|
||||
$IdcsmartTicketModel = new IdcsmartTicketModel();
|
||||
|
||||
$result = $IdcsmartTicketModel->createReply($param);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user