|
|
@@ -28,16 +28,8 @@ class Player extends BaseController
|
|
|
'adjust_status' => Request::get('adjust_status', ''),
|
|
|
'login_ip' => Request::get('login_ip', '', 'trim'),
|
|
|
'reg_ip' => Request::get('reg_ip', '', 'trim'),
|
|
|
- 'balance_min' => Request::get('balance_min', 0, 'floatval'),
|
|
|
- 'balance_max' => Request::get('balance_max', 0, 'floatval'),
|
|
|
- 'today_win_min' => Request::get('today_win_min', 0, 'floatval'),
|
|
|
- 'today_win_max' => Request::get('today_win_max', 0, 'floatval'),
|
|
|
- 'history_win_min' => Request::get('history_win_min', 0, 'floatval'),
|
|
|
- 'history_win_max' => Request::get('history_win_max', 0, 'floatval'),
|
|
|
'login_time_start' => Request::get('login_time_start', '', 'trim'),
|
|
|
'login_time_end' => Request::get('login_time_end', '', 'trim'),
|
|
|
- 'create_time_start' => Request::get('create_time_start', '', 'trim'),
|
|
|
- 'create_time_end' => Request::get('create_time_end', '', 'trim'),
|
|
|
'order' => Request::get('order', 'player_id', 'trim'),
|
|
|
'sort' => Request::get('sort', 'desc', 'trim'),
|
|
|
];
|
|
|
@@ -50,9 +42,7 @@ class Player extends BaseController
|
|
|
foreach ($result['list'] as &$player) {
|
|
|
$player['status_text'] = PlayerModel::getStatusText($player['status']);
|
|
|
$player['adjust_status_text'] = PlayerModel::getAdjustStatusText($player['adjust_status']);
|
|
|
- $player['login_time_text'] = $player['login_time'] ? date('Y-m-d H:i:s', $player['login_time']) : '未登录';
|
|
|
- $player['create_time_text'] = date('Y-m-d H:i:s', $player['create_time']);
|
|
|
- $player['update_time_text'] = date('Y-m-d H:i:s', $player['update_time']);
|
|
|
+ $player['login_time_text'] = $player['login_time'] ? date('Y-m-d H:i:s', (int)$player['login_time']) : '未登录';
|
|
|
}
|
|
|
|
|
|
return json_success($result, '获取成功');
|
|
|
@@ -82,9 +72,7 @@ class Player extends BaseController
|
|
|
// 添加状态文本
|
|
|
$player['status_text'] = PlayerModel::getStatusText($player['status']);
|
|
|
$player['adjust_status_text'] = PlayerModel::getAdjustStatusText($player['adjust_status']);
|
|
|
- $player['login_time_text'] = $player['login_time'] ? date('Y-m-d H:i:s', $player['login_time']) : '未登录';
|
|
|
- $player['create_time_text'] = date('Y-m-d H:i:s', $player['create_time']);
|
|
|
- $player['update_time_text'] = date('Y-m-d H:i:s', $player['update_time']);
|
|
|
+ $player['login_time_text'] = $player['login_time'] ? date('Y-m-d H:i:s', (int)$player['login_time']) : '未登录';
|
|
|
|
|
|
return json_success($player, '获取成功');
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -98,12 +86,14 @@ class Player extends BaseController
|
|
|
public function updateStatus()
|
|
|
{
|
|
|
$userInfo = $this->request->userInfo;
|
|
|
+
|
|
|
+ print_r($userInfo);
|
|
|
|
|
|
- $playerId = Request::post('player_id', 0, 'intval');
|
|
|
+ $playerIds = Request::post('player_ids', []);
|
|
|
$status = Request::post('status', 0, 'intval');
|
|
|
|
|
|
- if (!$playerId) {
|
|
|
- return json_error([], '玩家ID不能为空');
|
|
|
+ if (empty($playerIds) || !is_array($playerIds)) {
|
|
|
+ return json_error([], '请选择要更新的玩家');
|
|
|
}
|
|
|
|
|
|
if (!in_array($status, [PlayerModel::STATUS_NORMAL, PlayerModel::STATUS_FROZEN])) {
|
|
|
@@ -111,7 +101,7 @@ class Player extends BaseController
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- $result = PlayerModel::updatePlayerStatus($playerId, $userInfo['merchant_id'], $status);
|
|
|
+ $result = PlayerModel::updatePlayerStatus($playerIds, $userInfo['merchant_id'], $status);
|
|
|
if ($result) {
|
|
|
return json_success([], '状态更新成功');
|
|
|
} else {
|
|
|
@@ -129,11 +119,11 @@ class Player extends BaseController
|
|
|
{
|
|
|
$userInfo = $this->request->userInfo;
|
|
|
|
|
|
- $playerId = Request::post('player_id', 0, 'intval');
|
|
|
+ $playerIds = Request::post('player_ids', []);
|
|
|
$adjustStatus = Request::post('adjust_status', 0, 'intval');
|
|
|
|
|
|
- if (!$playerId) {
|
|
|
- return json_error([], '玩家ID不能为空');
|
|
|
+ if (empty($playerIds) || !is_array($playerIds)) {
|
|
|
+ return json_error([], '请选择要更新的玩家');
|
|
|
}
|
|
|
|
|
|
if (!in_array($adjustStatus, [
|
|
|
@@ -145,7 +135,7 @@ class Player extends BaseController
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- $result = PlayerModel::updatePlayerAdjustStatus($playerId, $userInfo['merchant_id'], $adjustStatus);
|
|
|
+ $result = PlayerModel::updatePlayerAdjustStatus($playerIds, $userInfo['merchant_id'], $adjustStatus);
|
|
|
if ($result) {
|
|
|
return json_success([], '调控状态更新成功');
|
|
|
} else {
|
|
|
@@ -170,71 +160,7 @@ class Player extends BaseController
|
|
|
return json_error([], '获取玩家统计失败:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量更新玩家状态
|
|
|
- */
|
|
|
- public function batchUpdateStatus()
|
|
|
- {
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
|
|
|
- $playerIds = Request::post('player_ids', []);
|
|
|
- $status = Request::post('status', 0, 'intval');
|
|
|
-
|
|
|
- if (empty($playerIds) || !is_array($playerIds)) {
|
|
|
- return json_error([], '请选择要更新的玩家');
|
|
|
- }
|
|
|
-
|
|
|
- if (!in_array($status, [PlayerModel::STATUS_NORMAL, PlayerModel::STATUS_FROZEN])) {
|
|
|
- return json_error([], '状态值无效');
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- $result = PlayerModel::batchUpdateStatus($playerIds, $userInfo['merchant_id'], $status);
|
|
|
- if ($result > 0) {
|
|
|
- return json_success(['updated' => $result], '批量更新成功');
|
|
|
- } else {
|
|
|
- return json_error([], '批量更新失败');
|
|
|
- }
|
|
|
- } catch (\Exception $e) {
|
|
|
- return json_error([], '批量更新玩家状态失败:' . $e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量更新玩家调控状态
|
|
|
- */
|
|
|
- public function batchUpdateAdjustStatus()
|
|
|
- {
|
|
|
- $userInfo = $this->request->userInfo;
|
|
|
-
|
|
|
- $playerIds = Request::post('player_ids', []);
|
|
|
- $adjustStatus = Request::post('adjust_status', 0, 'intval');
|
|
|
-
|
|
|
- if (empty($playerIds) || !is_array($playerIds)) {
|
|
|
- return json_error([], '请选择要更新的玩家');
|
|
|
- }
|
|
|
-
|
|
|
- if (!in_array($adjustStatus, [
|
|
|
- PlayerModel::ADJUST_STATUS_NORMAL,
|
|
|
- PlayerModel::ADJUST_STATUS_WIN,
|
|
|
- PlayerModel::ADJUST_STATUS_LOSE
|
|
|
- ])) {
|
|
|
- return json_error([], '调控状态值无效');
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- $result = PlayerModel::batchUpdateAdjustStatus($playerIds, $userInfo['merchant_id'], $adjustStatus);
|
|
|
- if ($result > 0) {
|
|
|
- return json_success(['updated' => $result], '批量更新成功');
|
|
|
- } else {
|
|
|
- return json_error([], '批量更新失败');
|
|
|
- }
|
|
|
- } catch (\Exception $e) {
|
|
|
- return json_error([], '批量更新玩家调控状态失败:' . $e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 导出玩家列表
|
|
|
*/
|
|
|
@@ -250,16 +176,10 @@ class Player extends BaseController
|
|
|
'adjust_status' => Request::get('adjust_status', ''),
|
|
|
'login_ip' => Request::get('login_ip', '', 'trim'),
|
|
|
'reg_ip' => Request::get('reg_ip', '', 'trim'),
|
|
|
- 'balance_min' => Request::get('balance_min', 0, 'floatval'),
|
|
|
- 'balance_max' => Request::get('balance_max', 0, 'floatval'),
|
|
|
- 'today_win_min' => Request::get('today_win_min', 0, 'floatval'),
|
|
|
- 'today_win_max' => Request::get('today_win_max', 0, 'floatval'),
|
|
|
- 'history_win_min' => Request::get('history_win_min', 0, 'floatval'),
|
|
|
- 'history_win_max' => Request::get('history_win_max', 0, 'floatval'),
|
|
|
'login_time_start' => Request::get('login_time_start', '', 'trim'),
|
|
|
'login_time_end' => Request::get('login_time_end', '', 'trim'),
|
|
|
- 'create_time_start' => Request::get('create_time_start', '', 'trim'),
|
|
|
- 'create_time_end' => Request::get('create_time_end', '', 'trim'),
|
|
|
+ 'order' => Request::get('order', 'player_id', 'trim'),
|
|
|
+ 'sort' => Request::get('sort', 'desc', 'trim'),
|
|
|
];
|
|
|
|
|
|
try {
|
|
|
@@ -284,16 +204,16 @@ class Player extends BaseController
|
|
|
$player['history_login_count'],
|
|
|
PlayerModel::getStatusText($player['status']),
|
|
|
PlayerModel::getAdjustStatusText($player['adjust_status']),
|
|
|
- $player['login_time'] ? date('Y-m-d H:i:s', $player['login_time']) : '未登录',
|
|
|
- date('Y-m-d H:i:s', $player['create_time'])
|
|
|
+ $player['login_time'] ? date('Y-m-d H:i:s', (int)$player['login_time']) : '未登录',
|
|
|
+ $player['create_time']
|
|
|
);
|
|
|
}
|
|
|
|
|
|
// 返回CSV数据
|
|
|
return response($csvData)
|
|
|
- ->header('Content-Type', 'text/csv; charset=utf-8')
|
|
|
- ->header('Content-Disposition', 'attachment; filename="players_' . date('YmdHis') . '.csv"')
|
|
|
- ->header('Cache-Control', 'no-cache, must-revalidate');
|
|
|
+ ->header(['Content-Type' => 'text/csv; charset=utf-8'])
|
|
|
+ ->header(['Content-Disposition' => 'attachment; filename="players_' . date('YmdHis') . '.csv"'])
|
|
|
+ ->header(['Cache-Control' => 'no-cache, must-revalidate']);
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
return json_error([], '导出玩家列表失败:' . $e->getMessage());
|