From 89965bd8fb1f0fb5bb1b951373f64405dabc57b1 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Fri, 3 Jan 2020 14:45:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PromoteGameRatioController.class.php | 48 ++++- .../Controller/QueryController.class.php | 197 +++++++++++++++--- .../Admin/View/PromoteGameRatio/lists.html | 14 ++ Application/Admin/View/Query/settlement.html | 47 ++--- Application/Admin/View/Query/withdraw.html | 10 +- 5 files changed, 241 insertions(+), 75 deletions(-) diff --git a/Application/Admin/Controller/PromoteGameRatioController.class.php b/Application/Admin/Controller/PromoteGameRatioController.class.php index e362834c7..aa3852bc7 100644 --- a/Application/Admin/Controller/PromoteGameRatioController.class.php +++ b/Application/Admin/Controller/PromoteGameRatioController.class.php @@ -38,12 +38,16 @@ class PromoteGameRatioController extends ThinkController } $field = 'create_time, update_time'; - $promoteGameRatios = D(self::MODEL_NAME)->field($field, true) + $query = D(self::MODEL_NAME)->field($field, true) ->where($map) - ->page($page, $row) - ->order('update_time desc, id desc') - ->select(); - $count = D(self::MODEL_NAME)->where($map)->count(); + ->order('update_time desc, id desc'); + if (I('export', 0) != 1) { + $query->page($page, $row); + } + $promoteGameRatios = $query->select(); + if (I('export', 0) != 1) { + $count = D(self::MODEL_NAME)->where($map)->count(); + } $records = []; if ($promoteGameRatios) { @@ -89,7 +93,7 @@ class PromoteGameRatioController extends ThinkController $thisGameRatio = $thisGameRatio ?? '0.00'; } - $records[] = [ + $record = [ 'id' => $promoteGameRatio['id'], 'promote_id' => $promoteGameRatio['promote_id'], 'promote_account' => $thisPromoteAccount, @@ -102,22 +106,50 @@ class PromoteGameRatioController extends ThinkController 'ratio' => $promoteGameRatio['ratio'] . '%', 'valid_date' => $validDate, 'remark' => $promoteGameRatio['remark'], - 'status' => $promoteGameRatio['status'], 'status_text' => $thisStatusText, 'applicant' => $thisApplicant ?? '未知', 'reviewer' => $thisReviewer ?? '未知', ]; + if (I('export', 0) != 1) { + $record['status'] = $promoteGameRatio['status']; + } + $records[] = $record; } } - $reviewRule = $this->getReviewRule(); + if (I('export', 0) == 1) { + $field = [ + 'promote_id' => '会长Id', + 'promote_account' => '会长账号', + 'promote_mobile_phone' => '手机号码', + 'promote_create_time' => '注册时间', + 'promote_status_text' => '状态', + 'promote_ver_status_text' => '身份状态', + 'game_name' => '已申请游戏', + 'last_ratio' => '原分成比例', + 'ratio' => '当前分成比例', + 'valid_date' => '开始时间', + 'remark' => '备注', + 'status_text' => '分成比例审核', + 'applicant' => '申请人', + 'reviewer' => '确认人', + ]; + data2csv($records,"公会分成管理", $field); + exit; + } + $reviewRule = $this->getReviewRule(); + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); + } $this->assign('records', $records); $this->assign('count', $count); $this->assign('gameList', getAllGameList()); $this->assign('promoteList', getPromoteByLevel(1)); $this->assign('statusList', self::$statusList); $this->assign('reviewRule', $reviewRule); + $this->assign('is_admin', is_administrator()); $this->meta_title = '公会分成管理'; $this->display(); } diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index d21825aec..6a93470ce 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -35,6 +35,7 @@ class QueryController extends ThinkController $row = intval(I('row', 10)); $group = I('group', 1); $this->assign('group', $group); + $this->assign('is_admin', is_administrator()); $promoteId = I('promote_id', 0); if ($group == 1) { @@ -76,20 +77,23 @@ class QueryController extends ThinkController $query = M('spend', 'tab_')->field($field) ->where($spendMap) ->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id') - ->order("{$order} {$orderType}") - ->page($page, $row) - ->buildSql(); - $records = M()->table($query) + ->order("{$order} {$orderType}"); + if(I('export', 0) != 1){ + $query->page($page, $row); + } + $records = M()->table($query->buildSql()) ->alias('record') ->select(); - $countQuery = M('spend', 'tab_')->field('tab_spend.id') - ->where($spendMap) - ->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id') - ->buildSql(); - $count = M()->table($countQuery) - ->alias('tab_spend') - ->count(); - $page = set_pagination($count, $row); + if(I('export', 0) != 1){ + $countQuery = M('spend', 'tab_')->field('tab_spend.id') + ->where($spendMap) + ->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id') + ->buildSql(); + $count = M()->table($countQuery) + ->alias('tab_spend') + ->count(); + $page = set_pagination($count, $row); + } if (!empty($records)) { $promote = M('promote', 'tab_')->find($promoteId); @@ -100,24 +104,40 @@ class QueryController extends ThinkController } $totalField = 'sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount'; - $total = array_sum(array_column($records, 'settlement_amount'));//当页 $zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//累计 $zTotal = bcdiv($zTotal, 100 ,2); - unset($spendMap['tab_spend.pay_time']); - $spendMap['_string'] = 'tab_spend.pay_time' . total(1); - $tTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//今日 - $tTotal = bcdiv($tTotal, 100 ,2); - $spendMap['_string'] = 'tab_spend.pay_time' . total(5); - $yTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//昨日 - $yTotal = bcdiv($yTotal, 100 ,2); + + if(I('export', 0) == 1) { + $data = []; + foreach ($records as $value) { + $data[] = [ + 'promote_account' => $value['promote_account'], + 'game_name' => $value['game_name'], + 'sum_amount' => $value['sum_amount'], + 'user_num' => $value['user_num'], + 'type' => 'CPS', + 'selle_ratio' => $value['selle_ratio'] . '%', + 'settlement_amount' => $value['settlement_amount'], + ]; + } + + $field = [ + 'promote_account' => '推广员账号', + 'game_name' => '游戏名称', + 'sum_amount' => '总充值', + 'user_num' => '总注册', + 'type' => '结算模式', + 'selle_ratio' => '分成比例', + 'settlement_amount' => '结算金额', + ]; + data2csv($data,"推广结算", $field); + exit; + } if($page) { $this->assign('_page', $page); } $this->assign('records', $records); - $this->assign('total', $total); - $this->assign('tTotal', $tTotal); - $this->assign('yTotal', $yTotal); $this->assign('zTotal', $zTotal); $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find()); $this->m_title = '推广结算'; @@ -150,14 +170,18 @@ class QueryController extends ThinkController $map['settlement_type'] = $settlementType; } - $records = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond, settlement_type') - ->where($map) - ->order('create_time desc') - ->page($page, $row) - ->select(); - $count = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond') + $query = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond, settlement_type') ->where($map) - ->count(); + ->order('create_time desc'); + if(I('export', 0) != 1){ + $query->page($page, $row); + } + $records = $query->select(); + if(I('export', 0) != 1){ + $count = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond') + ->where($map) + ->count(); + } if (!empty($records)) { foreach ($records as &$record) { $record['settlement_begin_time'] = $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--'; @@ -167,9 +191,53 @@ class QueryController extends ThinkController if ($record['status'] == -2) { $record['status_text'] = '' . $record['status_text'] . ''; } + $record['op_id_text'] = $this->getOpTypeText($record['op_type'], $record['op_id']); + $record['last_op_id_text'] = $this->getOpTypeText($record['last_op_type'], $record['last_op_id']); + $record['op_type_text'] = getPromoteWithdrawOpType($record['op_type']); + $record['last_op_type_text'] = getPromoteWithdrawOpType($record['last_op_type']); + $record['settlement_type_text'] = getPromoteWithdrawSettlementType($record['settlement_type']); } } + if(I('export', 0) == 1) { + $data = []; + foreach ($records as $value) { + $data[] = [ + 'promote_account' => $value['promote_account'], + 'widthdraw_number' => $value['widthdraw_number'], + 'sum_money' => $value['sum_money'], + 'op_id_text' => $value['op_id_text'], + 'op_type_text' => $value['op_type_text'], + 'last_op_id_text' => $value['last_op_id_text'], + 'last_op_type_text' => $value['last_op_type_text'], + 'settlement_type_text' => $value['settlement_type_text'], + 'settlement_begin_time' => $value['settlement_begin_time'], + 'settlement_end_time' => $value['settlement_end_time'], + 'create_time' => $value['create_time'], + 'status_text' => promoteWithdrawStatus($value['status']), + 'respond' => $value['respond'], + ]; + } + + $field = [ + 'promote_account' => '推广员账号', + 'widthdraw_number' => '结算单号', + 'sum_money' => '结算金额', + 'op_id_text' => '操作人', + 'op_type_text' => '操作人类型', + 'last_op_id_text' => '最后操作人', + 'last_op_type_text' => '最后操作人类型', + 'settlement_type_text' => '提现模式', + 'settlement_begin_time' => '结算开始时间', + 'settlement_end_time' => '结算截止时间', + 'create_time' => '提现时间', + 'status_text' => '提现状态', + 'respond' => '说明', + ]; + data2csv($data,"推广结算", $field); + exit; + } + $page = set_pagination($count, $row); if($page) { $this->assign('_page', $page); @@ -179,6 +247,21 @@ class QueryController extends ThinkController } } + private function getOpTypeText($type, $id) + { + switch ($type) { + case 1: + return get_promote_name($id); + break; + case 2: + return getAdminNickname($id); + break; + default: + return '自动'; + break; + } + } + public function settlementWithdraw() { $beginTime = strtotime(I('begin_time', '')); @@ -868,6 +951,7 @@ class QueryController extends ThinkController public function withdraw() { $page = I('p', 1); + $map['_string'] = '1=1'; $adminid = C('USER_ADMINISTRATOR');//获取超管id $adminmobile = M('UcenterMember')->field('mobile')->find($adminid); $this->assign('adminmobile', $adminmobile['mobile']); @@ -891,7 +975,6 @@ class QueryController extends ThinkController } } else { $map['promote_id'] = array('gt', 0); - } $order = 'create_time desc'; @@ -905,6 +988,58 @@ class QueryController extends ThinkController } } } + if (I('export', 0) == 1) { + $records = D('withdraw')->field('widthdraw_number, sum_money, promote_account, op_id, op_type, last_op_id, last_op_type, settlement_type, settlement_begin_time, settlement_end_time, create_time, status, respond, audit_time') + ->where($map) + ->order($order) + ->select(); + if (!empty($records)) { + $data = []; + foreach ($records as $record) { + $record['op_id_text'] = $this->getOpTypeText($record['op_type'], $record['op_id']); + $record['last_op_id_text'] = $this->getOpTypeText($record['last_op_type'], $record['last_op_id']); + $record['op_type_text'] = getPromoteWithdrawOpType($record['op_type']); + $record['last_op_type_text'] = getPromoteWithdrawOpType($record['last_op_type']); + $record['settlement_type_text'] = getPromoteWithdrawSettlementType($record['settlement_type']); + $data[] = [ + 'widthdraw_number' => $record['widthdraw_number'], + 'sum_money' => $record['sum_money'], + 'promote_account' => $record['promote_account'], + 'op_id_text' => $this->getOpTypeText($record['op_type'], $record['op_id']), + 'last_op_id_text' => $this->getOpTypeText($record['last_op_type'], $record['last_op_id']), + 'op_type_text' => getPromoteWithdrawOpType($record['op_type']), + 'last_op_type_text' => getPromoteWithdrawOpType($record['last_op_type']), + 'settlement_type_text' => getPromoteWithdrawSettlementType($record['settlement_type']), + 'settlement_begin_time' => $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--', + 'settlement_end_time' => date('Y-m-d H:i:s', $record['settlement_end_time']), + 'create_time' => date('Y-m-d H:i:s', $record['create_time']), + 'status_text' => promoteWithdrawStatus($record['status']), + 'respond' => $record['respond'], + 'audit_time' => $record['audit_time'] ? date('Y-m-d H:i:s', $record['audit_time']) : '--', + ]; + } + + $field = [ + 'widthdraw_number' => '结算单号', + 'sum_money' => '结算金额', + 'promote_account' => '推广员账号', + 'op_id_text' => '操作人', + 'op_type_text' => '操作人类型', + 'last_op_id_text' => '最后操作人', + 'last_op_type_text' => '最后操作人类型', + 'settlement_type_text' => '提现模式', + 'settlement_begin_time' => '结算开始时间', + 'settlement_end_time' => '结算截止时间', + 'create_time' => '申请时间', + 'status_text' => '提现状态', + 'respond' => '说明', + 'audit_time' => '审核时间', + ]; + data2csv($data,"推广结算", $field); + exit; + } + } + $model = array( 'm_name' => 'withdraw', 'order' => $order, diff --git a/Application/Admin/View/PromoteGameRatio/lists.html b/Application/Admin/View/PromoteGameRatio/lists.html index 140ce4052..cdfaa7868 100644 --- a/Application/Admin/View/PromoteGameRatio/lists.html +++ b/Application/Admin/View/PromoteGameRatio/lists.html @@ -164,6 +164,15 @@ + +