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.

118 lines
5.2 KiB
PHTML

5 years ago
<?php
namespace Admin\Controller;
class SuperStatisticalController extends ThinkController
{
private $super_money = 10;
private $ticketList_url = 'https://app.ipa365.com/Kirin/OpenApi/TicketList';
public function index() {
$params = I('get.');
$startDate = empty($params['timestart']) ? '': $params['timestart'];
$endDate = empty($params['timeend']) ? '' : $params['timeend'];
$startTime = strtotime($startDate);
$endTime = strtotime($endDate) + 86399;
if(!empty($startDate)) {
$where['pay_time'] = array('BETWEEN', [$startTime, $endTime]);
}
if(isset($params['game_id'])) {
$where['game_id'] = $params['game_id'];
}
$map['supersign_token'] = ['NEQ',''];
$supersign_game = M('game', 'tab_')->field('supersign_token')->where($map)->select();
$supersign_token = array_column($supersign_game, 'supersign_token');
$authorization_all_num = 0;
foreach($supersign_token as $k => $v) {
$authorization_all_num += count($this->game_supersign_num($v));
}
$where['pay_status'] = 1;
$data['buy_num'] = M('game_supersign', 'tab_')->where($where)->count();
$data['money_all'] = $data['buy_num'] * $this->super_money;
$data['authorization_all_num'] = $authorization_all_num;
$this->assign('data', $data);
$this->display('index');
}
public function lists($p = 1,$row = 10) {
$page = $p ? $p : 1;
$row = $row ? $row : 10;
5 years ago
$map['supersign_token'] = ['NEQ',''];
$supersign_game = M('game', 'tab_')->field('id,game_name,supersign_token')->where($map)->page($page,$row)->select();
5 years ago
$data = [];
$num['authorization'] = 0;
$num['pay_num'] = 0;
$num['promote_super_money'] = 0;
$num['official_super_money'] = 0;
5 years ago
foreach($supersign_game as $k => $v) {
$arr['game_name'] = $v['game_name'];
$arr['authorization_num'] = count($this->game_supersign_num($v['supersign_token']));
$num['authorization'] += $arr['authorization_num'];
5 years ago
$game_supersign = M('game_supersign', 'tab_')->field('promote_id')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->where(['game_id' => $v['id'], 'pay_status' => 1])->select();
$arr['pay_game_supersign'] = count($game_supersign);
$num['pay_num'] += $arr['pay_game_supersign'];
5 years ago
$arr['promote_super_money'] = 0;
$arr['official_super_money'] = 0;
foreach($game_supersign as $key => $val) {
if($val['promote_id'] != 0) {
$arr['promote_super_money'] += $this->super_money;
}else {
$arr['official_super_money'] += $this->super_money;
}
}
$num['official_super_money'] += $arr['official_super_money'];
$num['promote_super_money'] += $arr['promote_super_money'];
5 years ago
$data[] = $arr;
}
$count = M('game', 'tab_')->where($map)->count();
$page = set_pagination($count, $row);
$this->assign('_page', $page);
5 years ago
$this->assign('data', $data);
$this->assign('num', $num);
5 years ago
$this->display('lists');
}
private function game_supersign_num($token) {
$re_data = [];
$arr['token'] = $token;
$arr['limit'] = 2000;
for ($i = 1;$i > 0;$i++) {
if($i != 1) {
$pop = array_pop($data);
$arr['lastid'] = $pop['id'];
}
$curl_re = json_decode(curl_post($this->ticketList_url,$arr),true);
if($curl_re['errno'] == 0) {
$data = $curl_re['data']['list'];
$re_data = array_merge($re_data,$data);
} else {
break;
}
if(count($data) != $arr['limit']) {
break;
}
}
return $re_data;
}
public function superDetail($p = 1,$row = 10) {
$page = $p ? $p : 1;
$row = $row ? $row : 10;
$data = M('game_supersign', 'tab_')->field('tab_game_supersign.id,tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where(['tab_game_supersign.pay_status' => 1])->page($page,$row)->order('id DESC')->select();
5 years ago
$count = M('game_supersign', 'tab_')->field('tab_game_supersign.order_id,tab_user.account,tab_user.promote_account,tab_user.device_number,tab_game.game_name,tab_game_supersign.pay_time')->join('tab_user on tab_game_supersign.user_id = tab_user.id')->join('tab_game on tab_game_supersign.game_id = tab_game.id')->where(['tab_game_supersign.pay_status' => 1])->count();
$super_money_all = $count * $this->super_money;
$page = set_pagination($count, $row);
$this->assign('_page', $page);
5 years ago
$this->assign('data', $data);
$this->assign('super_money', $this->super_money);
$this->assign('super_money_all', $super_money_all);
$this->display('superDetail');
}
}