自动脚本->玩家角色充值数据统计

master
chenxiaojun 5 years ago
parent 855e943ccb
commit 3d3bfce947

@ -896,9 +896,6 @@ public function auto_rrdae(){
$time = strtotime(date('Y-m-d 00:00:00', time() - (3600 * 24))); $time = strtotime(date('Y-m-d 00:00:00', time() - (3600 * 24)));
$res = M('user_play_data_count', 'tab_')->where(array('create_time' => $time))->find(); $res = M('user_play_data_count', 'tab_')->where(array('create_time' => $time))->find();
if (empty($res)) { if (empty($res)) {
$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))]]; $spendMap['pay_time'] = ['between', [$time, strtotime(date('Y-m-d 23:59:59', $time))]];
$this->userPlayDataCountByMap($spendMap); $this->userPlayDataCountByMap($spendMap);
@ -911,9 +908,6 @@ public function auto_rrdae(){
$res = M('user_play_data_count', 'tab_')->order('id asc')->find(); $res = M('user_play_data_count', 'tab_')->order('id asc')->find();
if (empty($res)) { if (empty($res)) {
$time = strtotime(date('Y-m-d 00:00:00', time())); $time = strtotime(date('Y-m-d 00:00:00', time()));
$spendMap['pay_status'] = 1;
$spendMap['pay_game_status'] = 1;
$spendMap['game_player_id'] = ['gt', 0];
$spendMap['pay_time'] = ['lt', $time]; $spendMap['pay_time'] = ['lt', $time];
$this->userPlayDataCountByMap($spendMap); $this->userPlayDataCountByMap($spendMap);
@ -925,24 +919,29 @@ public function auto_rrdae(){
private function userPlayDataCountByMap($map) private function userPlayDataCountByMap($map)
{ {
$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'; if (isset($map['pay_time'])) {
$spendCostData = M('spend', 'tab_')->field($field) $map['pay_status'] = 1;
->where($map) $map['pay_game_status'] = 1;
->group('day,game_player_id,server_id,game_id') $map['game_player_id'] = ['gt', 0];
->select(); $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)
if (!empty($spendCostData)) { ->where($map)
$data = []; ->group('day,game_player_id,server_id,game_id')
foreach ($spendCostData as $list) { ->select();
$save['game_id'] = $list['game_id'];
$save['server_id'] = $list['server_id']; if (!empty($spendCostData)) {
$save['role_id'] = $list['game_player_id']; $data = [];
$save['recharge_cost'] = $list['recharge_cost']; foreach ($spendCostData as $list) {
$save['recharge_count'] = $list['recharge_count']; $save['game_id'] = $list['game_id'];
$save['create_time'] = strtotime($list['day']); $save['server_id'] = $list['server_id'];
$data[] = $save; $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);
} }
M('user_play_data_count', 'tab_')->addAll($data);
} }
} }
} }

Loading…
Cancel
Save