|
|
@@ -17,63 +17,118 @@ class TrendStatisModel extends Model
|
|
|
protected $connection = 'fortue_tiger';
|
|
|
|
|
|
/**
|
|
|
- * 获取游戏每日数据列表
|
|
|
+ * 获取输赢走势数据
|
|
|
*/
|
|
|
- public static function getGameDailyList($merchantId, $page = 1, $limit = 20, $filters = [])
|
|
|
+ public static function getWinLoseTrend($appId, $filters = [])
|
|
|
{
|
|
|
- $where = [
|
|
|
- ['app_id', '=', $merchantId]
|
|
|
- ];
|
|
|
+ $wheres = [];
|
|
|
+ $wheres[] = ['action_type', '=', 1];
|
|
|
+ $wheres[] = ['app_id', '=', $appId];
|
|
|
+
|
|
|
+ // 时间筛选
|
|
|
+ $startTime = !empty($filters['date']) ? strtotime($filters['date']) : strtotime(date('Ymd'));
|
|
|
+ $endTime = $startTime + 86400;
|
|
|
+
|
|
|
+ $wheres[] = ['create_time', '>=', $startTime];
|
|
|
+ $wheres[] = ['create_time', '<=', $endTime];
|
|
|
+
|
|
|
+ // 游戏ID筛选
|
|
|
+ if (!empty($filters['game_id'])) {
|
|
|
+ $filters['game_id'] = implode(',', $filters['game_id']);
|
|
|
+ $wheres[] = ['game_id', 'IN', $filters['game_id']];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 货币类型筛选
|
|
|
+ if (!empty($filters['currency'])) {
|
|
|
+ // 这里可能需要关联其他表来获取货币类型,暂时忽略
|
|
|
+ }
|
|
|
+
|
|
|
+ $query = self::where($wheres);
|
|
|
+ // 获取列表数据
|
|
|
+ $data = $query->field([
|
|
|
+ "from_unixtime(create_time, '%k') AS hour",
|
|
|
+ 'SUM(total_win_amount) as total_win',
|
|
|
+ ])
|
|
|
+ ->group('hour')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取返奖倍数走势数据(RTP走势)
|
|
|
+ */
|
|
|
+ public static function getMultipleTrend($appId, $filters = [])
|
|
|
+ {
|
|
|
+ $wheres = [];
|
|
|
+ $wheres[] = ['action_type', '=', 1];
|
|
|
+ $wheres[] = ['app_id', '=', $appId];
|
|
|
+
|
|
|
+ // 时间筛选
|
|
|
+ $startTime = !empty($filters['date']) ? strtotime($filters['date']) : strtotime(date('Ymd'));
|
|
|
+ $endTime = $startTime + 86400;
|
|
|
+
|
|
|
+ $wheres[] = ['create_time', '>=', $startTime];
|
|
|
+ $wheres[] = ['create_time', '<=', $endTime];
|
|
|
+
|
|
|
+ // 游戏ID筛选
|
|
|
+ if (!empty($filters['game_id'])) {
|
|
|
+ $filters['game_id'] = implode(',', $filters['game_id']);
|
|
|
+ $wheres[] = ['game_id', 'IN', $filters['game_id']];
|
|
|
+ }
|
|
|
+
|
|
|
+ $query = self::where($wheres);
|
|
|
+ // 获取列表数据
|
|
|
+ $data = $query->field([
|
|
|
+ "from_unixtime(create_time, '%k') AS hour",
|
|
|
+ 'SUM(res_multiple) as total_multiple',
|
|
|
+ ])
|
|
|
+ ->group('hour')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取商户每日走势数据
|
|
|
+ */
|
|
|
+ public static function getMerchantDailyTrend($appId, $filters = [])
|
|
|
+ {
|
|
|
+ $wheres = [];
|
|
|
+ $wheres[] = ['action_type', '=', 1];
|
|
|
+ $wheres[] = ['app_id', '=', $appId];
|
|
|
|
|
|
// 时间筛选
|
|
|
if (!empty($filters['start_time'])) {
|
|
|
$startTime = strtotime($filters['start_time']);
|
|
|
- $where[] = ['create_time', '>=', $startTime];
|
|
|
+ $wheres[] = ['create_time', '>=', $startTime];
|
|
|
}
|
|
|
|
|
|
if (!empty($filters['end_time'])) {
|
|
|
$endTime = strtotime($filters['end_time']);
|
|
|
- $where[] = ['create_time', '<=', $endTime];
|
|
|
- }
|
|
|
-
|
|
|
+ $wheres[] = ['create_time', '<=', $endTime];
|
|
|
+ }
|
|
|
+
|
|
|
+ // 游戏ID筛选
|
|
|
if (!empty($filters['game_id'])) {
|
|
|
- $gameId = is_array($filters['game_id']) ? $filters['game_id'] : explode(',', $filters['game_id']);
|
|
|
- $where[] = ['game_id', 'in', $gameId];
|
|
|
+ $wheres[] = ['game_id', 'IN', $filters['game_id']];
|
|
|
}
|
|
|
|
|
|
- $query = self::where($where);
|
|
|
- // 统计总数
|
|
|
- $total = $query->count();
|
|
|
+ $query = self::where($wheres);
|
|
|
// 获取列表数据
|
|
|
- $list = $query->field([
|
|
|
- "FROM_UNIXTIME(create_time, '%Y-%m-%d') as date", // 日期
|
|
|
- 'game_id', //游戏id
|
|
|
- 'AVG(rtp) AS rtp', // 平均RTP
|
|
|
+ $data = $query->field([
|
|
|
+ "from_unixtime(create_time, '%k') AS hour",
|
|
|
+ 'SUM(total_win_amount) as total_win',
|
|
|
+ 'SUM(bet) as total_bet',
|
|
|
+ 'COUNT(*) as bet_count', // 注单数
|
|
|
'COUNT(DISTINCT uname) as bet_users', // 投注用户数
|
|
|
- 'COUNT(id) as bet_count', // 注单数
|
|
|
- 'SUM(bet) as bet_amount', // 注单金额(下注分数)
|
|
|
- 'SUM(total_win_amount) as game_profit', // 游戏输赢(金额变化)
|
|
|
])
|
|
|
- ->order('date', 'desc')
|
|
|
- ->group('date, game_id')
|
|
|
- ->page($page, $limit)
|
|
|
+ ->group('hour')
|
|
|
->select()
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- // 获取登录用户、注册用户
|
|
|
- $merchantsUserStatic = MerchantsUserModel::getPlayerStatistics($merchantId, $filters);
|
|
|
-
|
|
|
- foreach ($list as &$row)
|
|
|
- {
|
|
|
- $row['login_users'] = $merchantsUserStatic[$row['date']]['login_users'] ?? 0;
|
|
|
- $row['register_users'] = $merchantsUserStatic[$row['date']]['register_users'] ?? 0;
|
|
|
- }
|
|
|
+ ->toArray();
|
|
|
|
|
|
- return [
|
|
|
- 'list' => $list,
|
|
|
- 'total' => $total,
|
|
|
- 'page' => $page,
|
|
|
- 'limit' => $limit
|
|
|
- ];
|
|
|
+ return $data;
|
|
|
}
|
|
|
}
|