master
elf 2 years ago
parent 29d0fca345
commit 88ba0d0749

@ -59,13 +59,13 @@ class JinlingCommand extends HyperfCommand
'power' => '', // 战力 'power' => '', // 战力
]); */ ]); */
/* Lanhuo::addLoginLog([ Lanhuo::addLoginLog([
'user_id' => 111, 'user_id' => 111,
'account' => 'bbbbbbbabc111', 'account' => 'bbbbbbbabc111',
'phone' => '18888888888', 'phone' => '18888888888',
'device_type' => 2, // 设备类型(1-andriod 2-ios) 'device_type' => 2, // 设备类型(1-andriod 2-ios)
'device_number' => 'ABCD', 'device_number' => 'ABCD',
]); */ ]);
/* Lanhuo::updateUser([ /* Lanhuo::updateUser([
'user_id' => 111, 'user_id' => 111,
@ -77,7 +77,7 @@ class JinlingCommand extends HyperfCommand
'is_real' => 1, // 是否实名(1-实名 0-未实名) 'is_real' => 1, // 是否实名(1-实名 0-未实名)
]); */ ]); */
Lanhuo::addOrder([ /* Lanhuo::addOrder([
'order_code' => 'sdflsdkflskdfsll', 'order_code' => 'sdflsdkflskdfsll',
'user_id' => 111, 'user_id' => 111,
'account' => 'bbbbbbbabc111', 'account' => 'bbbbbbbabc111',
@ -91,6 +91,6 @@ class JinlingCommand extends HyperfCommand
'order_amount' => '6.00', 'order_amount' => '6.00',
'pay_time' => date('Y-m-d H:i:s'), 'pay_time' => date('Y-m-d H:i:s'),
'status' => 1, //支付状态(待支付 0 已支付 1 支付失败 2) 'status' => 1, //支付状态(待支付 0 已支付 1 支付失败 2)
]); ]); */
} }
} }

@ -32,6 +32,10 @@ class GameEventController extends AbstractController
$userId = (int)$this->request->input('user_id', 0); $userId = (int)$this->request->input('user_id', 0);
$gameId = (int)$this->request->input('game_id', 0); $gameId = (int)$this->request->input('game_id', 0);
$loginTime = (int)$this->request->input('login_time', 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) { if (!$userId) {
throw new BusinessException('缺少参数[user_id]'); throw new BusinessException('缺少参数[user_id]');
} }
@ -44,7 +48,10 @@ class GameEventController extends AbstractController
Queue::push(AfterLoginJob::class, [ Queue::push(AfterLoginJob::class, [
'user_id' => $userId, 'user_id' => $userId,
'game_id' => $gameId, 'game_id' => $gameId,
'login_time' => $loginTime 'login_time' => $loginTime,
'sdk_version' => $sdkVersion,
'client_ip' => $clientIp,
'device_number' => $deviceNumber,
]); ]);
return $this->success(); return $this->success();
} }

@ -56,7 +56,7 @@ class Lanhuo
'device_type' => $data['device_type'], // 设备类型(1-andriod 2-ios) 'device_type' => $data['device_type'], // 设备类型(1-andriod 2-ios)
'device_number' => $data['device_number'], 'device_number' => $data['device_number'],
]; ];
return self::api('/llwf/user/AddLoginLog', $params); return self::api('/llwf/user/addLoginLog', $params);
} }
public static function addOrder($data) public static function addOrder($data)
@ -90,7 +90,7 @@ class Lanhuo
'profession_name' => '', // 职业名称 'profession_name' => '', // 职业名称
'power' => '', // 战力 'power' => '', // 战力
]; ];
return self::api('/llwf//role/add', $params); return self::api('/llwf/role/add', $params);
} }
private static function auth() private static function auth()
@ -139,6 +139,13 @@ class Lanhuo
'headers' => $headers, 'headers' => $headers,
]); ]);
$result = (string)$response->getBody(); $result = (string)$response->getBody();
Log::info(
'LANHUO_POST[' . $uri . ']: ',
['headers' => $headers, 'params' => $params, 'result' => $result],
'lanhuo'
);
return json_decode($result, true); return json_decode($result, true);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('LANHUO_NET_ERROR[' . $uri . ']: ' . $e->getMessage(), $params, 'lanhuo'); Log::error('LANHUO_NET_ERROR[' . $uri . ']: ' . $e->getMessage(), $params, 'lanhuo');

@ -10,14 +10,10 @@ class AfterLoginJob extends Job
{ {
public function handle() 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 * @var UserService $userService
*/ */
$userService = make(UserService::class); $userService = make(UserService::class);
$userService->afterLogin($gameId, $userId, $loginTime); $userService->afterLogin($this->params);
} }
} }

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Service; namespace App\Service;
use App\Exception\BusinessException; use App\Exception\BusinessException;
use App\Helper\Client\Lanhuo;
use App\Model\Game; use App\Model\Game;
use App\Model\PlayerRole; use App\Model\PlayerRole;
use App\Model\Server; use App\Model\Server;
@ -82,6 +83,20 @@ class PlayerRoleService extends Service
$role->play_ip = $clientIp; $role->play_ip = $clientIp;
$role->pipuid = $user->puid; $role->pipuid = $user->puid;
$role->save(); $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) private function saveServer(array $serverInfo, Game $game, int $time = 0)

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Service; namespace App\Service;
use App\Exception\BusinessException; use App\Exception\BusinessException;
use App\Helper\Client\Lanhuo;
use App\Model\GameData; use App\Model\GameData;
use App\Model\Spend; use App\Model\Spend;
use App\Model\UserData; use App\Model\UserData;
@ -35,6 +36,22 @@ class SpendService extends Service
$spend->event_status = 1; $spend->event_status = 1;
$spend->save(); $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) private function saveUserPlayDataCountBySpend(Spend $spend)

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Service; namespace App\Service;
use App\Exception\BusinessException; use App\Exception\BusinessException;
use App\Helper\Client\Lanhuo;
use App\Model\Player; use App\Model\Player;
use App\Model\PlayerRetention; use App\Model\PlayerRetention;
use App\Model\User; use App\Model\User;
@ -12,8 +13,15 @@ use App\Helper\Log;
class UserService extends Service 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)) { if (empty($time)) {
$loginTime = time(); $loginTime = time();
} }
@ -38,6 +46,17 @@ class UserService extends Service
$playerRetention->{'day' . $retentionDay} = 1; $playerRetention->{'day' . $retentionDay} = 1;
$playerRetention->save(); $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) private function getRetentionDay($createTime, $loginTime)
@ -58,7 +77,18 @@ class UserService extends Service
{ {
Log::info('[USER-REGISTER]用户['. $userId . ']注册'); 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) { if (!$user) {
throw new BusinessException('用户不存在'); throw new BusinessException('用户不存在');
} }
@ -72,5 +102,18 @@ class UserService extends Service
$user->save(); $user->save();
Log::info('[USER-REGISTER]用户['. $userId . ']为重复账号'); 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-未实名)
]);
}
} }
} }
Loading…
Cancel
Save