diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 5830f251a..7ae4e5ab8 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1437,4 +1437,22 @@ function cash_pay_way() $pay_way[7]=array('key'=>8,'value'=>'金猪'); return $pay_way; } + +function getMonth() { + + $start = "2019-08"; + $end = date("Y-m"); + + //开始月份 + $end = date('Y-m', strtotime($end)); // 转换为月 + $range = []; + $i = 0; + do { + $month = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $range[] = $month; + $i++; + } while ($month < $end); + + return $range; +} ?> diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index c6bb7449a..853f1dba4 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -5296,9 +5296,102 @@ if ($key == 'model'){ } + function exportFinanceIndex() { + $xlsName = '月结统计导出'; + $xlsCell = array( + array('count_date','月份'), + array('cash_count','游戏现金流水'), + array('balance_coin_count','平台币流水'), + array('inside_cash_count','内冲流水'), + array('all_cash_count','总流水'), + ); + + $map = []; + if(!empty(I('count_date'))){ + $map['count_date']=I('count_date'); + } + + if (!empty(I('game_id'))) { + $map['game_id']=I('game_id'); + } + if (!empty(I('collaborate_id'))) { + $map['collaborate_id']=I('collaborate_id'); + } + + if (empty(I('game_id'))) { + $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, + sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count+inside_cash_count) as all_cash_count"; + $allField = "cash_count+balance_coin_count+inside_cash_count"; + $InsideField = "inside_cash_count"; + } else { + $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, + sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count"; + $allField = "cash_count+balance_coin_count+bind_coin_count"; + $InsideField = "bind_coin_count"; + } + $group = "count_date"; + $order = "id DESC"; + $xlsData = D("spend_count")->getSpendCountData($map,$field,$group,$order); + + $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); + $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); + $sumInside = D("spend_count")->sumSpendCountField($map,$InsideField); + $sumAll = D("spend_count")->sumSpendCountField($map,$allField); + + $sumData = [['count_date'=>'总计', + 'cash_count'=>$sumCash, + 'balance_coin_count'=>$sumBalance, + 'inside_cash_count'=>$sumInside, + 'all_cash_count'=>$sumAll]]; + $xlsData = array_merge($xlsData,$sumData); + + $this->exportExcel($xlsName, $xlsCell, $xlsData); + + } + + function exportGameFinance() { + $month = I("count_date"); + $xlsName = $month.'月结统计导出'; + + $xlsCell = array( + array('game_name','游戏'), + array('collaborate_name','合作方'), + array('cash_count','游戏现金流水'), + array('balance_coin_count','平台币流水'), + array('inside_cash_count','内冲流水'), + array('all_cash_count','总流水'), + ); + + $map = []; + if(!empty(I('count_date'))){ + $map['count_date']=I('count_date'); + } + + $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, + sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count,game_name,collaborate_name"; + + $group = "game_id"; + $order = "id DESC"; + $xlsData = D("spend_count")->getSpendCountData($map,$field,$group,$order); + + $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); + $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); + $sumInside = D("spend_count")->sumSpendCountField($map,"bind_coin_count"); + $sumAll = D("spend_count")->sumSpendCountField($map,"cash_count+balance_coin_count+bind_coin_count"); + + $sumData = [['game_name'=>'总计', + 'cash_count'=>$sumCash, + 'balance_coin_count'=>$sumBalance, + 'inside_cash_count'=>$sumInside, + 'all_cash_count'=>$sumAll]]; + $xlsData = array_merge($xlsData,$sumData); + + $this->exportExcel($xlsName, $xlsCell, $xlsData); + + } } diff --git a/Application/Admin/Controller/FinanceController.class.php b/Application/Admin/Controller/FinanceController.class.php new file mode 100644 index 000000000..46a35fdd3 --- /dev/null +++ b/Application/Admin/Controller/FinanceController.class.php @@ -0,0 +1,211 @@ +field("count_date,cash_count,balance_coin_count,inside_cash_count,all_cash_count") +// ->where($map) +// ->page($page,$row) +// ->group("count_date") +// ->select(); + if (empty(I('game_id'))) { + $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, + sum(inside_cash_count) as inside_cash_count,sum(cash_count+balance_coin_count+inside_cash_count) as all_cash_count"; + $allField = "cash_count+balance_coin_count+inside_cash_count"; + $InsideField = "inside_cash_count"; + } else { + $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, + sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count"; + $allField = "cash_count+balance_coin_count+bind_coin_count"; + $InsideField = "bind_coin_count"; + } + $group = "count_date"; + $order = "id DESC"; + $data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row); + + $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); + $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); + $sumInside = D("spend_count")->sumSpendCountField($map,$InsideField); + $sumAll = D("spend_count")->sumSpendCountField($map,$allField); + + $count = D("spend_count")->getSpendCountData($map,$field,$group,$order); + $count = count($count); + $page = set_pagination($count,$row); + if($page) {$this->assign('_page', $page);} + + $this->assign('sumCash',$sumCash); + $this->assign('sumBalance',$sumBalance); + $this->assign('sumInside',$sumInside); + $this->assign('sumAll',$sumAll); + + $this->assign('data',$data); + + $this->display(); + } + + function gameFinance($p = 1) { + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $row=10; + if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} + + $map = []; + if(!empty(I('count_date'))){ + $map['count_date']=I('count_date'); + } + +// if (!empty(I('game_id'))) { +// $map['game_id']=I('game_id'); +// } +// if (!empty(I('collaborate_id'))) { +// $map['collaborate_id']=I('collaborate_id'); +// } + +// $data = M("spend_count","tab_") +// ->field("count_date,cash_count,balance_coin_count,inside_cash_count,all_cash_count") +// ->where($map) +// ->page($page,$row) +// ->group("game_id") +// ->select(); + + + $field = "count_date,sum(cash_count) as cash_count,sum(balance_coin_count) as balance_coin_count, + sum(bind_coin_count) as inside_cash_count,sum(cash_count+balance_coin_count+bind_coin_count) as all_cash_count,game_name,game_id,collaborate_name"; + + $group = "game_id"; + $order = "id DESC"; + $data = D("spend_count")->getSpendCountData($map,$field,$group,$order,$page,$row); + + $sumCash = D("spend_count")->sumSpendCountField($map,"cash_count"); + $sumBalance = D("spend_count")->sumSpendCountField($map,"balance_coin_count"); + $sumInside = D("spend_count")->sumSpendCountField($map,"bind_coin_count"); + $sumAll = D("spend_count")->sumSpendCountField($map,"cash_count+balance_coin_count+bind_coin_count"); + + $count = D("spend_count")->getSpendCountData($map,$field,$group,$order); + + $count = count($count); + $page = set_pagination($count,$row); + if($page) {$this->assign('_page', $page);} + + $this->assign('sumCash',$sumCash); + $this->assign('sumBalance',$sumBalance); + $this->assign('sumInside',$sumInside); + $this->assign('sumAll',$sumAll); + + $this->assign('data',$data); + + $this->display(); + + } + + function gameFinanceDetail($p = 1) { + + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $row=10; + if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} + + if (!empty(I("count_date"))) { + $month = I("count_date"); + } else { + $this->error('月份不能为空'); + } + + $startTime = strtotime(date("Y-m-01",strtotime($month))); + $endTime = strtotime(date("Y-m-t",strtotime($month))); + + $map['pay_time'] = array('between',array($startTime,$endTime)); + $map['pay_status'] = 1; + if (!empty(I("game_id"))) { + $map['game_id'] = I("game_id"); + } + if (!empty(I('user_account'))) { + $map['user_account'] = I("user_account"); + } + if (!empty(I('user_nickname'))) { + $map['user_nickname'] = 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"; + $group = ""; + $order = "pay_time DESC"; + $data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row); + + foreach($data as $key => $value) { + $data[$key]['pay_way'] = $this->getPayType($value['pay_way']); + } + + $sum = D('spend')->sumSpend($map,'pay_amount'); + + $this->assign('data',$data); + $this->assign('sum_amount',$sum); + + $this->display(); + + } + + public function getPayType($type) { + + $return = ''; + + switch ($type) { + case -1: + $return = '绑币'; + break; + case 0: + $return = '平台币'; + break; + case 1: + $return = '支付宝'; + break; + case 2: + $return = '微信(扫码)'; + break; + case 3: + $return = '微信app'; + break; + case 4: + $return = '威富通'; + break; + case 5: + $return = '聚宝云'; + break; + case 6: + $return = '竣付通'; + break; + default: + $return = '未知'; + break; + } + return $return; + + } + +} \ No newline at end of file diff --git a/Application/Admin/Model/SpendCountModel.class.php b/Application/Admin/Model/SpendCountModel.class.php new file mode 100644 index 000000000..eeafc366d --- /dev/null +++ b/Application/Admin/Model/SpendCountModel.class.php @@ -0,0 +1,52 @@ + +// +---------------------------------------------------------------------- + +namespace Admin\Model; +use Think\Model; + +/** + * 分类模型 + */ +class SpendCountModel extends Model{ + /** + * 构造函数 + * @param string $name 模型名称 + * @param string $tablePrefix 表前缀 + * @param mixed $connection 数据库连接信息 + */ + public function __construct($name = '', $tablePrefix = '', $connection = '') { + /* 设置默认的表前缀 */ + $this->tablePrefix ='tab_'; + /* 执行构造方法 */ + parent::__construct($name, $tablePrefix, $connection); + } + /** + * 获取统计 $map,$page,$row + */ + public function getSpendCountData($map=[],$field='',$group='',$order='',$page = 0,$row = 0) { + if ($row == 0) { + $data = $this->field($field)->where($map)->group($group)->order($order)->select(); + } else { + $data = $this->field($field)->where($map)->page($page,$row)->group($group)->order($order)->select(); + } + + return $data; + } + /** + * 获取某个字段的总和 $map,$field + */ + public function sumSpendCountField($map,$field) { + $sum = $this->where($map)->sum($field); + return $sum; + + } + + + +} diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index bfb91151c..f80edb062 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -740,5 +740,23 @@ protected function _after_select(&$result,$options){ return $data; } + /** + * 获取统计 $map,$page,$row + */ + public function getSpendData($map=[],$field='',$group='',$order='',$page = 0,$row = 0) { + if ($row == 0) { + $data = $this->field($field)->where($map)->group($group)->order($order)->select(); + } else { + $data = $this->field($field)->where($map)->page($page,$row)->group($group)->order($order)->select(); + } + + return $data; + } + + public function sumSpend($map=[],$field='') { + $sum = $this->where($map)->sum($field); + return $sum; + } + } diff --git a/Application/Admin/View/Finance/gameFinance.html b/Application/Admin/View/Finance/gameFinance.html new file mode 100644 index 000000000..cf474f7d1 --- /dev/null +++ b/Application/Admin/View/Finance/gameFinance.html @@ -0,0 +1,218 @@ + + + + + + + + + + + +
+ + +
+ + +
+ 返回 + 导出 +
+
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
游戏合作方游戏现金流水平台币流水内冲流水总流水操作
aOh! 暂时还没有内容!
{$data.game_name}{$data.collaborate_name}{$data.cash_count}{$data.balance_coin_count}{$data.inside_cash_count}{$data.all_cash_count} + 查看 +
总计{$sumCash}0{$sumBalance}0{$sumInside}0{$sumAll}0 + 查看 +
+
+
+
+ + {$_page|default=''} +
+
+ + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + diff --git a/Application/Admin/View/Finance/gameFinanceDetail.html b/Application/Admin/View/Finance/gameFinanceDetail.html new file mode 100644 index 000000000..5749609da --- /dev/null +++ b/Application/Admin/View/Finance/gameFinanceDetail.html @@ -0,0 +1,228 @@ + + + + + + + + + + + +
+ + +
+ + +
+ 返回 + 导出 +
+
+ +   +
+
+ +   +
+
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
支付订单号充值时间玩家账号游戏名称所属推广员充值ip游戏区服角色名称订单金额实付金额充值方式
aOh! 暂时还没有内容!
{$data.pay_order_number}{$data.pay_time}{$data.user_account}{$data.game_name}{$data.promote_account}{$data.spend_ip}{$data.server_name}{$data.game_player_name}{$data.cost}{$data.pay_amount}{$data.pay_way}
总计{$sum_amount}0
+
+
+
+ + {$_page|default=''} +
+
+ + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + diff --git a/Application/Admin/View/Finance/index.html b/Application/Admin/View/Finance/index.html new file mode 100644 index 000000000..e10de7d2b --- /dev/null +++ b/Application/Admin/View/Finance/index.html @@ -0,0 +1,247 @@ + + + + + + + + + + + +
+ + +
+ + +
+ +
+
+ +
+
+ +
+ +
+ 搜索 + 导出 +
+
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
月份游戏现金流水平台币流水内冲流水总流水操作
{$data.count_date}{$data.cash_count}{$data.balance_coin_count}{$data.inside_cash_count}{$data.all_cash_count} + 游戏查看 + 渠道查看 +
总计{$sumCash}0{$sumBalance}0{$sumInside}0{$sumAll}0 + 游戏查看 + 渠道查看 +
+
+
+
+ 导出 + {$_page|default=''} +
+
+ + + + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + +