diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php index 6ebe18b4b..b442ad320 100644 --- a/Application/Admin/Controller/AutoController.class.php +++ b/Application/Admin/Controller/AutoController.class.php @@ -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); + } } diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 4d0f5061b..be50a7529 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -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); - } } diff --git a/Data/update.sql b/Data/update.sql index c989c2a8c..9bfad8b2e 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -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; \ No newline at end of file