update niucloud

This commit is contained in:
全栈小学生 2023-06-21 16:47:46 +08:00
parent bda142a299
commit 4539074303
154 changed files with 3008 additions and 1515 deletions

View File

@ -7,6 +7,7 @@ return [
'cover' => '', // 页面封面图 'cover' => '', // 页面封面图
'preview' => '', // 页面预览图 'preview' => '', // 页面预览图
'desc' => '', // 页面描述 'desc' => '', // 页面描述
'mode' => 'diy', // 页面模式diy自定义fixed固定
// 页面数据源 // 页面数据源
"data" => [ "data" => [
"global" => [ "global" => [

View File

@ -4,9 +4,11 @@ return [
'DIY_HELLO_WORLD_INDEX' => [ 'DIY_HELLO_WORLD_INDEX' => [
'title' => get_lang('dict_diy.page_hello_world_index'), 'title' => get_lang('dict_diy.page_hello_world_index'),
'page' => 'pages/hello_world/index', 'page' => 'pages/hello_world/index',
'action' => ''
], ],
'DIY_HELLO_WORLD_INFO' => [ 'DIY_HELLO_WORLD_INFO' => [
'title' => get_lang('dict_diy.page_hello_world_info'), 'title' => get_lang('dict_diy.page_hello_world_info'),
'page' => 'pages/hello_world/info', 'page' => 'pages/hello_world/info',
'action' => ''
], ],
]; ];

View File

@ -3,6 +3,8 @@ return [
'hello_world_test' => [ 'hello_world_test' => [
'key' => 'hello_world_test', 'key' => 'hello_world_test',
'app_type' => 'site', 'app_type' => 'site',
'receiver_type' => 1,
'async' => false,
'name' => 'hello world消息', 'name' => 'hello world消息',
'title' => 'hello world演示插件消息', 'title' => 'hello world演示插件消息',
'variable' =>[ 'variable' =>[

View File

@ -0,0 +1,15 @@
<?php
return [
[
'key' => 'addon_schedule',
'name' => '插件计划任务',
'desc' => '',
'time' => [
'type' => 'min',
'min' => 1
],
'class' => 'addon\hello_world\app\job\AddonSchedule',
'function' => ''
],
];

View File

@ -0,0 +1,27 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace addon\hello_world\app\job;
use core\base\BaseJob;
use think\facade\Log;
/**
* 插件计划任务
*/
class AddonSchedule extends BaseJob
{
public function doJob()
{
Log::write('插件计划任务,执行时间:'.date('Y-m-d h:i:s'));
return true;
}
}

View File

@ -25,7 +25,7 @@ class AppManageListener
*/ */
public function handle() public function handle()
{ {
$data = [ return [
"category" => [ "category" => [
//插件如果要单独分类展示,需要专门定义 //插件如果要单独分类展示,需要专门定义
[ [
@ -43,6 +43,5 @@ class AppManageListener
"url" => "/hello_world" "url" => "/hello_world"
], ],
]; ];
return $data;
} }
} }

View File

@ -3,4 +3,4 @@ CREATE TABLE IF NOT EXISTS `{{prefix}}hello_world` (
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='演示插件表'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='演示插件表';
INSERT INTO `{{prefix}}hello_world`(`id`, `name`) VALUES (1, '名称'); INSERT INTO `{{prefix}}hello_world`(`name`) VALUES ('名称');

View File

@ -91,7 +91,7 @@ class ExceptionHandle extends Handle
// 添加自定义异常处理机制 // 添加自定义异常处理机制
if ($e instanceof DbException) { if ($e instanceof DbException) {
return fail('DATA_GET_FAIL', [ return fail(get_lang('DATA_GET_FAIL').':'.$e->getMessage(), [
'file' => $e->getFile(), 'file' => $e->getFile(),
'line' => $e->getLine(), 'line' => $e->getLine(),
'message' => $e->getMessage(), 'message' => $e->getMessage(),

View File

@ -149,7 +149,7 @@ class Request extends \think\Request
* @return array|string|null * @return array|string|null
*/ */
public function adminSiteId(){ public function adminSiteId(){
return $this->header(system_name('admin_site_id_name')) ?? $this->defaultSiteId(); return $this->header(system_name('admin_site_id_name'));
} }
/** /**
@ -157,7 +157,7 @@ class Request extends \think\Request
* @return array|string|null * @return array|string|null
*/ */
public function apiSiteId(){ public function apiSiteId(){
return $this->header(system_name('api_site_id_name')) ?? $this->defaultSiteId(); return $this->header(system_name('api_site_id_name'));
} }
/** /**

View File

@ -72,4 +72,15 @@ class Auth extends BaseAdminController
public function site(){ public function site(){
return success((new AuthSiteService())->getSiteInfo()); return success((new AuthSiteService())->getSiteInfo());
} }
/**
* 选择可以选择的页面
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getShowMenuList(){
return success((new AuthSiteService())->getShowMenuList());
}
} }

View File

@ -23,7 +23,7 @@ use core\base\BaseAdminController;
class Diy extends BaseAdminController class Diy extends BaseAdminController
{ {
/** /**
* @notes 获取自定义页面列表 * @notes 获取自定义页面分页列表
* @return \think\Response * @return \think\Response
*/ */
public function lists() public function lists()
@ -35,6 +35,20 @@ class Diy extends BaseAdminController
return success(( new DiyService() )->getPage($data)); return success(( new DiyService() )->getPage($data));
} }
/**
* @notes 获取自定义页面列表
* @return \think\Response
*/
public function getList()
{
$data = $this->request->params([
[ "title", "" ],
[ "type", "" ],
[ 'mode', '' ]
]);
return success(( new DiyService() )->getList($data));
}
/** /**
* 自定义页面详情 * 自定义页面详情
* @param int $id * @param int $id
@ -55,6 +69,8 @@ class Diy extends BaseAdminController
[ "title", "" ], [ "title", "" ],
[ "name", "" ], [ "name", "" ],
[ "type", "" ], [ "type", "" ],
[ 'template', '' ],
[ 'mode', 'diy' ],
[ "value", "" ], [ "value", "" ],
[ 'is_default', 0 ] [ 'is_default', 0 ]
]); ]);
@ -75,6 +91,7 @@ class Diy extends BaseAdminController
[ "title", "" ], [ "title", "" ],
[ "name", "" ], [ "name", "" ],
[ "value", "" ], [ "value", "" ],
[ 'is_change', '' ]
]); ]);
$this->validate($data, 'app\validate\diy\Diy.edit'); $this->validate($data, 'app\validate\diy\Diy.edit');
( new DiyService() )->edit($id, $data); ( new DiyService() )->edit($id, $data);
@ -113,8 +130,8 @@ class Diy extends BaseAdminController
$params = $this->request->params([ $params = $this->request->params([
[ 'id', "" ], [ 'id', "" ],
[ "name", "" ], [ "name", "" ],
[ "template", "" ], [ "type", "" ],
[ 'template_name', '' ], [ 'template', '' ],
[ "title", "" ], [ "title", "" ],
]); ]);
@ -138,10 +155,12 @@ class Diy extends BaseAdminController
public function getTemplate() public function getTemplate()
{ {
$params = $this->request->params([ $params = $this->request->params([
[ 'type', "" ], [ 'type', "" ], // 页面类型模板
[ 'action', '' ], // 页面是否装修标识为空标识不装修decorate装修
[ 'mode', '' ] // 页面展示模式diy自定义fixed固定
]); ]);
$diy_service = new DiyService(); $diy_service = new DiyService();
return success($diy_service->getTemplate($params[ 'type' ])); return success($diy_service->getTemplate($params));
} }
/** /**
@ -157,4 +176,39 @@ class Diy extends BaseAdminController
return success('MODIFY_SUCCESS'); return success('MODIFY_SUCCESS');
} }
/**
* 获取装修页面列表
*/
public function getDecoratePage()
{
return success(( new DiyService() )->getDecoratePage());
}
/**
* 切换模板
*/
public function changeTemplate()
{
$data = $this->request->params([
[ "id", "" ],
[ 'type', '' ], // 页面类型
[ 'mode', '' ], // 页面展示模式diy自定义fixed固定
[ 'template', '' ] // 模板名称
]);
return success(( new DiyService() )->changeTemplate($data));
}
/**
* 获取页面预览数据
*/
public function getPreviewData()
{
$data = $this->request->params([
[ "id", "" ],
[ 'name', '' ]
]);
$res = ( new DiyService() )->getPreviewData($data);
return success($res);
}
} }

View File

@ -37,7 +37,7 @@ class SmsLog extends BaseAdminController
public function info($id) public function info($id)
{ {
$res = ( new NoticeLogService() )->getInfo($id); $res = ( new NoticeSmsLogService() )->getInfo($id);
return success($res); return success($res);
} }

View File

@ -120,4 +120,8 @@ class Site extends BaseAdminController
(new SiteService())->edit($id, $data); (new SiteService())->edit($id, $data);
return success('SUCCESS'); return success('SUCCESS');
} }
public function indexConfig()
{
}
} }

View File

@ -0,0 +1,57 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\site;
use app\dict\site\SiteAccountLogDict;
use app\dict\site\SiteDict;
use app\service\admin\auth\AuthSiteService;
use app\service\admin\site\SiteAccountLogService;
use app\service\admin\site\SiteService;
use core\base\BaseAdminController;
use think\Response;
class SiteAccount extends BaseAdminController
{
/**
* 账单列表
* @return Response
*/
public function lists()
{
$data = $this->request->params([
['type', ''],
['create_time', []],
]);
return success((new SiteAccountLogService())->getPage($data));
}
/**
* 账单详情
* @param int $id
*/
public function info(int $id)
{
return success((new SiteAccountLogService())->getInfo($id));
}
/**
* 累计账单
*/
public function stat()
{
return success((new SiteAccountLogService())->stat());
}
public function accountType()
{
return success(SiteAccountLogDict::getType());
}
}

View File

@ -34,4 +34,26 @@ class Area extends BaseAdminController
{ {
return success((new AreaService())->getAreaTree($level)); return success((new AreaService())->getAreaTree($level));
} }
/**
* @param string $address
* 地址解析
*/
public function addressInfo(){
$data = $this->request->params([
['address', ''],
]);
return success((new AreaService())->getAddress($data['address']));
}
/**
* @param string $location
* 逆地址解析
*/
public function contraryAddress(){
$data = $this->request->params([
['location', ''],
]);
return success((new AreaService())->getAddressInfo($data['location']));
}
} }

View File

@ -123,4 +123,44 @@ class Config extends BaseAdminController
public function getMap(){ public function getMap(){
return success((new ConfigService())->getMap()); return success((new ConfigService())->getMap());
} }
/**
* 获取站点首页列表如果正在使用is_use = 1
*/
public function getSiteIndexList()
{
return success((new ConfigService())->getSiteIndexList());
}
/**
* 首页配置
*/
public function setSiteIndex()
{
$data = $this->request->params([
['view_path', ''],
]);
(new ConfigService())->setSiteIndexConfig($data);
return success();
}
/**
* 设置快捷菜单
*/
public function setShortcutMenu()
{
$data = $this->request->params([
['menu', []],
]);
(new ConfigService())->setShortcutMenu($data['menu']);
return success();
}
/**
* 获取站点快捷菜单
*/
public function getShortcutMenu()
{
return success(data:(new ConfigService())->getShortcutMenu());
}
} }

View File

@ -1,56 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\sys;
use app\dict\sys\CronDict;
use app\service\admin\cron\CronService;
use core\base\BaseAdminController;
/**
* 自动任务
* Class System
* @package app\adminapi\controller\sys
*/
class Cron extends BaseAdminController
{
/**
* 任务列表
* @return \think\Response
*/
public function lists(){
$data = $this->request->params([
['last_time', []],
['type', ''],
['title', '']
]);
$list = (new CronService())->getPage($data);
return success($list);
}
/**
* 任务详情
* @param $id
* @return Response
*/
public function info($id){
return success((new CronService())->getInfo($id));
}
/**
* 获取任务模式
* @return \think\Response
*/
public function getType(){
return success((new CronDict())->getType());
}
}

View File

@ -0,0 +1,107 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\sys;
use app\dict\schedule\ScheduleDict;
use app\service\admin\schedule\ScheduleService;
use core\base\BaseAdminController;
/**
* 自动任务
*/
class Schedule extends BaseAdminController
{
/**
* 任务列表
* @return \think\Response
*/
public function lists(){
$data = $this->request->params([
['key', ''],
['status', ''],
]);
return success(data:(new ScheduleService())->getPage($data));
}
/**
* 获取任务模式
* @return \think\Response
*/
public function getType(){
return success(data:ScheduleDict::getType());
}
/**
* 详情
* @param int $id
*/
public function info(int $id)
{
return success(( new ScheduleService() )->getInfo($id));
}
/**
* 添加
* @return Response
*/
public function add()
{
$data = $this->request->params([
[ 'key', '' ],
[ 'time', [] ],
[ 'status', ScheduleDict::OFF ],
]);
( new ScheduleService() )->add($data);
return success('ADD_SUCCESS');
}
/**
* 编辑
* @param int $id
* @return Response
*/
public function edit(int $id)
{
$data = $this->request->params([
[ 'key', '' ],
[ 'time', [] ],
[ 'status', ScheduleDict::OFF ],
]);
( new ScheduleService() )->edit($id, $data);
return success('EDIT_SUCCESS');
}
/**
* 启用或关闭
* @param int $id
* @return \think\Response
*/
public function modifyStatus(int $id){
$data = $this->request->params([
[ 'status', ScheduleDict::OFF ],
]);
( new ScheduleService() )->modifyStatus($id, $data['status']);
return success('EDIT_SUCCESS');
}
/**
* 删除
* @param int $id
*/
public function del(int $id)
{
( new ScheduleService() )->del($id);
return success('DELETE_SUCCESS');
}
}

View File

@ -11,6 +11,7 @@
namespace app\adminapi\controller\sys; namespace app\adminapi\controller\sys;
use app\service\admin\schedule\ScheduleService;
use app\service\admin\sys\SystemService; use app\service\admin\sys\SystemService;
use core\base\BaseAdminController; use core\base\BaseAdminController;
@ -70,4 +71,6 @@ class System extends BaseAdminController
public function checkSchedule(){ public function checkSchedule(){
return success(data:(new SystemService())->checkSchedule()); return success(data:(new SystemService())->checkSchedule());
} }
} }

View File

@ -32,6 +32,8 @@ Route::group('auth', function () {
Route::put('edit', 'auth.Auth/edit'); Route::put('edit', 'auth.Auth/edit');
//授权站点信息 //授权站点信息
Route::get('site', 'auth.Auth/site'); Route::get('site', 'auth.Auth/site');
//站点可以显示的菜单
Route::get('site/showmenu', 'auth.Auth/getShowMenuList');
})->middleware([ })->middleware([
AdminCheckToken::class, AdminCheckToken::class,

View File

@ -21,9 +21,17 @@ use think\facade\Route;
Route::group('diy', function() { Route::group('diy', function() {
/***************************************************** 自定义页面管理 ****************************************************/ /***************************************************** 自定义页面管理 ****************************************************/
//自定义页面列表 //自定义页面分页列表
Route::get('diy', 'diy.Diy/lists'); Route::get('diy', 'diy.Diy/lists');
Route::get('list', 'diy.Diy/getList');
// 页面装修列表
Route::get('decorate', 'diy.Diy/getDecoratePage');
// 切换模板
Route::put('change', 'diy.Diy/changeTemplate');
//自定义页面详情 //自定义页面详情
Route::get('diy/:id', 'diy.Diy/info'); Route::get('diy/:id', 'diy.Diy/info');
@ -60,6 +68,8 @@ Route::group('diy', function() {
// 编辑自定义页面分享内容 // 编辑自定义页面分享内容
Route::put('diy/share', 'diy.Diy/modifyShare'); Route::put('diy/share', 'diy.Diy/modifyShare');
// 获取页面预览数据
Route::put('preview', 'diy.Diy/getPreviewData');
/***************************************************** 配置相关 *****************************************************/ /***************************************************** 配置相关 *****************************************************/

View File

@ -70,7 +70,15 @@ Route::group('site', function () {
Route::get('log/:id', 'site.UserLog/info'); Route::get('log/:id', 'site.UserLog/info');
/***************************************************** 站点菜单 **************************************************/ /***************************************************** 站点菜单 **************************************************/
Route::get('site/menu', 'site.Site/menu'); Route::get('site/menu', 'site.Site/menu');
/***************************************************** 站点账单 *************************************************/
//站点账单列表
Route::get('account', 'site.SiteAccount/lists');
//站点账单详情
Route::get('account/:id', 'site.SiteAccount/info');
//账单统计
Route::get('account/stat', 'site.SiteAccount/stat');
//账单类型
Route::get('account/type', 'site.SiteAccount/accountType');
})->middleware([ })->middleware([
AdminCheckToken::class, AdminCheckToken::class,

View File

@ -72,6 +72,16 @@ Route::group('sys', function () {
//地图设置 //地图设置
Route::get('config/map', 'sys.Config/getMap'); Route::get('config/map', 'sys.Config/getMap');
//首页加载设置
Route::put('config/site_index', 'sys.Config/setSiteIndex');
//获取首页加载
Route::get('config/site_index', 'sys.Config/getSiteIndexList');
//快捷菜单设置
Route::put('config/shortcut_menu', 'sys.Config/setShortcutMenu');
//获取快捷菜单
Route::get('config/shortcut_menu', 'sys.Config/getShortcutMenu');
//登录注册设置 //登录注册设置
Route::get('config/login', 'login.Config/getConfig'); Route::get('config/login', 'login.Config/getConfig');
//登录注册设置 //登录注册设置
@ -126,14 +136,10 @@ Route::group('sys', function () {
Route::get('area/list_by_pid/:pid', 'sys.Area/listByPid'); Route::get('area/list_by_pid/:pid', 'sys.Area/listByPid');
//通过层级获取列表 //通过层级获取列表
Route::get('area/tree/:level', 'sys.Area/tree'); Route::get('area/tree/:level', 'sys.Area/tree');
//获取地址位置信息
Route::get('area/get_info', 'sys.Area/addressInfo');
Route::get('area/contrary', 'sys.Area/contraryAddress');
/***************************************************** 任务管理 ****************************************************/
//任务列表
Route::get('cron', 'sys.Cron/lists');
//任务详情
Route::get('cron/:id', 'sys.Cron/info');
//任务模式
Route::get('cron/type', 'sys.Cron/getType');
/***************************************************** 渠道管理 ****************************************************/ /***************************************************** 渠道管理 ****************************************************/
Route::get('channel', 'sys.Channel/getChannelType'); Route::get('channel', 'sys.Channel/getChannelType');
//场景域名 //场景域名
@ -144,12 +150,31 @@ Route::group('sys', function () {
Route::get('job', 'sys.System/checkJob'); Route::get('job', 'sys.System/checkJob');
//校验计划任务 //校验计划任务
Route::get('schedule', 'sys.System/checkSchedule'); Route::get('schedule', 'sys.System/checkSchedule');
/***************************************************** 计划任务 ****************************************************/
//计划任务列表
Route::get('schedule/list', 'sys.Schedule/lists');
//任务详情
Route::get('schedule/:id', 'sys.Schedule/info');
//设置任务状态
Route::put('schedule/modify/status/:id', 'sys.Schedule/modifyStatus');
//任务新增
Route::post('schedule', 'sys.Schedule/add');
//编辑任务
Route::put('schedule/:id', 'sys.Schedule/edit');
//删除任务
Route::delete('schedule/:id', 'sys.Schedule/del');
//任务模式
Route::get('schedule/type', 'sys.Schedule/getType');
/***************************************************** 应用管理 ****************************************************/ /***************************************************** 应用管理 ****************************************************/
Route::get('applist', 'sys.App/getAppList'); Route::get('applist', 'sys.App/getAppList');
/***************************************************** 清理缓存-刷新菜单 ****************************************************/ /***************************************************** 清理缓存-刷新菜单 ****************************************************/
Route::post('schema/clear', 'sys.System/schemaCache'); Route::post('schema/clear', 'sys.System/schemaCache');
})->middleware([ })->middleware([
AdminCheckToken::class, AdminCheckToken::class,
AdminCheckRole::class, AdminCheckRole::class,

View File

@ -12,13 +12,15 @@
namespace app\api\middleware; namespace app\api\middleware;
use app\Request; use app\Request;
use app\service\core\site\CoreSiteService;
use Closure; use Closure;
use core\exception\AuthException;
use Exception; use Exception;
use think\facade\Log; use think\facade\Log;
/** /**
* api渠道处理, 各种渠道的请求不叫特殊, 会在这儿将渠道的公共数据处理好 * api渠道处理, 各种渠道的请求, 会在这儿将渠道的公共数据处理好
*/ */
class ApiChannel class ApiChannel
{ {
@ -38,7 +40,10 @@ class ApiChannel
if (in_array($request->rule()->getRule(), $channel_rules)) { if (in_array($request->rule()->getRule(), $channel_rules)) {
$site_id = $request->param('site_id', -1); $site_id = $request->param('site_id', -1);
if ($site_id != -1) { if ($site_id != -1) {
$request->pushHeader([ system_name('api_site_id_name') => $site_id ]); $site_info = (new CoreSiteService())->getSiteCache($site_id);
if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
$site_code = $site_info['code'] ?? '';
$request->pushHeader([ system_name('api_site_id_name') => $site_code ]);
} }
} }
return $next($request); return $next($request);

View File

@ -30,11 +30,11 @@ class ApiCheckToken
/** /**
* @param Request $request * @param Request $request
* @param Closure $next * @param Closure $next
* @param bool $exception 是否把错误抛出 * @param bool $is_throw_exception 是否把错误抛出
* @return mixed * @return mixed
* @throws Exception * @throws Exception
*/ */
public function handle(Request $request, Closure $next, bool $exception = false) public function handle(Request $request, Closure $next, bool $is_throw_exception = false)
{ {
$request->appType(AppTypeDict::API); $request->appType(AppTypeDict::API);
//检测站点 //检测站点
@ -45,8 +45,8 @@ class ApiCheckToken
$token_info = ( new LoginService() )->parseToken($token); $token_info = ( new LoginService() )->parseToken($token);
} catch (AuthException $e) { } catch (AuthException $e) {
//是否将登录错误抛出 //是否将登录错误抛出
if ($exception) if ($is_throw_exception)
return fail($e->getMessage()); return fail($e->getMessage(), [], $e->getCode());
} }
if (!empty($token_info)) { if (!empty($token_info)) {
$request->memberId($token_info[ 'member_id' ]); $request->memberId($token_info[ 'member_id' ]);

View File

@ -32,7 +32,7 @@ class BindDispatch extends Controller
$controller = 'weapp.Weapp'; $controller = 'weapp.Weapp';
$action = 'register'; $action = 'register';
break; break;
}; }
$this->controller = $controller ?? ''; $this->controller = $controller ?? '';

View File

@ -1,92 +0,0 @@
<?php
namespace app\command;
use app\service\core\schedule\CoreScheduleService;
use schedule\console\Command;
use think\console\Input;
use think\console\Output;
use think\helper\Str;
use DateTimeZone;
use Workerman\Crontab\Crontab;
class Schedule extends Command
{
protected function configure()
{
$this->setName('schedule:run');
}
protected function execute(Input $input, Output $output)
{
//写入计划任务最后一次执行事件,用于环境监测
$file = root_path('runtime').'.schedule';
file_put_contents($file, time());
$schedules = (new CoreScheduleService())->getList();
foreach($schedules as $v){
$class = $v['class'] ?: 'app\\job\\schedule\\'.Str::studly($v['key']);
$function = $v['function'] ?: 'doJob';
$call_back = [
$class,
$function
];
$event = $this->call($call_back);
switch($v['time']['type']){
case 'min':
$event->everyMinute();
break;
case 'hour':
$event->hourly();
break;
case 'day':
$event->daily();
break;
case 'week':
$event->weekly();
break;
case 'month':
$event->monthly();
break;
}
}
parent::execute($input, $output);
}
/**
* 获取计划事件默认使用的时区
*/
protected function scheduleTimezone(): DateTimeZone|string|null
{
return 'Asia/Shanghai';
}
// protected function getCrontab($data): string
// {
// $crontab = '';
// switch ($data['type']) {
// case 'sec':// 每隔几秒
// $crontab = '*/' . $data['sec'] . ' * * * * *';
// break;
// case 'min':// 每隔几分
// $crontab = '0 */' . $data['min'] . ' * * * *';
// break;
// case 'hour':// 每隔几时第几分钟执行
// $crontab = '0 ' . $data['min'] . ' * * * *';
// break;
// case 'day':// 每日几时几分几秒
// $crontab = $data['sec'] . ' ' . $data['min'] . ' ' . $data['hour'] . ' * * *';
// break;
// case 'week':// 每周一次,周几具体时间执行
// $crontab = $data['sec'] . ' ' . $data['min'] . ' ' . $data['hour'] . ' * * ' . $data['week'];
// break;
// case 'month':// 每月一次,某日具体时间执行
// $crontab = $data['sec'] . ' ' . $data['min'] . ' ' . $data['hour'] . ' ' . $data['day'] . ' * *';
// break;
// }
// return $crontab;
// }
}

View File

@ -0,0 +1,54 @@
<?php
namespace app\command\schedule;
use app\service\core\schedule\CoreScheduleService;
use think\Container;
use think\helper\Str;
use yunwuxin\cron\Task;
class Schedule extends Task
{
public function configure()
{
$this->expression($this->getCrontab($this->vars['time']));
}
/**
* 执行任务
* @return mixed
*/
protected function execute()
{
//...具体的任务执行
(new CoreScheduleService())->execute($this->vars);
}
protected function getCrontab($data): string
{
$crontab = '';
$min = $data['min'] ?? '*';
$hour = $data['hour'] ?? '*';
$day = $data['day'] ?? '*';
$week = $data['week'] ?? '*';
switch ($data['type']) {
case 'min':// 每隔几分
$crontab = '*/' . $min . ' * * * *';
break;
case 'hour':// 每隔几时第几分钟执行
$crontab = $min . ' */' . $hour . ' * * *';
break;
case 'day':// 每隔几日几时几分几秒执行
$crontab = $min . ' ' . $hour . ' */' . $day . ' * *';
break;
case 'week':// 每周一次,周几具体时间执行
$crontab = $min . ' ' . $hour . ' * * ' . $week;
break;
case 'month':// 每月一次,某日具体时间执行
$crontab = $min . ' ' . $hour . ' ' . $day . ' * *';
break;
}
return $crontab;
}
}

View File

@ -5,7 +5,7 @@ use think\Response;
use think\facade\Lang; use think\facade\Lang;
use think\facade\Queue; use think\facade\Queue;
use think\facade\Cache; use think\facade\Cache;
use core\util\Snowflake;
// 应用公共文件 // 应用公共文件
/** /**
@ -369,8 +369,11 @@ function filter($string)
*/ */
function create_no(string $prefix = '', string $tag = '') function create_no(string $prefix = '', string $tag = '')
{ {
return $prefix . substr(md5($tag), -5) . uniqid(); $dataCenterId = 1;
$machineId = 2;
$snowflake = new Snowflake($dataCenterId, $machineId);
$id = $snowflake->generateId();
return $prefix.$tag.$id;
} }
/** /**
@ -416,8 +419,7 @@ function unique_random($len = 10)
{ {
$str = 'qwertyuiopasdfghjklzxcvbnmasdfgh'; $str = 'qwertyuiopasdfghjklzxcvbnmasdfgh';
str_shuffle($str); str_shuffle($str);
$res = substr(str_shuffle($str), 0, $len); return substr(str_shuffle($str), 0, $len);
return $res;
} }
/** /**
@ -623,6 +625,7 @@ function parse_sql($content = '', $string = false, $replace = [])
* 递归查询目录下所有文件 * 递归查询目录下所有文件
* @param $path * @param $path
* @param $data * @param $data
* @param $search
* @return void * @return void
*/ */
function search_dir($path, &$data, $search = '') function search_dir($path, &$data, $search = '')
@ -677,8 +680,8 @@ function getFileMap($path, $arr = [])
* 如果不存在则写入缓存 * 如果不存在则写入缓存
* @param string|null $name * @param string|null $name
* @param $value * @param $value
* @param $options
* @param $tag * @param $tag
* @param $options
* @return mixed|string * @return mixed|string
*/ */
function cache_remember(string $name = null, $value = '', $tag = null, $options = null){ function cache_remember(string $name = null, $value = '', $tag = null, $options = null){

View File

@ -23,18 +23,19 @@ class PagesDict
/** /**
* 获取页面数据 * 获取页面数据
* @param string $type * @param array $params
* @return array|string|null * @return array|string|null
*/ */
public static function getPages($type = '') public static function getPages($params = [])
{ {
$system_pages = [ $system_pages = [
'DIY_INDEX' => [ 'DIY_INDEX' => [
'default_index' => [ // 页面标识 'default_index' => [ // 页面标识
"title" => "首页", // 页面名称 "title" => "首页", // 页面名称
'cover' => '', // 页面封面图 'cover' => 'static/resource/images/diy/template/default_index_cover.png', // 页面封面图
'preview' => '', // 页面预览图 'preview' => '', // 页面预览图
'desc' => '', // 页面描述 'desc' => '官方推出的系统首页', // 页面描述
'mode' => 'diy', // 页面模式diy自定义fixed固定
// 页面数据源 // 页面数据源
"data" => [ "data" => [
"global" => [ "global" => [
@ -255,14 +256,26 @@ class PagesDict
] ]
] ]
] ]
] ],
// 'tourism' => [
// "title" => "旅游", // 页面名称
// 'cover' => 'static/resource/images/diy/template/tourism_cover.png', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '酒店旅游住宿门票景点', // 页面描述
// 'mode' => 'fixed', // 页面模式diy自定义fixed固定
// 'data' => [
// 'component' => 'tourism-index', // 模板组件名称
// 'link' => '' // 装修链接
// ]
// ]
], ],
'DIY_MEMBER_INDEX' => [ 'DIY_MEMBER_INDEX' => [
'default_member_index_one' => [ 'default_member_index_one' => [
"title" => "个人中心(风格一)", // 页面名称 "title" => "个人中心(风格一)", // 页面名称
'cover' => '', // 页面封面图 'cover' => 'static/resource/images/diy/template/default_member_index_one_cover.png', // 页面封面图
'preview' => '', // 页面预览图 'preview' => '', // 页面预览图
'desc' => '', // 页面描述 'desc' => '官方推出个人中心(风格一)', // 页面描述
'mode' => 'diy',
// 页面数据源 // 页面数据源
"data" => [ "data" => [
"global" => [ "global" => [
@ -583,9 +596,10 @@ class PagesDict
], ],
'default_member_index_two' => [ 'default_member_index_two' => [
"title" => "个人中心(风格二)", // 页面名称 "title" => "个人中心(风格二)", // 页面名称
'cover' => '', // 页面封面图 'cover' => 'static/resource/images/diy/template/default_member_index_two_cover.png', // 页面封面图
'preview' => '', // 页面预览图 'preview' => '', // 页面预览图
'desc' => '', // 页面描述 'desc' => '官方推出个人中心(风格二)', // 页面描述
'mode' => 'diy',
// 页面数据源 // 页面数据源
"data" => [ "data" => [
"global" => [ "global" => [
@ -904,14 +918,40 @@ class PagesDict
] ]
] ]
] ],
// 'tourism' => [
// "title" => "旅游", // 页面名称
// 'cover' => 'static/resource/images/diy/template/tourism_member_index_cover.png', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '酒店旅游住宿门票景点', // 页面描述
// 'mode' => 'fixed', // 页面模式diy自定义fixed固定
// 'data' => [
// 'component' => 'tourism-member', // 模板组件名称
// 'link' => '' // 装修链接
// ]
// ]
] ]
]; ];
$pages = ( new DictLoader("UniappPages") )->load($system_pages); $pages = ( new DictLoader("UniappPages") )->load($system_pages);
if (empty($type)) { if (!empty($params[ 'type' ])) {
return $pages; if (!empty($pages[ $params[ 'type' ] ])) {
$temp = $pages[ $params[ 'type' ] ];
if (isset($params[ 'mode' ]) && !empty($params[ 'mode' ])) {
foreach ($temp as $k => $v) {
if ($params[ 'mode' ] != $v[ 'mode' ]) {
unset($temp[ $k ]);
}
}
}
} else {
return [];
}
return $temp;
} }
return $pages[ $type ] ?? '';
return $pages;
} }
} }

View File

@ -23,30 +23,47 @@ class TemplateDict
/** /**
* 获取页面模板 * 获取页面模板
* @param string $type * @param array $params
* @return array|string * @return array|string|null
*/ */
public static function getTemplate($type = '') public static function getTemplate($params = [])
{ {
$system_pages = [ $system_pages = [
'DIY_INDEX' => [ 'DIY_INDEX' => [
'title' => get_lang('dict_diy.page_index'), 'title' => get_lang('dict_diy.page_index'),
'page' => 'pages/index/index', 'page' => 'pages/index/index',
'action' => 'decorate' // 页面是否装修标识为空标识不装修decorate装修
], ],
'DIY_MEMBER_INDEX' => [ 'DIY_MEMBER_INDEX' => [
'title' => get_lang('dict_diy.page_member_index'), 'title' => get_lang('dict_diy.page_member_index'),
'page' => 'pages/member/index', 'page' => 'pages/member/index',
'action' => 'decorate'
], ],
'DIY_PAGE' => [ 'DIY_PAGE' => [
'title' => get_lang('dict_diy.page_diy'), 'title' => get_lang('dict_diy.page_diy'),
'page' => 'pages/index/diy', 'page' => 'pages/index/diy',
'action' => ''
] ]
]; ];
$pages = (new DictLoader("UniappTemplate"))->load($system_pages);
if (empty($type)) { $pages = ( new DictLoader("UniappTemplate") )->load($system_pages);
return $pages;
if (!empty($params[ 'type' ]) && !empty($pages[ $params[ 'type' ] ])) {
return [ $params[ 'type' ] => $pages[ $params[ 'type' ] ] ];
} }
return $pages[ $type ] ?? '';
if (!empty($params[ 'action' ])) {
$temp = [];
foreach ($pages as $k => $v) {
if (isset($v[ 'action' ]) && $params[ 'action' ] == $v[ 'action' ]) {
$temp[ $k ] = $v;
}
}
return $temp;
}
return $pages;
} }
} }

View File

@ -525,6 +525,19 @@
'sort' => 50, 'sort' => 50,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
],
[
'menu_name' => '计划任务',
'menu_key' => 'tools_schedule',
'menu_type' => 1,
'icon' => 'element-SetUp',
'api_url' => '',
'router_path' => 'schedule',
'view_path' => 'tools/schedule',
'methods' => '',
'sort' => 40,
'status' => 1,
'is_show' => 1,
] ]
] ]
], ],

View File

@ -28,8 +28,8 @@ return
'is_show' => 1, 'is_show' => 1,
'children' => [ 'children' => [
[ [
'menu_name' => '页装修', 'menu_name' => '装修',
'menu_key' => 'diy_page_index', 'menu_key' => 'diy_page_decorate',
'menu_type' => 1, 'menu_type' => 1,
'icon' => 'element-House', 'icon' => 'element-House',
'api_url' => '', 'api_url' => '',
@ -40,19 +40,6 @@ return
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
], ],
[
'menu_name' => '个人中心',
'menu_key' => 'diy_page_member',
'menu_type' => 1,
'icon' => 'element-ScaleToOriginal',
'api_url' => '',
'router_path' => 'member',
'view_path' => 'diy/member',
'methods' => '',
'sort' => 90,
'status' => 1,
'is_show' => 1,
],
[ [
'menu_name' => '保存', 'menu_name' => '保存',
'menu_key' => 'diy_page_update', 'menu_key' => 'diy_page_update',
@ -62,12 +49,12 @@ return
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => 'post', 'methods' => 'post',
'sort' => 80, 'sort' => 95,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
], ],
[ [
'menu_name' => '页面管理', 'menu_name' => '页面',
'menu_key' => 'diy_page_list', 'menu_key' => 'diy_page_list',
'menu_type' => 1, 'menu_type' => 1,
'icon' => 'iconfont-icondianpuzhuangxiu', 'icon' => 'iconfont-icondianpuzhuangxiu',
@ -75,7 +62,20 @@ return
'router_path' => 'list', 'router_path' => 'list',
'view_path' => 'diy/list', 'view_path' => 'diy/list',
'methods' => 'get', 'methods' => 'get',
'sort' => 70, 'sort' => 90,
'status' => 1,
'is_show' => 1,
],
[
'menu_name' => '页面路径',
'menu_key' => 'diy_page_route',
'menu_type' => 1,
'icon' => 'iconfont-icondianpuzhuangxiu',
'api_url' => 'diy/diy',
'router_path' => 'route',
'view_path' => 'diy/route',
'methods' => 'get',
'sort' => 85,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
], ],
@ -88,25 +88,24 @@ return
'router_path' => 'tabbar', 'router_path' => 'tabbar',
'view_path' => 'diy/tabbar', 'view_path' => 'diy/tabbar',
'methods' => 'get', 'methods' => 'get',
'sort' => 60, 'sort' => 80,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
'children' => 'children' => [
[ [
[ 'menu_name' => '保存',
'menu_name' => '保存', 'menu_key' => 'diy_tabbar_update',
'menu_key' => 'diy_tabbar_update', 'menu_type' => 2,
'menu_type' => 2, 'icon' => '',
'icon' => '', 'api_url' => 'diy/bottom',
'api_url' => 'diy/bottom', 'router_path' => '',
'router_path' => '', 'view_path' => '',
'view_path' => '', 'methods' => 'post',
'methods' => 'post', 'sort' => 100,
'sort' => 100, 'status' => 1,
'status' => 1, 'is_show' => 1,
'is_show' => 1,
],
], ],
],
], ],
[ [
'menu_name' => '素材管理', 'menu_name' => '素材管理',
@ -117,7 +116,7 @@ return
'router_path' => 'attachment', 'router_path' => 'attachment',
'view_path' => 'tools/attachment', 'view_path' => 'tools/attachment',
'methods' => 'get', 'methods' => 'get',
'sort' => 50, 'sort' => 75,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
] ]
@ -148,6 +147,19 @@ return
'sort' => 0, 'sort' => 0,
'status' => 1, 'status' => 1,
'is_show' => 0, 'is_show' => 0,
],
[
'menu_name' => '页面预览',
'menu_key' => 'page_preview',
'menu_type' => 1,
'icon' => '',
'api_url' => '',
'router_path' => 'preview',
'view_path' => 'diy/preview',
'methods' => '',
'sort' => 1,
'status' => 1,
'is_show' => 0,
] ]
] ]
], ],
@ -472,6 +484,19 @@ return
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
'children' => [ 'children' => [
[
'menu_name' => '账单管理',
'menu_key' => 'site_account_list',
'menu_type' => 1,
'icon' => 'element-Postcard',
'api_url' => 'finance/account',
'router_path' => 'account',
'view_path' => 'finance/account',
'methods' => 'get',
'sort' => 100,
'status' => 1,
'is_show' => 1,
],
[ [
'menu_name' => '会员提现', 'menu_name' => '会员提现',
'menu_key' => 'cash_out_list', 'menu_key' => 'cash_out_list',
@ -484,7 +509,7 @@ return
'sort' => 99, 'sort' => 99,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
] ],
] ]
], ],
[ [
@ -997,7 +1022,7 @@ return
'sort' => 90, 'sort' => 90,
'status' => 1, 'status' => 1,
'is_show' => 1, 'is_show' => 1,
'children' => [ 'children' => [
[ [
'menu_name' => '设置', 'menu_name' => '设置',
'menu_key' => 'setting_pay_transfer_set', 'menu_key' => 'setting_pay_transfer_set',

View File

@ -2,7 +2,7 @@
return [ return [
'verify_code' => [ 'verify_code' => [
'key' => 'verify_code', 'key' => 'verify_code',
'receiver_type' => 1, 'receiver_type' => 0,
'name' => '手机验证码', 'name' => '手机验证码',
'title' => '管理端验证码登录', 'title' => '管理端验证码登录',
'async' => false, 'async' => false,
@ -13,7 +13,7 @@ return [
//手机验证码,站点应用发送 //手机验证码,站点应用发送
'member_verify_code' => [ 'member_verify_code' => [
'key' => 'member_verify_code', 'key' => 'member_verify_code',
'receiver_type' => 2, 'receiver_type' => 1,
'name' => '手机验证码', 'name' => '手机验证码',
'title' => '前端验证码登录,注册,手机验证', 'title' => '前端验证码登录,注册,手机验证',
'async' => false, 'async' => false,
@ -25,7 +25,7 @@ return [
'recharge_success' => [ 'recharge_success' => [
'key' => 'recharge_success', 'key' => 'recharge_success',
'receiver_type' => 2, 'receiver_type' => 1,
'name' => '充值成功通知', 'name' => '充值成功通知',
'title' => '会员充值成功后发送', 'title' => '会员充值成功后发送',
'async' => true, 'async' => true,

View File

@ -9,41 +9,35 @@
// | Author: Niucloud Team // | Author: Niucloud Team
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\dict\sys; namespace app\dict\schedule;
class CronDict class ScheduleDict
{ {
const CRON = 'cron';//定时任务 const CRON = 'cron';//定时任务
const CROND = 'crond';//周期任务 const CROND = 'crond';//周期任务
const MINUTE = 'minute';//分钟
const DAY = 'day';//天
const WEEK = 'week';//星期
const MONTH = 'month';//月份
const ON = 1;
const OFF = 2;
/** /**
* 任务模式 * 任务模式
* @return array * @return array
*/ */
public static function getType(){ public static function getType(){
return [ return [
self::CRON => get_lang('dict_cron.type_cron'),//定时任务 self::CRON => get_lang('dict_schedule.type_cron'),//定时任务
self::CROND => get_lang('dict_cron.type_crond'),//周期任务 self::CROND => get_lang('dict_schedule.type_crond'),//周期任务
]; ];
} }
/** /**
* 周期类型 * 任务启用状态
* @return array * @return array
*/ */
public static function getCrondType(){ public static function getStatus(){
return [ return [
self::MINUTE => get_lang('dict_cron.type_minute'),//分钟 self::ON => get_lang('dict_schedule.on'),//启用
self::DAY => get_lang('dict_cron.type_day'),//天 self::OFF => get_lang('dict_schedule.off'),//关闭
self::WEEK => get_lang('dict_cron.type_week'),//星期
self::MONTH => get_lang('dict_cron.type_month'),//月份
]; ];
} }
} }

View File

@ -4,8 +4,10 @@ return [
[ [
'key' => 'order_close', 'key' => 'order_close',
'name' => '未支付订单自动关闭', 'name' => '未支付订单自动关闭',
'desc' => '',
'time' => [ 'time' => [
'type' => 'min', 'type' => 'min',
'min' => 1
], ],
'class' => '', 'class' => '',
'function' => '' 'function' => ''
@ -13,10 +15,14 @@ return [
[ [
'key' => 'site_expire_close', 'key' => 'site_expire_close',
'name' => '站点到期自动关闭', 'name' => '站点到期自动关闭',
'desc' => '',
'time' => [ 'time' => [
'type' => 'min', 'type' => 'day',
'day' => 1,
'hour' => 1,
'min' => 1
], ],
'class' => '', 'class' => 'app\job\schedule\SiteExpireClose',
'function' => '' 'function' => ''
] ]
]; ];

View File

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\site;
class SiteAccountLogDict
{
const PAY = 'pay';//支付
const REFUND = 'refund'; //退款
const TRANSFER = 'transfer'; //转账
/**
* 站点状态
* @return array
*/
public static function getType(){
return [
self::PAY => get_lang('dict_site.pay'),//支付
self::REFUND => get_lang('dict_site.refund'),//退款
self::TRANSFER => get_lang('dict_site.transfer'),//转账
];
}
}

View File

@ -0,0 +1,78 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\sys;
/**
* 日期的字典
*/
class DateDict
{
const MON = 1;
const TUE = 2;
const WED = 3;
const THUR = 4;
const FRI = 5;
const SAT = 6;
const SUN = 0;
CONST JAN = 1;
CONST FEB = 2;
CONST MAR = 3;
CONST APR = 4;
CONST MAY = 5;
CONST JUN = 6;
CONST JUL = 7;
CONST AUG = 8;
CONST SEPT = 9;
CONST OCT = 10;
CONST NOV = 11;
CONST DEC = 12;
/**
* 星期
* @return array
*/
public static function getWeek(){
return [
self::MON => get_lang('dict_date.mon'),//周一
self::TUE => get_lang('dict_date.tue'),//周二
self::WED => get_lang('dict_date.wed'),//周三
self::THUR => get_lang('dict_date.thur'),//周四
self::FRI => get_lang('dict_date.fri'),//周五
self::SAT => get_lang('dict_date.sat'),//周六
self::SUN => get_lang('dict_date.sun'),//周日
];
}
/**
* 月份
* @return array
*/
public function getMonth(){
return [
self::JAN => get_lang('dict_date.jan'),//1月
self::FEB => get_lang('dict_date.feb'),//2月
self::MAR => get_lang('dict_date.mar'),//3月
self::APR => get_lang('dict_date.apr'),//4月
self::MAY => get_lang('dict_date.may'),//5月
self::JUN => get_lang('dict_date.jun'),//6月
self::JUL => get_lang('dict_date.jul'),//7月
self::AUG => get_lang('dict_date.aug'),//8月
self::SEPT => get_lang('dict_date.sept'),//9月
self::OCT => get_lang('dict_date.oct'),//10月
self::NOV => get_lang('dict_date.nov'),//11月
self::DEC => get_lang('dict_date.dec'),//12月
];
}
}

View File

@ -53,7 +53,7 @@ class SmsDict
const SUCCESS = 'success'; const SUCCESS = 'success';
const FAIL = 'fail'; const FAIL = 'fail';
public function getStatusType(){ public static function getStatusType(){
return [ return [
self::SENDING => 'dict_sms.status_sending', self::SENDING => 'dict_sms.status_sending',
self::SUCCESS => 'dict_sms.status_success', self::SUCCESS => 'dict_sms.status_success',

View File

@ -39,17 +39,23 @@ $system_event = [
//退款成功 //退款成功
'RefundSuccess' => [ 'app\listener\pay\RefundSuccessListener' ], 'RefundSuccess' => [ 'app\listener\pay\RefundSuccessListener' ],
//转账成功 //转账成功
'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ], 'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ], 'SiteIndex' => [
'app\listener\system\SiteIndexListener'
],
// 任务失败统一回调,有四种定义方式 // 任务失败统一回调,有四种定义方式
'queue_failed'=> [ 'queue_failed'=> [
['app\listener\job\QueueFailedLoggerListener', 'report'], ['app\listener\job\QueueFailedLoggerListener', 'report'],
], ],
//系统应用管理加载
'AppManage' => [ 'AppManage' => [
'app\listener\system\AppManageListener' 'app\listener\system\AppManageListener'
], ],
//站点首页加载
'siteIndex' => [
'app\listener\system\SiteIndexListener'
],
//消息模板数据内容 //消息模板数据内容
'NoticeData' => [ 'NoticeData' => [
'app\listener\notice_template\VerifyCode',//手机验证码 'app\listener\notice_template\VerifyCode',//手机验证码

View File

@ -8,6 +8,7 @@ use app\model\sys\SysUser;
use app\service\admin\install\InstallSystemService; use app\service\admin\install\InstallSystemService;
use app\service\admin\site\SiteGroupService; use app\service\admin\site\SiteGroupService;
use app\service\admin\site\SiteService; use app\service\admin\site\SiteService;
use app\service\core\schedule\CoreScheduleInstallService;
use think\facade\Cache; use think\facade\Cache;
use think\facade\Db; use think\facade\Db;
use think\facade\View; use think\facade\View;
@ -320,6 +321,13 @@ class Index extends BaseInstall
$this->setSuccessLog([ '菜单初始化失败', 'error' ]); $this->setSuccessLog([ '菜单初始化失败', 'error' ]);
return fail('菜单初始化失败'); return fail('菜单初始化失败');
} }
//初始化计划任务
$res = ( new CoreScheduleInstallService())->installSystemSchedule();
if (!$res) {
$this->setSuccessLog([ '计划任务初始化失败', 'error' ]);
return fail('计划任务初始化失败');
}
$user = ( new SysUser() )->where([ [ 'uid', '=', 1 ] ])->findOrEmpty(); $user = ( new SysUser() )->where([ [ 'uid', '=', 1 ] ])->findOrEmpty();
if (!$user->isEmpty()) { if (!$user->isEmpty()) {

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ namespace app\job\schedule;
use app\service\core\site\CoreSiteService; use app\service\core\site\CoreSiteService;
use core\base\BaseJob; use core\base\BaseJob;
use think\facade\Log;
/** /**
* 站点到期自动关闭 * 站点到期自动关闭
@ -28,7 +29,7 @@ class SiteExpireClose extends BaseJob
$core_site_service->expire($v['site_id']); $core_site_service->expire($v['site_id']);
} }
} }
// Log::write('站点到期自动关闭'.date('Y-m-d h:i:s')); Log::write('站点到期自动关闭'.date('Y-m-d h:i:s'));
return true; return true;
} }
} }

View File

@ -98,14 +98,11 @@ return [
'status_off' => 'off' 'status_off' => 'off'
], ],
//自动任务时间间隔 //自动任务时间间隔
'dict_cron' => [ 'dict_schedule' => [
'type_minute' => 'minute',
'type_day' => 'day',
'type_week' => 'week',
'type_month' => 'month',
'type_cron' => 'time work', 'type_cron' => 'time work',
'type_crond' => 'period work' 'type_crond' => 'period work',
'on' => 'on',
'off' => 'off'
], ],
//支付相关 //支付相关
'dict_pay' => [ 'dict_pay' => [
@ -270,4 +267,27 @@ return [
'sms_notice_records' => 'send log', 'sms_notice_records' => 'send log',
'map_setting' => 'map config', 'map_setting' => 'map config',
], ],
'dict_date' => [
//week
'mon' => 'monday',
'tue' => 'tuesday',
'wed' => 'wednesday',
'thur' => 'thursday',
'fri' => 'friday',
'sat' => 'saturday',
'sun' => 'sunday',
//month
'jan' => 'january',
'feb' => 'february',
'mar' => 'march',
'apr' => 'april',
'may' => 'may',
'jun' => 'june',
'jul' => 'july',
'aug' => 'august',
'sept' => 'sept',
'oct' => 'october',
'nov' => 'november',
'dec' => 'december',
],
]; ];

View File

@ -38,6 +38,7 @@ return [
'ADDON_INSTALL_NOT_EXIST' => '未找到插件安装任务', 'ADDON_INSTALL_NOT_EXIST' => '未找到插件安装任务',
'ADDON_INSTALL_EXECUTED' => '插件安装任务已执行', 'ADDON_INSTALL_EXECUTED' => '插件安装任务已执行',
'INSTALL_CHECK_NOT_PASS' => '安装校验未通过', 'INSTALL_CHECK_NOT_PASS' => '安装校验未通过',
'SITE_INDEX_VIEW_PATH_NOT_EXIST' => '当前首页路径不存在',
//登录注册重置账号.... //登录注册重置账号....

View File

@ -42,7 +42,15 @@ return [
'status_on' => '正常', 'status_on' => '正常',
'status_experience' => '体验期', 'status_experience' => '体验期',
'status_expire' => '已到期', 'status_expire' => '已到期',
'status_close' => '已停止' 'status_close' => '已停止',
'pay' => '收款',
'refund' => '退款',
'transfer' => '转账',
],
// 站点
'dict_site_index' => [
//站点类型
'system' => '框架首页',
], ],
'dict_notice' => [ 'dict_notice' => [
'type_sms' => '短信', 'type_sms' => '短信',
@ -125,14 +133,11 @@ return [
'status_off' => '停用' 'status_off' => '停用'
], ],
//自动任务时间间隔 //自动任务时间间隔
'dict_cron' => [ 'dict_schedule' => [
'type_minute' => '分钟',
'type_day' => '天',
'type_week' => '星期',
'type_month' => '月',
'type_cron' => '定时任务', 'type_cron' => '定时任务',
'type_crond' => '周期任务' 'type_crond' => '周期任务',
'on' => '启用',
'off' => '关闭'
], ],
//支付相关 //支付相关
'dict_pay' => [ 'dict_pay' => [
@ -263,6 +268,31 @@ return [
'mysql_ask' => '大于等于5.7', 'mysql_ask' => '大于等于5.7',
'php_authority_ask' => '开启', 'php_authority_ask' => '开启',
'file_authority_ask' => '可读可写' 'file_authority_ask' => '可读可写'
] ],
//日期
'dict_date' => [
//星期
'mon' => '周一',
'tue' => '周二',
'wed' => '周三',
'thur' => '周四',
'fri' => '周五',
'sat' => '周六',
'sun' => '周日',
//月份
'jan' => '1月',
'feb' => '2月',
'mar' => '3月',
'apr' => '4月',
'may' => '5月',
'jun' => '6月',
'jul' => '7月',
'aug' => '8月',
'sept' => '9月',
'oct' => '10月',
'nov' => '11月',
'dec' => '12月',
],
]; ];

View File

@ -12,6 +12,7 @@
namespace app\listener\pay; namespace app\listener\pay;
use app\service\core\order\recharge\CoreRechargeOrderService; use app\service\core\order\recharge\CoreRechargeOrderService;
use app\service\core\site\CoreSiteAccountService;
/** /**
* 支付异步回调事件 * 支付异步回调事件
@ -25,5 +26,8 @@ class PaySuccessListener
{ {
(new CoreRechargeOrderService())->pay($pay_info); (new CoreRechargeOrderService())->pay($pay_info);
} }
//账单记录添加
(new CoreSiteAccountService())->addPayLog($pay_info);
} }
} }

View File

@ -11,8 +11,10 @@
namespace app\listener\pay; namespace app\listener\pay;
use app\model\site\SiteAccountLog;
use app\service\core\order\recharge\CoreRechargeOrderService; use app\service\core\order\recharge\CoreRechargeOrderService;
use app\service\core\order\recharge\CoreRechargeRefundService; use app\service\core\order\recharge\CoreRechargeRefundService;
use app\service\core\site\CoreSiteAccountService;
/** /**
* 退款成功事件 * 退款成功事件
@ -21,10 +23,14 @@ class RefundSuccessListener
{ {
public function handle(array $refund_info) public function handle(array $refund_info)
{ {
//添加账单记录
(new CoreSiteAccountService())->addRefundLog($refund_info['site_id'], $refund_info['refund_no']);
//交易单据处理
$trade_type = $refund_info['trade_type'] ?? ''; $trade_type = $refund_info['trade_type'] ?? '';
if($trade_type == 'recharge') if($trade_type == 'recharge')
{ {
(new CoreRechargeRefundService())->refundComplete($refund_info['refund_no']); (new CoreRechargeRefundService())->refundComplete($refund_info['refund_no']);
} }
} }
} }

View File

@ -13,6 +13,7 @@ namespace app\listener\pay;
use app\dict\cash_out\CashOutTypeDict; use app\dict\cash_out\CashOutTypeDict;
use app\service\core\member\CoreMemberCashOutService; use app\service\core\member\CoreMemberCashOutService;
use app\service\core\site\CoreSiteAccountService;
/** /**
* 转账事件 * 转账事件
@ -21,6 +22,8 @@ class TransferSuccessListener
{ {
public function handle(array $info) public function handle(array $info)
{ {
//添加账单记录
(new CoreSiteAccountService())->addTransferLog($info['site_id'], $info['transfer_no']);
//会员零钱提现 //会员零钱提现
if($info['trade_type'] == CashOutTypeDict::MEMBER_CASH_OUT) if($info['trade_type'] == CashOutTypeDict::MEMBER_CASH_OUT)
{ {

View File

@ -20,7 +20,7 @@ class AppManageListener
{ {
public function handle() public function handle()
{ {
$data = [ return [
"category" =>[ "category" =>[
[ [
@ -45,9 +45,8 @@ class AppManageListener
"desc" => get_lang('dict_app_manage.member_recharge'), "desc" => get_lang('dict_app_manage.member_recharge'),
"icon" => "static/resource/images/app/recharge_icon.png", "icon" => "static/resource/images/app/recharge_icon.png",
"cover" => "static/resource/images/app/recharge_cover.png", "cover" => "static/resource/images/app/recharge_cover.png",
"url" => "/finance/recharge" "url" => "/order/recharge/order"
], ],
]; ];
return $data;
} }
} }

View File

@ -0,0 +1,30 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\system;
/**
* 站点首页加载事件
* Class AppInit
* @package app\listener\system
*/
class SiteIndexListener
{
public function handle()
{
return [
[
"name" => get_lang("dict_site_index.system"),
"view_path" => "index/site_index"
]
];
}
}

View File

@ -45,7 +45,7 @@ class Addon extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return AddonDict::getStatus()[ $data[ 'status' ] ?? '' ] ?? ''; return AddonDict::getStatus()[ $data[ 'status' ]] ?? '';
} }
/** /**

View File

@ -11,6 +11,7 @@
namespace app\model\article; namespace app\model\article;
use app\model\site\Site;
use core\base\BaseModel; use core\base\BaseModel;
use think\db\Query; use think\db\Query;
use think\model\relation\HasOne; use think\model\relation\HasOne;
@ -99,12 +100,16 @@ class Article extends BaseModel
} }
public function getArticleUrlAttr($value, $data) { public function getArticleUrlAttr($value, $data) {
$site_tag = $data['site_id'] == 1 ? '' : '/s' . $data['site_id']; $site = Site::find($data['site_id']);
$data = [ $site_tag = $site['site_code'];
'wap_url' => ( !empty(env("system.wap_domain")) ? env("system.wap_domain") : request()->domain() ) . "/wap" . $site_tag . "/pages/article/detail?id={$data['id']}",
'web_url' => ( !empty(env("system.web_domain")) ? env("system.web_domain") : request()->domain() ) . "/web" . $site_tag . "/article/detail?id={$data['id']}" $wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain();
$web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
return [
'wap_url' => $wap_domain . "/wap/" . $site_tag . "/pages/article/detail?id={$data['id']}",
'web_url' => $web_domain . "/web/" . $site_tag . "/article/detail?id={$data['id']}"
]; ];
return $data;
} }
} }

View File

@ -47,7 +47,10 @@ class Diy extends BaseModel
*/ */
public function getTypeNameAttr($value, $data) public function getTypeNameAttr($value, $data)
{ {
return TemplateDict::getTemplate($data[ 'type' ] ?? '')[ 'title' ] ?? ''; if (!empty($data[ 'type' ])) {
return TemplateDict::getTemplate([ 'type' => $data[ 'type' ] ])[ $data[ 'type' ] ][ 'title' ] ?? '';
}
return '';
} }
/** /**

View File

@ -72,7 +72,9 @@ class Member extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return MemberDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status']))
return '';
return MemberDict::getStatus()[$data['status']] ?? '';
} }
/** /**
* 注册来源字段转化 * 注册来源字段转化
@ -81,7 +83,9 @@ class Member extends BaseModel
*/ */
public function getRegisterChannelNameAttr($value, $data) public function getRegisterChannelNameAttr($value, $data)
{ {
return MemberRegisterChannelDict::getType()[ $data[ 'register_channel' ] ?? '' ] ?? ''; if(empty($data['register_channel']))
return '';
return MemberRegisterChannelDict::getType()[ $data[ 'register_channel' ]] ?? '';
} }
/** /**
@ -91,7 +95,9 @@ class Member extends BaseModel
*/ */
public function getRegisterTypeNameAttr($value, $data) public function getRegisterTypeNameAttr($value, $data)
{ {
return MemberRegisterTypeDict::getType()[ $data[ 'register_type' ] ?? '' ] ?? ''; if(empty($data['register_type']))
return '';
return MemberRegisterTypeDict::getType()[ $data[ 'register_type' ]] ?? '';
} }
/** /**
@ -101,7 +107,9 @@ class Member extends BaseModel
*/ */
public function getLoginChannelNameAttr($value, $data) public function getLoginChannelNameAttr($value, $data)
{ {
return ChannelDict::getType()[ $data[ 'login_channel' ] ?? '' ] ?? ''; if(empty($data['login_channel']))
return '';
return ChannelDict::getType()[ $data[ 'login_channel' ]] ?? '';
} }
/** /**
@ -111,7 +119,9 @@ class Member extends BaseModel
*/ */
public function getLoginTypeNameAttr($value, $data) public function getLoginTypeNameAttr($value, $data)
{ {
return MemberLoginTypeDict::getType()[ $data[ 'login_type' ] ?? '' ] ?? ''; if(empty($data['login_type']))
return '';
return MemberLoginTypeDict::getType()[ $data[ 'login_type' ]] ?? '';
} }
/** /**
@ -122,7 +132,9 @@ class Member extends BaseModel
*/ */
public function getSexNameAttr($value, $data) public function getSexNameAttr($value, $data)
{ {
return CommonDict::getSexType()[ $data[ 'sex' ] ?? '' ] ?? ''; if(empty($data['sex']))
return '';
return CommonDict::getSexType()[ $data[ 'sex' ]] ?? '';
} }
/** /**

View File

@ -44,7 +44,9 @@ class MemberAccountLog extends BaseModel
*/ */
public function getAccountTypeNameAttr($value,$data) public function getAccountTypeNameAttr($value,$data)
{ {
return MemberAccountTypeDict::getType()[$data['account_type'] ?? ''] ?? ''; if(empty($data['account_type']))
return '';
return MemberAccountTypeDict::getType()[$data['account_type']] ?? '';
} }
/** /**

View File

@ -76,7 +76,9 @@ class MemberCashOut extends BaseModel
* @return mixed|string * @return mixed|string
*/ */
public function getAccountTypeNameAttr($value, $data){ public function getAccountTypeNameAttr($value, $data){
return MemberAccountTypeDict::getType()[ $data[ 'account_type' ] ?? '' ] ?? ''; if(empty($data['account_type']))
return '';
return MemberAccountTypeDict::getType()[ $data[ 'account_type' ]] ?? '';
} }
/** /**
* 提现状态名称 * 提现状态名称
@ -85,7 +87,9 @@ class MemberCashOut extends BaseModel
* @return mixed|string * @return mixed|string
*/ */
public function getStatusNameAttr($value, $data){ public function getStatusNameAttr($value, $data){
return MemberCashOutDict::getStatus()[ $data[ 'status' ] ?? '' ] ?? ''; if(empty($data[ 'status' ]))
return '';
return MemberCashOutDict::getStatus()[ $data[ 'status' ]] ?? '';
} }
/** /**
* 转账方式名称 * 转账方式名称
@ -95,7 +99,10 @@ class MemberCashOut extends BaseModel
*/ */
public function getTransferTypeNameAttr($value, $data) public function getTransferTypeNameAttr($value, $data)
{ {
return TransferDict::getTransferType()[ $data[ 'transfer_type' ] ?? '' ]['name'] ?? ''; if(empty($data[ 'transfer_type' ]))
return '';
$temp = TransferDict::getTransferType()[ $data[ 'transfer_type' ]] ?? [];
return $temp['name'] ?? '';
} }
/** /**
@ -105,7 +112,9 @@ class MemberCashOut extends BaseModel
* @return mixed|string * @return mixed|string
*/ */
public function getTransferStatusNameAttr($value, $data){ public function getTransferStatusNameAttr($value, $data){
return TransferDict::getStatus()[ $data[ 'transfer_status' ] ?? '' ] ?? ''; if(empty($data[ 'transfer_status' ]))
return '';
return TransferDict::getStatus()[ $data[ 'transfer_status' ]] ?? '';
} }
/** /**
* 会员搜索 * 会员搜索

View File

@ -39,7 +39,10 @@ class MemberCashOutAccount extends BaseModel
* @return mixed|string * @return mixed|string
*/ */
public function getAccountTypeNameAttr($value, $data){ public function getAccountTypeNameAttr($value, $data){
return TransferDict::getTransferType()[ $data[ 'transfer_type' ] ?? '' ] ?? ''; if(empty($data[ 'transfer_type' ]))
return '';
$temp = TransferDict::getTransferType()[ $data[ 'transfer_type' ]] ?? [];
return $temp['name'] ?? '';
} }
/** /**

View File

@ -49,7 +49,10 @@ class RechargeOrderItemRefund extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return RechargeOrderDict::getRefundStatus()[$data['status'] ?? '']['name'] ?? ''; if(empty($data['status']))
return '';
$temp = RechargeOrderDict::getRefundStatus()[$data['status']] ?? [];
return $temp['name'] ?? '';
} }
/** /**

View File

@ -53,7 +53,9 @@ class Pay extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return PayDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status']))
return '';
return PayDict::getStatus()[$data['status']] ?? '';
} }
/** /**
* 支付方式字段转化 * 支付方式字段转化
@ -62,7 +64,10 @@ class Pay extends BaseModel
*/ */
public function getTypeNameAttr($value, $data) public function getTypeNameAttr($value, $data)
{ {
return PayDict::getPayType()[$data['type'] ?? '']['name'] ?? ''; if(empty($data['type']))
return '';
$temp = PayDict::getPayType()[$data['type']] ?? [];
return $temp['name'] ?? '';
} }
} }

View File

@ -47,7 +47,9 @@ class PayChannel extends BaseModel
*/ */
public function getTypeNameAttr($value, $data) public function getTypeNameAttr($value, $data)
{ {
return PayDict::getPayType()[$data['type'] ?? '']['name'] ?? ''; if(empty($data['type'])) return '';
$temp = PayDict::getPayType()[$data['type']] ?? [];
return $temp['name'] ?? '';
} }
/** /**
@ -57,7 +59,8 @@ class PayChannel extends BaseModel
*/ */
public function getChannelNameAttr($value, $data) public function getChannelNameAttr($value, $data)
{ {
return ChannelDict::getType()[$data['channel'] ?? ''] ?? ''; if(empty($data['channel'])) return '';
return ChannelDict::getType()[$data['channel']] ?? '';
} }
} }

View File

@ -47,7 +47,8 @@ class Refund extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return RefundDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status'])) return '';
return RefundDict::getStatus()[$data['status']] ?? '';
} }
/** /**
@ -57,7 +58,8 @@ class Refund extends BaseModel
*/ */
public function getTypeNameAttr($value, $data) public function getTypeNameAttr($value, $data)
{ {
return RefundDict::getType()[$data['type'] ?? ''] ?? ''; if(empty($data['type'])) return '';
return RefundDict::getType()[$data['type']] ?? '';
} }
} }

View File

@ -48,7 +48,8 @@ class Transfer extends BaseModel
*/ */
public function getTransferStatusNameAttr($value, $data) public function getTransferStatusNameAttr($value, $data)
{ {
return TransferDict::getStatus()[$data['transfer_status'] ?? ''] ?? ''; if(empty($data['transfer_status'])) return '';
return TransferDict::getStatus()[$data['transfer_status']] ?? '';
} }
@ -59,7 +60,9 @@ class Transfer extends BaseModel
*/ */
public function getTransferTypeNameAttr($value, $data) public function getTransferTypeNameAttr($value, $data)
{ {
return TransferDict::getTransferType()[$data['transfer_type'] ?? '']['name'] ?? ''; if(empty($data['transfer_type'])) return '';
$temp = TransferDict::getTransferType()[$data['transfer_type']] ?? [];
return $temp['name'] ?? '';
} }
} }

View File

@ -46,7 +46,9 @@ class Site extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return SiteDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status']))
return '';
return SiteDict::getStatus()[$data['status']] ?? '';
} }
/** /**
* 关键字搜索 * 关键字搜索

View File

@ -0,0 +1,118 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\site;
use app\dict\site\SiteAccountLogDict;
use app\dict\site\SiteDict;
use app\model\pay\Pay;
use app\model\pay\Refund;
use app\model\pay\Transfer;
use core\base\BaseModel;
use think\db\Query;
/**
* 站点账单记录
* Class SiteAccountLog
* @package app\model\site
*/
class SiteAccountLog extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'site_account_log';
/**
* 状态字段转化
* @param $value
* @return mixed
*/
public function getTypeNameAttr($value, $data)
{
return SiteAccountLogDict::getType()[$data['type']] ?? '';
}
/**
* 获取相关支付单据信息
* @param $value
* @param $data
*/
public function getPayInfoAttr($value, $data)
{
switch ($data['type']){
case 'pay' :
return (new Pay())->where([['out_trade_no', '=', $data['trade_no']]])->append(['type_name'])->findOrEmpty()->toArray();
break;
case 'refund' :
return (new Refund())->where([['refund_no', '=', $data['trade_no']]])->findOrEmpty()->toArray();
break;
case 'transfer':
return (new Transfer())->where([['transfer_no', '=', $data['trade_no']]])->findOrEmpty()->toArray();
break;
default:
return [];
}
}
/**
* 状态字段转化
* @param $value
* @return mixed
*/
public function searchTypeAttr($query, $value, $data)
{
if ($value) {
$query->where('type', '=', $value );
}
}
/**
* 金额转化
* @param $value
* @return mixed
*/
public function getMoneyAttr($value, $data)
{
if(strpos($data['money'], "-") !== false){
return $data['money'];
}else{
return "+".$data['money'];
}
}
/**
* 创建时间搜索器
* @param $value
*/
public function searchCreateTimeAttr(Query $query, $value, $data)
{
$start_time = empty($value[ 0 ]) ? 0 : strtotime($value[ 0 ]);
$end_time = empty($value[ 1 ]) ? 0 : strtotime($value[ 1 ]);
if ($start_time > 0 && $end_time > 0) {
$query->whereBetweenTime('create_time', $start_time, $end_time);
} else if ($start_time > 0 && $end_time == 0) {
$query->where([ [ 'create_time', '>=', $start_time ] ]);
} else if ($start_time == 0 && $end_time > 0) {
$query->where([ [ 'create_time', '<=', $end_time ] ]);
}
}
}

View File

@ -12,6 +12,7 @@
namespace app\model\sys; namespace app\model\sys;
use app\dict\sys\AgreementDict; use app\dict\sys\AgreementDict;
use app\dict\sys\StorageDict;
use core\base\BaseModel; use core\base\BaseModel;
/** /**
@ -45,6 +46,7 @@ class SysAgreement extends BaseModel
*/ */
public function getAgreementKeyNameAttr($value, $data) public function getAgreementKeyNameAttr($value, $data)
{ {
return AgreementDict::getType()[$data['agreement_key'] ?? ''] ?? ''; if(empty($data['agreement_key'])) return '';
return AgreementDict::getType()[$data['agreement_key']] ?? '';
} }
} }

View File

@ -58,7 +58,9 @@ class SysMenu extends BaseModel
*/ */
public function getMenuTypeNameAttr($value,$data) public function getMenuTypeNameAttr($value,$data)
{ {
return MenuTypeDict::getMenuType()[$data['menu_type'] ?? ''] ?? ''; if(empty($data['menu_type']))
return '';
return MenuTypeDict::getMenuType()[$data['menu_type']] ?? '';
} }
/** /**
@ -69,6 +71,8 @@ class SysMenu extends BaseModel
*/ */
public function getStatusNameAttr($value,$data) public function getStatusNameAttr($value,$data)
{ {
return MenuDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status']))
return '';
return MenuDict::getStatus()[$data['status']] ?? '';
} }
} }

View File

@ -11,7 +11,9 @@
namespace app\model\sys; namespace app\model\sys;
use app\dict\notice\NoticeDict;
use app\dict\notice\NoticeTypeDict; use app\dict\notice\NoticeTypeDict;
use app\dict\sys\SmsDict;
use core\base\BaseModel; use core\base\BaseModel;
use think\db\Query; use think\db\Query;
@ -52,7 +54,9 @@ class SysNoticeLog extends BaseModel
*/ */
public function getContentAttr($value,$data) public function getContentAttr($value,$data)
{ {
$temp = json_decode($value); if($value){
$temp = json_decode($value, true);
}
if(!$temp){ if(!$temp){
$temp = $value; $temp = $value;
} }
@ -66,8 +70,12 @@ class SysNoticeLog extends BaseModel
*/ */
public function getNameAttr($value,$data) public function getNameAttr($value,$data)
{ {
$temp = \app\dict\notice\NoticeDict::getNotice()[$data['key'] ?? ''] ?? ''; $name = '';
return $temp['name'] ?? ''; if(!empty($data['key'])){
$temp = NoticeDict::getNotice()[$data['key']] ?? [];
$name = $temp['name'] ?? '';
}
return $name;
} }
/** /**
@ -78,8 +86,12 @@ class SysNoticeLog extends BaseModel
*/ */
public function getNoticeTypeNameAttr($value,$data) public function getNoticeTypeNameAttr($value,$data)
{ {
$temp = NoticeTypeDict::getType()[$data['notice_type'] ?? ''] ?? ''; $name = '';
return $temp['name'] ?? ''; if (!empty($data['notice_type'])) {
$temp = NoticeTypeDict::getType()[$data['notice_type']] ?? [];
$name = $temp['name'] ?? '';
}
return $name;
} }
/** /**
* 消息类型 * 消息类型

View File

@ -11,12 +11,13 @@
namespace app\model\sys; namespace app\model\sys;
use app\dict\notice\NoticeDict;
use app\dict\sys\SmsDict; use app\dict\sys\SmsDict;
use core\base\BaseModel; use core\base\BaseModel;
/** /**
* 系统短信消息发送记录 * 系统短信消息发送记录
* Class SysMessageLog * Class SysNoticeSmsLog
* @package app\model\sys * @package app\model\sys
*/ */
class SysNoticeSmsLog extends BaseModel class SysNoticeSmsLog extends BaseModel
@ -35,7 +36,7 @@ class SysNoticeSmsLog extends BaseModel
protected $name = 'sys_notice_sms_log'; protected $name = 'sys_notice_sms_log';
protected $type = [ protected $type = [
'send_time' => 'timestamp', 'send_time' => 'timestamp',
]; ];
// 设置json类型字段 // 设置json类型字段
@ -49,24 +50,31 @@ class SysNoticeSmsLog extends BaseModel
* @param $data * @param $data
* @return string * @return string
*/ */
public function getResultAttr($value,$data) public function getResultAttr($value, $data)
{ {
$temp = json_decode($value); if ($value) {
if(!$temp){ $temp = json_decode($value, true);
}
if (empty($temp)) {
$temp = $value; $temp = $value;
} }
return $temp; return $temp ?? '';
} }
/** /**
* 名称 * 名称
* @param $value * @param $value
* @param $data * @param $data
* @return string * @return string
*/ */
public function getNameAttr($value,$data) public function getNameAttr($value, $data)
{ {
$temp = \app\dict\notice\NoticeDict::getNotice()[$data['key'] ?? '']; $name = '';
return $temp['name'] ?? ''; if (!empty($data['key'])) {
$temp = NoticeDict::getNotice()[$data['key']] ?? [];
$name = $temp['name'] ?? '';
}
return $name;
} }
/** /**
@ -75,9 +83,13 @@ class SysNoticeSmsLog extends BaseModel
* @param $data * @param $data
* @return string * @return string
*/ */
public function getStatusNameAttr($value,$data) public function getStatusNameAttr($value, $data)
{ {
return SmsDict::getStatusType()[$data['status'] ?? ''] ?? ''; $name = '';
if (!empty($data['status'])) {
$name = SmsDict::getStatusType()[$data['status']] ?? '';
}
return $name;
} }
/** /**
@ -86,11 +98,25 @@ class SysNoticeSmsLog extends BaseModel
* @param $data * @param $data
* @return string * @return string
*/ */
public function getSmsTypesNameAttr($value,$data) public function getSmsTypesNameAttr($value, $data)
{ {
$temp = SmsDict::getType()[$data['sms_type'] ?? ''] ?? []; if(empty($data['sms_type'])) return '';
$temp = SmsDict::getType()[$data['sms_type']] ?? [];
return $temp['name'] ?? ''; return $temp['name'] ?? '';
} }
/**
* 消息标识
* @param $value
* @return mixed
*/
public function searchKeyAttr($query, $value)
{
if ($value) {
$query->where('key', $value);
}
}
/** /**
* 短信方式 * 短信方式
* @param $value * @param $value

View File

@ -45,7 +45,8 @@ class SysRole extends BaseModel
* @return string * @return string
*/ */
public function getStatusNameAttr($value, $data){ public function getStatusNameAttr($value, $data){
return RoleStatusDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status'])) return '';
return RoleStatusDict::getStatus()[$data['status']] ?? '';
} }

View File

@ -11,16 +11,14 @@
namespace app\model\sys; namespace app\model\sys;
use app\dict\sys\CronDict; use app\dict\schedule\ScheduleDict;
use core\base\BaseModel; use core\base\BaseModel;
use think\db\Query; use think\db\Query;
/** /**
* 定时任务模型 * 定时任务模型
* Class SysArea
* @package app\model\sys
*/ */
class SysCronTask extends BaseModel class SysSchedule extends BaseModel
{ {
/** /**
@ -33,7 +31,7 @@ class SysCronTask extends BaseModel
* 模型名称 * 模型名称
* @var string * @var string
*/ */
protected $name = 'sys_cron_task'; protected $name = 'sys_schedule';
protected $type = [ protected $type = [
'last_time' => 'timestamp', 'last_time' => 'timestamp',
@ -42,50 +40,47 @@ class SysCronTask extends BaseModel
]; ];
// 设置json类型字段 // 设置json类型字段
protected $json = ['data']; protected $json = ['time'];
// 设置JSON数据返回数组 // 设置JSON数据返回数组
protected $jsonAssoc = true; protected $jsonAssoc = true;
/** /**
* 任务模式 * 启用状态
* @param $value * @param $value
* @return mixed * @return mixed
*/ */
public function getTypeNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return CronDict::getType()[$data['type'] ?? ''] ?? ''; if(empty($data['status'])) return '';
return ScheduleDict::getStatus()[$data['status']] ?? '';
} }
/**
* 任务周期
* @param $value
* @return mixed
*/
public function getCrondTypeNameAttr($value, $data)
{
return CronDict::getCrondType()[$data['crond_type'] ?? ''] ?? '';
}
/**
* 任务名称搜索器
* @param $value
*/
public function searchTitleAttr(Query $query, $value, $data)
{
if ($value) {
$query->whereLike('title', '%'.$value.'%');
}
}
/** /**
* 任务类型搜索器 * 任务类型搜索器
* @param $value * @param $value
*/ */
public function searchTypeAttr(Query $query, $value, $data) public function searchKeyAttr(Query $query, $value, $data)
{ {
if ($value) { if ($value) {
$query->where('type', $value); $query->where('key', $value);
} }
} }
/**
* 状态搜索
* @param Query $query
* @param $value
* @param $data
* @return void
*/
public function searchStatusAttr(Query $query, $value, $data)
{
if ($value) {
$query->where('status', $value);
}
}
/** /**
* 执行时间搜索器 * 执行时间搜索器
* @param $value * @param $value

View File

@ -72,7 +72,8 @@ class SysUser extends BaseModel
*/ */
public function getStatusNameAttr($value, $data) public function getStatusNameAttr($value, $data)
{ {
return UserDict::getStatus()[$data['status'] ?? ''] ?? ''; if(empty($data['status'])) return '';
return UserDict::getStatus()[$data['status']] ?? '';
} }
public function getCreateTimeAttr($value, $data) public function getCreateTimeAttr($value, $data)

View File

@ -27,9 +27,7 @@ class AliappConfigService extends BaseAdminService
*/ */
public function getAliappConfig() public function getAliappConfig()
{ {
$config_info = (new CoreAliappConfigService())->getAliappConfig($this->site_id); return (new CoreAliappConfigService())->getAliappConfig($this->site_id);
return $config_info;
} }
/** /**

View File

@ -38,8 +38,7 @@ class ArticleCategoryService extends BaseAdminService
$field = 'category_id, site_id, name, sort, is_show, create_time, update_time'; $field = 'category_id, site_id, name, sort, is_show, create_time, update_time';
$order = 'create_time desc'; $order = 'create_time desc';
$search_model = $this->model->where([['site_id', '=', $this->site_id]])->withSearch(['name'], $where)->field($field)->order($order)->append(["article_num"]); $search_model = $this->model->where([['site_id', '=', $this->site_id]])->withSearch(['name'], $where)->field($field)->order($order)->append(["article_num"]);
$list = $this->pageQuery($search_model); return $this->pageQuery($search_model);
return $list;
} }
/** /**
@ -50,8 +49,7 @@ class ArticleCategoryService extends BaseAdminService
$field = 'category_id, site_id, name, sort'; $field = 'category_id, site_id, name, sort';
$order = 'sort desc'; $order = 'sort desc';
$list = $this->model->where([['site_id', '=', $this->site_id], ['is_show', '=', 1]])->field($field)->order($order)->select()->toArray(); return $this->model->where([['site_id', '=', $this->site_id], ['is_show', '=', 1]])->field($field)->order($order)->select()->toArray();
return $list;
} }
/** /**
@ -62,8 +60,7 @@ class ArticleCategoryService extends BaseAdminService
{ {
$field = 'category_id, site_id, name, sort, is_show, create_time, update_time'; $field = 'category_id, site_id, name, sort, is_show, create_time, update_time';
$info = $this->model->field($field)->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->append(["article_num"])->findOrEmpty()->toArray(); return $this->model->field($field)->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->append(["article_num"])->findOrEmpty()->toArray();
return $info;
} }
/** /**
@ -96,8 +93,7 @@ class ArticleCategoryService extends BaseAdminService
*/ */
public function del(int $id) public function del(int $id)
{ {
$res = $this->model->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->delete(); return $this->model->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->delete();
return $res;
} }
} }

View File

@ -39,8 +39,7 @@ class ArticleService extends BaseAdminService
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time'; $field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
$order = 'create_time desc'; $order = 'create_time desc';
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id', 'is_show'], $where)->with('articleCategory')->field($field)->order($order)->append(['article_url']); $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id', 'is_show'], $where)->with('articleCategory')->field($field)->order($order)->append(['article_url']);
$list = $this->pageQuery($search_model); return $this->pageQuery($search_model);
return $list;
} }
/** /**
@ -51,8 +50,7 @@ class ArticleService extends BaseAdminService
{ {
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time'; $field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
$info = $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->findOrEmpty()->toArray(); return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->findOrEmpty()->toArray();
return $info;
} }
/** /**
@ -86,8 +84,7 @@ class ArticleService extends BaseAdminService
*/ */
public function del(int $id) public function del(int $id)
{ {
$res = $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->delete(); return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->delete();
return $res;
} }
} }

View File

@ -19,6 +19,7 @@ use app\service\admin\sys\MenuService;
use app\service\admin\sys\RoleService; use app\service\admin\sys\RoleService;
use app\service\admin\user\UserRoleService; use app\service\admin\user\UserRoleService;
use app\service\admin\user\UserService; use app\service\admin\user\UserService;
use app\service\core\site\CoreSiteService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use core\exception\AuthException; use core\exception\AuthException;
use Exception; use Exception;
@ -35,21 +36,15 @@ class AuthService extends BaseAdminService
* @param $site_id * @param $site_id
*/ */
public function checkSiteAuth(Request $request){ public function checkSiteAuth(Request $request){
$site_id = $request->adminSiteId(); $site_code = $request->adminSiteId();
//没有当前站点的信息 //todo 将站点编号转化为站点id
if(!$this->getAuthRole($site_id)) $site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
{
throw new AuthException('NO_SITE_PERMISSION');
}
//查询站点信息并返回
$site_service = new SiteService();
$site_info = $site_service->getSiteCache($site_id);
//站点不存在 //站点不存在
if(empty($site_info)) if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
{ $site_id = $site_info['site_id'];
throw new AuthException('SITE_NOT_EXIST'); //没有当前站点的信息
} if(!$this->getAuthRole($site_id)) throw new AuthException('NO_SITE_PERMISSION');
$request->siteId($site_id); $request->siteId($site_id);
$request->appType($site_info['app_type']); $request->appType($site_info['app_type']);
return true; return true;

View File

@ -12,7 +12,11 @@
namespace app\service\admin\auth; namespace app\service\admin\auth;
use app\dict\sys\AppTypeDict;
use app\dict\sys\MenuDict;
use app\dict\sys\MenuTypeDict;
use app\model\site\Site; use app\model\site\Site;
use app\model\sys\SysMenu;
use app\service\admin\site\SiteService; use app\service\admin\site\SiteService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use think\facade\Cache; use think\facade\Cache;
@ -50,18 +54,11 @@ class AuthSiteService extends BaseAdminService
$auth_service = new AuthService(); $auth_service = new AuthService();
$user_role_list = $auth_service->getAuthSiteRoleList(); $user_role_list = $auth_service->getAuthSiteRoleList();
$site_ids = array_column($user_role_list, 'site_id'); $site_ids = array_column($user_role_list, 'site_id');
$site_list = $this->model->where([['site_id', 'in', $site_ids]])->field('app_type,site_name,logo')->column('site_id, site_name, logo, app_type'); return $this->model->where([['site_id', 'in', $site_ids]])->field('app_type,site_name,logo')->column('site_id, site_name, logo, app_type');
return $site_list;
}, },
SiteService::$cache_tag_name SiteService::$cache_tag_name
); );
// return Cache::tag(SiteService::$cache_tag_name)->remember($cache_name, function (){
// $auth_service = new AuthService();
// $user_role_list = $auth_service->getAuthSiteRoleList();
// $site_ids = array_column($user_role_list, 'site_id');
// $site_list = $this->model->where([['site_id', 'in', $site_ids]])->field('app_type,site_name,logo')->column('site_id, site_name, logo, app_type');
// return $site_list;
// });
} }
/** /**
@ -82,5 +79,15 @@ class AuthSiteService extends BaseAdminService
return (new SiteService())->getApiList($this->site_id, $status); return (new SiteService())->getApiList($this->site_id, $status);
} }
/**
* 查询当前站点可以单独显示的菜单(仅支持站点端调用)
* @return SysMenu[]|array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getShowMenuList(){
$menu_keys = (new SiteService())->getMenuIdsBySiteId($this->site_id, 1);
return (new SysMenu())->where([['menu_key', 'in', $menu_keys], ['menu_type', '=', MenuTypeDict::MENU], ['app_type', '=', AppTypeDict::SITE],['is_show', '=', 1]])->select()->toArray();
}
} }

View File

@ -37,13 +37,12 @@ class ConfigService extends BaseAdminService
public function getConfig() public function getConfig()
{ {
$info = (new CoreConfigService())->getConfig($this->request->defaultSiteId(), ConfigKeyDict::ADMIN_LOGIN)['value'] ?? []; $info = (new CoreConfigService())->getConfig($this->request->defaultSiteId(), ConfigKeyDict::ADMIN_LOGIN)['value'] ?? [];
$config = [ return [
'is_captcha' => $info['is_captcha'] ?? 0,//是否启用验证码 'is_captcha' => $info['is_captcha'] ?? 0,//是否启用验证码
'is_site_captcha' => $info['is_site_captcha'] ?? 0,//是否启用站点验证码 'is_site_captcha' => $info['is_site_captcha'] ?? 0,//是否启用站点验证码
'bg' => $info['bg'] ?? '',//平台登录端 背景 'bg' => $info['bg'] ?? '',//平台登录端 背景
'site_bg' => $info['site_bg'] ?? '',//站点登录端 背景 'site_bg' => $info['site_bg'] ?? '',//站点登录端 背景
]; ];
return $config;
} }
/** /**

View File

@ -70,7 +70,6 @@ class LoginService extends BaseAdminService
throw new AuthException('USER_LOCK'); throw new AuthException('USER_LOCK');
} }
if($app_type == AppTypeDict::ADMIN){ if($app_type == AppTypeDict::ADMIN){
$default_site_id = $this->request->defaultSiteId(); $default_site_id = $this->request->defaultSiteId();
$userrole = (new UserRoleService())->getUserRole($default_site_id, $userinfo->uid); $userrole = (new UserRoleService())->getUserRole($default_site_id, $userinfo->uid);

View File

@ -1,55 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\cron;
use app\service\core\schedule\CoreCronService;
use core\base\BaseAdminService;
/**
* 自动任务服务层
* Class SiteGroupService
* @package app\service\admin\site
*/
class CronService extends BaseAdminService
{
protected $core_cron_service;
public function __construct()
{
parent::__construct();
$this->core_cron_service = new CoreCronService();
}
/**
* 自动任务列表
* @param array $where
* @return mixed
*/
public function getPage(array $where = [])
{
return $this->core_cron_service->getPage($this->site_id, $where);
}
/**
* 分组详情
* @param int $group_id
* @return array
*/
public function getInfo(int $id)
{
return $this->core_cron_service->getInfo($this->site_id, $id);
}
}

