diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 2d48c4a3c..412f7f792 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -8983,6 +8983,7 @@ class ExportController extends Controller array('status','状态'), array('user_account','游戏账号'), array('creator','创单人'), + array('handler','创单人'), array('created_time', '创单时间'), array('score', '分数'), array('attachment_type', '附件') @@ -8994,6 +8995,7 @@ class ExportController extends Controller $item['type'] = $item['type'] == 1 ? '资源' : '反馈'; $item['status'] = $item['status'] == 1 ? '完成' : '处理中'; $item['creator'] = get_admin_name($item['creator_id']); + $item['handler'] = get_admin_name($item['handler_id']); $item['created_time'] = date('Y-m-d H:i:s', $item['created_time']); $item['attachment_type'] = empty($item['attachment_url']) ? '无' : '有'; $item['order_no'] = "\t{$item['order_no']}"; @@ -9035,13 +9037,17 @@ class ExportController extends Controller $pdlMap .= " and pdl.create_time < {$endTime}"; } - if ($info['level'] == PromoteModel::LEVEL_GROUP_LEADER) { + if ($level == PromoteModel::LEVEL_TEAM_MEMBER) { + $beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")); + $endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")); $xlsData = M('promote', 'tab_')->alias('p') - ->field('p.id, p.level, p.account, count(pdl.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') + ->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left') ->where($map) ->group('p.id') - ->select(); + ->select(); + } else { $xlsData = M('promote', 'tab_')->alias('p') ->field('p.id, p.level, p.account, count(if(p2.level = '.($level+1).', 1, null)) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') @@ -9051,14 +9057,28 @@ class ExportController extends Controller ->group('p.id') ->select(); } - $xlsCell = array( - array('account', PromoteModel::$levelArr[$level]."账号"), - array('lowercount', PromoteModel::$levelArr[$level+1]."数量"), - array('tfcount', 'TF下载数'), - array('supersigncount', "超级签下载数"), - array('signcount', "企业签下载数"), - ); - + + if ($level == PromoteModel::LEVEL_TEAM_MEMBER) { + foreach($xlsData as &$item) { + $item['tfcount'] = $item['tfcount'] . "(" . (empty($item['ioscount']) ? 0 : round( ($item['tfcount'] / $item['ioscount']) * 100 , 2)) . ")%"; + } + $xlsCell = array( + array('account', PromoteModel::$levelArr[$level]."账号"), + array('ioscount', "iOS用户总数"), + array('weekcount', "新增iOS用户总数"), + array('tfcount', 'TF下载数/iOS用户总数'), + array('supersigncount', "超级签下载数"), + array('signcount', "企业签下载数"), + ); + } else { + $xlsCell = array( + array('account', PromoteModel::$levelArr[$level]."账号"), + array('lowercount', PromoteModel::$levelArr[$level+1]."数量"), + array('tfcount', 'TF下载数'), + array('supersigncount', "超级签下载数"), + array('signcount', "企业签下载数"), + ); + } $this->exportAddOperationLog('Statistics/packDownload','统计-IOS下载统计-导出'); $this->exportExcel($xlsName, $xlsCell, $xlsData); } @@ -9157,4 +9177,86 @@ class ExportController extends Controller $this->exportExcel($xlsName, $xlsCell, $list); } + public function exportWorkOrderStatistics() + { + $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"); + } + $xlsName = '工单统计报表'; + $xlsCell = array( + array('nickname', "账号"), + array('total_create_count', "发布工单数"), + array('total_accepted_count', '被接手工单数'), + array('total_handle_count', "接手工单数"), + array('total_complete_count', "完成工单数"), + ); + + $this->exportAddOperationLog('Statistics/exportWorkOrderStatistics','用户-工单统计-导出'); + $this->exportExcel($xlsName, $xlsCell, $list); + } } diff --git a/Application/Admin/Controller/StatisticsController.class.php b/Application/Admin/Controller/StatisticsController.class.php index ec158d31b..583498def 100644 --- a/Application/Admin/Controller/StatisticsController.class.php +++ b/Application/Admin/Controller/StatisticsController.class.php @@ -1172,17 +1172,22 @@ class StatisticsController extends ThinkController { $pdlMap .= " and pdl.create_time < {$endTime}"; } - if ($info['level'] == PromoteModel::LEVEL_GROUP_LEADER) { + if ($level == PromoteModel::LEVEL_TEAM_MEMBER) { + $beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")); + $endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")); $list = M('promote', 'tab_')->alias('p') - ->field('p.id, p.level, p.account, count(pdl.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->field('p.id, p.level, p.account, count(u.id) as iosCount, count(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null)) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') + ->join("tab_user u on u.promote_id = p.id and u.device_type=2", 'left') ->where($map) ->page($p, $row) ->group('p.id') ->select(); + $total = M('promote', 'tab_')->alias('p') - ->field('count(pdl.id) as lowerCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->field('count(distinct(u.id)) as iosCount, count(distinct(if (u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') ->join("tab_package_download_log pdl on pdl.promote_id = p.id $pdlMap", 'left') + ->join("tab_user u on u.promote_id = p.id and u.device_type=2") ->where($map) ->select(); } else { @@ -1263,8 +1268,10 @@ class StatisticsController extends ThinkController { ->page($p, $row) ->select(); + $beginThisweek = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y")); + $endThisweek = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y")); $total = M('package_download_log', 'tab_')->alias('pdl') - ->field('count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') + ->field('count(distinct(if(u.device_type=2, 1, null))) as iosCount, count(distinct(if (u.device_type=2 and u.register_time between '. $beginThisweek . ' and ' . $endThisweek .', 1, null))) as weekCount, count(if(pdl.type = 1, 1, null)) as signCount, count(if(pdl.type = 2, 1, null)) as tfCount, count(if(pdl.type = 3, 1, null)) as superSignCount') ->join('tab_promote p on p.id = pdl.promote_id') ->join('tab_user u on u.id = pdl.user_id', 'left') ->where($map) diff --git a/Application/Admin/Controller/WorkOrderController.class.php b/Application/Admin/Controller/WorkOrderController.class.php index 14f43e449..96ebd2753 100644 --- a/Application/Admin/Controller/WorkOrderController.class.php +++ b/Application/Admin/Controller/WorkOrderController.class.php @@ -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'); + } } \ No newline at end of file diff --git a/Application/Admin/View/Statistics/packdownload.html b/Application/Admin/View/Statistics/packdownload.html index 4d1de96b5..47be3bd97 100644 --- a/Application/Admin/View/Statistics/packdownload.html +++ b/Application/Admin/View/Statistics/packdownload.html @@ -80,8 +80,14 @@ -->
账号 | +
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+ aOh! 暂时还没有内容! | +
---|---|---|---|---|
{$data.nickname} | +{$data.total_create_count} | +{$data.total_accepted_count} | ++ | + |