|
@@ -17,8 +17,8 @@ class Util
|
|
# 获取某个setting值
|
|
# 获取某个setting值
|
|
public function setting($key, $account, $project = 'api')
|
|
public function setting($key, $account, $project = 'api')
|
|
{
|
|
{
|
|
- $setting = Dever::db('platform_setting', 'api')->find(['key' => $key]);
|
|
|
|
- $setting = Dever::db('account_setting', $project)->find(['account_id' => $account, 'platform_setting_id' => $setting['id']]);
|
|
|
|
|
|
+ $setting = Dever::db('api/platform_setting')->find(['key' => $key]);
|
|
|
|
+ $setting = Dever::db($project . '/account_setting')->find(['account_id' => $account, 'platform_setting_id' => $setting['id']]);
|
|
$value = $setting['value'] ?? 0;
|
|
$value = $setting['value'] ?? 0;
|
|
return $value;
|
|
return $value;
|
|
}
|
|
}
|
|
@@ -26,13 +26,14 @@ class Util
|
|
# 获取openid 仅jspai和小程序需要openid
|
|
# 获取openid 仅jspai和小程序需要openid
|
|
public function openid($account, $env, $uid, $result = [], $project = 'api')
|
|
public function openid($account, $env, $uid, $result = [], $project = 'api')
|
|
{
|
|
{
|
|
- $account = Dever::load('account', 'api')->get($account, $project);
|
|
|
|
|
|
+ $account = Dever::load(Account::class)->get($account, $project);
|
|
if ($account) {
|
|
if ($account) {
|
|
- $info = Dever::db('openid', 'api')->find(['account_id' => $account['id'], 'uid' => $uid, 'env' => $env]);
|
|
|
|
|
|
+ $info = Dever::db('api/openid')->find(['account_id' => $account['id'], 'uid' => $uid, 'env' => $env]);
|
|
if ($info) {
|
|
if ($info) {
|
|
$result['openid'] = $info['openid'];
|
|
$result['openid'] = $info['openid'];
|
|
} else {
|
|
} else {
|
|
- if ($env == 3) {
|
|
|
|
|
|
+ # 这里需要修改
|
|
|
|
+ if ($env == 3 || $env == 2) {
|
|
# jsapi 一般需要oauth授权
|
|
# jsapi 一般需要oauth授权
|
|
if (empty($result['t'])) {
|
|
if (empty($result['t'])) {
|
|
$result['t'] = \Dever\Helper\Secure::login($uid);
|
|
$result['t'] = \Dever\Helper\Secure::login($uid);
|
|
@@ -42,14 +43,14 @@ class Util
|
|
} elseif ($env == 5) {
|
|
} elseif ($env == 5) {
|
|
# 小程序
|
|
# 小程序
|
|
$param['js_code'] = Dever::input('applet_code', 'is_string', '登录信息');
|
|
$param['js_code'] = Dever::input('applet_code', 'is_string', '登录信息');
|
|
- $data = Dever::load('account', 'api')->run($account, 'applet_login', $param, $env, 'run', $project);
|
|
|
|
|
|
+ $data = Dever::load(Account::class)->run($account, 'applet_login', $param, $env, 'run', $project);
|
|
if (isset($data['openid'])) {
|
|
if (isset($data['openid'])) {
|
|
$result['openid'] = $data['openid'];
|
|
$result['openid'] = $data['openid'];
|
|
$update['uid'] = $uid;
|
|
$update['uid'] = $uid;
|
|
$update['account_id'] = $account['id'];
|
|
$update['account_id'] = $account['id'];
|
|
$update['env'] = $env;
|
|
$update['env'] = $env;
|
|
$update['openid'] = $data['openid'];
|
|
$update['openid'] = $data['openid'];
|
|
- Dever::db('openid', 'api')->insert($update);
|
|
|
|
|
|
+ Dever::db('api/openid')->insert($update);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -60,7 +61,7 @@ class Util
|
|
# 获取token
|
|
# 获取token
|
|
public function token($account, $env, $project = 'api')
|
|
public function token($account, $env, $project = 'api')
|
|
{
|
|
{
|
|
- $account = Dever::load('account', 'api')->get($account, $project);
|
|
|
|
|
|
+ $account = Dever::load(Account::clas)->get($account, $project);
|
|
$result = '';
|
|
$result = '';
|
|
if ($env == 5) {
|
|
if ($env == 5) {
|
|
$appid = 'applet_appid';
|
|
$appid = 'applet_appid';
|
|
@@ -70,19 +71,19 @@ class Util
|
|
$secret = $this->setting($secret, $account['id'], $project);
|
|
$secret = $this->setting($secret, $account['id'], $project);
|
|
if ($account && $appid && $secret) {
|
|
if ($account && $appid && $secret) {
|
|
$param = ['appid' => $appid, 'appsecret' => $secret];
|
|
$param = ['appid' => $appid, 'appsecret' => $secret];
|
|
- $info = Dever::db('token', 'api')->find($param);
|
|
|
|
|
|
+ $info = Dever::db('api/token')->find($param);
|
|
if ($info && time() <= $info['edate']) {
|
|
if ($info && time() <= $info['edate']) {
|
|
$result = $info['token'];
|
|
$result = $info['token'];
|
|
} else {
|
|
} else {
|
|
- $data = Dever::load('account', 'api')->run($account, 'access_token', $param, 1, 'run', $project);
|
|
|
|
|
|
+ $data = Dever::load(Account::clas)->run($account, 'access_token', $param, 1, 'run', $project);
|
|
if (isset($data['access_token'])) {
|
|
if (isset($data['access_token'])) {
|
|
$result = $data['access_token'];
|
|
$result = $data['access_token'];
|
|
$param['token'] = $result;
|
|
$param['token'] = $result;
|
|
$param['edate'] = time() + $data['expires_in'];
|
|
$param['edate'] = time() + $data['expires_in'];
|
|
if ($info) {
|
|
if ($info) {
|
|
- Dever::db('token', 'api')->update($info['id'], $param);
|
|
|
|
|
|
+ Dever::db('api/token')->update($info['id'], $param);
|
|
} else {
|
|
} else {
|
|
- Dever::db('token', 'api')->insert($param);
|
|
|
|
|
|
+ Dever::db('api/token')->insert($param);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -98,7 +99,7 @@ class Util
|
|
(
|
|
(
|
|
'id' => 1,
|
|
'id' => 1,
|
|
'name' => '格式转换',
|
|
'name' => '格式转换',
|
|
- 'children' => Dever::db('format', 'api')->select([]),
|
|
|
|
|
|
+ 'children' => Dever::db('api/format')->select([]),
|
|
);
|
|
);
|
|
|
|
|
|
$where = ['platform_id' => $platform_id];
|
|
$where = ['platform_id' => $platform_id];
|
|
@@ -107,14 +108,14 @@ class Util
|
|
(
|
|
(
|
|
'id' => 2,
|
|
'id' => 2,
|
|
'name' => '加密',
|
|
'name' => '加密',
|
|
- 'children' => Dever::db('platform_ssl', 'api')->select($where),
|
|
|
|
|
|
+ 'children' => Dever::db('api/platform_ssl')->select($where),
|
|
);
|
|
);
|
|
|
|
|
|
$data[] = array
|
|
$data[] = array
|
|
(
|
|
(
|
|
'id' => 3,
|
|
'id' => 3,
|
|
'name' => '签名',
|
|
'name' => '签名',
|
|
- 'children' => Dever::db('platform_sign', 'api')->select($where),
|
|
|
|
|
|
+ 'children' => Dever::db('api/platform_sign')->select($where),
|
|
);
|
|
);
|
|
return $data;
|
|
return $data;
|
|
}
|
|
}
|
|
@@ -122,15 +123,15 @@ class Util
|
|
# 获取签名列表
|
|
# 获取签名列表
|
|
public function getPlatformSign($platform_id)
|
|
public function getPlatformSign($platform_id)
|
|
{
|
|
{
|
|
- return Dever::db('platform_sign', 'api')->select(['platform_id' => $platform_id]);
|
|
|
|
|
|
+ return Dever::db('api/platform_sign')->select(['platform_id' => $platform_id]);
|
|
}
|
|
}
|
|
|
|
|
|
# 格式转换
|
|
# 格式转换
|
|
public function format($id, $value)
|
|
public function format($id, $value)
|
|
{
|
|
{
|
|
- $info = Dever::db('format', 'api')->find($id);
|
|
|
|
|
|
+ $info = Dever::db('api/format')->find($id);
|
|
if ($info) {
|
|
if ($info) {
|
|
- //$info['method'] = str_replace('{value}', "'{value}'", $info['method']);
|
|
|
|
|
|
+ $info['method'] = str_replace('{value}', "'{value}'", $info['method']);
|
|
$value = \Dever\Helper\Str::val($info['method'], ['value' => $value]);
|
|
$value = \Dever\Helper\Str::val($info['method'], ['value' => $value]);
|
|
}
|
|
}
|
|
return $value;
|
|
return $value;
|