根据时间统计玩家充值

master
chenxiaojun 5 years ago
commit 5fcad13fce

@ -890,5 +890,31 @@ public function auto_rrdae(){
}
}
//根据时间统计玩家充值
public function userPlayDataCount()
{
$time = strtotime(date('Y-m-d 00:00:00', time() - (3600 * 24)));
$spendMap['pay_status'] = 1;
$spendMap['pay_game_status'] = 1;
$spendMap['game_player_id'] = ['gt', 0];
$spendMap['pay_time'] = ['between', [$time, strtotime(date('Y-m-d 23:59:59', $time))]];
$field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count';
$spendCostData = M('spend', 'tab_')->field($field)
->where($spendMap)
->group('day,game_player_id,server_id,game_id')
->select();
$data = [];
foreach ($spendCostData as $list) {
$save['game_id'] = $list['game_id'];
$save['server_id'] = $list['server_id'];
$save['role_id'] = $list['game_player_id'];
$save['recharge_cost'] = $list['recharge_cost'];
$save['recharge_count'] = $list['recharge_count'];
$save['create_time'] = strtotime($list['day']);
$data[] = $save;
}
M('user_play_data_count', 'tab_')->addAll($data);
}
}

@ -2134,31 +2134,4 @@ class QueryController extends BaseController
$this->ajaxReturn($data);
}
public function userPlayDataCount()
{
$time = strtotime(date('Y-m-d 00:00:00', time() - (3600 * 24)));
$spendMap['pay_status'] = 1;
$spendMap['pay_game_status'] = 1;
$spendMap['game_player_id'] = ['gt', 0];
$spendMap['pay_time'] = ['between', [$time, strtotime(date('Y-m-d 23:59:59', $time))]];
$field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count';
$spendCostData = M('spend', 'tab_')->field($field)
->where($spendMap)
->group('day,game_player_id,server_id,game_id')
->select();
$data = [];
foreach ($spendCostData as $list) {
$save['game_id'] = $list['game_id'];
$save['server_id'] = $list['server_id'];
$save['role_id'] = $list['game_player_id'];
$save['recharge_cost'] = $list['recharge_cost'];
$save['recharge_count'] = $list['recharge_count'];
$save['create_time'] = strtotime($list['day']);
$data[] = $save;
}
M('user_play_data_count', 'tab_')->addAll($data);
}
}

@ -524,7 +524,7 @@ CREATE TABLE `tab_user_play_data_count` (
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
ALTER TABLE `tab_user_play_data_count`
ADD INDEX `search`(`game_id`, `server_id`, `role_id`) USING BTREE,
ADD INDEX `search`(`game_id`, `server_id`, `role_id`, `create_time`) USING BTREE,
ADD INDEX `create_time`(`create_time`) USING BTREE;
ADD INDEX `recharge_cost`(`recharge_cost`) USING BTREE,
ADD INDEX `recharge_count`(`recharge_count`) USING BTREE;

Loading…
Cancel
Save