View File

@ -143,6 +143,7 @@ class DiyRouteService extends BaseAdminService
public function modifyShare($data) public function modifyShare($data)
{ {
$field = 'id'; $field = 'id';
$data[ 'site_id' ] = $this->site_id;
$info = $this->model->field($field)->where([ [ 'name', '=', $data[ 'name' ] ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray(); $info = $this->model->field($field)->where([ [ 'name', '=', $data[ 'name' ] ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
if (!empty($info)) { if (!empty($info)) {
$this->model->where([ [ 'id', '=', $info[ 'id' ] ], [ 'site_id', '=', $this->site_id ] ])->update([ 'share' => $data[ 'share' ] ]); $this->model->where([ [ 'id', '=', $info[ 'id' ] ], [ 'site_id', '=', $this->site_id ] ])->update([ 'share' => $data[ 'share' ] ]);

View File

@ -16,6 +16,7 @@ use app\dict\diy\LinkDict;
use app\dict\diy\PagesDict; use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict; use app\dict\diy\TemplateDict;
use app\model\diy\Diy; use app\model\diy\Diy;
use app\model\site\Site;
use app\service\admin\sys\SystemService; use app\service\admin\sys\SystemService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use Exception; use Exception;
@ -36,14 +37,14 @@ class DiyService extends BaseAdminService
} }
/** /**
* 获取自定义页面列表 * 获取自定义页面分页列表
* @param array $where * @param array $where
* @return array * @return array
*/ */
public function getPage(array $where = []) public function getPage(array $where = [])
{ {
$where[] = [ 'site_id', '=', $this->site_id ]; $where[] = [ 'site_id', '=', $this->site_id ];
$field = 'id,site_id,title,name,type,is_default,share,visit_count,create_time,update_time'; $field = 'id,site_id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time';
$order = "is_default desc,update_time desc"; $order = "is_default desc,update_time desc";
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type" ], $where)->field($field)->order($order)->append([ 'type_name' ]); $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type" ], $where)->field($field)->order($order)->append([ 'type_name' ]);
$list = $this->pageQuery($search_model); $list = $this->pageQuery($search_model);
@ -51,17 +52,19 @@ class DiyService extends BaseAdminService
} }
/** /**
* 获取自定义页面列表
* @param array $where * @param array $where
* @param string $field
* @return array * @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/ */
public function getList(array $where = []) public function getList(array $where = [], $field = 'id,site_id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time')
{ {
$where[] = [ 'site_id', '=', $this->site_id ];
$field = 'id,site_id,title,name,type,is_default,share,visit_count,create_time,update_time';
$order = "is_default desc,update_time desc"; $order = "is_default desc,update_time desc";
$list = $this->model->where($where)->field($field)->select()->order($order)->toArray(); $list = $this->model->where([ [ [ 'site_id', '=', $this->site_id ] ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->select()->order($order)->toArray();
return $list; return $list;
} }
/** /**
@ -71,19 +74,29 @@ class DiyService extends BaseAdminService
*/ */
public function getInfo(int $id) public function getInfo(int $id)
{ {
$field = 'id,site_id,title,name,type,value,is_default,share,visit_count'; $field = 'id,site_id,title,name,template,type,mode,value,is_default,share,visit_count';
$info = $this->model->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray(); $info = $this->model->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
return $info; return $info;
} }
public function getInfoByName(string $name) public function getInfoByName(string $name)
{ {
$field = 'id,site_id,title,name,type,value,is_default,share,visit_count'; $field = 'id,site_id,title,name,template,type,mode,value,is_default,share,visit_count';
$info = $this->model->field($field)->where([ [ 'name', '=', $name ], [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ])->findOrEmpty()->toArray(); $info = $this->model->field($field)->where([ [ 'name', '=', $name ], [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ])->findOrEmpty()->toArray();
return $info; return $info;
} }
/**
* 查询数量
* @param array $where
* @return int
* @throws \think\db\exception\DbException
*/
public function getCount(array $where = [])
{
return $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'type' ], $where)->count();
}
/** /**
* 添加自定义页面 * 添加自定义页面
* @param array $data * @param array $data
@ -147,7 +160,7 @@ class DiyService extends BaseAdminService
} }
Db::startTrans(); Db::startTrans();
$this->model->where([ [ 'name', '=', $info[ 'name' ] ], [ 'site_id', '=', $this->site_id ] ])->update([ 'is_default' => 0 ]); $this->model->where([ [ 'name', '=', $info[ 'name' ] ], [ 'site_id', '=', $this->site_id ] ])->update([ 'is_default' => 0 ]);
$this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->update([ 'is_default' => 1 ]); $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->update([ 'is_default' => 1, 'update_time' => time() ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -163,7 +176,7 @@ class DiyService extends BaseAdminService
*/ */
public function getInit(array $params = []) public function getInit(array $params = [])
{ {
$page_template = TemplateDict::getTemplate(); $template = $this->getTemplate();
$time = time(); $time = time();
$data = []; $data = [];
@ -175,61 +188,80 @@ class DiyService extends BaseAdminService
if (!empty($data)) { if (!empty($data)) {
// 编辑赋值 // 编辑赋值
if (isset($page_template[ $data[ 'type' ] ])) {
$page = $page_template[ $data[ 'type' ] ]; if (isset($template[ $data[ 'type' ] ])) {
$page = $template[ $data[ 'type' ] ];
$data[ 'type_name' ] = $page[ 'title' ]; $data[ 'type_name' ] = $page[ 'title' ];
$data[ 'page' ] = $page[ 'page' ]; $data[ 'page' ] = $page[ 'page' ];
} }
} else { } else {
// 新页面赋值 // 新页面赋值
$type = 'DIY_PAGE'; $title = $params[ 'title' ] ? $params[ 'title' ] : '页面' . $time;
$type = $params[ 'type' ] ? $params[ 'type' ] : 'DIY_PAGE';
$name = $type == 'DIY_PAGE' ? 'DIY_PAGE_RANDOM_' . $time : $type;
$type_name = ''; $type_name = '';
$name = $params[ 'name' ]; $template_name = $params[ 'template' ] ?? ''; // 页面模板名称
$page_route = ''; $page_route = ''; // 页面路径
$mode = 'diy'; // 页面模式diy自定义fixed固定
$value = ''; $value = '';
if (isset($page_template[ $params[ 'template' ] ])) { $is_default = 0;
$page = $page_template[ $params[ 'template' ] ];
$name = $params[ 'template' ] == 'DIY_PAGE' ? 'DIY_PAGE_RANDOM_' . $time : $params[ 'template' ]; // 查询默认第一个页面模板数据
$type = $params[ 'template' ]; if (isset($template[ $params[ 'name' ] ])) {
$page = $template[ $params[ 'name' ] ];
$name = $params[ 'name' ];
$type = $params[ 'name' ];
$title = $page[ 'title' ];
$type_name = $page[ 'title' ]; $type_name = $page[ 'title' ];
$page_route = $page[ 'page' ]; $page_route = $page[ 'page' ];
// 查询指定页面数据 $page_data = $this->getFirstPageData($type);
$page_data = $this->getPageData($params[ 'template' ], $params[ 'template_name' ]);
if (!empty($page_data)) { if (!empty($page_data)) {
$value = json_encode($page_data[ 'data' ], JSON_UNESCAPED_UNICODE); $value = json_encode($page_data[ 'data' ], JSON_UNESCAPED_UNICODE);
$is_default = 1;
$template_name = $page_data[ 'template' ];
$mode = $page_data[ 'mode' ];
}
} else if (isset($template[ $type ])) {
// 查询指定页面数据
$page = $template[ $type ];
$type_name = $page[ 'title' ];
$page_route = $page[ 'page' ];
// 如果页面类型一条数据也没有,那么要默认 使用中
$count = $this->getCount([ 'type' => $type ]);
if ($count == 0) {
$is_default = 1;
}
if (!empty($params[ 'template' ])) {
$page_template = $page[ 'template' ][ $params[ 'template' ] ];
$mode = $page_template[ 'mode' ];
$page_data = $page_template[ 'data' ];
$page_data[ 'global' ][ 'title' ] = $title;
$value = json_encode($page_data, JSON_UNESCAPED_UNICODE);
} }
} }
$data = [ $data = [
'name' => $name, 'name' => $name,
'title' => $params[ 'title' ] ? $params[ 'title' ] : '页面' . $time, 'title' => $title,
'type' => $type, 'type' => $type,
'type_name' => $type_name, 'type_name' => $type_name,
'template' => $template_name,
'page' => $page_route, 'page' => $page_route,
'mode' => $mode,
'value' => $value, 'value' => $value,
'is_default' => 0 'is_default' => $is_default
]; ];
if (isset($page_template[ $params[ 'name' ] ])) {
$page = $page_template[ $params[ 'name' ] ];
$data[ 'name' ] = $params[ 'template' ] ? $params[ 'template' ] : $params[ 'name' ];
$data[ 'type' ] = $data[ 'name' ];
$data[ 'title' ] = $page[ 'title' ];
$data[ 'type_name' ] = $page[ 'title' ];
$data[ 'page' ] = $page[ 'page' ];
// 查询默认页面数据
$page_data = $this->getFirstPageData($data[ 'name' ]);
if (!empty($page_data)) {
$data[ 'value' ] = json_encode($page_data[ 'data' ], JSON_UNESCAPED_UNICODE);
$data[ 'is_default' ] = 1;
}
}
} }
$data[ 'component' ] = $this->getComponentList($data[ 'name' ]); $data[ 'component' ] = $this->getComponentList($data[ 'type' ]);
$data[ 'domain_url' ] = ( new SystemService() )->getUrl(); $data[ 'domain_url' ] = ( new SystemService() )->getUrl();
$data[ 'site_id' ] = $this->site_id; $site = Site::find($this->site_id);
$data[ 'site_id' ] = $site[ 'site_code' ];
return $data; return $data;
} }
@ -279,7 +311,7 @@ class DiyService extends BaseAdminService
// 查询自定义页面 // 查询自定义页面
if ($k == 'DIY_PAGE') { if ($k == 'DIY_PAGE') {
$diy_service = new DiyService(); $diy_service = new DiyService();
$list = $diy_service->getList([ [ 'type', '=', 'DIY_PAGE' ] ]); $list = $diy_service->getList([ 'type' => 'DIY_PAGE' ]);
foreach ($list as $ck => $cv) { foreach ($list as $ck => $cv) {
$link[ $k ][ 'child_list' ][] = [ $link[ $k ][ 'child_list' ][] = [
'name' => $cv[ 'name' ], 'name' => $cv[ 'name' ],
@ -312,28 +344,32 @@ class DiyService extends BaseAdminService
/** /**
* 获取页面模板 * 获取页面模板
* @param string $type * @param array $params
* @return array|string * @return array|string
*/ */
public function getTemplate(string $type) public function getTemplate($params = [])
{ {
$page_template = TemplateDict::getTemplate($type); $page_template = TemplateDict::getTemplate($params);
foreach ($page_template as $k => $v) { foreach ($page_template as $k => $v) {
// 查询页面数据 // 查询页面数据
$page_template[ $k ][ 'template' ] = PagesDict::getPages($k); $page_params = [
'type' => $k,
'mode' => $params[ 'mode' ] ?? ''
];
$page_template[ $k ][ 'template' ] = PagesDict::getPages($page_params);
} }
return $page_template; return $page_template;
} }
/** /**
* 获取页面数据 * 获取页面数据
* @param $template * @param $type
* @param $name * @param $name
* @return array * @return array
*/ */
public function getPageData($template, $name) public function getPageData($type, $name)
{ {
$pages = PagesDict::getPages($template); $pages = PagesDict::getPages([ 'type' => $type ]);
if (isset($pages[ $name ])) { if (isset($pages[ $name ])) {
return $pages[ $name ]; return $pages[ $name ];
} }
@ -342,18 +378,207 @@ class DiyService extends BaseAdminService
/** /**
* 获取默认页面数据 * 获取默认页面数据
* @param $template * @param $type
* @return array|mixed * @return array|mixed
*/ */
public function getFirstPageData($template) public function getFirstPageData($type)
{ {
$pages = PagesDict::getPages($template); $pages = PagesDict::getPages([ 'type' => $type ]);
if (!empty($pages)) { if (!empty($pages)) {
$template = array_key_first($pages);
$page = array_shift($pages); $page = array_shift($pages);
$page[ 'template' ] = $template; $page[ 'template' ] = $template;
$page[ 'type' ] = $type;
return $page; return $page;
} }
return []; return [];
} }
/**
* 获取页面装修列表
* @return array|string|null
*/
public function getDecoratePage()
{
// 查询可装修的页面
$template = $this->getTemplate([ 'action' => 'decorate' ]);
// 遍历查询页面数据,使用了那套模板
foreach ($template as $k => $v) {
// 查询我的微页面
$template[ $k ][ 'my_page' ] = $this->getList([ 'type' => $k, 'mode' => 'diy' ], 'id,title,name,template,type,is_default,mode');
$template[ $k ][ 'domain_url' ] = ( new SystemService() )->getUrl();
// 查询默认页面数据
$default_page_data = $this->getFirstPageData($k);
$use_template = [
'id' => 0,
'name' => $k,
'title' => $default_page_data[ 'title' ], // 模板名称
'template' => $default_page_data[ 'template' ], // 模板标识
'cover' => $default_page_data[ 'cover' ], // 封面图
'preview' => $default_page_data[ 'preview' ], // 预览图
'desc' => $default_page_data[ 'desc' ], // 模板描述
'mode' => $default_page_data[ 'mode' ], // 页面模式diy自定义fixed固定
'hope' => 'template', // 默认选中 模板
'url' => '' // 自定义页面链接,实时预览效果
];
// 查询页面数据
$info = $this->getInfoByName($k);
if (!empty($info)) {
$use_template[ 'id' ] = $info[ 'id' ];
$use_template[ 'title' ] = $info[ 'title' ];
// 检测模板是否存在
if (!empty($info[ 'template' ])) {
if (in_array($info[ 'template' ], array_keys($v[ 'template' ]))) {
$use_template[ 'template' ] = $info[ 'template' ];
$use_template[ 'mode' ] = $info[ 'mode' ];
$use_template[ 'hope' ] = $info[ 'mode' ] == 'fixed' ? 'template' : $info[ 'mode' ];
}
}
$use_template[ 'preview' ] = ''; // 默认图
$use_template[ 'desc' ] = '通过自定义装修的页面';
// 查询模板页面数
$page_data = $this->getPageData($k, $use_template[ 'template' ]);
if (!empty($page_data)) {
$use_template[ 'cover' ] = $page_data[ 'cover' ]; // 默认图
$use_template[ 'desc' ] = $page_data[ 'desc' ];
} else {
// 自定义页面,实时预览效果
$site = Site::find($this->site_id);
$use_template[ 'url' ] = '/pages/index/diy?&mode=preview&site_id=' . $site[ 'site_code' ] . '&id=' . $info[ 'id' ];
}
}
$template[ $k ][ 'use_template' ] = $use_template;
}
return $template;
}
/**
* 切换模板
* @param array $params
* @return array|mixed
* @throws Exception
*/
public function changeTemplate(array $params = [])
{
if ($params[ 'mode' ] == 'diy') {
// 自定义页面
// 查询
if (!empty($params[ 'id' ])) {
// 使用了微页面
$info = $this->getInfo($params[ 'id' ]);
if (!empty($info)) {
// 状态 变为 使用中
$this->setUse($info[ 'id' ]);
}
return $info;
} elseif ($params[ 'template' ]) {
// 查询模板信息
$page_data = $this->getPageData($params[ 'type' ], $params[ 'template' ]);
// 查询表中未修改的模板数据
$field = 'id';
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'type', '=', $params[ 'type' ] ],
[ 'template', '=', $params[ 'template' ] ],
[ 'mode', '=', $params[ 'mode' ] ],
[ 'is_change', '=', 0 ]
];
$info = $this->model->field($field)->where($condition)->findOrEmpty()->toArray();
if (!empty($info)) {
// 状态 变为 使用中
$this->setUse($info[ 'id' ]);
return $info;
} else {
// 新增 数据
$data = [
'title' => $page_data[ 'title' ],
'name' => $params[ 'type' ],
'type' => $params[ 'type' ],
'value' => json_encode($page_data[ 'data' ], JSON_UNESCAPED_UNICODE),
'template' => $params[ 'template' ],
'mode' => $params[ 'mode' ]
];
$res = $this->add($data);
$this->setUse($res);
}
}
} elseif ($params[ 'mode' ] == 'fixed') {
// 固定模板
// 查询模板信息
$page_data = $this->getPageData($params[ 'type' ], $params[ 'template' ]);
// 检查表里是否存在数据
$field = 'id';
$condition = [
[ 'site_id', '=', $this->site_id ],
[ 'type', '=', $params[ 'type' ] ],
[ 'template', '=', $params[ 'template' ] ],
[ 'mode', '=', $params[ 'mode' ] ]
];
$info = $this->model->field($field)->where($condition)->findOrEmpty()->toArray();
if (!empty($info)) {
// 状态 变为 使用中
$this->setUse($info[ 'id' ]);
} else {
// 新增 数据
$data = [
'title' => $page_data[ 'title' ],
'name' => $params[ 'type' ],
'type' => $params[ 'type' ],
'value' => json_encode($page_data[ 'data' ], JSON_UNESCAPED_UNICODE),
'template' => $params[ 'template' ],
'mode' => $params[ 'mode' ]
];
$res = $this->add($data);
$this->setUse($res);
}
return $info;
}
return $params;
}
/**
* 获取页面预览数据
* @param array $params
* @return array
*/
public function getPreviewData(array $params = [])
{
$info = [];
if (!empty($params[ 'id' ])) {
$info = $this->getInfo($params[ 'id' ]);
} elseif (!empty($params[ 'name' ])) {
$info = $this->getInfoByName($params[ 'name' ]);
}
$res = [
'page' => $this->getTemplate([ 'type' => 'DIY_PAGE' ])[ 'DIY_PAGE' ][ 'page' ]
];
if (!empty($info)) {
if ($info[ 'is_default' ] == 1) {
$template = $this->getTemplate([ 'type' => $info[ 'type' ] ])[ $info[ 'type' ] ];
$res[ 'page' ] = $template[ 'page' ] . '?id=' . $info[ 'id' ];
}
}
return $res;
}
} }

View File

@ -115,7 +115,7 @@ class ModelGenerator extends BaseGenerator
if (!$column['is_search']) { if (!$column['is_search']) {
continue; continue;
} }
$function_str .= '/**'.PHP_EOL.' * 搜索器:'.$this->table['table_content'].$column['column_comment'].''.PHP_EOL.' * @param $value'.PHP_EOL.' * @param $data'.PHP_EOL.' */'.PHP_EOL; $function_str .= '/**'.PHP_EOL.' * 搜索器:'.$this->table['table_content'].$column['column_comment'].PHP_EOL.' * @param $value'.PHP_EOL.' * @param $data'.PHP_EOL.' */'.PHP_EOL;
$function_str .= 'public function search'.Str::studly($column['column_name']).'Attr($query, $value, $data)'.PHP_EOL; $function_str .= 'public function search'.Str::studly($column['column_name']).'Attr($query, $value, $data)'.PHP_EOL;
$function_str .= '{'.PHP_EOL; $function_str .= '{'.PHP_EOL;
$function_str .= ' if ($value) {'.PHP_EOL; $function_str .= ' if ($value) {'.PHP_EOL;

View File

@ -70,7 +70,7 @@ class ServiceGenerator extends BaseGenerator
{ {
$field = []; $field = [];
foreach ($this->tableColumn as $column) { foreach ($this->tableColumn as $column) {
if ($column['is_lists'] || $column['is_insert'] || $column['is_update']) { if ($column['is_query']) {
$field[] = $column['column_name']; $field[] = $column['column_name'];
} }
} }

View File

@ -101,7 +101,7 @@ class WebIndexGenerator extends BaseGenerator
$file_name = str_replace('_', '-', Str::lower($this->getTableName())).'-edit'; $file_name = str_replace('_', '-', Str::lower($this->getTableName())).'-edit';
if($this->className){ if($this->className){
$file_name = Str::lower($this->className) . '-edit';; $file_name = Str::lower($this->className) . '-edit';
} }
return '<'.$file_name.' ref="edit'.$this->getUCaseClassName().'Dialog" @complete="load'.$this->getUCaseName().'List" />'; return '<'.$file_name.' ref="edit'.$this->getUCaseClassName().'Dialog" @complete="load'.$this->getUCaseName().'List" />';

View File

@ -28,7 +28,7 @@ Route::group('{MODULE_NAME}', function () {
//添加{NOTES} //添加{NOTES}
Route::post('{ROUTE_NAME}', '{MODULE_NAME}.{UCASE_CLASS_NAME}/add'); Route::post('{ROUTE_NAME}', '{MODULE_NAME}.{UCASE_CLASS_NAME}/add');
//编辑{NOTES} //编辑{NOTES}
Route::put('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/update'); Route::put('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/edit');
//删除{NOTES} //删除{NOTES}
Route::delete('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/del'); Route::delete('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/del');

View File

@ -61,7 +61,7 @@ class MemberAccountService extends BaseAdminService
public function getInfo(int $id) public function getInfo(int $id)
{ {
$field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo'; $field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo';
return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('memberInfo')->field($field)->findOrEmpty()->append([ 'from_type_name', 'account_type_name' ])->toArray(); return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('memberInfo')->field($field)->append([ 'from_type_name', 'account_type_name' ])->findOrEmpty()->toArray();
} }
/** /**

View File

@ -17,7 +17,7 @@ use app\service\core\notice\CoreNoticeSmsLogService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
/** /**
* 消息管理服务层 * 短信消息管理服务层
*/ */
class NoticeSmsLogService extends BaseAdminService class NoticeSmsLogService extends BaseAdminService
{ {
@ -40,8 +40,8 @@ class NoticeSmsLogService extends BaseAdminService
* 获取消息内容 * 获取消息内容
* @param string $key * @param string $key
*/ */
public function getInfo(string $key) public function getInfo(int $id)
{ {
return (new CoreNoticeLogService())->getInfo($this->site_id, $key); return (new CoreNoticeSmsLogService())->getInfo($this->site_id, $id);
} }
} }

View File

@ -0,0 +1,93 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\schedule;
use app\service\core\schedule\CoreScheduleService;
use core\base\BaseAdminService;
/**
* 计划任务服务层
* Class CoreCronService
* @package app\service\core\cron
*/
class ScheduleService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
}
/**
* 获取自动任务列表
* @param array $where
* @return mixed
*/
public function getPage(array $data = [])
{
return (new CoreScheduleService())->getPage($data);
}
/**
* 获取信息
* @param int $id
* @return array
*/
public function getInfo(int $id){
return (new CoreScheduleService())->getInfo($id);
}
/**
* 启用或关闭
* @param int $id
* @param $status
* @return true
*/
public function modifyStatus(int $id, $status)
{
return (new CoreScheduleService())->modifyStatus($id, $status);
}
/**
* 添加
* @param array $data
*/
public function add(array $data)
{
$res = (new CoreScheduleService())->add($data);
return $res->id;
}
/**
* 编辑
* @param int $id
* @param array $data
*/
public function edit(int $id, array $data)
{
(new CoreScheduleService())->edit($id, $data);
return true;
}
/**
* 删除
* @param int $id
*/
public function del(int $id)
{
return (new CoreScheduleService())->del($id);
}
}

View File

@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\site;
use app\dict\sys\AppTypeDict;
use app\model\site\Site;
use app\model\site\SiteAccountLog;
use app\service\admin\sys\MenuService;
use app\service\admin\user\UserService;
use core\base\BaseAdminService;
use core\exception\AdminException;
use Exception;
use think\facade\Cache;
use think\facade\Db;
/**
* 站点账单服务层
* Class SiteAccountLogService
* @package app\service\admin\site
*/
class SiteAccountLogService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
$this->model = new SiteAccountLog();
}
/**
* 获取账单列表
* @param array $where
* @param string $order
* @return mixed
*/
public function getPage(array $where = [])
{
$field = 'id, site_id, type, money, trade_no, create_time';
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'create_time', 'type' ], $where)->field($field)->append([ 'type_name', 'pay_info', 'money' ])->order('create_time desc');
$list = $this->pageQuery($search_model);
return $list;
}
/**
* 获取账单详情
* @param int $id
* @return array
*/
public function getInfo(int $id)
{
$field = 'id, site_id, type, money, trade_no, create_time';
return $this->model->where([ [ 'site_id', '=', $this->site_id ], ['id', '=', $id]])->field($field)->append([ 'type_name', 'pay_info' ])->findOrEmpty()->toArray();
}
/**
* 统计数据
* @return array
*/
public function stat()
{
return [
'pay' => $this->model->where([[ 'site_id', '=', $this->site_id ], ['type', '=', 'pay']])->sum("money")*1,
'refund' => $this->model->where([[ 'site_id', '=', $this->site_id ], ['type', '=', 'refund']])->sum("money")*-1,
'transfer' => $this->model->where([[ 'site_id', '=', $this->site_id ], ['type', '=', 'transfer']])->sum("money")*-1,
];
}
}

View File

@ -128,9 +128,6 @@ class SiteGroupService extends BaseAdminService
}, },
[MenuService::$cache_tag_name,self::$cache_tag_name] [MenuService::$cache_tag_name,self::$cache_tag_name]
); );
// return Cache::tag([MenuService::$cache_tag_name,self::$cache_tag_name])->remember($cache_name, function () use ($group_id) {
// return $this->model->findOrEmpty($group_id)?->group_roles ?? [];
// });
} }
/** /**

View File

@ -46,7 +46,7 @@ class SiteService extends BaseAdminService
{ {
$field = 'site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id, $field = 'site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id,
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id'; district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, site_code';
$search_model = $this->model->where([ [ 'app_type', '<>', 'admin' ] ])->withSearch([ 'create_time', 'expire_time', 'keywords', 'status', 'group_id' ], $where)->with('groupName')->field($field)->append([ 'status_name' ])->order('create_time desc'); $search_model = $this->model->where([ [ 'app_type', '<>', 'admin' ] ])->withSearch([ 'create_time', 'expire_time', 'keywords', 'status', 'group_id' ], $where)->with('groupName')->field($field)->append([ 'status_name' ])->order('create_time desc');
$list = $this->pageQuery($search_model); $list = $this->pageQuery($search_model);
return $list; return $list;
@ -60,7 +60,7 @@ class SiteService extends BaseAdminService
public function getInfo(int $site_id) public function getInfo(int $site_id)
{ {
$field = 'site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id, $field = 'site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id,
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id'; district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, site_code';
return $this->model->where([ [ 'site_id', '=', $site_id ] ])->with('groupName')->field($field)->append([ 'status_name' ])->findOrEmpty()->toArray(); return $this->model->where([ [ 'site_id', '=', $site_id ] ])->with('groupName')->field($field)->append([ 'status_name' ])->findOrEmpty()->toArray();
} }
@ -88,6 +88,7 @@ class SiteService extends BaseAdminService
try { try {
$site = $this->model->create($data_site); $site = $this->model->create($data_site);
$site_id = $site->site_id; $site_id = $site->site_id;
//$this->model->where([['site_id', '=', $site_id]])->update(['site_code' => $this->createSiteCodeBySiteId($site_id)]);
//添加用户 //添加用户
$data_user = [ $data_user = [
'username' => $data[ 'username' ], 'username' => $data[ 'username' ],
@ -111,6 +112,24 @@ class SiteService extends BaseAdminService
} }
} }
/**
* 通过站点id生成站点code
* @param int $site_id
*/
public function createSiteCodeBySiteId(int $site_id)
{
retrun ($site_id + 1000000) *11 + 1;
}
/**
* 通过站点code获取站点id
* @param $site_code
*/
public function getSiteIdBySiteCode($site_code)
{
retrun ($site_code-1) /11-1000000;
}
/** /**
* 修改站点 * 修改站点
* @param int $site_id * @param int $site_id
@ -149,24 +168,11 @@ class SiteService extends BaseAdminService
$where = [ $where = [
[ 'site_id', '=', $site_id ], [ 'site_id', '=', $site_id ],
]; ];
$site = $this->model->where($where)->field('app_type,site_name,front_end_name,front_end_logo,logo,icon,group_id, status, expire_time')->findOrEmpty(); $site = $this->model->where($where)->field('site_id, app_type,site_name,front_end_name,front_end_logo,logo,icon,group_id, status, expire_time, site_code')->append([ 'status_name' ])->findOrEmpty();
if (!$site->isEmpty()) {
$site->append([ 'status_name' ]);
}
return $site->toArray(); return $site->toArray();
}, },
self::$cache_tag_name . $site_id self::$cache_tag_name . $site_id
); );
// return Cache::tag(self::$cache_tag_name . $site_id)->remember($cache_name . $site_id, function() use ($site_id) {
// $where = [
// [ 'site_id', '=', $site_id ],
// ];
// $site = $this->model->where($where)->field('app_type,site_name,logo,group_id, status, expire_time')->findOrEmpty();
// if (!$site->isEmpty()) {
// $site->append([ 'status_name' ]);
// }
// return $site->toArray();
// });
} }
@ -203,7 +209,7 @@ class SiteService extends BaseAdminService
* @param $status * @param $status
* @return array|mixed|string|null * @return array|mixed|string|null
*/ */
public function getMenuIdsBySiteId(int $site_id, $is_tree, $status) public function getMenuIdsBySiteId(int $site_id, $status)
{ {
$site_info = $this->getSiteCache($site_id); $site_info = $this->getSiteCache($site_id);
if (empty($site_info)) if (empty($site_info))

View File

@ -99,6 +99,10 @@ class SiteStatService extends BaseAdminService
$woman_count = (new MemberService())->getCount([ ['sex', '=', '2'] ]); $woman_count = (new MemberService())->getCount([ ['sex', '=', '2'] ]);
$data['member_stat']['value'] = [$man_count, $woman_count, (int)($member_count - $man_count - $woman_count)]; $data['member_stat']['value'] = [$man_count, $woman_count, (int)($member_count - $man_count - $woman_count)];
$data['site_info'] = (new SiteService())->getInfo($this->site_id); $data['site_info'] = (new SiteService())->getInfo($this->site_id);
$site_create_time = strtotime($data['site_info']['create_time']);
$site_expire_time = strtotime($data['site_info']['expire_time']);
$data['site_info']['mix'] = (number_format((time() - $site_create_time) / ($site_expire_time - $site_create_time), 2) * 100).'%'; ;
$data['site_info']['over_date'] = $site_expire_time - time() > 0 ? number_format(($site_expire_time - time())/ 86400, 2) : 0;
return $data; return $data;
} }

View File

@ -41,16 +41,10 @@ class AreaService extends BaseAdminService
return cache_remember( return cache_remember(
$cache_name, $cache_name,
function() use($pid) { function() use($pid) {
$list = $this->model->where([['pid', '=', $pid]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray(); return $this->model->where([['pid', '=', $pid]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
return $list;
}, },
[self::$cache_tag_name] [self::$cache_tag_name]
); );
// return Cache::tag([self::$cache_tag_name])->remember($cache_name, function() use($pid) {
// $list = $this->model->where([['pid', '=', $pid]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
// return $list;
// });
} }
/** /**
@ -65,17 +59,80 @@ class AreaService extends BaseAdminService
$cache_name, $cache_name,
function() use($level) { function() use($level) {
$list = $this->model->where([['level', '<=', $level]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray(); $list = $this->model->where([['level', '<=', $level]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
$tree = list_to_tree($list, 'id', 'pid'); return list_to_tree($list, 'id', 'pid');
return $tree;
}, },
[self::$cache_tag_name] [self::$cache_tag_name]
); );
// return Cache::tag([self::$cache_tag_name])->remember($cache_name, function() use($level) {
// $list = $this->model->where([['level', '<=', $level]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
// $tree = list_to_tree($list, 'id', 'pid');
// return $tree;
// });
} }
/**
* @param string $address
* @return int|mixed
* 地址解析
*/
public function getAddress(string $address){
$map = (new ConfigService())->getMap();
$url = "https://apis.map.qq.com/ws/geocoder/v1/?address=".$address."&key=".$map['key'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$res = curl_exec($curl);
$res = json_decode($res, true);
if($res){
curl_close($curl);
return $res;
}else {
$error = curl_errno($curl);
curl_close($curl);
return $error;
}
}
/**
* @param string $location
* @return int|mixed
* 逆地址解析
*/
public function getAddressInfo(string $location){
$map = (new ConfigService())->getMap();
$url = "https://apis.map.qq.com/ws/geocoder/v1/?location=".$location."&key=".$map['key'];
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$res = curl_exec($curl);
$res = json_decode($res, true);
if($res){
curl_close($curl);
return $res;
}else {
$error = curl_errno($curl);
curl_close($curl);
return $error;
}
}
public function getAreaId($name, $level){
$field = 'id';
$info = $this->model->field($field)->where([['name', 'like', '%' . $name . '%' ], ['level', '=', $level]])->findOrEmpty()->toArray();
return $info;
}
/**
* 获取地址名称
*/
public function getAreaName($id){
$info = $this->model->field("name")->where([['id', '=', $id ]])->findOrEmpty()->toArray();
return $info['name'];
}
} }

View File

@ -174,8 +174,7 @@ class AttachmentService extends BaseAdminService
['id', '=', $id] ['id', '=', $id]
); );
$category_model = new SysAttachmentCategory(); $category_model = new SysAttachmentCategory();
$res = $category_model->where($where)->update($data); return $category_model->where($where)->update($data);
return $res;
} }
/** /**
@ -191,8 +190,7 @@ class AttachmentService extends BaseAdminService
throw new AdminException('ATTACHMENT_GROUP_HAS_IMAGE'); throw new AdminException('ATTACHMENT_GROUP_HAS_IMAGE');
//下级存在图片不能删除 //下级存在图片不能删除
$res = $category->delete(); return $category->delete();
return $res;
} }

View File

@ -15,6 +15,7 @@ use app\service\admin\site\SiteService;
use app\service\core\sys\CoreConfigService; use app\service\core\sys\CoreConfigService;
use app\service\core\sys\CoreSysConfigService; use app\service\core\sys\CoreSysConfigService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use core\exception\AdminException;
/** /**
* 配置服务层 * 配置服务层
@ -58,8 +59,7 @@ class ConfigService extends BaseAdminService
'copyright_link' => $value['copyright_link'], 'copyright_link' => $value['copyright_link'],
'copyright_desc' => $value['copyright_desc'] 'copyright_desc' => $value['copyright_desc']
]; ];
$res = $this->core_config_service->setConfig(0,'COPYRIGHT', $data); return $this->core_config_service->setConfig(0,'COPYRIGHT', $data);
return $res;
} }
/** /**
@ -120,8 +120,7 @@ class ConfigService extends BaseAdminService
"enterprise_wechat" => $value['enterprise_wechat'], "enterprise_wechat" => $value['enterprise_wechat'],
"tel" => $value['tel'] "tel" => $value['tel']
]; ];
$res = $this->core_config_service->setConfig(0,'SERVICE_INFO', $data); return $this->core_config_service->setConfig(0,'SERVICE_INFO', $data);
return $res;
} }
/** /**
@ -134,8 +133,7 @@ class ConfigService extends BaseAdminService
$data = [ $data = [
'key' => $value['key'], 'key' => $value['key'],
]; ];
$res = $this->core_config_service->setConfig($this->site_id,'MAPKEY', $data); return $this->core_config_service->setConfig($this->site_id,'MAPKEY', $data);
return $res;
} }
/** /**
@ -148,9 +146,100 @@ class ConfigService extends BaseAdminService
{ {
$info = []; $info = [];
$info['value'] = [ $info['value'] = [
'key' => '', 'key' => 'IZQBZ-3UHEU-WTCVD-2464U-I5N4V-ZFFU3',
]; ];
} }
return $info['value']; return $info['value'];
} }
/**
* 获取站点主页配置
* @return mixed|string[]
*/
public function getSiteIndexConfig()
{
$config = (new CoreConfigService())->getConfig($this->site_id, "site_index");
if(empty($config))
{
$config['value'] = [
'view_path' => 'index/site_index'
];
}
return $config['value']['view_path'];
}
/**
* 站点主页配置
* @param $data
* @return \app\model\sys\SysConfig|bool|\think\Model
*/
public function setSiteIndexConfig($data)
{
$config = [
'view_path' => $data['view_path'] ,
];
//检测是否路劲一个异常
$index_list = $this->getSiteIndexList();
$check_tag = 0;
foreach($index_list as $k => $v)
{
if($v['view_path'] == $data['view_path'])
{
$check_tag = 1;
}
}
if($check_tag == 0) throw new AdminException('SITE_INDEX_VIEW_PATH_NOT_EXIST');
(new CoreConfigService())->setConfig($this->site_id, "site_index", $config);
return true;
}
/**
* 获取站点配置的首页列表
* @return array
*/
public function getSiteIndexList()
{
$result = event("SiteIndex");
$index_list = [];
foreach ($result as $k => $v)
{
$index_list = empty($index_list) ? $v: array_merge($index_list, $v);
}
$view_path = $this->getSiteIndexConfig();
foreach ($index_list as $k => $v)
{
$v_view_path = $v['view_path'] ?? '';
$index_list[$k]['is_use'] = ($v_view_path == $view_path) ? 1: 0;
}
return $index_list;
}
/**
* 设置站点快捷菜单
* @param $data
* @return bool
*/
public function setShortcutMenu($data)
{
(new CoreConfigService())->setConfig($this->site_id, 'shortcut_menu', $data);
return true;
}
/**
* 获取站点快捷菜单
* @return array|mixed
*/
public function getShortcutMenu()
{
$config = (new CoreConfigService())->getConfig($this->site_id, 'shortcut_menu');
$menu = $config['value'] ?? [];
if(!empty($menu)){
$menu_service = new MenuService();
foreach($menu as &$v){
$item_router_path = $v['router_path'] ?? '';
if(!$item_router_path) $v['router_path'] = $menu_service->getFullRouterPath($v['menu_key']);
}
}
return $menu;
}
} }

