diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 686cb5a10..131d99eca 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -8559,89 +8559,89 @@ class ExportController extends Controller $this->exportExcel($xlsName, $xlsCell, $xlsData); } - public function gameStatisticsDetail() { - $game_name = I("game_name"); - $xlsName = $game_name . '游戏订单查看'; - - $xlsCell = array( - array('pay_order_number','支付订单号'), - array('extend','游戏订单号'), - array('pay_time','充值时间'), - array('user_account','玩家账号'), - array('game_name','游戏名称'), - array('promote_account','所属推广员'), - array('spend_ip','充值ip'), - array('server_name','游戏区服'), - array('game_player_name','角色名称'), - array('cost','订单金额'), - array('pay_amount','实付金额'), - array('pay_way','充值方式'), - ); - - if (isset($_REQUEST['pay_way'])) { - $map['pay_way'] = $_REQUEST['pay_way']; - } - - if (!empty($_REQUEST['pay_order_number'])) { - $map['pay_order_number'] = $_REQUEST['pay_order_number']; - } - - if (!empty(I('partner_id'))&&empty(I("game_id"))) { - $wherePartner = I('partner_id'); - $gameId = M("game","tab_")->field("id")->where("partner_id={$wherePartner}")->select(); - $gameId = implode(',',array_column($gameId,'id')); - $map['game_id'] = ['in',$gameId]; - } - - if (!empty(I('timestart'))) { - $timestart = strtotime(I('timestart')); - $map['_string'] = "pay_time >= {$timestart}"; - } - - if (!empty(I('timeend'))) { - $timeend = strtotime(I('timeend') . ' 23:59:59'); - if (!empty($map['_string'])) { - $map['_string'] .= " and "; - } - $map['_string'] .= " pay_time < {$timeend}"; - } - - $map['pay_game_status'] = 1; - if (!empty(I("game_id"))) { - $map['game_id'] = I("game_id"); - } - if (!empty(I('user_account'))) { - $map['user_account'] = array('like','%'.I("user_account").'%'); - } - if (!empty(I('user_nickname'))) { - $map['game_player_name'] = array('like',I("user_nickname").'%'); - } - - $field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way,extend"; - $group = ""; - $order = "pay_time DESC"; - - $xlsData = D('spend')->getSpendData($map,$field,$group,$order); -// dd(D("spend")->_sql()); - foreach($xlsData as $key => $value) { - $xlsData[$key]['pay_way'] = getPayType($value['pay_way']); - } - - $totalData = D("spend")->totalGameStatistics($map, false); - - $sumCash = $totalData['cash_count'] ?? 0; - $sumBalance = $totalData['balance_coin_count'] ?? 0; - $sumInside = $totalData['inside_cash_count'] ?? 0; - $sumAll = $sumCash + $sumBalance + $sumInside; - - $sumData = [['pay_order_number'=>'总计:' . $sumAll, - 'extend'=>'现金金额:' . $sumCash, - 'pay_time'=>'平台币:' . $sumBalance, - 'user_account'=>'绑币:' . $sumInside]]; - $xlsData = array_merge($xlsData,$sumData); - $this->exportAddOperationLog("Finance/gameStatisticsDetail","充值-财务管理-游戏统计-查看-导出"); - $this->exportExcel($xlsName, $xlsCell, $xlsData); - } +// public function gameStatisticsDetail() { +// $game_name = I("game_name"); +// $xlsName = $game_name . '游戏订单查看'; + +// $xlsCell = array( +// array('pay_order_number','支付订单号'), +// array('extend','游戏订单号'), +// array('pay_time','充值时间'), +// array('user_account','玩家账号'), +// array('game_name','游戏名称'), +// array('promote_account','所属推广员'), +// array('spend_ip','充值ip'), +// array('server_name','游戏区服'), +// array('game_player_name','角色名称'), +// array('cost','订单金额'), +// array('pay_amount','实付金额'), +// array('pay_way','充值方式'), +// ); + +// if (isset($_REQUEST['pay_way'])) { +// $map['pay_way'] = $_REQUEST['pay_way']; +// } + +// if (!empty($_REQUEST['pay_order_number'])) { +// $map['pay_order_number'] = $_REQUEST['pay_order_number']; +// } + +// if (!empty(I('partner_id'))&&empty(I("game_id"))) { +// $wherePartner = I('partner_id'); +// $gameId = M("game","tab_")->field("id")->where("partner_id={$wherePartner}")->select(); +// $gameId = implode(',',array_column($gameId,'id')); +// $map['game_id'] = ['in',$gameId]; +// } + +// if (!empty(I('timestart'))) { +// $timestart = strtotime(I('timestart')); +// $map['_string'] = "pay_time >= {$timestart}"; +// } + +// if (!empty(I('timeend'))) { +// $timeend = strtotime(I('timeend') . ' 23:59:59'); +// if (!empty($map['_string'])) { +// $map['_string'] .= " and "; +// } +// $map['_string'] .= " pay_time < {$timeend}"; +// } + +// $map['pay_game_status'] = 1; +// if (!empty(I("game_id"))) { +// $map['game_id'] = I("game_id"); +// } +// if (!empty(I('user_account'))) { +// $map['user_account'] = array('like','%'.I("user_account").'%'); +// } +// if (!empty(I('user_nickname'))) { +// $map['game_player_name'] = array('like',I("user_nickname").'%'); +// } + +// $field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_name,pay_amount,cost,pay_way,extend"; +// $group = ""; +// $order = "pay_time DESC"; + +// $xlsData = D('spend')->getSpendData($map,$field,$group,$order); +// // dd(D("spend")->_sql()); +// foreach($xlsData as $key => $value) { +// $xlsData[$key]['pay_way'] = getPayType($value['pay_way']); +// } + +// $totalData = D("spend")->totalGameStatistics($map, false); + +// $sumCash = $totalData['cash_count'] ?? 0; +// $sumBalance = $totalData['balance_coin_count'] ?? 0; +// $sumInside = $totalData['inside_cash_count'] ?? 0; +// $sumAll = $sumCash + $sumBalance + $sumInside; + +// $sumData = [['pay_order_number'=>'总计:' . $sumAll, +// 'extend'=>'现金金额:' . $sumCash, +// 'pay_time'=>'平台币:' . $sumBalance, +// 'user_account'=>'绑币:' . $sumInside]]; +// $xlsData = array_merge($xlsData,$sumData); +// $this->exportAddOperationLog("Finance/gameStatisticsDetail","充值-财务管理-游戏统计-查看-导出"); +// $this->exportExcel($xlsName, $xlsCell, $xlsData); +// } public function coinDetail() { diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php index 46970e636..91c54410c 100644 --- a/Application/Admin/Controller/FinanceController.class.php +++ b/Application/Admin/Controller/FinanceController.class.php @@ -712,12 +712,10 @@ class FinanceController extends ThinkController $gameWhere = []; $testStrWhere = '1=1'; if ($game_ids) { - // $map['s.game_id'] = ['in', $game_ids]; $gameWhere['id'] = ['in', $game_ids]; } if (!empty(I('partner_id'))) { - // $map['g.partner_id'] = I('partner_id'); $gameWhere['partner_id'] = I('partner_id'); } @@ -737,14 +735,18 @@ class FinanceController extends ThinkController } if (!empty(I('game_type_id'))) { - // $map['g.game_type_id'] = I('game_type_id'); $gameWhere['game_type_id'] = I('game_type_id', 0); } $searchGameIds = M('game', 'tab_')->where($gameWhere)->getField('id', true); $startTime = time(); //游戏统计列表 - $data = D("spend")->gameStatistics($map,$searchGameIds, $row, $p); + if(isset($_REQUEST['export'])){ + $data = D("spend")->gameStatistics($map,$searchGameIds, 0, 0); + }else{ + $data = D("spend")->gameStatistics($map,$searchGameIds, $row, $p); + } + $gameIds = array_column($data, 'game_id'); $uniqueCodes = array_column($data, 'unique_code'); $uniqueCodes = array_filter($uniqueCodes, function($value) { @@ -843,6 +845,30 @@ class FinanceController extends ThinkController $data[$key]['test_amount'] = $testAmount; } + if(isset($_REQUEST['export'])){ + //操作日志 + $GetData = $_GET; + unset($GetData['export']); + $dcop = array( + 'partner_name'=>'合作公司', + 'game_name'=>'游戏', + 'sdk_version'=>'设备类型', + 'game_type_name'=>'游戏类型', + 'cash_count'=>'游戏现金金额', + 'balance_coin_count'=>'平台币直充支出', + 'inside_cash_count'=>'内充支出', + 'all_cash_count'=>'游戏内充值合计', + 'notice_fail_count'=>'联运通知失败合计', + 'agg_wm_amount'=>'聚合万盟数据', + 'agg_wm_failed_amount'=>'聚合万盟通知失败', + 'test_amount'=>'聚合平台测试订单', + 'agg_amount'=>'聚合其他渠道数据', + 'agg_failed_amount'=>'聚合其他渠道通知失败订单' + ); + addOperationLog(['op_type'=>3,'key'=>getNowDate(),'url'=>U(CONTROLLER_NAME.'/'.ACTION_NAME,$GetData),'menu'=>"充值-财务管理-游戏统计-导出"]); + data2csv($data,"游戏统计",$dcop); + } + $count = count($searchGameIds);//列表总数 // $allData = D("spend")->gameStatistics($map);//列表总数 // $count = count($allData); @@ -1045,9 +1071,9 @@ class FinanceController extends ThinkController $order = "payed_time DESC"; if(isset($_REQUEST['export'])){ - $data = D('spend')->getSpendData($map,$field,$group,$order,0,0); + $data = D('spend')->getSubSpendData($map,$field,$group,$order,0,0); }else{ - $data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row); + $data = D('spend')->getSubSpendData($map,$field,$group,$order,$page,$row); } $merchant_data = M("payment_merchant","tab_") @@ -1116,7 +1142,7 @@ class FinanceController extends ThinkController $this->assign('sumInside', $sumInside); $this->assign('sumAll', null_to_0($sumAll)); - $count = D("spend")->getSpendData($map,'count(*) as count',$group,$order); + $count = D("spend")->getSubSpendData($map,'count(*) as count',$group,$order); $this->checkListOrCountAuthRestMap($map,[]); $count = $count[0]['count']; diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index e6fffad4e..4ef667a17 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -816,12 +816,27 @@ class SpendModel extends Model return $data; } + /** + * 获取多站点查询 + */ + public function getSubSpendData($map = [], $field = '', $group = '', $order = '', $page = 0, $row = 0) + { + $query = $this->field($field)->where($map)->group($group)->order($order); + if ($row == 0) { + $data = $query->select(); + } else { + $data = $query->page($page, $row)->select(); + } + return $data; + } + + /** * 获取统计 $map,$page,$row */ public function getSpendData($map = [], $field = '', $group = '', $order = '', $page = 0, $row = 0, $join = false) { - $query = $this->field($field)->where($map)->group($group)->order($order); + $query = M('spend',"tab_")->field($field)->where($map)->group($group)->order($order); if ($join) { $query = $query->join($join); } @@ -892,10 +907,10 @@ class SpendModel extends Model SUM(CASE WHEN pay_way = -1 and s.pay_status = 1 and pay_game_status = 1 THEN pay_amount ELSE 0 END) as inside_cash_count, SUM(CASE WHEN s.pay_status = 1 and pay_game_status = 0 THEN pay_amount ELSE 0 END) as notice_fail_count"); $base = [ - 'cash_count' => 0, - 'balance_coin_count' => 0, - 'inside_cash_count' => 0, - 'notice_fail_count' => 0 + 'cash_count' => "0.00", + 'balance_coin_count' => "0.00", + 'inside_cash_count' => "0.00", + 'notice_fail_count' => "0.00" ]; $records = []; foreach ($games as $game) { @@ -918,7 +933,10 @@ class SpendModel extends Model */ public function totalGameStatistics($map,$gameIds, $join = true) { - $map['s.game_id'] = ['in', $gameIds]; + if($gameIds){ + $map['s.game_id'] = ['in', $gameIds]; + } + $data = SM("Spend","tab_") ->alias('s') ->index('game_time')