You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
726 lines
30 KiB
PHP
726 lines
30 KiB
PHP
<?php
|
|
namespace Admin\Controller;
|
|
class FinancePromoteController extends AdminController
|
|
{
|
|
public function _initialize(Type $var = null)
|
|
{
|
|
parent::_initialize();
|
|
// echo "<pre>";
|
|
}
|
|
public function index()
|
|
{
|
|
//排序
|
|
if(!array_key_exists("time_start",$_REQUEST)){
|
|
$this->redirect(ACTION_NAME, array('time_start' => date('Y-m-d',strtotime('-30 day')),"time_end"=>date('Y-m-d')));
|
|
}
|
|
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);
|
|
}
|
|
//时间
|
|
$istimeselect = false;
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
$istimeselect = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]];
|
|
} elseif (isset($_REQUEST['time_start'])) {
|
|
$istimeselect = ['GT', strtotime($_REQUEST['time_start'])];
|
|
} elseif (isset($_REQUEST['time_end'])) {
|
|
$istimeselect = ['LT', strtotime($_REQUEST['time_end']) + 86399];
|
|
}
|
|
|
|
$senddata = [];
|
|
//获取各会长的现金充值
|
|
$cash = self::getJoinPromoteData(array("pay_way"=>array("GT",0)),$istimeselect);
|
|
foreach($cash as $k=>$v){
|
|
$v['cash_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['p_id']] = $v;
|
|
}
|
|
//平台币直充支出
|
|
$balance = self::getJoinPromoteData(array("pay_way"=>array("EQ",0)),$istimeselect);
|
|
foreach($balance as $k=>$v){
|
|
if(array_key_exists($v['p_id'],$senddata)){
|
|
$senddata[$v['p_id']]['balance_coin_count']= $v['pay_amount'];
|
|
}else{
|
|
$v['balance_coin_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['p_id']] = $v;
|
|
};
|
|
}
|
|
//平台币内充
|
|
$bind = self::getJoinPromoteData(array("pay_way"=>array("LT",0)),$istimeselect);
|
|
foreach($bind as $k=>$v){
|
|
if(array_key_exists($v['p_id'],$senddata)){
|
|
$senddata[$v['p_id']]['bind_coin_count']= $v['pay_amount'];
|
|
}else{
|
|
$v['bind_coin_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['p_id']] = $v;
|
|
};
|
|
}
|
|
//内冲
|
|
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
|
|
foreach($inside as $k=>$v){
|
|
if(array_key_exists($v['p_id'],$senddata)){
|
|
$senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount'];
|
|
}else{
|
|
$v['inside_cash_count'] = $v['pay_amount']-$v['back_amount'];
|
|
unset($v['pay_amount']);
|
|
unset($v['back_amount']);
|
|
$senddata[$v['p_id']] = $v;
|
|
};
|
|
}
|
|
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
|
|
$pmap['status']=1;
|
|
if($istimeselect){
|
|
$pmap['create_time'] = $istimeselect;
|
|
}
|
|
$admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find();
|
|
if($admininside['amount'] >0){
|
|
$senddata[0]['inside_cash_count']= $admininside['amount'];
|
|
}
|
|
|
|
}
|
|
|
|
$data = [];
|
|
$count =array(
|
|
"cash_count"=>0,
|
|
"balance_coin_count"=>0,
|
|
"bind_coin_count"=>0,
|
|
"inside_cash_count"=>0,
|
|
);
|
|
foreach($senddata as $k=>$v){
|
|
|
|
if(empty($v['company_name'])) $v['company_name']= "万盟天下科技";
|
|
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
|
|
if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0;
|
|
if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0;
|
|
if(!array_key_exists('inside_cash_count',$v)) $v['inside_cash_count']=0;
|
|
$v['allcount'] = $v['cash_count']-0+$v['balance_coin_count']+$v['bind_coin_count'];
|
|
$count['cash_count'] += $v['cash_count'];
|
|
$count['balance_coin_count'] += $v['balance_coin_count'];
|
|
$count['bind_coin_count'] += $v['bind_coin_count'];
|
|
$count['inside_cash_count'] += $v['inside_cash_count'];
|
|
$count['all_count'] += $v['allcount'];
|
|
$data[] = $v;
|
|
}
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
$this->assign('list_data', $data);
|
|
$this->assign('all_count', $count);
|
|
$this->meta_title = '公会统计';
|
|
$this->display();
|
|
# code...
|
|
}
|
|
private function getJoinPromoteData($map,$istimeselect,$type="spend")
|
|
{
|
|
if ($_REQUEST['promote_id'] != '') {
|
|
if ($_REQUEST['promote_id'] == 0) {
|
|
$map['s.promote_id'] = 0;
|
|
} else {
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
if ($promoter_ids) {
|
|
$map['s.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
}
|
|
}
|
|
}
|
|
if($type == "spend"){
|
|
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
|
|
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
|
|
}
|
|
if($istimeselect){
|
|
$map['s.pay_time']=$istimeselect;
|
|
}
|
|
|
|
$map['s.pay_status']=1;
|
|
$field= "sum(pay_amount) pay_amount,IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,IFNULL(company_id,0) company_id,company_name";
|
|
return M()
|
|
->table("tab_spend s")
|
|
->field($field)
|
|
->where($map)
|
|
->join("tab_promote promote ON s.promote_id = promote.id","left")
|
|
->join("tab_promote_company company ON promote.company_id = company.id","left")
|
|
->group('p_id')
|
|
->select();
|
|
}else{
|
|
if($istimeselect){
|
|
$map['s.create_time']=$istimeselect;
|
|
}
|
|
$map['s.status']=1;
|
|
$map['s.source_id']=0;
|
|
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,IFNULL(if(substring_index(substring_index(`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(`chain`,'/',2),'/',-1)),0) p_id";
|
|
return M("promote_coin s","tab_")
|
|
->field($field)
|
|
->where($map)
|
|
->join("tab_promote promote ON s.promote_id = promote.id","left")
|
|
->group('p_id')
|
|
->select();
|
|
}
|
|
|
|
}
|
|
|
|
//渠道查看
|
|
public function promoteUser($p = 0)
|
|
{
|
|
$page = intval($p);
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
$arraypage = $page;
|
|
|
|
if (isset($_REQUEST['row'])) {
|
|
$row = $_REQUEST['row'];
|
|
} else {
|
|
$row = 10;
|
|
}
|
|
|
|
$istimeselect = false;
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
$istimeselect = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]];
|
|
} elseif (isset($_REQUEST['time_start'])) {
|
|
$istimeselect = ['GT', strtotime($_REQUEST['time_start'])];
|
|
} elseif (isset($_REQUEST['time_end'])) {
|
|
$istimeselect = ['LT', strtotime($_REQUEST['time_end']) + 86399];
|
|
}
|
|
$senddata = [];
|
|
//获取各会长的现金充值
|
|
$cash = self::promoteUserData(array("pay_way"=>array("GT",0)),$istimeselect);
|
|
foreach($cash as $k=>$v){
|
|
$v['cash_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['promote_id']] = $v;
|
|
}
|
|
//平台币直充支出
|
|
$balance = self::promoteUserData(array("pay_way"=>array("EQ",0)),$istimeselect);
|
|
foreach($balance as $k=>$v){
|
|
if(array_key_exists($v['promote_id'],$senddata)){
|
|
$senddata[$v['promote_id']]['balance_coin_count']= $v['pay_amount'];
|
|
}else{
|
|
$v['balance_coin_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['promote_id']] = $v;
|
|
};
|
|
}
|
|
//平台币内充
|
|
$bind = self::promoteUserData(array("pay_way"=>array("LT",0)),$istimeselect);
|
|
foreach($bind as $k=>$v){
|
|
if(array_key_exists($v['promote_id'],$senddata)){
|
|
$senddata[$v['promote_id']]['bind_coin_count']= $v['pay_amount'];
|
|
}else{
|
|
$v['bind_coin_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['promote_id']] = $v;
|
|
};
|
|
}
|
|
$inside = self::promoteUserData([],$istimeselect,"promote_coin");
|
|
foreach($inside as $k=>$v){
|
|
if(array_key_exists($v['promote_id'],$senddata)){
|
|
$senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount'];
|
|
}else{
|
|
$v['inside_cash_count'] = $v['pay_amount'];
|
|
unset($v['pay_amount']);
|
|
$senddata[$v['promote_id']] = $v;
|
|
};
|
|
}
|
|
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
|
|
$pmap['status']=1;
|
|
if($istimeselect){
|
|
$pmap['create_time'] = $istimeselect;
|
|
}
|
|
$admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find();
|
|
if($admininside['amount'] >0){
|
|
$senddata[0]['inside_cash_count']= $admininside['amount'];
|
|
}
|
|
|
|
}
|
|
$count = count($senddata);
|
|
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);
|
|
}
|
|
|
|
$page = set_pagination($count, $row);
|
|
if ($page) {
|
|
$this->assign('_page', $page);
|
|
}
|
|
$data = [];
|
|
$allcount =array(
|
|
"cash_count"=>0,
|
|
"balance_coin_count"=>0,
|
|
"bind_coin_count"=>0,
|
|
"inside_cash_count"=>0,
|
|
);
|
|
foreach($senddata as $k=>$v){
|
|
|
|
if(empty($v['company_name'])) $v['company_name']= "万盟天下科技";
|
|
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
|
|
if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0;
|
|
if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0;
|
|
if(!array_key_exists('inside_cash_count',$v)) $v['inside_cash_count']=0;
|
|
$v['allcount'] = $v['cash_count']-0+$v['balance_coin_count']+$v['bind_coin_count'];
|
|
$allcount['cash_count'] += $v['cash_count'];
|
|
$allcount['balance_coin_count'] += $v['balance_coin_count'];
|
|
$allcount['bind_coin_count'] += $v['bind_coin_count'];
|
|
$allcount['inside_cash_count'] += $v['inside_cash_count'];
|
|
$allcount['all_count'] += $v['allcount'];
|
|
$data[] = $v;
|
|
}
|
|
|
|
$data = my_sort($data, $data_order_type, (int)$data_order);
|
|
$size = $row;
|
|
$data = array_slice($data, ($arraypage - 1) * $size, $size);
|
|
$this->assign('all_count', $allcount);
|
|
$this->assign('list_data', $data);
|
|
$this->display();
|
|
// dump($senddata);
|
|
|
|
}
|
|
private function promoteUserData($map,$istimeselect,$type="spend")
|
|
{
|
|
if ($_REQUEST['promote_id'] != '') {
|
|
if ($_REQUEST['promote_id'] == 0) {
|
|
$map['s.promote_id'] = 0;
|
|
} else {
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
if ($promoter_ids) {
|
|
$map['s.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
}
|
|
}
|
|
}
|
|
if ($type == "spend") {
|
|
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
|
|
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
|
|
}
|
|
if($istimeselect){
|
|
$map['s.pay_time']=$istimeselect;
|
|
}
|
|
$map['s.pay_status']=1;
|
|
$field= "sum(pay_amount) pay_amount,IFNULL(company_id,0) company_id,company_name,promote_id";
|
|
return M()
|
|
->table("tab_spend s")
|
|
->field($field)
|
|
->where($map)
|
|
->join("tab_promote promote ON s.promote_id = promote.id", "left")
|
|
->join("tab_promote_company company ON promote.company_id = company.id", "left")
|
|
->group('promote_id')
|
|
->select();
|
|
}else{
|
|
if($istimeselect){
|
|
$map['s.create_time']=$istimeselect;
|
|
}
|
|
$map['s.status']=1;
|
|
$map['s.source_id']=0;
|
|
$map['s.type']=1;
|
|
$field= "sum(num) pay_amount,promote_id";
|
|
return M("promote_coin s","tab_")
|
|
->field($field)
|
|
->where($map)
|
|
->join("tab_promote promote ON s.promote_id = promote.id","left")
|
|
->group('promote_id')
|
|
->select();
|
|
}
|
|
# code...
|
|
}
|
|
/**
|
|
*游戏统计
|
|
*/
|
|
public function gameStatistics($p = 1) {
|
|
$page = intval($p);
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
$row = $_REQUEST['row'] ?? 10;
|
|
|
|
$map = [];
|
|
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
|
|
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
|
|
}
|
|
if (!empty(I('partner_id'))) {
|
|
$map['g.partner_id'] = I('partner_id');
|
|
}
|
|
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
$map['s.pay_time'] = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]];
|
|
} elseif (isset($_REQUEST['time_start'])) {
|
|
$map['s.pay_time'] = ['GT', strtotime($_REQUEST['time_start'])];
|
|
} elseif (isset($_REQUEST['time_end'])) {
|
|
$map['s.pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399];
|
|
}
|
|
//判断是否有推广员
|
|
$level = 1;
|
|
if ($_REQUEST['promote_id'] != '') {
|
|
if ($_REQUEST['promote_id'] != 0){
|
|
$level = M('promote', 'tab_')->field('level')->where(array('id' => $_REQUEST['promote_id']))->find()['level'];
|
|
}
|
|
if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) {
|
|
$map['s.promote_id'] = $_REQUEST['promote_id'];
|
|
} else {
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
if ($promoter_ids) {
|
|
$map['s.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
}
|
|
}
|
|
}
|
|
$this->assign('promote_level', $level);
|
|
|
|
//游戏统计列表
|
|
$data =self::gameStatisticsData($map, $row, $p);
|
|
foreach ($data as $key => $value) {
|
|
$data[$key]['all_cash_count'] = $value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count'];
|
|
}
|
|
|
|
$allData = self::gameStatisticsData($map);//列表总数
|
|
$count = count($allData);
|
|
$page = set_pagination($count, $row);
|
|
if ($page) {
|
|
$this->assign('_page', $page);//分页
|
|
}
|
|
|
|
//统计合计
|
|
$totalData = self::totalGameStatisticsData($map);
|
|
|
|
$sumCash = $totalData['cash_count'];
|
|
$sumBalance = $totalData['balance_coin_count'];
|
|
$sumInside = $totalData['inside_cash_count'];
|
|
$sumAll = $sumCash + $sumBalance + $sumInside;
|
|
|
|
$this->assign('sumCash', $sumCash);
|
|
$this->assign('sumBalance', $sumBalance);
|
|
$this->assign('sumInside', $sumInside);
|
|
$this->assign('sumAll', $sumAll);
|
|
$this->assign('data',$data);
|
|
|
|
$this->display();
|
|
}
|
|
//游戏订单详情
|
|
public function gameStatisticsDetail($p = 1) {
|
|
set_time_limit(0);
|
|
if(isset($_REQUEST['game_id'])){
|
|
|
|
//转化为名称和类型,重新请求
|
|
$game = M("game","tab_")->field("relation_game_name,sdk_version")->where(" id = {$_REQUEST['game_id']} ")->find();
|
|
if($game === false){
|
|
$this->error("参数错误");
|
|
}
|
|
$_GET['game_name'] = $game['relation_game_name'];
|
|
$_GET['game_type'] = $game['sdk_version'];
|
|
unset($_GET['game_id']);
|
|
$this->redirect(ACTION_NAME, I('get.'));
|
|
}
|
|
|
|
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'))) {
|
|
$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 (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
|
|
$map["game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
|
|
}
|
|
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
$map['pay_time'] = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]];
|
|
} elseif (isset($_REQUEST['time_start'])) {
|
|
$map['pay_time'] = ['GT', strtotime($_REQUEST['time_start'])];
|
|
} elseif (isset($_REQUEST['time_end'])) {
|
|
$map['pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399];
|
|
}
|
|
|
|
//判断是否有推广员
|
|
if ($_REQUEST['promote_id'] != '') {
|
|
if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) {
|
|
$map['promote_id'] = $_REQUEST['promote_id'];
|
|
} else {
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
if ($promoter_ids) {
|
|
$map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty(I("root_id"))) {
|
|
$root_id = I("root_id");
|
|
$promote_id = $this->getPromoteList($root_id);
|
|
array_push($promote_id, $root_id);
|
|
}
|
|
|
|
if ($_REQUEST['root_id']=='0') {
|
|
$map['promote_id'] = $_REQUEST['root_id'];
|
|
}
|
|
|
|
$promote_id = implode(',',$promote_id);
|
|
if ($promote_id) {
|
|
$map['promote_id'] = ['in',$promote_id];
|
|
}
|
|
|
|
$page = intval($p);
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
if (isset($_REQUEST['row'])) {
|
|
$row = $_REQUEST['row'];
|
|
} else {
|
|
$row = 10;
|
|
}
|
|
$map['pay_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,user_nickname,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'] = getPayType($value['pay_way']);
|
|
}
|
|
|
|
$totalData = self::totalGameStatisticsData($map, false);
|
|
$sumCash = $totalData['cash_count'] ?? 0;
|
|
$sumBalance = $totalData['balance_coin_count'] ?? 0;
|
|
$sumInside = $totalData['inside_cash_count'] ?? 0;
|
|
$sumAll = $sumCash + $sumBalance + $sumInside;
|
|
|
|
$this->assign('sumCash', $sumCash);
|
|
$this->assign('sumBalance', $sumBalance);
|
|
$this->assign('sumInside', $sumInside);
|
|
$this->assign('sumAll', null_to_0($sumAll));
|
|
|
|
$count = D("spend")->getSpendData($map,$field,$group,$order);
|
|
|
|
$count = count($count);
|
|
$page = set_pagination($count,$row);
|
|
if($page) {$this->assign('_page', $page);}
|
|
$this->meta_title = '游戏订单查看';
|
|
|
|
$this->assign('data',$data);
|
|
$from = I('from', '');
|
|
$this->display($from);
|
|
}
|
|
|
|
private function gameStatisticsData($map, $row = 0, $page = 1)
|
|
{
|
|
$map['s.pay_status']=1;
|
|
$query = M("spend","tab_")->alias("s")
|
|
->field("s.game_id,s.game_name,p.partner as partner_name,
|
|
SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
|
|
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
|
|
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count")
|
|
->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
|
|
->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id')
|
|
->where($map)
|
|
->group('s.game_id');
|
|
if ($row) {
|
|
$query = $query->page($page,$row);
|
|
}
|
|
$data = $query->select();
|
|
// dump($data);die();
|
|
return $data;
|
|
}
|
|
private function totalGameStatisticsData($map, $join = true)
|
|
{
|
|
$query = M("spend","tab_")->alias("s")
|
|
->field("SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
|
|
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
|
|
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count");
|
|
if ($join) {
|
|
$query = $query->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
|
|
->join('LEFT JOIN tab_partner as p ON g.partner_id=p.id');
|
|
}
|
|
$data = $query->where(['s.pay_status' => 1])
|
|
->where($map)
|
|
->find();
|
|
return $data;
|
|
}
|
|
//游戏弹框详情
|
|
public function gameCoinDetail($p = 1) {
|
|
|
|
set_time_limit(0);
|
|
|
|
if (isset($_REQUEST['pay_way'])) {
|
|
$map['pay_way'] = $_REQUEST['pay_way'];
|
|
$this->assign('pay_way', $map['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['tab_spend.game_id'] = ['in',$gameId];
|
|
}
|
|
if (!empty(I("game_id"))) {
|
|
$map['tab_spend.game_id'] = I("game_id");
|
|
}
|
|
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
|
|
$map["tab_spend.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
|
|
}
|
|
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
$map['pay_time'] = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]];
|
|
} elseif (isset($_REQUEST['time_start'])) {
|
|
$map['pay_time'] = ['GT', strtotime($_REQUEST['time_start'])];
|
|
} elseif (isset($_REQUEST['time_end'])) {
|
|
$map['pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399];
|
|
}
|
|
|
|
if ($_REQUEST['promote_id'] != '') {
|
|
if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) {
|
|
$map['tab_spend.promote_id'] = $_REQUEST['promote_id'];
|
|
} else {
|
|
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
|
|
if ($promoter_ids) {
|
|
$map['tab_spend.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
$page = intval($p);
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
if (isset($_REQUEST['row'])) {
|
|
$row = $_REQUEST['row'];
|
|
} else {
|
|
$row = 10;
|
|
}
|
|
$map['pay_status'] = 1;
|
|
|
|
if (!empty(I('user_account'))) {
|
|
$map['tab_spend.user_account'] = array('like','%'.I("user_account").'%');
|
|
}
|
|
if (!empty(I('user_nickname'))) {
|
|
$map['tab_spend.game_player_name'] = array('like',I("user_nickname").'%');
|
|
}
|
|
$field = "pay_order_number,FROM_UNIXTIME(pay_time) as pay_time,tab_spend.user_account,
|
|
tab_spend.user_nickname,tab_spend.game_name,tab_spend.promote_account,spend_ip,tab_spend.server_name,
|
|
game_player_name,pay_amount,cost,pay_way";
|
|
$group = "";
|
|
$order = "pay_time DESC";
|
|
$join = false;
|
|
if ($map['pay_way'] ==-1) {//绑定币
|
|
$field2 = $field . ',bind_balance';
|
|
$join = 'left join tab_user_play as p on p.user_id = tab_spend.user_id and tab_spend.game_id=p.game_id';
|
|
} elseif ($map['pay_way'] ==0) {//平台币
|
|
$field2 = $field . ',balance';
|
|
$join = 'left join tab_user as u on u.id = tab_spend.user_id';
|
|
}
|
|
|
|
$data = D('spend')->getSpendData($map, $field2, $group, $order, $page, $row, $join);
|
|
|
|
foreach($data as $key => $value) {
|
|
$data[$key]['pay_way'] = getPayType($value['pay_way']);
|
|
}
|
|
|
|
$count = D("spend")->getSpendData($map,$field,$group,$order);
|
|
$count = count($count);
|
|
$page = set_pagination($count,$row);
|
|
|
|
|
|
// $map['pay_game_status'] = 1;
|
|
$total_cost = D('spend')->sumSpend($map, 'cost');//订单金额合计
|
|
$total_pay_amount = D('spend')->sumSpend($map, 'pay_amount');//实付金额合计
|
|
|
|
$this->assign('total_cost', $total_cost);
|
|
$this->assign('total_pay_amount', $total_pay_amount);
|
|
|
|
if($page) {$this->assign('_page', $page);}
|
|
$this->meta_title = '游戏订单查看';
|
|
|
|
$this->assign('data',$data);
|
|
$this->display();
|
|
}
|
|
//平台币内充弹框
|
|
public function insideCoinDetail($p = 1)
|
|
{
|
|
$page = intval($p);
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
if (isset($_REQUEST['row'])) {
|
|
$row = $_REQUEST['row'];
|
|
} else {
|
|
$row = 10;
|
|
}
|
|
//时间
|
|
$istimeselect = false;
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
$istimeselect = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]];
|
|
} elseif (isset($_REQUEST['time_start'])) {
|
|
$istimeselect = ['GT', strtotime($_REQUEST['time_start'])];
|
|
} elseif (isset($_REQUEST['time_end'])) {
|
|
$istimeselect = ['LT', strtotime($_REQUEST['time_end']) + 86399];
|
|
}
|
|
|
|
//是否是官方渠道
|
|
$isgf = false;
|
|
if ($_REQUEST['promote_id'] != '') {
|
|
if($_REQUEST['promote_id'] == 0){
|
|
$isgf = true;
|
|
}
|
|
$map['s.promote_id'] = $_REQUEST['promote_id'];
|
|
}
|
|
|
|
//
|
|
$senddata = [];
|
|
$count =0;
|
|
$total_cost = 0;
|
|
if($isgf){
|
|
$pmap['status']=1;
|
|
if($istimeselect){
|
|
$pmap['create_time'] = $istimeselect;
|
|
}
|
|
$admininside = M("provide_user p","tab_")
|
|
->field("order_number,user_account,amount,balance")
|
|
->join("left join tab_user as u on u.id = p.user_id")
|
|
->page($page, $row)
|
|
->where($pmap)
|
|
->select();
|
|
foreach ($admininside as $k => $v) {
|
|
$temp = [
|
|
"sn"=>$v['order_number'],
|
|
"op_type"=>"收入",
|
|
"op_sty"=>"后台发放玩家",
|
|
""
|
|
];
|
|
# code...
|
|
}
|
|
|
|
$admincount = M("provide_user p","tab_")->field("sum(amount) amount,count(*) count")->where($pmap)->find();
|
|
$count = $admincount["count"]?:0;
|
|
$total_cost = $admincount["amount"]?:0;
|
|
}else{
|
|
if($istimeselect){
|
|
$map['s.create_time']=$istimeselect;
|
|
}
|
|
$map['s.status']=1;
|
|
$map['s.source_id']=0;
|
|
$field= "num,sn,promote.balance_coin,account,s.type";
|
|
$ininside = M("promote_coin s","tab_")
|
|
->field($field)
|
|
->where($map)
|
|
->page($page, $row)
|
|
->join("tab_promote promote ON s.promote_id = promote.id","left")
|
|
->select();
|
|
$ininsidecount = M("promote_coin s","tab_")
|
|
->field("SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,count(*) count")
|
|
->where($map)
|
|
->find();
|
|
$count = $ininsidecount["count"]?:0;
|
|
$total_cost = ($ininsidecount["pay_amount"]-$ininsidecount["back_amount"]);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
} |