View File

@ -142,12 +142,63 @@ class MenuService extends BaseAdminService
{ {
$menu_list[$k]['menu_name'] = $lang_menu_name; $menu_list[$k]['menu_name'] = $lang_menu_name;
} }
//首页加载
if($v['menu_key'] == 'overview' && $v['app_type'] == 'site')
{
$view_path = (new ConfigService())->getSiteIndexConfig();
$menu_list[$k]['view_path'] = $view_path;
}
} }
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', 1) : $menu_list; return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', 1) : $menu_list;
} }
/**
* 获取所有接口菜单
*/
public function getAllMenuList($app_type = '', $status = 'all', $is_tree = 0, $is_button = 0)
{
$cache_name = 'menu_api_' .$app_type.'_'. $status . '_' . $is_tree . '_' . $is_button;
$menu_list = cache_remember(
$cache_name,
function () use ($status, $is_tree, $is_button, $app_type) {
$where = [
// ['menu_type', 'in', [0,1]]
['app_type', '=', $app_type],
];
if ($status != 'all') {
$where[] = ['status', '=', $status];
}
$menu_list = $this->model->where($where)->order('sort desc')->select()->toArray();
return $menu_list;
},
self::$cache_tag_name
);
foreach ($menu_list as $k => $v)
{
$lang_menu_key = "dict_menu_". $v['app_type']. '.'. $v['menu_key'];
$lang_menu_name = get_lang("dict_menu_". $v['app_type']. '.'. $v['menu_key']);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$menu_list[$k]['menu_name'] = $lang_menu_name;
}
//首页加载
if($v['menu_key'] == 'overview' && $v['app_type'] == 'site')
{
$view_path = (new ConfigService())->getSiteIndexConfig();
$menu_list[$k]['view_path'] = $view_path;
}
}
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list;
}
/** /**
* 通过菜单menu_key组获取接口数组 * 通过菜单menu_key组获取接口数组
* @param array $menu_keys * @param array $menu_keys
@ -173,19 +224,6 @@ class MenuService extends BaseAdminService
}, },
self::$cache_tag_name self::$cache_tag_name
); );
// return Cache::tag(self::$cache_tag_name)->remember($cache_name, function () use ($menu_keys, $app_type) {
// $where = [
// ['menu_key', 'in', $menu_keys]
// ];
// if(!empty($app_type)){
// $where[] = ['app_type', '=', $app_type];
// }
// $menu_list = (new SysMenu())->where($where)->order('sort', 'desc')->column('api_url,methods');
// foreach ($menu_list as $v) {
// $auth_menu_list[$v['methods']][] = $v['api_url'];
// }
// return $auth_menu_list ?? [];
// });
} }
@ -214,18 +252,6 @@ class MenuService extends BaseAdminService
}, },
self::$cache_tag_name self::$cache_tag_name
); );
// return Cache::tag(self::$cache_tag_name)->remember($cache_name, function () use ($menu_keys, $app_type) {
// $where = [
// ['menu_key', 'in', $menu_keys],
// ['menu_type', '=', MenuTypeDict::BUTTON]
// ];
// if(!empty($app_type)){
// $where[] = ['app_type', '=', $app_type];
// }
// $menu_list = $this->model->where($where)->order('sort', 'desc')->column('menu_key');
// return $menu_list;
//
// });
} }
/** /**
@ -256,21 +282,6 @@ class MenuService extends BaseAdminService
}, },
self::$cache_tag_name self::$cache_tag_name
); );
// return Cache::tag(self::$cache_tag_name)->remember($cache_name, function () use ($status, $app_type) {
// $where = [
// ['api_url', '<>', ''],
// ['app_type', '=', $app_type],
// ];
// if ($status != 'all') {
// $where[] = ['status', '=', $status];
// }
// $menu_list = $this->model->where($where)->order('sort', 'desc')->column('methods, api_url');
// $auth_menu_list = [];
// foreach ($menu_list as $v) {
// $auth_menu_list[$v['methods']][] = $v['api_url'];
// }
// return $auth_menu_list;
// });
} }
/** /**
@ -296,41 +307,6 @@ class MenuService extends BaseAdminService
self::$cache_tag_name self::$cache_tag_name
); );
} }
/**
* 获取所有接口菜单
*/
public function getAllMenuList($app_type = '', $status = 'all', $is_tree = 0, $is_button = 0)
{
$cache_name = 'menu_api_' .$app_type.'_'. $status . '_' . $is_tree . '_' . $is_button;
$menu_list = cache_remember(
$cache_name,
function () use ($status, $is_tree, $is_button, $app_type) {
$where = [
// ['menu_type', 'in', [0,1]]
['app_type', '=', $app_type],
];
if ($status != 'all') {
$where[] = ['status', '=', $status];
}
$menu_list = $this->model->where($where)->order('sort desc')->select()->toArray();
return $menu_list;
},
self::$cache_tag_name
);
foreach ($menu_list as $k => $v)
{
$lang_menu_key = "dict_menu_". $v['app_type']. '.'. $v['menu_key'];
$lang_menu_name = get_lang("dict_menu_". $v['app_type']. '.'. $v['menu_key']);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$menu_list[$k]['menu_name'] = $lang_menu_name;
}
}
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list;;
}
@ -355,17 +331,6 @@ class MenuService extends BaseAdminService
}, },
self::$cache_tag_name self::$cache_tag_name
); );
// return Cache::tag(self::$cache_tag_name)->remember($cache_name, function () use ($status, $is_tree, $app_type) {
// $where = [
// ['menu_type', '=', MenuTypeDict::BUTTON],
// ['app_type', '=', $app_type],
// ];
// if ($status != 'all') {
// $where[] = ['status', '=', $status];
// }
// $menu_list = $this->model->where($where)->order('sort', 'desc')->column('menu_key');
// return $menu_list;
// });
} }
/** /**
@ -409,6 +374,40 @@ class MenuService extends BaseAdminService
} }
/**
* 获取完整的路由地址
* @param $menu
* @return string
*/
public function getFullRouterPath($menu_key){
$menu = $this->find($menu_key);
$parents = [];
$this->getParentDirectory($menu, $parents);
$parents = array_reverse($parents);
$router_path = implode('/', $parents);
if(!empty($router_path)){
$router_path .= '/'.$menu['router_path'];
}else{
$router_path = $menu['router_path'];
}
return $router_path;
}
/**
* 递归查询模板集合
* @param SysMenu $menu
* @param $parents
* @return void
*/
public function getParentDirectory(SysMenu $menu, &$parents){
if(!$menu->isEmpty() && !empty($menu['parent_key'])){
$parent_menu = $this->model->where([['menu_key', '=', $menu['parent_key']]])->findOrEmpty();
if(!empty($parent_menu)){
if(!empty($parent_menu['router_path'])) $parents[] = $parent_menu['router_path'];
$this->getParentDirectory($parent_menu, $parents);
}
}
}
} }

