【程序目录】优化易联云小票打印流程

This commit is contained in:
吴昊天 2022-12-16 16:54:32 +08:00
parent 60c2b28cba
commit d8a561c311
2 changed files with 3 additions and 15 deletions

View File

@ -80,7 +80,6 @@ class AccessToken extends HttpService
$this->machineCode = $config['terminal'] ?? null;
$this->name = $name;
$this->configFile = $configFile;
$this->apiUrl = Config::get($this->configFile . '.stores.' . $this->name . '.apiUrl', 'https://open-api.10ss.net/');
}
/**
@ -112,7 +111,7 @@ class AccessToken extends HttpService
/** @var CacheServices $cacheServices */
$cacheServices = app()->make(CacheServices::class);
$this->accessToken[$this->name] = $cacheServices->getDbCache('YLY_access_token', function () {
$request = self::postRequest($this->apiUrl . 'oauth/oauth', [
$request = self::postRequest('https://open-api.10ss.net/auth/oauth', [
'client_id' => $this->clientId,
'grant_type' => 'client_credentials',
'sign' => strtolower(md5($this->clientId . time() . $this->apiKey)),
@ -127,22 +126,13 @@ class AccessToken extends HttpService
return $request['body']['access_token'] ?? '';
}
return '';
},86400);
}, 86400);
if (!$this->accessToken[$this->name])
throw new AdminException(400718);
return $this->accessToken[$this->name];
}
/**
* 获取请求链接
* @return string
*/
public function getApiUrl(string $url = '')
{
return $url ? $this->apiUrl . $url : $this->apiUrl;
}
/**
* 生成UUID4
* @return string

View File

@ -39,7 +39,7 @@ class YiLianYun extends BasePrinter
if (!$this->printerContent) {
return $this->setError('Missing print');
}
$request = $this->accessToken->postRequest($this->accessToken->getApiUrl('print/index'), [
$request = $this->accessToken->postRequest('https://open-api.10ss.net/print/index', [
'client_id' => $this->accessToken->clientId,
'access_token' => $this->accessToken->getAccessToken(),
'machine_code' => $this->accessToken->machineCode,
@ -103,6 +103,4 @@ class YiLianYun extends BasePrinter
CONTENT;
return $this;
}
}