mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-29 14:01:07 +00:00
【程序目录】更新优化功能,更新安装sql
This commit is contained in:
parent
b5e47dd0fc
commit
8988e9f965
@ -54,7 +54,7 @@ class Common extends AuthController
|
||||
// 正常域名
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $host,
|
||||
'label' => 19,
|
||||
'label' => 34,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
@ -64,7 +64,7 @@ class Common extends AuthController
|
||||
$host = str_replace('test.', '', $host);
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $host,
|
||||
'label' => 19,
|
||||
'label' => 34,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
@ -75,7 +75,7 @@ class Common extends AuthController
|
||||
$host = str_replace('www.', '', $host);
|
||||
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
|
||||
'domain_name' => $host,
|
||||
'label' => 19,
|
||||
'label' => 34,
|
||||
'version' => $version
|
||||
]);
|
||||
$res = $res ? json_decode($res, true) : [];
|
||||
|
||||
@ -97,10 +97,12 @@ class Login extends AuthController
|
||||
return app('json')->fail(400336);
|
||||
}
|
||||
|
||||
try {
|
||||
aj_captcha_check_two($captchaType, $captchaVerification);
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail(400336);
|
||||
if ($captchaVerification != '') {
|
||||
try {
|
||||
aj_captcha_check_two($captchaType, $captchaVerification);
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail(400336);
|
||||
}
|
||||
}
|
||||
|
||||
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
|
||||
|
||||
@ -96,6 +96,9 @@ class Express extends AuthController
|
||||
['account', ''],
|
||||
['key', ''],
|
||||
['net_name', ''],
|
||||
['courier_name', ''],
|
||||
['customer_name', ''],
|
||||
['code_name', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]]);
|
||||
if (!$expressInfo = $this->services->get($id)) return app('json')->fail(100026);
|
||||
@ -108,9 +111,21 @@ class Express extends AuthController
|
||||
if ($expressInfo['net'] == 1 && !$data['net_name']) {
|
||||
return app('json')->fail(400404);
|
||||
}
|
||||
if ($expressInfo['check_man'] == 1 && !$data['courier_name']) {
|
||||
return app('json')->fail(500001);
|
||||
}
|
||||
if ($expressInfo['partner_name'] == 1 && !$data['customer_name']) {
|
||||
return app('json')->fail(500002);
|
||||
}
|
||||
if ($expressInfo['is_code'] == 1 && !$data['code_name']) {
|
||||
return app('json')->fail(500003);
|
||||
}
|
||||
$expressInfo->account = $data['account'];
|
||||
$expressInfo->key = $data['key'];
|
||||
$expressInfo->net_name = $data['net_name'];
|
||||
$expressInfo->courier_name = $data['courier_name'];
|
||||
$expressInfo->customer_name = $data['customer_name'];
|
||||
$expressInfo->code_name = $data['code_name'];
|
||||
$expressInfo->sort = $data['sort'];
|
||||
$expressInfo->is_show = $data['is_show'];
|
||||
$expressInfo->status = 1;
|
||||
|
||||
@ -65,6 +65,7 @@ class LangCountry extends AuthController
|
||||
$data = $this->request->postMore([
|
||||
['name', ''],
|
||||
['code', ''],
|
||||
['type_id', 0],
|
||||
]);
|
||||
$this->services->langCountrySave($id, $data);
|
||||
return app('json')->success(100000);
|
||||
|
||||
@ -69,6 +69,18 @@ class LangType extends AuthController
|
||||
return app('json')->success(100000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改语言类型状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function langTypeStatus($id, $status)
|
||||
{
|
||||
$this->services->langTypeStatus($id, $status);
|
||||
return app('json')->success(100014);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除语言类型
|
||||
* @param int $id
|
||||
|
||||
@ -331,6 +331,9 @@ class SystemConfig extends AuthController
|
||||
@copy($from, $toHome);
|
||||
@copy($from, $toPublic);
|
||||
}
|
||||
if(isset($post['reward_integral']) || isset($post['reward_money'])) {
|
||||
if($post['reward_integral'] < 0 || $post['reward_money'] < 0) return app('json')->fail(400558);
|
||||
}
|
||||
foreach ($post as $k => $v) {
|
||||
$config_one = $this->services->getOne(['menu_name' => $k]);
|
||||
if ($config_one) {
|
||||
|
||||
@ -61,8 +61,9 @@ class SystemFile extends AuthController
|
||||
$adminInfo = $this->request->adminInfo();
|
||||
if (!$adminInfo) return app('json')->fail(100101);
|
||||
if ($adminInfo['level'] != 0) return app('json')->fail(100101);
|
||||
if ($password === '') return app('json')->fail(400256);
|
||||
|
||||
return app('json')->success($this->services->login($adminInfo['account'], $password, 'admin_edit'));
|
||||
return app('json')->success($this->services->login($password, 'file_edit'));
|
||||
}
|
||||
|
||||
//打开目录
|
||||
@ -104,7 +105,7 @@ class SystemFile extends AuthController
|
||||
*/
|
||||
public function createFolder()
|
||||
{
|
||||
[$path,$name] = $this->request->postMore([
|
||||
[$path, $name] = $this->request->postMore([
|
||||
['path', ''],
|
||||
['name', '']
|
||||
], true);
|
||||
@ -113,19 +114,18 @@ class SystemFile extends AuthController
|
||||
}
|
||||
$data = [];
|
||||
try {
|
||||
$res = $this->services->createFolder($path,$name);
|
||||
if($res)
|
||||
{
|
||||
$res = $this->services->createFolder($path, $name);
|
||||
if ($res) {
|
||||
$data = [
|
||||
'children' => [],
|
||||
'contextmenu'=> true,
|
||||
'isDir'=> true,
|
||||
'loading'=> false,
|
||||
'path'=> $path,
|
||||
'pathname'=> $path . DS . $name,
|
||||
'title'=> $name,
|
||||
'contextmenu' => true,
|
||||
'isDir' => true,
|
||||
'loading' => false,
|
||||
'path' => $path,
|
||||
'pathname' => $path . DS . $name,
|
||||
'title' => $name,
|
||||
];
|
||||
}else{
|
||||
} else {
|
||||
return app('json')->fail(100005);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@ -143,7 +143,7 @@ class SystemFile extends AuthController
|
||||
*/
|
||||
public function createFile()
|
||||
{
|
||||
[$path,$name] = $this->request->postMore([
|
||||
[$path, $name] = $this->request->postMore([
|
||||
['path', ''],
|
||||
['name', '']
|
||||
], true);
|
||||
@ -152,19 +152,18 @@ class SystemFile extends AuthController
|
||||
}
|
||||
$data = [];
|
||||
try {
|
||||
$res = $this->services->createFile($path,$name);
|
||||
if($res)
|
||||
{
|
||||
$res = $this->services->createFile($path, $name);
|
||||
if ($res) {
|
||||
$data = [
|
||||
'children' => [],
|
||||
'contextmenu'=> true,
|
||||
'isDir'=> false,
|
||||
'loading'=> false,
|
||||
'path'=> $path,
|
||||
'pathname'=> $path . DS . $name,
|
||||
'title'=> $name,
|
||||
'contextmenu' => true,
|
||||
'isDir' => false,
|
||||
'loading' => false,
|
||||
'path' => $path,
|
||||
'pathname' => $path . DS . $name,
|
||||
'title' => $name,
|
||||
];
|
||||
}else{
|
||||
} else {
|
||||
return app('json')->fail(100005);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@ -196,9 +195,16 @@ class SystemFile extends AuthController
|
||||
return app('json')->success(100010);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件重命名
|
||||
* @return mixed
|
||||
*
|
||||
* @date 2022/09/28
|
||||
* @author yyw
|
||||
*/
|
||||
public function rename()
|
||||
{
|
||||
[$newname,$oldname] = $this->request->postMore([
|
||||
[$newname, $oldname] = $this->request->postMore([
|
||||
['newname', ''],
|
||||
['oldname', '']
|
||||
], true);
|
||||
@ -206,7 +212,7 @@ class SystemFile extends AuthController
|
||||
return app('json')->fail(410087);
|
||||
}
|
||||
try {
|
||||
$this->services->rename($newname,$oldname);
|
||||
$this->services->rename($newname, $oldname);
|
||||
} catch (\Exception $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
|
||||
@ -165,6 +165,7 @@ class User extends AuthController
|
||||
$this->services->transaction(function () use ($data, $label) {
|
||||
$res = true;
|
||||
$userInfo = $this->services->save($data);
|
||||
$this->services->rewardNewUser((int)$userInfo->uid);
|
||||
if ($label) {
|
||||
$res = $this->services->saveSetLabel([$userInfo->uid], $label);
|
||||
}
|
||||
|
||||
@ -29,14 +29,6 @@ class AdminAuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
$authInfo = null;
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
// 获取文件token,让其失效
|
||||
$invalid_token = trim(ltrim($request->header(Config::get('cookie.invalid_token_name', 'Invalid-zation')), 'Bearer'));
|
||||
if($invalid_token)
|
||||
{
|
||||
$md5Token = md5($invalid_token);
|
||||
$res = CacheService::clearToken($md5Token);
|
||||
}
|
||||
|
||||
/** @var AdminAuthServices $service */
|
||||
$service = app()->make(AdminAuthServices::class);
|
||||
$adminInfo = $service->parseToken($token);
|
||||
|
||||
@ -14,8 +14,10 @@ namespace app\adminapi\middleware;
|
||||
|
||||
use app\Request;
|
||||
use app\services\system\admin\AdminAuthServices;
|
||||
use app\services\system\log\SystemFileServices;
|
||||
use crmeb\exceptions\AuthException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\services\CacheService;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
@ -27,26 +29,11 @@ class AdminEditorTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$authInfo = null;
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
$token = CacheService::get(trim($request->get('fileToken')));
|
||||
|
||||
/** @var AdminAuthServices $service */
|
||||
$service = app()->make(AdminAuthServices::class);
|
||||
$adminInfo = $service->parseToken($token,110008);
|
||||
if($adminInfo['type'] !== 'admin_edit')
|
||||
{
|
||||
throw new AuthException('登陆异常,请重新登录',[],110008);
|
||||
}
|
||||
Request::macro('isAdminLogin', function () use (&$adminInfo) {
|
||||
return !is_null($adminInfo);
|
||||
});
|
||||
Request::macro('adminId', function () use (&$adminInfo) {
|
||||
return $adminInfo['id'];
|
||||
});
|
||||
|
||||
Request::macro('adminInfo', function () use (&$adminInfo) {
|
||||
return $adminInfo;
|
||||
});
|
||||
/** @var SystemFileServices $service */
|
||||
$service = app()->make(SystemFileServices::class);
|
||||
$service->parseToken($token);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@ -185,6 +185,8 @@ Route::group('setting', function () {
|
||||
Route::post('lang_type/save/:id', 'v1.setting.LangType/langTypeSave')->option(['real_name' => '保存新增修改语言']);
|
||||
//删除语言
|
||||
Route::delete('lang_type/del/:id', 'v1.setting.LangType/langTypeDel')->option(['real_name' => '删除语言']);
|
||||
//修改语言类型状态
|
||||
Route::put('lang_type/status/:id/:status', 'v1.setting.LangType/langTypeStatus')->option(['real_name' => '修改语言类型状态']);
|
||||
//获取语言列表
|
||||
Route::get('lang_code/list', 'v1.setting.LangCode/langCodeList')->option(['real_name' => '语言列表']);
|
||||
//获取语言信息
|
||||
|
||||
@ -121,8 +121,9 @@ Route::group('system', function () {
|
||||
Route::get('file/rename', 'v1.system.SystemFile/rename')->option(['real_name' => '重命名文件夹']);
|
||||
})->middleware([
|
||||
\app\http\middleware\AllowOriginMiddleware::class,
|
||||
\app\adminapi\middleware\AdminEditorTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
|
||||
\app\adminapi\middleware\AdminEditorTokenMiddleware::class,
|
||||
\app\adminapi\middleware\AdminLogMiddleware::class
|
||||
]);
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class PublicController
|
||||
{
|
||||
$data['contact_number'] = sys_config('contact_number');
|
||||
$data['company_address'] = sys_config('company_address');
|
||||
$data['copyright'] = sys_config('copyright');
|
||||
$data['copyright'] = sys_config('nncnL_crmeb_copyright', '');
|
||||
$data['record_No'] = sys_config('record_No');
|
||||
$data['site_name'] = sys_config('site_name');
|
||||
$data['site_keywords'] = sys_config('site_keywords');
|
||||
|
||||
@ -89,6 +89,7 @@ class StoreOrderController
|
||||
['type', ''],
|
||||
['field_key', ''],
|
||||
['field_value', ''],
|
||||
['keywords', '', '', 'real_name']
|
||||
]);
|
||||
$where['is_system_del'] = 0;
|
||||
if (!in_array($where['status'], [-1, -2, -3])) {
|
||||
|
||||
@ -82,8 +82,8 @@ class Login extends BaseController
|
||||
'appid' => sys_config('wechat_open_app_id', 'wxc736972a4ca1e2a1'),
|
||||
'version' => get_crmeb_version(),
|
||||
'site_name' => sys_config('site_name'),
|
||||
'copyright' => sys_config('nncnL_crmeb_copyright'),
|
||||
'copyrightImg' => sys_config('nncnL_crmeb_copyright_image'),
|
||||
'copyright' => sys_config('nncnL_crmeb_copyright', ''),
|
||||
'copyrightImg' => sys_config('nncnL_crmeb_copyright_image', ''),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ class LangCode extends BaseModel
|
||||
*/
|
||||
public function searchRemarksAttr($query, $value)
|
||||
{
|
||||
if ($value !== '') $query->where('remarks', 'like', '%' . $value . '%');
|
||||
if ($value !== '') $query->where('remarks|code|lang_explain', 'like', '%' . $value . '%');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -86,9 +86,12 @@ class ExpressServices extends BaseServices
|
||||
*/
|
||||
public function createExpressForm(array $formData = [])
|
||||
{
|
||||
if (isset($formData['partner_id']) && $formData['partner_id'] == 1) $field[] = Form::input('account', '月结账号', $formData['account'] ?? '');
|
||||
if (isset($formData['partner_key']) && $formData['partner_key'] == 1) $field[] = Form::input('key', '月结密码', $formData['key'] ?? '');
|
||||
if (isset($formData['net']) && $formData['net'] == 1) $field[] = Form::input('net_name', '取件网点', $formData['net_name'] ?? '');
|
||||
if (isset($formData['partner_id']) && $formData['partner_id'] == 1) $field[] = Form::input('account', '月结账号', $formData['account'] ?? '')->required();
|
||||
if (isset($formData['partner_key']) && $formData['partner_key'] == 1) $field[] = Form::input('key', '月结密码', $formData['key'] ?? '')->required();
|
||||
if (isset($formData['net']) && $formData['net'] == 1) $field[] = Form::input('net_name', '取件网点', $formData['net_name'] ?? '')->required();
|
||||
if (isset($formData['check_man']) && $formData['check_man'] == 1) $field[] = Form::input('courier_name', '承载快递员名', $formData['net_name'] ?? '')->required();
|
||||
if (isset($formData['partner_name']) && $formData['partner_name'] == 1) $field[] = Form::input('customer_name', '客户账户名称', $formData['net_name'] ?? '')->required();
|
||||
if (isset($formData['is_code']) && $formData['is_code'] == 1) $field[] = Form::input('code_name', '电子面单承载编号', $formData['net_name'] ?? '')->required();
|
||||
$field[] = Form::number('sort', '排序', (int)($formData['sort'] ?? 0))->precision(0);
|
||||
$field[] = Form::radio('is_show', '是否启用', $formData['is_show'] ?? 1)->options([['value' => 0, 'label' => '隐藏'], ['value' => 1, 'label' => '启用']]);
|
||||
return $field;
|
||||
@ -253,10 +256,13 @@ class ExpressServices extends BaseServices
|
||||
$data['code'] = $express['code'] ?? '';
|
||||
$data['partner_id'] = $express['partner_id'] ?? '';
|
||||
$data['partner_key'] = $express['partner_key'] ?? '';
|
||||
$data['check_man'] = $express['check_man'] ?? '';
|
||||
$data['partner_name'] = $express['partner_name'] ?? '';
|
||||
$data['is_code'] = $express['is_code'] ?? '';
|
||||
$data['net'] = $express['net'] ?? '';
|
||||
$data['is_show'] = 1;
|
||||
$data['status'] = 0;
|
||||
if ($express['partner_id'] == 0 && $express['partner_key'] == 0 && $express['net'] == 0) {
|
||||
if ($express['partner_id'] == 0 && $express['partner_key'] == 0 && $express['net'] == 0 && $express['check_man'] == 0 && $express['partner_name'] == 0 && $express['is_code'] == 0) {
|
||||
$data['status'] = 1;
|
||||
}
|
||||
$data_all[] = $data;
|
||||
|
||||
@ -163,7 +163,7 @@ class SystemAdminServices extends BaseServices
|
||||
'logo_rectangle' => sys_config('site_logo'),//方形
|
||||
'login_logo' => sys_config('login_logo'),//登陆
|
||||
'site_name' => sys_config('site_name'),
|
||||
'copyright' => sys_config('nncnL_crmeb_copyright'),
|
||||
'copyright' => sys_config('nncnL_crmeb_copyright', ''),
|
||||
'version' => get_crmeb_version(),
|
||||
'key' => $key
|
||||
];
|
||||
@ -367,6 +367,7 @@ class SystemAdminServices extends BaseServices
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前管理员文件管理密码
|
||||
* @param int $id
|
||||
|
||||
@ -30,6 +30,16 @@ class LangCountryServices extends BaseServices
|
||||
{
|
||||
[$page, $limit] = $this->getPageValue();
|
||||
$list = $this->dao->selectList($where, '*', $page, $limit, 'id desc', true)->toArray();
|
||||
/** @var LangTypeServices $langTypeServices */
|
||||
$langTypeServices = app()->make(LangTypeServices::class);
|
||||
$langTypeList = $langTypeServices->getColumn([], 'language_name,file_name,id', 'id');
|
||||
foreach ($list as &$item) {
|
||||
if (isset($langTypeList[$item['type_id']])) {
|
||||
$item['link_lang'] = $langTypeList[$item['type_id']]['language_name'] . '(' . $langTypeList[$item['type_id']]['file_name'] . ')';
|
||||
} else {
|
||||
$item['link_lang'] = '';
|
||||
}
|
||||
}
|
||||
$count = $this->dao->count($where);
|
||||
return compact('list', 'count');
|
||||
}
|
||||
@ -49,6 +59,17 @@ class LangCountryServices extends BaseServices
|
||||
$field = [];
|
||||
$field[] = Form::input('name', '所属地区', $info['name'] ?? '')->required('请填写所属地区');
|
||||
$field[] = Form::input('code', '语言码', $info['code'] ?? '')->required('请填写语言码');
|
||||
/** @var LangTypeServices $langTypeServices */
|
||||
$langTypeServices = app()->make(LangTypeServices::class);
|
||||
$list = $langTypeServices->getColumn(['is_del' => 0, 'status' => 1], 'language_name,file_name,id', 'id');
|
||||
$setOption = function () use ($list) {
|
||||
$menus = [];
|
||||
foreach ($list as $item) {
|
||||
$menus[] = ['value' => $item['id'], 'label' => $item['language_name'] . '(' . $item['file_name'] . ')'];
|
||||
}
|
||||
return $menus;
|
||||
};
|
||||
$field[] = Form::select('type_id', '语言类型', $info['type_id'] ?? 0)->setOptions(Form::setOptions($setOption))->filterable(true);
|
||||
return create_form($id ? '修改语言地区' : '新增语言地区', $field, Url::buildUrl('/setting/lang_country/save/' . $id), 'POST');
|
||||
}
|
||||
|
||||
|
||||
@ -83,6 +83,19 @@ class LangTypeServices extends BaseServices
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改语言类型状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return bool
|
||||
*/
|
||||
public function langTypeStatus($id, $status)
|
||||
{
|
||||
$res = $this->dao->update(['id' => $id], ['status' => $status]);
|
||||
if(!$res) throw new AdminException(100015);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除语言类型
|
||||
* @param int $id
|
||||
|
||||
@ -16,8 +16,11 @@ use app\dao\system\log\SystemFileDao;
|
||||
use app\services\BaseServices;
|
||||
use app\services\system\admin\SystemAdminServices;
|
||||
use crmeb\exceptions\AdminException;
|
||||
use crmeb\exceptions\AuthException;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\FileService as FileClass;
|
||||
use crmeb\utils\JwtAuth;
|
||||
use Firebase\JWT\ExpiredException;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
@ -49,19 +52,83 @@ class SystemFileServices extends BaseServices
|
||||
* @date 2022/09/07
|
||||
* @author yyw
|
||||
*/
|
||||
public function Login($account, string $password, string $type)
|
||||
public function Login(string $password, string $type)
|
||||
{
|
||||
/** @var SystemAdminServices $adminServer */
|
||||
$adminServer = app()->make(SystemAdminServices::class);
|
||||
$adminInfo = $adminServer->verifyFileLogin($account, $password);
|
||||
$tokenInfo = $this->createToken($adminInfo->id, $type,$adminInfo->pwd);
|
||||
if (config('filesystem.password') !== $password) {
|
||||
throw new AdminException(400140);
|
||||
}
|
||||
$md5Password = md5($password);
|
||||
/** @var JwtAuth $jwtAuth */
|
||||
$jwtAuth = app()->make(JwtAuth::class);
|
||||
$tokenInfo = $jwtAuth->createToken($md5Password, $type, ['pwd' => $md5Password]);
|
||||
CacheService::set(md5($tokenInfo['token']), $tokenInfo['token'], 3600);
|
||||
return [
|
||||
'token' => $tokenInfo['token'],
|
||||
'token' => md5($tokenInfo['token']),
|
||||
'expires_time' => $tokenInfo['params']['exp'],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Admin授权信息
|
||||
* @param string $token
|
||||
* @return bool
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function parseToken(string $token): bool
|
||||
{
|
||||
/** @var CacheService $cacheService */
|
||||
$cacheService = app()->make(CacheService::class);
|
||||
|
||||
if (!$token || $token === 'undefined') {
|
||||
throw new AuthException(110008);
|
||||
}
|
||||
|
||||
/** @var JwtAuth $jwtAuth */
|
||||
$jwtAuth = app()->make(JwtAuth::class);
|
||||
//设置解析token
|
||||
[$id, $type, $pwd] = $jwtAuth->parseToken($token);
|
||||
|
||||
//检测token是否过期
|
||||
$md5Token = md5($token);
|
||||
if (!$cacheService->hasToken($md5Token) || !($cacheToken = $cacheService->getTokenBucket($md5Token))) {
|
||||
throw new AuthException(110008);
|
||||
}
|
||||
|
||||
//是否超出有效次数
|
||||
if (isset($cacheToken['invalidNum']) && $cacheToken['invalidNum'] >= 3) {
|
||||
if (!request()->isCli()) {
|
||||
$cacheService->clearToken($md5Token);
|
||||
}
|
||||
throw new AuthException(110008);
|
||||
}
|
||||
|
||||
//验证token
|
||||
try {
|
||||
$jwtAuth->verifyToken();
|
||||
$cacheService->setTokenBucket($md5Token, $cacheToken, $cacheToken['exp']);
|
||||
} catch (ExpiredException $e) {
|
||||
$cacheToken['invalidNum'] = isset($cacheToken['invalidNum']) ? $cacheToken['invalidNum']++ : 1;
|
||||
$cacheService->setTokenBucket($md5Token, $cacheToken, $cacheToken['exp']);
|
||||
} catch (\Throwable $e) {
|
||||
if (!request()->isCli()) {
|
||||
$cacheService->clearToken($md5Token);
|
||||
}
|
||||
|
||||
throw new AuthException(110008);
|
||||
}
|
||||
|
||||
if ($id !== md5(config('filesystem.password'))) {
|
||||
throw new AuthException(110008);
|
||||
}
|
||||
|
||||
if ($pwd !== md5(config('filesystem.password'))) {
|
||||
throw new AuthException(110008);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件校验列表
|
||||
@ -201,7 +268,6 @@ class SystemFileServices extends BaseServices
|
||||
$dir = !empty($request_dir) ? $request_dir : $rootdir;
|
||||
$dir = rtrim($dir, DS) . DS . app('request')->param('filedir');
|
||||
}
|
||||
Log::error(['dir'=>$dir]);
|
||||
$list = scandir($dir);
|
||||
foreach ($list as $key => $v) {
|
||||
if ($v != '.' && $v != '..') {
|
||||
@ -226,14 +292,14 @@ class SystemFileServices extends BaseServices
|
||||
$list[$key]['mtime'] = date('Y-m-d H:i:s', $value['mtime']);
|
||||
|
||||
$navList[$key]['title'] = $value['filename'];
|
||||
if($value['isDir']) $navList[$key]['loading'] = false;
|
||||
if ($value['isDir']) $navList[$key]['loading'] = false;
|
||||
$navList[$key]['children'] = [];
|
||||
$navList[$key]['path'] = $value['path'];
|
||||
$navList[$key]['isDir'] = $value['isDir'];
|
||||
$navList[$key]['pathname'] = $value['pathname'];
|
||||
$navList[$key]['contextmenu'] = true;
|
||||
}
|
||||
return compact('dir', 'list','navList');
|
||||
return compact('dir', 'list', 'navList');
|
||||
}
|
||||
|
||||
//读取文件
|
||||
@ -242,7 +308,7 @@ class SystemFileServices extends BaseServices
|
||||
$filepath = $this->formatPath($filepath);
|
||||
$content = FileClass::readFile($filepath);//防止页面内嵌textarea标签
|
||||
$ext = FileClass::getExt($filepath);
|
||||
$encoding = mb_detect_encoding($content, mb_detect_order());
|
||||
$encoding = mb_detect_encoding($content, mb_detect_order());
|
||||
//前端组件支持的语言类型
|
||||
//['plaintext', 'json', 'abap', 'apex', 'azcli', 'bat', 'cameligo', 'clojure', 'coffeescript', 'c', 'cpp', 'csharp', 'csp', 'css', 'dart', 'dockerfile', 'fsharp', 'go', 'graphql', 'handlebars', 'hcl', 'html', 'ini', 'java', 'javascript', 'julia', 'kotlin', 'less', 'lexon', 'lua', 'markdown', 'mips', 'msdax', 'mysql', 'objective-c', 'pascal', 'pascaligo', 'perl', 'pgsql', 'php', 'postiats', 'powerquery', 'powershell', 'pug', 'python', 'r', 'razor', 'redis', 'redshift', 'restructuredtext', 'ruby', 'rust', 'sb', 'scala', 'scheme', 'scss', 'shell', 'sol', 'aes', 'sql', 'st', 'swift', 'systemverilog', 'verilog', 'tcl', 'twig', 'typescript', 'vb', 'xml', 'yaml']
|
||||
|
||||
@ -255,7 +321,7 @@ class SystemFileServices extends BaseServices
|
||||
, 'php' => 'php'
|
||||
, 'sql' => 'mysql'
|
||||
, 'css' => 'css'
|
||||
, 'txt'=>'plaintext'
|
||||
, 'txt' => 'plaintext'
|
||||
, 'vue' => 'html'
|
||||
, 'json' => 'json'
|
||||
, 'lock' => 'json'
|
||||
@ -266,11 +332,11 @@ class SystemFileServices extends BaseServices
|
||||
|
||||
];
|
||||
$mode = empty($extarray[$ext]) ? 'php' : $extarray[$ext];
|
||||
return compact('content', 'mode', 'filepath','encoding');
|
||||
return compact('content', 'mode', 'filepath', 'encoding');
|
||||
}
|
||||
|
||||
//保存文件
|
||||
public function savefile($filepath,$comment)
|
||||
public function savefile($filepath, $comment)
|
||||
{
|
||||
$filepath = $this->formatPath($filepath);
|
||||
if (!FileClass::isWritable($filepath)) {
|
||||
@ -280,12 +346,12 @@ class SystemFileServices extends BaseServices
|
||||
}
|
||||
|
||||
// 文件重命名
|
||||
public function rename($newname,$oldname)
|
||||
public function rename($newname, $oldname)
|
||||
{
|
||||
if (($newname != $oldname) && is_writable($oldname)) {
|
||||
return rename($oldname, $newname);
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -300,8 +366,7 @@ class SystemFileServices extends BaseServices
|
||||
public function delFolder(string $path)
|
||||
{
|
||||
$path = $this->formatPath($path);
|
||||
if(is_file($path))
|
||||
{
|
||||
if (is_file($path)) {
|
||||
return unlink($path);
|
||||
}
|
||||
$dir = opendir($path);
|
||||
@ -331,10 +396,10 @@ class SystemFileServices extends BaseServices
|
||||
*/
|
||||
public function createFolder(string $path, string $name, int $permissions = 0755)
|
||||
{
|
||||
$path = $this->formatPath($path,$name);
|
||||
$path = $this->formatPath($path, $name);
|
||||
/** @var FileClass $fileClass */
|
||||
$fileClass = app()->make(FileClass::class);
|
||||
return $fileClass->createDir($path,$permissions);
|
||||
return $fileClass->createDir($path, $permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -348,14 +413,15 @@ class SystemFileServices extends BaseServices
|
||||
*/
|
||||
public function createFile(string $path, string $name)
|
||||
{
|
||||
$path = $this->formatPath($path,$name);
|
||||
$path = $this->formatPath($path, $name);
|
||||
/** @var FileClass $fileClass */
|
||||
$fileClass = app()->make(FileClass::class);
|
||||
return $fileClass->createFile($path);
|
||||
}
|
||||
public function copyFolder($surDir,$toDir)
|
||||
|
||||
public function copyFolder($surDir, $toDir)
|
||||
{
|
||||
return FileClass::copyDir($surDir,$toDir);
|
||||
return FileClass::copyDir($surDir, $toDir);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,12 +433,11 @@ class SystemFileServices extends BaseServices
|
||||
* @date 2022/09/20
|
||||
* @author yyw
|
||||
*/
|
||||
public function formatPath(string $path = '',string $name = ''):string
|
||||
public function formatPath(string $path = '', string $name = ''): string
|
||||
{
|
||||
if($path)
|
||||
{
|
||||
$path = rtrim($path,DS);
|
||||
if($name) $path = $path . DS . $name;
|
||||
if ($path) {
|
||||
$path = rtrim($path, DS);
|
||||
if ($name) $path = $path . DS . $name;
|
||||
$uname = php_uname('s');
|
||||
// $search = '/';
|
||||
if (strstr($uname, 'Windows') !== false)
|
||||
|
||||
@ -200,6 +200,8 @@ class LoginServices extends BaseServices
|
||||
if ($this->dao->getOne(['account|phone' => $account, 'is_del' => 0])) {
|
||||
throw new ApiException(410028);
|
||||
}
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$phone = $account;
|
||||
$data['account'] = $account;
|
||||
$data['pwd'] = md5((string)$password);
|
||||
@ -207,8 +209,6 @@ class LoginServices extends BaseServices
|
||||
if ($spread) {
|
||||
$data['spread_uid'] = $spread;
|
||||
$data['spread_time'] = time();
|
||||
/** @var UserServices $userServices */
|
||||
$userServices = app()->make(UserServices::class);
|
||||
$spreadInfo = $userServices->get($spread);
|
||||
$data['division_id'] = $spreadInfo['division_id'];
|
||||
$data['agent_id'] = $spreadInfo['agent_id'];
|
||||
@ -234,6 +234,7 @@ class LoginServices extends BaseServices
|
||||
if (!$re = $this->dao->save($data)) {
|
||||
throw new ApiException(410014);
|
||||
} else {
|
||||
$userServices->rewardNewUser((int)$re->uid);
|
||||
//用户生成后置事件
|
||||
event('user.register', [$spread, $user_type, $data['nickname'], $re->uid, 1]);
|
||||
//推送消息
|
||||
|
||||
@ -116,7 +116,7 @@ class UserLabelServices extends BaseServices
|
||||
if (!$data['label_cate']) {
|
||||
throw new AdminException(400669);
|
||||
}
|
||||
$levelName = $this->dao->getOne(['label_name' => $data['label_name']]);
|
||||
$levelName = $this->dao->getOne(['label_name' => $data['label_name'], 'label_cate' => $data['label_cate']]);
|
||||
if ($id) {
|
||||
if (!$this->getLable($id)) {
|
||||
throw new AdminException(100026);
|
||||
|
||||
@ -86,6 +86,13 @@ class UserMoneyServices extends BaseServices
|
||||
'status' => 1,
|
||||
'pm' => 1
|
||||
],
|
||||
'register_system_add' => [
|
||||
'title' => '新用户注册赠送余额',
|
||||
'type' => 'system_add',
|
||||
'mark' => '新用户注册赠送{%num%}余额',
|
||||
'status' => 1,
|
||||
'pm' => 1
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -138,6 +138,9 @@ class UserServices extends BaseServices
|
||||
$res = $this->dao->save($data);
|
||||
if (!$res)
|
||||
throw new AdminException(400684);
|
||||
|
||||
//新用户注册奖励
|
||||
$this->rewardNewUser((int)$res->uid);
|
||||
//用户生成后置事件
|
||||
event('user.register', [$spreadUid, $userType, $user['nickname'], $res->uid, 1]);
|
||||
//推送消息
|
||||
@ -2100,4 +2103,53 @@ class UserServices extends BaseServices
|
||||
$labelInfo = $userLabelCateServices->getUserLabel($uid);
|
||||
return compact('userInfo', 'levelInfo', 'groupInfo', 'labelInfo');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新用户注册奖励
|
||||
* @param int $id
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*
|
||||
* @date 2022/09/28
|
||||
* @author yyw
|
||||
*/
|
||||
public function rewardNewUser(int $id)
|
||||
{
|
||||
$user = $this->getUserInfo($id);
|
||||
if (!$user) {
|
||||
throw new AdminException(100026);
|
||||
}
|
||||
$res1 = false;
|
||||
$res2 = false;
|
||||
$reward_money = sys_config('reward_money');
|
||||
$reward_integral = sys_config('reward_integral');
|
||||
$edit = array();
|
||||
if ($reward_money > 0) {//余额增加
|
||||
/** @var UserMoneyServices $userMoneyServices */
|
||||
$userMoneyServices = app()->make(UserMoneyServices::class);
|
||||
$edit['now_money'] = bcadd($user['now_money'], $reward_money, 2);
|
||||
$res1 = $userMoneyServices->income('register_system_add', $user['uid'], $reward_money, $edit['now_money'], 1);
|
||||
} else {
|
||||
$res1 = true;
|
||||
}
|
||||
if ($reward_integral > 0) {//积分增加
|
||||
/** @var UserBillServices $userBill */
|
||||
$userBill = app()->make(UserBillServices::class);
|
||||
$integral_data = ['link_id' => 1, 'number' => $reward_integral];
|
||||
$edit['integral'] = bcadd($user['integral'], $reward_integral, 2);
|
||||
$integral_data['balance'] = $edit['integral'];
|
||||
$integral_data['title'] = '新用户注册增加积分';
|
||||
$integral_data['mark'] = '新用户注册增加了' . floatval($reward_integral) . '积分';
|
||||
$res2 = $userBill->incomeIntegral($user['uid'], 'system_add', $integral_data);
|
||||
} else {
|
||||
$res2 = true;
|
||||
}
|
||||
if ($edit) $res3 = $this->dao->update($id, $edit);
|
||||
|
||||
else $res3 = true;
|
||||
if ($res1 && $res2 && $res3)
|
||||
return true;
|
||||
else throw new AdminException(100007);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,4 +17,5 @@ return [
|
||||
],
|
||||
// 更多的磁盘配置信息
|
||||
],
|
||||
'password' => ''
|
||||
];
|
||||
@ -291,7 +291,7 @@ class PayClient extends BaseClient
|
||||
$res = $this->request($this->getApiUrl(self::API_REFUND_QUERY_URL, ['out_refund_no'], [$outRefundNo]), 'GET');
|
||||
|
||||
if (!$res) {
|
||||
throw new PayException(50001);
|
||||
throw new PayException(500000);
|
||||
}
|
||||
|
||||
if (isset($res['code']) && isset($res['message'])) {
|
||||
|
||||
@ -162,6 +162,9 @@ class Express extends BaseExpress
|
||||
if ($expressData['partner_id'] == 1) $param['partner_id'] = $expressData['account'];
|
||||
if ($expressData['partner_key'] == 1) $param['partner_key'] = $expressData['key'];
|
||||
if ($expressData['net'] == 1) $param['net'] = $expressData['net_name'];
|
||||
if ($expressData['check_man'] == 1) $param['checkMan'] = $expressData['courier_name'];
|
||||
if ($expressData['partner_name'] == 1) $param['partnerName'] = $expressData['customer_name'];
|
||||
if ($expressData['is_code'] == 1) $param['code'] = $expressData['code_name'];
|
||||
return $this->accessToken->httpRequest(self::EXPRESS_DUMP, $param, 'POST');
|
||||
}
|
||||
|
||||
|
||||
@ -33,12 +33,12 @@ class JwtAuth
|
||||
|
||||
/**
|
||||
* 获取token
|
||||
* @param int $id
|
||||
* @param int|string $id
|
||||
* @param string $type
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function getToken(int $id, string $type, array $params = []): array
|
||||
public function getToken($id, string $type, array $params = []): array
|
||||
{
|
||||
$host = app()->request->host();
|
||||
$time = time();
|
||||
@ -83,12 +83,13 @@ class JwtAuth
|
||||
|
||||
/**
|
||||
* 获取token并放入令牌桶
|
||||
* @param int $id
|
||||
* @param $id
|
||||
* @param string $type
|
||||
* @param array $params
|
||||
* @return array
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function createToken(int $id, string $type, array $params = [])
|
||||
public function createToken($id, string $type, array $params = [])
|
||||
{
|
||||
$tokenInfo = $this->getToken($id, $type, $params);
|
||||
$exp = $tokenInfo['params']['exp'] - $tokenInfo['params']['iat'] + 60;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user