View File

@ -55,7 +55,7 @@ class RoleService extends BaseAdminService
* @return mixed * @return mixed
*/ */
public function getInfo(int $role_id){ public function getInfo(int $role_id){
return $this->model->findOrEmpty($role_id)->append(['status_name'])->toArray(); return $this->model->append(['status_name'])->findOrEmpty($role_id)->toArray();
} }
/** /**
@ -148,13 +148,6 @@ class RoleService extends BaseAdminService
}, },
[MenuService::$cache_tag_name, self::$cache_tag_name.$this->site_id] [MenuService::$cache_tag_name, self::$cache_tag_name.$this->site_id]
); );
// return Cache::tag([MenuService::$cache_tag_name, self::$cache_tag_name.$this->site_id])->remember($cache_name, function() use($site_id) {
// $where = [
// ['site_id', '=', $site_id]
// ];
// return $this->model->where($where)->column('role_name', 'role_id');
// });
} }
/** /**
@ -163,20 +156,24 @@ class RoleService extends BaseAdminService
* @return array * @return array
*/ */
public function getMenuIdsByRoleIds(int $site_id, array $role_ids){ public function getMenuIdsByRoleIds(int $site_id, array $role_ids){
$menu_keys = (new SiteService())->getMenuIdsBySiteId($site_id, true, 1); $menu_keys = (new SiteService())->getMenuIdsBySiteId($site_id, 1);
$allow_role_ids = array_intersect($role_ids, $menu_keys); $allow_role_ids = array_merge($role_ids, $menu_keys);
sort($allow_role_ids); sort($allow_role_ids);
$cache_name = 'user_role_'.$site_id.'_'.md5(implode('_', $allow_role_ids)); $cache_name = 'user_role_'.$site_id.'_'.md5(implode('_', $allow_role_ids));
return cache_remember( return cache_remember(
$cache_name, $cache_name,
function() use($role_ids) { function() use($role_ids, $menu_keys) {
$rules = $this->model::where([['role_id', 'IN', $role_ids], ['status', '=', RoleStatusDict::ON]])->field('rules')->select()->toArray(); $rules = $this->model::where([['role_id', 'IN', $role_ids], ['status', '=', RoleStatusDict::ON]])->field('rules')->select()->toArray();
if(!empty($rules)){ if(!empty($rules)){
$temp = []; $temp = [];
foreach($rules as $k => $v){ foreach($rules as $k => $v){
$temp = array_merge($temp, $v['rules']); $temp = array_merge($temp, $v['rules']);
} }
return array_unique($temp); $temp = array_unique($temp);
if(empty($menu_keys)) return [];
if(empty($temp)) return [];
$allow_menu_ids = array_intersect($temp, $menu_keys);
return $allow_menu_ids;
} }
return []; return [];
}, },

View File

@ -12,6 +12,7 @@
namespace app\service\admin\sys; namespace app\service\admin\sys;
use app\job\sys\CheckJob; use app\job\sys\CheckJob;
use app\model\site\Site;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use think\facade\Db; use think\facade\Db;
@ -47,11 +48,16 @@ class SystemService extends BaseAdminService
*/ */
public function getUrl() public function getUrl()
{ {
$site_tag = $this->site_id == 1 ? '' : '/s' . $this->site_id; $site = Site::find($this->site_id);
$site_tag = $site[ 'site_code' ];
$wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain();
$web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
$data = [ $data = [
'wap_domain' => env("system.wap_domain"), 'wap_domain' => env("system.wap_domain"),
'wap_url' => ( !empty(env("system.wap_domain")) ? env("system.wap_domain") : request()->domain() ) . "/wap" . $site_tag, 'wap_url' => $wap_domain . "/wap/" . $site_tag,
'web_url' => ( !empty(env("system.web_domain")) ? env("system.web_domain") : request()->domain() ) . "/web" . $site_tag, 'web_url' => $web_domain . "/web/" . $site_tag,
]; ];
return $data; return $data;
} }

View File

@ -102,14 +102,6 @@ class UserRoleService extends BaseAdminService
}, },
[self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id] [self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id]
); );
// return Cache::tag([self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id])->remember($cache_name, function() use($uid, $site_id) {
// $user_role_model = new SysUserRole();
// $where = array(
// ['uid', '=', $uid],
// ['site_id', '=', $site_id]
// );
// return $user_role_model::where($where)->findOrEmpty()->toArray();
// });
} }
/** /**
@ -143,32 +135,7 @@ class UserRoleService extends BaseAdminService
}, },
[self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id] [self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id]
); );
// return Cache::tag([self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id])->remember($cache_name, function() use($role_ids, $site_id) {
// $where = array(
// ['role_id', 'in', $role_ids],
// ['site_id', '=', $site_id]
// );
// return SysRole::where($where)->column('role_name');
// });
} }
// public function getFirstMenuByUser(int $site_id, int $uid){
// $role_service = (new RoleService())->getMenuIdsByRoleIds();
// $userrole = $this->getUserRole($site_id, $uid);
// $site_info = (new SiteService())->getSiteCache($site_id);
// if(empty($userrole)) throw new AuthException('SITE_USER_CAN_NOT_LOGIN_IN_ADMIN');
// if($userrole->is_admin){
// if($site_info->app_type == AppTypeDict::SITE){
//
// }else if($site_info->app_type == AppTypeDict::ADMIN){
//
// }
// }else{
// $user_role_ids = $userrole->role_ids;
// $menu_keys = (new RoleService())->getMenuIdsByRoleIds($site_id, $user_role_ids);
// if(in_array('siteindex', $menu_keys)){
//
// }
// }
// }
} }

Some files were not shown because too many files have changed in this diff Show More