This commit is contained in:
2025-12-24 16:59:05 +08:00
parent b52a51c09b
commit b68946fe79
218 changed files with 10790 additions and 3878 deletions
+26 -4
View File
@@ -85,7 +85,10 @@ class Utils
{
$url = Url::buildUrl($path);
//cp($url);
$res = json_decode(self::request($url, $data, $token), true);
$res = self::request($url, $data, $token);
//cp($data);
//cp($res);
$res = json_decode($res, true);
if($res['errCode'] !==0 ){
throw new \Exception($res['errMsg'],$res['errCode']);
//throw new \Exception($res['errDlt'],$res['errCode']);
@@ -139,10 +142,10 @@ class Utils
* 获取用户Token
* 如果缓存中没有,则自动获取并缓存
* @param string $userID 用户ID
* @param int $platformID 平台ID
* @param string $platformID 平台ID
* @return string|null
*/
public static function getUserToken(string $userID, int $platformID = 1): ?string
public static function getUserToken(string $userID, string $platformID = 'android'): ?string
{
$tokenManager = self::getTokenManager();
$token = $tokenManager->getUserToken($userID);
@@ -156,7 +159,7 @@ class Utils
$result = self::send(Url::$getUserToken, [
'userID' => $userID,
'platformID' => $platformID
'platformID' => self::getPlatformId($platformID)
], '获取用户Token失败', $adminToken);
$token = $result['token'];
@@ -181,4 +184,23 @@ class Utils
{
return self::getTokenManager()->clearToken($userID, $isAdmin);
}
public static function getPlatformId($name=''): int{
$arr = [
'ios' => 1,
'android' => 2,
'windows' => 3,
'macos' => 4,
'web' => 5,
'mp-weixin' => 6,
'linux' => 7,
'androidpad' => 8,
'ipad' => 9,
'admin' => 10,
];
$name = strtolower($name);
if(isset($arr[$name])){
return $arr[$name];
}
return 2;
}
}