|
|
|
@ -103,7 +103,7 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
$info['role_name'] = I('role_names')[$i];
|
|
|
|
|
$info['resource_num'] = I('apply_resources')[$i];
|
|
|
|
|
$info['order_no'] = $info['type'] . date('YmdHis'). $i. rand(10, 99) . $info['creator_id'];
|
|
|
|
|
$info['handler_id'] = $info['creator_id'];
|
|
|
|
|
//$info['handler_id'] = $info['creator_id'];
|
|
|
|
|
$ins = M('work_order_info', 'tab_')->add($info);
|
|
|
|
|
|
|
|
|
|
if (!$ins) {M('work_order_info', 'tab_')->rollback(); $this->error("创建失败");}
|
|
|
|
@ -113,7 +113,7 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
// 添加一条附件信息
|
|
|
|
|
$attachement_info = $data;
|
|
|
|
|
$attachement_info['attachment_url'] = I('attachment_url', '');
|
|
|
|
|
$attachement_info['handler_id'] = $attachement_info['creator_id'];
|
|
|
|
|
//$attachement_info['handler_id'] = $attachement_info['creator_id'];
|
|
|
|
|
$attachement_info['order_no'] = $attachement_info['type'] . date('YmdHis'). rand(100, 999) . $attachement_info['creator_id'];
|
|
|
|
|
$ins = M('work_order_info', 'tab_')->add($attachement_info);
|
|
|
|
|
if (!$ins) {M('work_order_info', 'tab_')->rollback(); $this->error("创建失败");}
|
|
|
|
@ -126,16 +126,16 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
if (empty(I('user_account')) || empty(I('role_name')) || empty(I('feedback'))) {
|
|
|
|
|
$this->error('请填写必填的数据');
|
|
|
|
|
}
|
|
|
|
|
if (empty('handler_id')) {
|
|
|
|
|
$this->error('请选择处理人');
|
|
|
|
|
}
|
|
|
|
|
// if (empty('handler_id')) {
|
|
|
|
|
// $this->error('请选择处理人');
|
|
|
|
|
// }
|
|
|
|
|
$user = M('user', 'tab_')->where(['account'=>I('user_account')])->find();
|
|
|
|
|
if (empty($user)) $this->error("账号不存在");
|
|
|
|
|
$data['attachment_url'] = I('attachment_url', '');
|
|
|
|
|
$data['user_account'] = I('user_account');
|
|
|
|
|
$data['role_name'] = I('role_name');
|
|
|
|
|
$data['feedback'] = I('feedback');
|
|
|
|
|
$data['handler_id'] = I('handler_id');
|
|
|
|
|
//$data['handler_id'] = I('handler_id');
|
|
|
|
|
$data['remark'] = I('remark', '');
|
|
|
|
|
$data['process_log'] = json_encode([['title'=>sprintf('%s于 %s 创建了工单%s,工单状态处理中。', get_admin_name($data['creator_id']), date('Y-m-d H:i:s'), $data['order_no']), 'type'=>1]]);
|
|
|
|
|
$ins = M('work_order_info', 'tab_')->add($data);
|
|
|
|
@ -203,7 +203,7 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
|
|
|
|
|
private function modifyProcessLog($oldData, $newData)
|
|
|
|
|
{
|
|
|
|
|
$key = ['game_name'=>'游戏名称', 'server_name'=>'区服名称', 'role_name'=>'角色名称', 'user_account'=>'玩家账号', 'feedback'=>'反馈原因', 'handler_id'=>'处理人', 'remark'=>'备注', 'status'=>'状态', 'attachment_url'=>'附件'];
|
|
|
|
|
$key = ['game_name'=>'游戏名称', 'server_name'=>'区服名称', 'role_name'=>'角色名称', 'user_account'=>'玩家账号', 'feedback'=>'反馈原因', 'handler_id'=>'接单人员', 'remark'=>'备注', 'status'=>'状态', 'attachment_url'=>'附件'];
|
|
|
|
|
$log = [];
|
|
|
|
|
foreach ($newData as $k => $v) {
|
|
|
|
|
if (array_key_exists($k, $oldData) && array_key_exists($k, $key) && $oldData[$k] != $newData[$k]) {
|
|
|
|
@ -254,7 +254,7 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
if (!I('resource_num')) $this->error('请填写申请资源数量');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data['handler_id'] = $data['creator_id'] = is_login();
|
|
|
|
|
$data['creator_id'] = is_login();
|
|
|
|
|
$data['created_time'] = time();
|
|
|
|
|
$data['type'] = $info['type'];
|
|
|
|
|
$data['server_id'] = $info['server_id'];
|
|
|
|
@ -314,7 +314,7 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
// 删除
|
|
|
|
|
public function delete($ids)
|
|
|
|
|
{
|
|
|
|
|
$delete = M('work_order_info', 'tab_')->where(['id'=>['in', $ids]])->save(['status'=>2]);
|
|
|
|
|
$delete = M('work_order_info', 'tab_')->where(['id'=>['in', $ids]])->delete();
|
|
|
|
|
return $delete ? $this->success('删除成功') : $this->error('删除失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -329,4 +329,109 @@ class WorkOrderController extends ThinkController
|
|
|
|
|
$delete = M('work_order_info', 'tab_')->where(['id'=>$id])->save($data);
|
|
|
|
|
return $delete ? $this->success('成功完成工单') : $this->error('更新失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function take($id)
|
|
|
|
|
{
|
|
|
|
|
$info = M('work_order_info', 'tab_')->where(['id'=>$id])->find();
|
|
|
|
|
if (empty($info)) $this->error('未找到该资源');
|
|
|
|
|
$userid = is_login();
|
|
|
|
|
if ($info['status'] == 1) {
|
|
|
|
|
$this->error('工单已完成');
|
|
|
|
|
}
|
|
|
|
|
if (!empty($info['handler_id'])) {
|
|
|
|
|
if ($info['handler_id'] != $userid) {
|
|
|
|
|
$this->error('工单已被他人领取');
|
|
|
|
|
} else {
|
|
|
|
|
$this->error('请勿重复领取工单');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($info['type'] == 2) {
|
|
|
|
|
$process_log = json_decode($info['process_log'], true) ?: [];
|
|
|
|
|
$log = ['title'=>sprintf("%s于%s 接取了工单%s", get_admin_name(is_login()), date('Y-m-d H:i:s'), $info['order_no']), 'detail'=>$log, 'type'=>2];
|
|
|
|
|
$data['process_log'] = json_encode(array_merge($process_log, [$log]));
|
|
|
|
|
}
|
|
|
|
|
$data['handler_id'] = $userid;
|
|
|
|
|
$upt = M('work_order_info', 'tab_')->where(['id'=>$id])->save($data);
|
|
|
|
|
return $upt ? $this->success('成功接取工单') : $this->error('接单失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function statistics($row = 10, $p = 1)
|
|
|
|
|
{
|
|
|
|
|
$limit = ($p-1)*$row . ", {$row}";
|
|
|
|
|
$order = '';
|
|
|
|
|
if ($_REQUEST['data_order'] != '') {
|
|
|
|
|
$data_order = reset(explode(',', $_REQUEST['data_order']));
|
|
|
|
|
$data_order_type = end(explode(',', $_REQUEST['data_order']));
|
|
|
|
|
$this->assign('userarpu_order', $data_order);
|
|
|
|
|
$this->assign('userarpu_order_type', $data_order_type);
|
|
|
|
|
$order = 'order by ' . $data_order_type . " " . ($data_order == 3 ? 'desc' : 'asc');
|
|
|
|
|
}
|
|
|
|
|
$map = '1=1';
|
|
|
|
|
if (!empty(I('nickname'))) {
|
|
|
|
|
$map .= " and t.nickname = '" . I('nickname') . "'";
|
|
|
|
|
}
|
|
|
|
|
// 获取所有传单或者接单用户id
|
|
|
|
|
$userids = M('work_order_info', 'tab_')
|
|
|
|
|
->field("concat(creator_id, ',', handler_id) as userid")
|
|
|
|
|
->join('sys_member as t on creator_id = t.uid or handler_id = t.uid')
|
|
|
|
|
->where($map)
|
|
|
|
|
->select();
|
|
|
|
|
if (empty($userids)) {
|
|
|
|
|
$list = [];
|
|
|
|
|
$count = 0;
|
|
|
|
|
} else {
|
|
|
|
|
$userids = implode(',', array_unique(array_filter(explode(',', implode(',', array_column($userids, 'userid'))))));
|
|
|
|
|
$count = count($userids);
|
|
|
|
|
$list = M('work_order_info', 'tab_')->query("SELECT
|
|
|
|
|
t.id,
|
|
|
|
|
t.nickname,
|
|
|
|
|
sum(total_create_count) as total_create_count,
|
|
|
|
|
sum(total_accepted_count) as total_accepted_count,
|
|
|
|
|
sum(total_handle_count) as total_handle_count,
|
|
|
|
|
sum(total_complete_count) as total_complete_count
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
u.uid as id,
|
|
|
|
|
u.nickname,
|
|
|
|
|
count(*) AS total_create_count,
|
|
|
|
|
count(
|
|
|
|
|
|
|
|
|
|
IF (i.`handler_id` > 0, 1, NULL)
|
|
|
|
|
) AS total_accepted_count,
|
|
|
|
|
NULL AS total_handle_count,
|
|
|
|
|
NULL AS total_complete_count
|
|
|
|
|
FROM
|
|
|
|
|
sys_member u
|
|
|
|
|
LEFT JOIN tab_work_order_info i ON i.creator_id = u.uid
|
|
|
|
|
WHERE
|
|
|
|
|
u.uid in ({$userids})
|
|
|
|
|
GROUP BY u.uid
|
|
|
|
|
UNION
|
|
|
|
|
SELECT
|
|
|
|
|
u.uid as id,
|
|
|
|
|
u.nickname,
|
|
|
|
|
NULL AS total_create_count,
|
|
|
|
|
NULL AS total_accepted_count,
|
|
|
|
|
count(*) AS total_handle_count,
|
|
|
|
|
count(IF(i.`status` = 1, 1, NULL)) AS total_complete_count
|
|
|
|
|
FROM
|
|
|
|
|
sys_member u
|
|
|
|
|
JOIN tab_work_order_info i ON i.handler_id = u.uid
|
|
|
|
|
WHERE
|
|
|
|
|
u.uid in ({$userids})
|
|
|
|
|
GROUP BY u.uid
|
|
|
|
|
) AS t
|
|
|
|
|
where {$map}
|
|
|
|
|
GROUP BY t.id
|
|
|
|
|
$order
|
|
|
|
|
limit {$limit}");
|
|
|
|
|
}
|
|
|
|
|
$page = set_pagination($count, $row);
|
|
|
|
|
if ($page) {
|
|
|
|
|
$this->assign('_page', $page);
|
|
|
|
|
}
|
|
|
|
|
$this->assign('list_data', $list);
|
|
|
|
|
$this->display('statistics');
|
|
|
|
|
}
|
|
|
|
|
}
|