diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index de98b3833..014419e59 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -2265,7 +2265,7 @@ class ExportController extends Controller $re_data['pay_time'] = set_show_time($order_detail['pay_time']); $re_data['payed_time'] = set_show_time($order_detail['payed_time']); } elseif($v['tab'] == 'deposit') { - $order_detail = M('deposit', 'tab_')->field('create_time,payed_time,user_account,promote_account,pay_amount,pay_way')->where(['pay_order_number' => $v['pay_order_number']])->find(); + $order_detail = M('deposit', 'tab_')->field('create_time,payed_time,user_account,promote_account,pay_amount,pay_way')->where(['pay_order_number' => $v['pay_order_number']])->find(); $re_data['pay_time'] = set_show_time($order_detail['create_time']); $re_data['payed_time'] = set_show_time($order_detail['payed_time']); } @@ -2708,7 +2708,6 @@ class ExportController extends Controller ->where($map) ->limit(($i-1)*$perSize ,$perSize) ->select(); - foreach ($valueDetailDatas as $key => $valueDetailData) { $vlaueDetailData['order_number'] = $valueDetailData['order_number']; $vlaueDetailData['create_time'] = date('Y-m-d H:i:s', $valueDetailData['create_time']); @@ -2726,14 +2725,22 @@ class ExportController extends Controller } $vlaueDetailData['value'] = $valueDetailData['value']; $vlaueDetailData['after_value'] = $valueDetailData['after_value']; + $map8['user_id'] = $id; + $map8['create_time'] = $map['create_time']; + $newValueByTimeDatas = M('value_detail_log', 'tab_')->field('after_value')->where($map8)->group('user_id')->select(); + $aValue = $newValueByTimeDatas['after_value']; + $allDatas['bind_balance'] = $aValue; + $allDatas['spend_amount'] = $spend; + $allDatas['deposit_amount'] = $deposit; + $allDatas['coin_amount'] = $promoteCoin; mb_convert_variables('GBK', 'UTF-8', $vlaueDetailData); fputcsv($fp, $vlaueDetailData); } - unset($vlaueDetailDatas);//释放变量的内存 - //刷新输出缓冲到浏览器 - ob_flush(); - flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 + + + // mb_convert_variables('GBK', 'UTF-8', $allDatas); + // fputcsv($fp, $allDatas); } if($t >= 0 ) { $fuhao = '+'; @@ -9012,6 +9019,7 @@ class ExportController extends Controller array('status','状态'), array('user_account','游戏账号'), array('creator','创单人'), + array('handler','接单人'), array('created_time', '创单时间'), array('score', '分数'), array('attachment_type', '附件') @@ -9023,6 +9031,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']}"; @@ -9064,13 +9073,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') @@ -9080,14 +9093,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); } @@ -9186,4 +9213,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); + } }