|
|
@ -8,7 +8,10 @@ class SpendRepository {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getPayGameByDay($params) {
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 付费游戏数
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getPayGameCountByDay($params) {
|
|
|
|
$beginTime = $params['begin_time'] ?? 0;
|
|
|
|
$beginTime = $params['begin_time'] ?? 0;
|
|
|
|
$endTime = $params['end_time'] ?? 0;
|
|
|
|
$endTime = $params['end_time'] ?? 0;
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
@ -23,10 +26,183 @@ class SpendRepository {
|
|
|
|
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
|
|
|
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
|
|
|
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
|
|
|
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
|
|
|
|
|
|
|
|
|
|
|
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time,game_id as pay_num';
|
|
|
|
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time, game_id';
|
|
|
|
$subTable = M('spend', 'tab_')->field($field)->where($map)->group('pay_time')->select(false);
|
|
|
|
$subTable = M('spend', 'tab_')->field($field)->where($map)->group('pay_time')->select(false);
|
|
|
|
$data = M()->field('a.pay_time,count(DISTINCT a.pay_num) as pay_num')->table('(' . $subTable . ') as a')->group('a.pay_time')->select();
|
|
|
|
$data = M()->field('a.pay_time, count(DISTINCT a.game_id) as pay_num')->table('(' . $subTable . ') as a')->group('a.pay_time')->select();
|
|
|
|
// var_dump(M()->getLastSql());die();
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPayAmountByDay($params) {
|
|
|
|
|
|
|
|
$beginTime = $params['begin_time'] ?? 0;
|
|
|
|
|
|
|
|
$endTime = $params['end_time'] ?? 0;
|
|
|
|
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
|
|
|
|
$serverId = $params['server_id'] ?? 0;
|
|
|
|
|
|
|
|
$ids = $params['promote_id'] ?? [];
|
|
|
|
|
|
|
|
$isBan = $params['is_ban'] ?? false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['pay_status'] = 1;
|
|
|
|
|
|
|
|
$map['pay_time'] = ['between', [$beginTime, $endTime]];
|
|
|
|
|
|
|
|
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
|
|
|
|
|
|
|
$map['promote_id'] = ['in', $ids];
|
|
|
|
|
|
|
|
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time,sum(pay_amount) as money_amount';
|
|
|
|
|
|
|
|
$data = M('spend', 'tab_')->field($field)->where($map)->group('FROM_UNIXTIME(pay_time,"%Y-%m-%d")')->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPayUserCountByDay($params) {
|
|
|
|
|
|
|
|
$beginTime = $params['begin_time'] ?? 0;
|
|
|
|
|
|
|
|
$endTime = $params['end_time'] ?? 0;
|
|
|
|
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
|
|
|
|
$serverId = $params['server_id'] ?? 0;
|
|
|
|
|
|
|
|
$ids = $params['promote_id'] ?? [];
|
|
|
|
|
|
|
|
$isBan = $params['is_ban'] ?? false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['pay_status'] = 1;
|
|
|
|
|
|
|
|
$map['pay_time'] = ['between', [$beginTime, $endTime]];
|
|
|
|
|
|
|
|
$map['game_id'] = $gameId > 0 ? $gameId : ['gt', 0];
|
|
|
|
|
|
|
|
$map['promote_id'] = ['in', $ids];
|
|
|
|
|
|
|
|
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$field = 'FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time,user_id as pay_num';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$subTable = M('spend', 'tab_')->field($field)->where($map)->group('pay_time')->buildSql();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return M('spend', 'tab_')->field('a.pay_time,count(distinct a.pay_num) as pay_num')->table('(' . $subTable . ') as a')->group('a.pay_time')->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 按照时间分组统计新增付费用户数
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getNewPayUserCountByDay($params) {
|
|
|
|
|
|
|
|
$dayList = $params['dayList'] ?? [];
|
|
|
|
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
|
|
|
|
$serverId = $params['server_id'] ?? 0;
|
|
|
|
|
|
|
|
$ids = $params['promote_id'] ?? [];
|
|
|
|
|
|
|
|
$isBan = $params['is_ban'] ?? false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
$map['pay_status']=1;
|
|
|
|
|
|
|
|
if ($gameId > 0) {
|
|
|
|
|
|
|
|
$map['game_id'] = $gameId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($serverId > 0) {
|
|
|
|
|
|
|
|
$map['server_id'] = $serverId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$map['promote_id'] = ['in', $ids];
|
|
|
|
|
|
|
|
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
|
|
|
|
|
|
|
$oldMap = $map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$records = [];
|
|
|
|
|
|
|
|
foreach ($dayList as $day) {
|
|
|
|
|
|
|
|
$time = strtotime($day);
|
|
|
|
|
|
|
|
$oldMap['pay_time'] = ['lt', $time];
|
|
|
|
|
|
|
|
$map['pay_time'] = ['between', $time, ($time + 24 * 3600 -1)];
|
|
|
|
|
|
|
|
$oldQuery = M('spend', 'tab_')->field('user_id')->where($oldMap)->group('user_id')->buildSql();
|
|
|
|
|
|
|
|
$map['user_id'] = ['exp', ' not in (' . $oldQuery . ')'];
|
|
|
|
|
|
|
|
$result = M('spend', 'tab_')->field('count(distinct user_id) count')->where($map)->find();
|
|
|
|
|
|
|
|
$records[$day] = $result['count'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $records;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 按照时间分组统计新增付费用户数
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getNewPayAmountByDay($params) {
|
|
|
|
|
|
|
|
$dayList = $params['dayList'] ?? [];
|
|
|
|
|
|
|
|
$gameId = $params['game_id'] ?? 0;
|
|
|
|
|
|
|
|
$serverId = $params['server_id'] ?? 0;
|
|
|
|
|
|
|
|
$ids = $params['promote_id'] ?? [];
|
|
|
|
|
|
|
|
$isBan = $params['is_ban'] ?? false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
$map['pay_status']=1;
|
|
|
|
|
|
|
|
if ($gameId > 0) {
|
|
|
|
|
|
|
|
$map['game_id'] = $gameId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($serverId > 0) {
|
|
|
|
|
|
|
|
$map['server_id'] = $serverId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$map['promote_id'] = ['in', $ids];
|
|
|
|
|
|
|
|
$map['pay_way'] = $isBan ? ['neq', '-10'] : ['neq', '-1'];
|
|
|
|
|
|
|
|
$oldMap = $map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$records = [];
|
|
|
|
|
|
|
|
foreach ($dayList as $day) {
|
|
|
|
|
|
|
|
$time = strtotime($day);
|
|
|
|
|
|
|
|
$oldMap['pay_time'] = ['lt', $time];
|
|
|
|
|
|
|
|
$map['pay_time'] = ['between', $time, ($time + 24 * 3600 -1)];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$oldQuery = M('spend', 'tab_')->field('user_id')->where($oldMap)->group('user_id')->buildSql();
|
|
|
|
|
|
|
|
$map['user_id'] = ['exp', ' not in (' . $oldQuery . ')'];
|
|
|
|
|
|
|
|
$result = M('spend', 'tab_')->field('sum(pay_amount) amount')->where($map)->find();
|
|
|
|
|
|
|
|
$records[$day] = $result['amount'];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $records;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 按照时间分组统计付费玩家付费数(新付费用户指用户第一次付费)
|
|
|
|
|
|
|
|
* @param array $daylist 时间序列
|
|
|
|
|
|
|
|
* @param integer $game_id 游戏编号
|
|
|
|
|
|
|
|
* @param integer/string $promote_id 渠道编号或渠道编号列表字符串(字符串逗号分隔)
|
|
|
|
|
|
|
|
* @param integer $flag 类别(1:新玩家,2:老玩家)
|
|
|
|
|
|
|
|
* @return array 详细数据
|
|
|
|
|
|
|
|
* @author 鹿文学
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function pay_sum_by_time_class_game($daylist,$game_id=0,$promote_id=0,$flag=1,$bangbi=true) {
|
|
|
|
|
|
|
|
$map['pay_status']=1;
|
|
|
|
|
|
|
|
$oldmap['game_id'] = $map['game_id'] = $game_id>0?$game_id:array('gt',0);
|
|
|
|
|
|
|
|
$map['promote_id'] = is_numeric($promote_id)?$promote_id:array('in',$promote_id);
|
|
|
|
|
|
|
|
$map['pay_way'] = $bangbi ? array('neq','-10') : array('neq',-1);
|
|
|
|
|
|
|
|
if ($flag == 1) {$str='user_id not in ';$map['_string']='(small_id=0 or small_id=user_id)';} else {$str = 'user_id in';}
|
|
|
|
|
|
|
|
foreach ($daylist as $value) {
|
|
|
|
|
|
|
|
$time = strtotime($value);
|
|
|
|
|
|
|
|
$oldmap['pay_time'] = array('lt',$time);
|
|
|
|
|
|
|
|
$old_sdk_id=$this->field('user_id')
|
|
|
|
|
|
|
|
->where($oldmap)->group('user_id')
|
|
|
|
|
|
|
|
->buildSql();
|
|
|
|
|
|
|
|
$map['pay_time'] = array(array('egt',$time),array('elt',strtotime("+1 day",$time)-1));
|
|
|
|
|
|
|
|
$map['_string'] = $map['_string']?($map['_string'].' and '.$str.$old_sdk_id):($str.$old_sdk_id);
|
|
|
|
|
|
|
|
$sql=$this
|
|
|
|
|
|
|
|
->field('user_id,pay_amount,FROM_UNIXTIME(pay_time,"%Y-%m-%d") as pay_time')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
->where($map)
|
|
|
|
|
|
|
|
->buildSql();
|
|
|
|
|
|
|
|
$d = $this->query('select sum(a.pay_amount) as pay_sum, a.pay_time as pay_time from '.$sql.' as a group by pay_time');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($d)
|
|
|
|
|
|
|
|
$data[]=$d[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 统计给定时间前的付费玩家总数
|
|
|
|
|
|
|
|
* @param integer $start 开始时间(时间戳)
|
|
|
|
|
|
|
|
* @param integer $game_id 游戏编号
|
|
|
|
|
|
|
|
* @param integer/string $promote_id 渠道编号或渠道编号列表字符串(字符串逗号分隔)
|
|
|
|
|
|
|
|
* @return integer 结果
|
|
|
|
|
|
|
|
* @author 鹿文学
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function payUsersStatisticsAgo($start,$game_id,$promote_id,$bangbi=true) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['pay_status']=1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['pay_time'] = array('lt',$start);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['game_id'] = $game_id>0?$game_id:array('gt',0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['promote_id'] = is_numeric($promote_id)?$promote_id:array('in',$promote_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map['pay_way'] = $bangbi ? array('neq','-10') : array('neq',-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = $this->field('count(DISTINCT user_id) as user_id')->where($map)->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $data[0]['user_id']?$data[0]['user_id']:0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|