erp/app/api/logic/shop/ShopLogic.php
2024-05-18 14:01:51 +08:00

29 lines
784 B
PHP

<?php
namespace app\api\logic\shop;
use app\api\service\UserTokenService;
use app\common\logic\BaseLogic;
use think\facade\Db;
class ShopLogic extends BaseLogic
{
public static function auth($token)
{
list(, $base64UrlPayload,) = explode('.', $token);
$payload = base64UrlDecode($base64UrlPayload);
$data = json_decode($payload, true);
if($data){
if($data['exp'] < time()){
return false;
}
$user=Db::name('user_auth_shop')->where('shop_uid',$data['jti'][0])->where('apply_status',1)->find();
if($user){
$userInfo = UserTokenService::setToken($user['user_id'], 6);
return $userInfo['token'];
}
}
return false;
}
}