diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index 666dfd6d0..1f31cfe96 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -1561,25 +1561,32 @@ class QueryController extends ThinkController if ($_REQUEST['promote_id']||$_REQUEST['promote_id']=='0') { if ($_REQUEST['promote_id']=='0') { unset($map['root_id']); + $whereMarket['promote_account'] = '官方渠道'; $map['promote_account'] = C('OFFICIEL_CHANNEL'); } else { $map['root_id'] = $_REQUEST['promote_id']; + $whereMarket['root_id'] = $_REQUEST['promote_id']; } } if ($_REQUEST['game_name']) { $map['game_names'] = $_REQUEST['game_name']; + $whereMarket['game_names'] = $_REQUEST['game_name']; } if ($_REQUEST['count_date']) { $map['my_time'] = $_REQUEST['count_date']; + $whereMarket['my_time'] = $_REQUEST['count_date']; } if ($_REQUEST['device']) { // $map['tab_spend.sdk_version'] = $_REQUEST['device']; $spendMap['tab_spend.sdk_version'] = $_REQUEST['device']; + $whereMarket['sdk_version'] = $_REQUEST['device']; } + + $spendMap['pay_time'] = ['between',[strtotime(date('Ymd',time())),strtotime(date('Ymd',time()))+86399]]; $spendMap['tab_spend.pay_status'] = 1; //获取spend表中的数据,同时根据会长id进行group分类 $data = M('Spend','tab_') @@ -1592,13 +1599,13 @@ class QueryController extends ThinkController ->select(false); - $count = M()->table('('.$data.') as a') - ->field("my_time,pay_amount,game_id,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account") - ->join("left join tab_promote on root_id = tab_promote.id") - ->group("my_time,game_names,root_id") - ->where($map) - ->order("my_time Desc") - ->select(false); +// $count = M()->table('('.$data.') as a') +// ->field("my_time,pay_amount,game_id,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account") +// ->join("left join tab_promote on root_id = tab_promote.id") +// ->group("my_time,game_names,root_id") +// ->where($map) +// ->order("my_time Desc") +// ->select(false); //关联表获取会长账号名 $data = M()->table('('.$data.') as a') @@ -1606,35 +1613,34 @@ class QueryController extends ThinkController ->join("left join tab_promote on root_id = tab_promote.id") ->join("left join tab_promote_game_ratio as tab_ratio on tab_ratio.game_id = a.relation_game_id and tab_ratio.promote_id=root_id and tab_ratio.status=1") // ->join("left join tab_cp_game_ratio as game_ratio on game_ratio.game_id = a.game_id") - ->page($page,$row) +// ->page($page,$row) ->where($map) ->group("my_time,game_names,root_id") ->order("my_time Desc") ->select(); -// var_dump($data);die(); // dump($data);die(); - $pagecount = M()->table('('.$count.') as a')->count(); +// $pagecount = M()->table('('.$count.') as a')->count(); foreach($data as $key => $value) { - $mytime = $value['my_time']; - $nextMonth = date('Y-m',strtotime("$mytime + 1 month")); - $game_id = $value['game_id']; - $gameInfo = M('game','tab_')->where(['id'=>$game_id])->getField('game_name'); - $gameName = substr($gameInfo,0,strpos($gameInfo,'(')); - $gameMap['game_name'] = ['like','%'.$gameName.'%']; - $gameIdArr = M('game','tab_')->field('id')->where($gameMap)->select(); + $mytime = $value['my_time']; + $nextMonth = date('Y-m',strtotime("$mytime + 1 month")); + $game_id = $value['game_id']; + $gameInfo = M('game','tab_')->where(['id'=>$game_id])->getField('game_name'); + $gameName = substr($gameInfo,0,strpos($gameInfo,'(')); + $gameMap['game_name'] = ['like','%'.$gameName.'%']; + $gameIdArr = M('game','tab_')->field('id')->where($gameMap)->select(); ($data[$key]['account']=='官方渠道')?($data[$key]['account']=C('OFFICIEL_CHANNEL')):''; - $gameNameIdArr = []; - foreach($gameIdArr as $gameKey => $gameValue){ - $gameNameIdArr[] = $gameValue['id']; - } - $promote_id = $value['promote_id']; - $pay_status = 1; - $promoteInfo = M('promote','tab_')->where(['id'=>$promote_id])->find(); - $level = $promoteInfo['level']; - if($promote_id != 0) { + $gameNameIdArr = []; + foreach($gameIdArr as $gameKey => $gameValue){ + $gameNameIdArr[] = $gameValue['id']; + } + $promote_id = $value['promote_id']; + $pay_status = 1; + $promoteInfo = M('promote','tab_')->where(['id'=>$promote_id])->find(); + $level = $promoteInfo['level']; + if($promote_id != 0) { $promoteIdArr = []; if ($level == 1) { $rootPromoteId = $promote_id; @@ -1644,33 +1650,38 @@ class QueryController extends ThinkController $chainArr = explode('/',$chain); $rootPromoteId = $chainArr[1]; } - $where1['chain'] = array('like', '%/' . $rootPromoteId. '/%'); + $where1['chain'] = array('like', '%/' . $rootPromoteId. '/%'); $promoteIdInfo = M('promote','tab_')->field('id')->where($where1)->select(); foreach($promoteIdInfo as $key2 => $v1) { - $promoteIdArr[] = $v1['id']; + $promoteIdArr[] = $v1['id']; } $where['promote_id'] = ['in',$promoteIdArr]; - }else { + }else { $where['promote_id'] = 0; - } - $where['game_id'] = ['in',$gameNameIdArr]; - $where['pay_status'] = 1; - $begTime = strtotime($mytime); - $endTime = strtotime($nextMonth); - $where['pay_time'] = ['between',[$begTime,$endTime]]; - $spendInfo = M('spend','tab_')->field('pay_amount,pay_way')->where($where)->select(); - $initNum = 0; - foreach($spendInfo as $key1 => $spendValue) { - $pay_way = $spendValue['pay_way']; - $channel_rate = $this->getChannelConfig($pay_way) / 100; - $initNum += $spendValue['pay_amount'] * $channel_rate; - - } - $data[$key]['pay_amount'] = $value['pay_amount'] - $initNum; + } + $where['game_id'] = ['in',$gameNameIdArr]; + $where['pay_status'] = 1; + + $where['sdk_version'] = $value['sdk_version']; + + $begTime = strtotime($mytime); + $endTime = strtotime($nextMonth); + + + $where['pay_time'] = ['between',[strtotime(date('Ymd',time())),strtotime(date('Ymd',time()))+86399]]; + $spendInfo = M('spend','tab_')->field('pay_amount,pay_way')->where($where)->select(); + $initNum = 0; + foreach($spendInfo as $key1 => $spendValue) { + $pay_way = $spendValue['pay_way']; + $channel_rate = $this->getChannelConfig($pay_way) / 100; + $initNum += $spendValue['pay_amount'] * $channel_rate; + + } + $data[$key]['pay_amount'] = $value['pay_amount'] - $initNum; // if ($value['games_ratio']) { // $data[$key]['upstream'] = $value['pay_amount'] * ($value['games_ratio']*0.01); // } else { - $data[$key]['upstream'] = caculateUpstream($value['game_id'],$value['pay_amount']); + $data[$key]['upstream'] = caculateUpstream($value['game_id'],$value['pay_amount']); // } if ($value['ratio']) { @@ -1703,7 +1714,58 @@ class QueryController extends ThinkController } - $page = set_pagination($pagecount, $row); +// dump($data);die(); +// $whereMarket['my_time'] = date('Y-m',time()); + + $marketData = M('market_balance','tab_') + ->field("*,sum(pay_amount) pay_amount,sum(upstream) upstream,sum(downstream) downstream,sum(highquality) highquality") + ->where($whereMarket) + ->group('my_time,game_names,root_id') + ->order('id ASC') + ->select(); + + +// dump($marketData);die(); + + $data = array_merge($marketData,$data); +// dump($data); +//die(); + $new_data = []; + + foreach($data as $key => $value) { + + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['pay_amount'] += $value['pay_amount']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['upstream'] += $value['upstream']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['downstream'] += $value['downstream']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['highquality'] += $value['highquality']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['id'] = $value['id']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['my_time'] = $value['my_time']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['game_id'] = $value['game_id']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['game_name'] = $value['game_name']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['game_names'] = $value['game_names']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['promote_id'] = $value['promote_id']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['promote_account'] = $value['promote_account']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['company_relation'] = $value['company_relation']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['company_belong'] = $value['company_belong']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['root_id'] = $value['root_id']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['account'] = $value['account']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['ratio'] = $value['ratio']; + + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['turnover_ratio'] = $value['turnover_ratio']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['game_ratio'] = $value['game_ratio']; + $new_data[$value['my_time'].$value['game_names'].$value['promote_id'].$value['root_id']]['sdk_version'] = $value['sdk_version']; + + } +// die(); + $data = array_values($new_data); + + $count = count($data); + + + $page = set_pagination($count, $row); + $size = $row;//每页显示的记录数 + $data = array_slice($data, ($arraypage - 1) * $size, $size); + if ($page) { $this->assign('_page', $page); } diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 9468a53b9..36a4d2f7d 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -383,6 +383,7 @@ class TimingController extends AdminController { foreach($data as $key => $value) { + echo "{$value['my_time']}-{$value['promote_account']}-{$value['game_name']}:{$value['pay_amount']}\n"; $mytime = $value['my_time']; $nextMonth = date('Y-m',strtotime("$mytime + 1 month")); $game_id = $value['game_id'];