|
|
|
@ -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-未实名)
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|