diff --git a/app/Command/JinlingCommand.php b/app/Command/JinlingCommand.php index fe03c66..141d818 100644 --- a/app/Command/JinlingCommand.php +++ b/app/Command/JinlingCommand.php @@ -59,13 +59,13 @@ class JinlingCommand extends HyperfCommand 'power' => '', // 战力 ]); */ - /* Lanhuo::addLoginLog([ + Lanhuo::addLoginLog([ 'user_id' => 111, 'account' => 'bbbbbbbabc111', 'phone' => '18888888888', 'device_type' => 2, // 设备类型(1-andriod 2-ios) 'device_number' => 'ABCD', - ]); */ + ]); /* Lanhuo::updateUser([ 'user_id' => 111, @@ -77,7 +77,7 @@ class JinlingCommand extends HyperfCommand 'is_real' => 1, // 是否实名(1-实名 0-未实名) ]); */ - Lanhuo::addOrder([ + /* Lanhuo::addOrder([ 'order_code' => 'sdflsdkflskdfsll', 'user_id' => 111, 'account' => 'bbbbbbbabc111', @@ -91,6 +91,6 @@ class JinlingCommand extends HyperfCommand 'order_amount' => '6.00', 'pay_time' => date('Y-m-d H:i:s'), 'status' => 1, //支付状态(待支付 0 已支付 1 支付失败 2) - ]); + ]); */ } } \ No newline at end of file diff --git a/app/Controller/GameEventController.php b/app/Controller/GameEventController.php index 959bf57..fba8be5 100644 --- a/app/Controller/GameEventController.php +++ b/app/Controller/GameEventController.php @@ -32,6 +32,10 @@ class GameEventController extends AbstractController $userId = (int)$this->request->input('user_id', 0); $gameId = (int)$this->request->input('game_id', 0); $loginTime = (int)$this->request->input('login_time', 0); + $sdkVersion = $this->request->input('sdk_version', 0); + $clientIp = $this->request->input('client_ip', ''); + $deviceNumber = $this->request->input('device_number', ''); + if (!$userId) { throw new BusinessException('缺少参数[user_id]'); } @@ -44,7 +48,10 @@ class GameEventController extends AbstractController Queue::push(AfterLoginJob::class, [ 'user_id' => $userId, 'game_id' => $gameId, - 'login_time' => $loginTime + 'login_time' => $loginTime, + 'sdk_version' => $sdkVersion, + 'client_ip' => $clientIp, + 'device_number' => $deviceNumber, ]); return $this->success(); } diff --git a/app/Helper/Client/Lanhuo.php b/app/Helper/Client/Lanhuo.php index 3e34591..9761f1f 100644 --- a/app/Helper/Client/Lanhuo.php +++ b/app/Helper/Client/Lanhuo.php @@ -56,7 +56,7 @@ class Lanhuo 'device_type' => $data['device_type'], // 设备类型(1-andriod 2-ios) 'device_number' => $data['device_number'], ]; - return self::api('/llwf/user/AddLoginLog', $params); + return self::api('/llwf/user/addLoginLog', $params); } public static function addOrder($data) @@ -90,7 +90,7 @@ class Lanhuo 'profession_name' => '', // 职业名称 'power' => '', // 战力 ]; - return self::api('/llwf//role/add', $params); + return self::api('/llwf/role/add', $params); } private static function auth() @@ -139,6 +139,13 @@ class Lanhuo 'headers' => $headers, ]); $result = (string)$response->getBody(); + + Log::info( + 'LANHUO_POST[' . $uri . ']: ', + ['headers' => $headers, 'params' => $params, 'result' => $result], + 'lanhuo' + ); + return json_decode($result, true); } catch (\Exception $e) { Log::error('LANHUO_NET_ERROR[' . $uri . ']: ' . $e->getMessage(), $params, 'lanhuo'); diff --git a/app/Job/AfterLoginJob.php b/app/Job/AfterLoginJob.php index fe9b270..2a47beb 100644 --- a/app/Job/AfterLoginJob.php +++ b/app/Job/AfterLoginJob.php @@ -10,14 +10,10 @@ class AfterLoginJob extends Job { public function handle() { - $userId = (int)$this->params['user_id'] ?? 0; - $gameId = (int)$this->params['game_id'] ?? 0; - $loginTime = (int)$this->params['login_time'] ?? 0; - /** * @var UserService $userService */ $userService = make(UserService::class); - $userService->afterLogin($gameId, $userId, $loginTime); + $userService->afterLogin($this->params); } } \ No newline at end of file diff --git a/app/Service/PlayerRoleService.php b/app/Service/PlayerRoleService.php index 21f1c61..cef49af 100644 --- a/app/Service/PlayerRoleService.php +++ b/app/Service/PlayerRoleService.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Service; use App\Exception\BusinessException; +use App\Helper\Client\Lanhuo; use App\Model\Game; use App\Model\PlayerRole; use App\Model\Server; @@ -82,6 +83,20 @@ class PlayerRoleService extends Service $role->play_ip = $clientIp; $role->pipuid = $user->puid; $role->save(); + + if ($role->game_id) { + Lanhuo::addRole([ + 'user_id' => 111, + 'server_id' => 1, + 'server_name' => '测试', + 'role_id' => '111', + 'role_name' => '测试', + 'role_level' => 23, + 'profession_id' => '', // 职业ID + 'profession_name' => '', // 职业名称 + 'power' => '', // 战力 + ]); + } } private function saveServer(array $serverInfo, Game $game, int $time = 0) diff --git a/app/Service/SpendService.php b/app/Service/SpendService.php index 6c64ea8..0d99cbe 100644 --- a/app/Service/SpendService.php +++ b/app/Service/SpendService.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Service; use App\Exception\BusinessException; +use App\Helper\Client\Lanhuo; use App\Model\GameData; use App\Model\Spend; use App\Model\UserData; @@ -35,6 +36,22 @@ class SpendService extends Service $spend->event_status = 1; $spend->save(); + + // if (in_array($spend->game_id, [335, 336])) { + Lanhuo::addOrder([ + 'order_code' => $spend->pay_order_number, + 'user_id' => $spend->user_id, + 'account' => $spend->user_account, + 'server_id' => $spend->server_id, + 'server_name' => $spend->server_name, + 'role_id' => $spend->game_player_id, + 'role_name' => $spend->game_player_name, + 'game_name' => $spend->game_name, + 'order_amount' => $spend->pay_amount, + 'pay_time' => date('Y-m-d H:i:s', $spend->spend_time), + 'status' => $spend->pay_status, //支付状态(待支付 0 已支付 1 支付失败 2) + ]); + // } } private function saveUserPlayDataCountBySpend(Spend $spend) diff --git a/app/Service/UserService.php b/app/Service/UserService.php index 7dd0db0..6bee2c7 100644 --- a/app/Service/UserService.php +++ b/app/Service/UserService.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Service; use App\Exception\BusinessException; +use App\Helper\Client\Lanhuo; use App\Model\Player; use App\Model\PlayerRetention; use App\Model\User; @@ -12,8 +13,15 @@ use App\Helper\Log; class UserService extends Service { - public function afterLogin($gameId, $userId, $loginTime = 0) + public function afterLogin($params) { + $gameId = $params['game_id']; + $userId = $params['user_id']; + $loginTime = $params['login_time']; + $sdkVersion = $params['sdk_version']; + $deviceNumber = $params['device_number']; + $clientIp = $params['client_ip']; + if (empty($time)) { $loginTime = time(); } @@ -38,6 +46,17 @@ class UserService extends Service $playerRetention->{'day' . $retentionDay} = 1; $playerRetention->save(); } + + if (in_array($gameId, [335, 336])) { + $user = User::where('id', $userId)->first(['id', 'account', 'phone']); + Lanhuo::addLoginLog([ + 'user_id' => $userId, + 'account' => $user->account, + 'phone' => $user->phone, + 'device_type' => $sdkVersion ?? 1, // 设备类型(1-andriod 2-ios) + 'device_number' => $deviceNumber, + ]); + } } private function getRetentionDay($createTime, $loginTime) @@ -58,7 +77,18 @@ class UserService extends Service { Log::info('[USER-REGISTER]用户['. $userId . ']注册'); - $user = User::where('id', $userId)->first(['device_number', 'register_ip', 'id']); + $user = User::where('id', $userId)->first([ + 'id', + 'device_number', + 'register_ip', + 'fgame_id', + 'device_type', + 'account', + 'phone', + 'real_name', + 'idcard', + 'age_status', + ]); if (!$user) { throw new BusinessException('用户不存在'); } @@ -72,5 +102,18 @@ class UserService extends Service $user->save(); Log::info('[USER-REGISTER]用户['. $userId . ']为重复账号'); } + + if (in_array($user->fgame_id, [335, 336])) { + Lanhuo::addUser([ + 'user_id' => $user->id, + 'account' => $user->account, + 'phone' => $user->phone, + 'device_type' => $user->device_type ?? 1, // 设备类型(1-andriod 2-ios) + 'device_number' => $user->device_number, + 'name' => $user->real_name, + 'id_card' => $user->idcard, + 'is_real' => $user->age_status == 2 ? 1 : 0, // 是否实名(1-实名 0-未实名) + ]); + } } } \ No newline at end of file