diff --git a/niucloud/addon/hello_world/app/dict/diy/pages.php b/niucloud/addon/hello_world/app/dict/diy/pages.php
index 1492ee40f..1d788bdf4 100644
--- a/niucloud/addon/hello_world/app/dict/diy/pages.php
+++ b/niucloud/addon/hello_world/app/dict/diy/pages.php
@@ -7,6 +7,7 @@ return [
'cover' => '', // 页面封面图
'preview' => '', // 页面预览图
'desc' => '', // 页面描述
+ 'mode' => 'diy', // 页面模式:diy:自定义,fixed:固定
// 页面数据源
"data" => [
"global" => [
diff --git a/niucloud/addon/hello_world/app/dict/diy/template.php b/niucloud/addon/hello_world/app/dict/diy/template.php
index 98a006df6..0e5621557 100644
--- a/niucloud/addon/hello_world/app/dict/diy/template.php
+++ b/niucloud/addon/hello_world/app/dict/diy/template.php
@@ -4,9 +4,11 @@ return [
'DIY_HELLO_WORLD_INDEX' => [
'title' => get_lang('dict_diy.page_hello_world_index'),
'page' => 'pages/hello_world/index',
+ 'action' => ''
],
'DIY_HELLO_WORLD_INFO' => [
'title' => get_lang('dict_diy.page_hello_world_info'),
'page' => 'pages/hello_world/info',
+ 'action' => ''
],
];
\ No newline at end of file
diff --git a/niucloud/addon/hello_world/app/dict/notice/notice.php b/niucloud/addon/hello_world/app/dict/notice/notice.php
index 0a9e304d6..def067e88 100644
--- a/niucloud/addon/hello_world/app/dict/notice/notice.php
+++ b/niucloud/addon/hello_world/app/dict/notice/notice.php
@@ -3,6 +3,8 @@ return [
'hello_world_test' => [
'key' => 'hello_world_test',
'app_type' => 'site',
+ 'receiver_type' => 1,
+ 'async' => false,
'name' => 'hello world消息',
'title' => 'hello world演示插件消息',
'variable' =>[
diff --git a/niucloud/addon/hello_world/app/dict/schedule/schedule.php b/niucloud/addon/hello_world/app/dict/schedule/schedule.php
new file mode 100644
index 000000000..57867a985
--- /dev/null
+++ b/niucloud/addon/hello_world/app/dict/schedule/schedule.php
@@ -0,0 +1,15 @@
+ 'addon_schedule',
+ 'name' => '插件计划任务',
+ 'desc' => '',
+ 'time' => [
+ 'type' => 'min',
+ 'min' => 1
+ ],
+ 'class' => 'addon\hello_world\app\job\AddonSchedule',
+ 'function' => ''
+ ],
+];
diff --git a/niucloud/addon/hello_world/app/job/AddonSchedule.php b/niucloud/addon/hello_world/app/job/AddonSchedule.php
new file mode 100644
index 000000000..182e81b4a
--- /dev/null
+++ b/niucloud/addon/hello_world/app/job/AddonSchedule.php
@@ -0,0 +1,27 @@
+ [
//插件如果要单独分类展示,需要专门定义
[
@@ -43,6 +43,5 @@ class AppManageListener
"url" => "/hello_world"
],
];
- return $data;
}
}
\ No newline at end of file
diff --git a/niucloud/addon/hello_world/sql/install.sql b/niucloud/addon/hello_world/sql/install.sql
index 5464ddfee..e2f11abf9 100644
--- a/niucloud/addon/hello_world/sql/install.sql
+++ b/niucloud/addon/hello_world/sql/install.sql
@@ -3,4 +3,4 @@ CREATE TABLE IF NOT EXISTS `{{prefix}}hello_world` (
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='演示插件表';
-INSERT INTO `{{prefix}}hello_world`(`id`, `name`) VALUES (1, '名称');
\ No newline at end of file
+INSERT INTO `{{prefix}}hello_world`(`name`) VALUES ('名称');
\ No newline at end of file
diff --git a/niucloud/app/ExceptionHandle.php b/niucloud/app/ExceptionHandle.php
index d27b4dc29..f89092007 100644
--- a/niucloud/app/ExceptionHandle.php
+++ b/niucloud/app/ExceptionHandle.php
@@ -91,7 +91,7 @@ class ExceptionHandle extends Handle
// 添加自定义异常处理机制
if ($e instanceof DbException) {
- return fail('DATA_GET_FAIL', [
+ return fail(get_lang('DATA_GET_FAIL').':'.$e->getMessage(), [
'file' => $e->getFile(),
'line' => $e->getLine(),
'message' => $e->getMessage(),
diff --git a/niucloud/app/Request.php b/niucloud/app/Request.php
index 4670f5e45..c8e8751ac 100644
--- a/niucloud/app/Request.php
+++ b/niucloud/app/Request.php
@@ -149,7 +149,7 @@ class Request extends \think\Request
* @return array|string|null
*/
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
*/
public function apiSiteId(){
- return $this->header(system_name('api_site_id_name')) ?? $this->defaultSiteId();
+ return $this->header(system_name('api_site_id_name'));
}
/**
diff --git a/niucloud/app/adminapi/controller/auth/Auth.php b/niucloud/app/adminapi/controller/auth/Auth.php
index acc3adc96..22b9509d9 100644
--- a/niucloud/app/adminapi/controller/auth/Auth.php
+++ b/niucloud/app/adminapi/controller/auth/Auth.php
@@ -72,4 +72,15 @@ class Auth extends BaseAdminController
public function site(){
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());
+ }
}
diff --git a/niucloud/app/adminapi/controller/diy/Diy.php b/niucloud/app/adminapi/controller/diy/Diy.php
index bcdbce201..ee693bcf2 100644
--- a/niucloud/app/adminapi/controller/diy/Diy.php
+++ b/niucloud/app/adminapi/controller/diy/Diy.php
@@ -23,7 +23,7 @@ use core\base\BaseAdminController;
class Diy extends BaseAdminController
{
/**
- * @notes 获取自定义页面列表
+ * @notes 获取自定义页面分页列表
* @return \think\Response
*/
public function lists()
@@ -35,6 +35,20 @@ class Diy extends BaseAdminController
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
@@ -55,6 +69,8 @@ class Diy extends BaseAdminController
[ "title", "" ],
[ "name", "" ],
[ "type", "" ],
+ [ 'template', '' ],
+ [ 'mode', 'diy' ],
[ "value", "" ],
[ 'is_default', 0 ]
]);
@@ -75,6 +91,7 @@ class Diy extends BaseAdminController
[ "title", "" ],
[ "name", "" ],
[ "value", "" ],
+ [ 'is_change', '' ]
]);
$this->validate($data, 'app\validate\diy\Diy.edit');
( new DiyService() )->edit($id, $data);
@@ -113,8 +130,8 @@ class Diy extends BaseAdminController
$params = $this->request->params([
[ 'id', "" ],
[ "name", "" ],
- [ "template", "" ],
- [ 'template_name', '' ],
+ [ "type", "" ],
+ [ 'template', '' ],
[ "title", "" ],
]);
@@ -138,10 +155,12 @@ class Diy extends BaseAdminController
public function getTemplate()
{
$params = $this->request->params([
- [ 'type', "" ],
+ [ 'type', "" ], // 页面类型模板
+ [ 'action', '' ], // 页面是否装修标识,为空标识不装修,decorate:装修
+ [ 'mode', '' ] // 页面展示模式,diy:自定义,fixed:固定
]);
$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');
}
+ /**
+ * 获取装修页面列表
+ */
+ 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);
+ }
+
}
diff --git a/niucloud/app/adminapi/controller/notice/SmsLog.php b/niucloud/app/adminapi/controller/notice/SmsLog.php
index 62666f2e1..60303af6d 100644
--- a/niucloud/app/adminapi/controller/notice/SmsLog.php
+++ b/niucloud/app/adminapi/controller/notice/SmsLog.php
@@ -37,7 +37,7 @@ class SmsLog extends BaseAdminController
public function info($id)
{
- $res = ( new NoticeLogService() )->getInfo($id);
+ $res = ( new NoticeSmsLogService() )->getInfo($id);
return success($res);
}
diff --git a/niucloud/app/adminapi/controller/site/Site.php b/niucloud/app/adminapi/controller/site/Site.php
index 8c41c6594..c2af25072 100644
--- a/niucloud/app/adminapi/controller/site/Site.php
+++ b/niucloud/app/adminapi/controller/site/Site.php
@@ -120,4 +120,8 @@ class Site extends BaseAdminController
(new SiteService())->edit($id, $data);
return success('SUCCESS');
}
+ public function indexConfig()
+ {
+
+ }
}
diff --git a/niucloud/app/adminapi/controller/site/SiteAccount.php b/niucloud/app/adminapi/controller/site/SiteAccount.php
new file mode 100644
index 000000000..66f965c2f
--- /dev/null
+++ b/niucloud/app/adminapi/controller/site/SiteAccount.php
@@ -0,0 +1,57 @@
+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());
+ }
+}
diff --git a/niucloud/app/adminapi/controller/sys/Area.php b/niucloud/app/adminapi/controller/sys/Area.php
index e2c8d172e..d5c520544 100644
--- a/niucloud/app/adminapi/controller/sys/Area.php
+++ b/niucloud/app/adminapi/controller/sys/Area.php
@@ -34,4 +34,26 @@ class Area extends BaseAdminController
{
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']));
+ }
}
diff --git a/niucloud/app/adminapi/controller/sys/Config.php b/niucloud/app/adminapi/controller/sys/Config.php
index e3d90f7d4..2eaf22d2f 100644
--- a/niucloud/app/adminapi/controller/sys/Config.php
+++ b/niucloud/app/adminapi/controller/sys/Config.php
@@ -123,4 +123,44 @@ class Config extends BaseAdminController
public function 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());
+ }
}
diff --git a/niucloud/app/adminapi/controller/sys/Cron.php b/niucloud/app/adminapi/controller/sys/Cron.php
deleted file mode 100644
index cf20b7552..000000000
--- a/niucloud/app/adminapi/controller/sys/Cron.php
+++ /dev/null
@@ -1,56 +0,0 @@
-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());
- }
-}
diff --git a/niucloud/app/adminapi/controller/sys/Schedule.php b/niucloud/app/adminapi/controller/sys/Schedule.php
new file mode 100644
index 000000000..b91c15086
--- /dev/null
+++ b/niucloud/app/adminapi/controller/sys/Schedule.php
@@ -0,0 +1,107 @@
+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');
+ }
+}
diff --git a/niucloud/app/adminapi/controller/sys/System.php b/niucloud/app/adminapi/controller/sys/System.php
index 377ff5cf8..46fd3c567 100644
--- a/niucloud/app/adminapi/controller/sys/System.php
+++ b/niucloud/app/adminapi/controller/sys/System.php
@@ -11,6 +11,7 @@
namespace app\adminapi\controller\sys;
+use app\service\admin\schedule\ScheduleService;
use app\service\admin\sys\SystemService;
use core\base\BaseAdminController;
@@ -70,4 +71,6 @@ class System extends BaseAdminController
public function checkSchedule(){
return success(data:(new SystemService())->checkSchedule());
}
+
+
}
diff --git a/niucloud/app/adminapi/route/auth.php b/niucloud/app/adminapi/route/auth.php
index 2afce3892..14158f339 100644
--- a/niucloud/app/adminapi/route/auth.php
+++ b/niucloud/app/adminapi/route/auth.php
@@ -32,6 +32,8 @@ Route::group('auth', function () {
Route::put('edit', 'auth.Auth/edit');
//授权站点信息
Route::get('site', 'auth.Auth/site');
+ //站点可以显示的菜单
+ Route::get('site/showmenu', 'auth.Auth/getShowMenuList');
})->middleware([
AdminCheckToken::class,
diff --git a/niucloud/app/adminapi/route/diy.php b/niucloud/app/adminapi/route/diy.php
index 5e6e8068e..94945a497 100644
--- a/niucloud/app/adminapi/route/diy.php
+++ b/niucloud/app/adminapi/route/diy.php
@@ -21,9 +21,17 @@ use think\facade\Route;
Route::group('diy', function() {
/***************************************************** 自定义页面管理 ****************************************************/
- //自定义页面列表
+ //自定义页面分页列表
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');
@@ -60,6 +68,8 @@ Route::group('diy', function() {
// 编辑自定义页面分享内容
Route::put('diy/share', 'diy.Diy/modifyShare');
+ // 获取页面预览数据
+ Route::put('preview', 'diy.Diy/getPreviewData');
/***************************************************** 配置相关 *****************************************************/
diff --git a/niucloud/app/adminapi/route/site.php b/niucloud/app/adminapi/route/site.php
index 0e7ba889c..b6edc43f4 100644
--- a/niucloud/app/adminapi/route/site.php
+++ b/niucloud/app/adminapi/route/site.php
@@ -70,7 +70,15 @@ Route::group('site', function () {
Route::get('log/:id', 'site.UserLog/info');
/***************************************************** 站点菜单 **************************************************/
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([
AdminCheckToken::class,
diff --git a/niucloud/app/adminapi/route/sys.php b/niucloud/app/adminapi/route/sys.php
index 6297910ba..c9792f679 100644
--- a/niucloud/app/adminapi/route/sys.php
+++ b/niucloud/app/adminapi/route/sys.php
@@ -72,6 +72,16 @@ Route::group('sys', function () {
//地图设置
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');
//登录注册设置
@@ -126,14 +136,10 @@ Route::group('sys', function () {
Route::get('area/list_by_pid/:pid', 'sys.Area/listByPid');
//通过层级获取列表
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');
//场景域名
@@ -144,12 +150,31 @@ Route::group('sys', function () {
Route::get('job', 'sys.System/checkJob');
//校验计划任务
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::post('schema/clear', 'sys.System/schemaCache');
+
+
})->middleware([
AdminCheckToken::class,
AdminCheckRole::class,
diff --git a/niucloud/app/api/middleware/ApiChannel.php b/niucloud/app/api/middleware/ApiChannel.php
index 0a6a9065b..e78513184 100644
--- a/niucloud/app/api/middleware/ApiChannel.php
+++ b/niucloud/app/api/middleware/ApiChannel.php
@@ -12,13 +12,15 @@
namespace app\api\middleware;
use app\Request;
+use app\service\core\site\CoreSiteService;
use Closure;
+use core\exception\AuthException;
use Exception;
use think\facade\Log;
/**
- * api渠道处理, 各种渠道的请求不叫特殊, 会在这儿将渠道的公共数据处理好
+ * api渠道处理, 各种渠道的请求, 会在这儿将渠道的公共数据处理好
*/
class ApiChannel
{
@@ -38,7 +40,10 @@ class ApiChannel
if (in_array($request->rule()->getRule(), $channel_rules)) {
$site_id = $request->param('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);
diff --git a/niucloud/app/api/middleware/ApiCheckToken.php b/niucloud/app/api/middleware/ApiCheckToken.php
index 090839dbb..0010a653c 100644
--- a/niucloud/app/api/middleware/ApiCheckToken.php
+++ b/niucloud/app/api/middleware/ApiCheckToken.php
@@ -30,11 +30,11 @@ class ApiCheckToken
/**
* @param Request $request
* @param Closure $next
- * @param bool $exception 是否把错误抛出
+ * @param bool $is_throw_exception 是否把错误抛出
* @return mixed
* @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);
//检测站点
@@ -45,8 +45,8 @@ class ApiCheckToken
$token_info = ( new LoginService() )->parseToken($token);
} catch (AuthException $e) {
//是否将登录错误抛出
- if ($exception)
- return fail($e->getMessage());
+ if ($is_throw_exception)
+ return fail($e->getMessage(), [], $e->getCode());
}
if (!empty($token_info)) {
$request->memberId($token_info[ 'member_id' ]);
diff --git a/niucloud/app/api/route/dispatch/BindDispatch.php b/niucloud/app/api/route/dispatch/BindDispatch.php
index f8c31041a..f3b8ba26e 100644
--- a/niucloud/app/api/route/dispatch/BindDispatch.php
+++ b/niucloud/app/api/route/dispatch/BindDispatch.php
@@ -32,7 +32,7 @@ class BindDispatch extends Controller
$controller = 'weapp.Weapp';
$action = 'register';
break;
- };
+ }
$this->controller = $controller ?? '';
diff --git a/niucloud/app/command/Schedule.php b/niucloud/app/command/Schedule.php
deleted file mode 100644
index 97a430a3b..000000000
--- a/niucloud/app/command/Schedule.php
+++ /dev/null
@@ -1,92 +0,0 @@
-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;
-// }
-
-}
\ No newline at end of file
diff --git a/niucloud/app/command/schedule/Schedule.php b/niucloud/app/command/schedule/Schedule.php
new file mode 100644
index 000000000..cd7dd82e0
--- /dev/null
+++ b/niucloud/app/command/schedule/Schedule.php
@@ -0,0 +1,54 @@
+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;
+ }
+}
diff --git a/niucloud/app/common.php b/niucloud/app/common.php
index b6d3c46d2..37c2931d6 100644
--- a/niucloud/app/common.php
+++ b/niucloud/app/common.php
@@ -5,7 +5,7 @@ use think\Response;
use think\facade\Lang;
use think\facade\Queue;
use think\facade\Cache;
-
+use core\util\Snowflake;
// 应用公共文件
/**
@@ -369,8 +369,11 @@ function filter($string)
*/
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_shuffle($str);
- $res = substr(str_shuffle($str), 0, $len);
- return $res;
+ return substr(str_shuffle($str), 0, $len);
}
/**
@@ -623,6 +625,7 @@ function parse_sql($content = '', $string = false, $replace = [])
* 递归查询目录下所有文件
* @param $path
* @param $data
+ * @param $search
* @return void
*/
function search_dir($path, &$data, $search = '')
@@ -677,8 +680,8 @@ function getFileMap($path, $arr = [])
* 如果不存在则写入缓存
* @param string|null $name
* @param $value
- * @param $options
* @param $tag
+ * @param $options
* @return mixed|string
*/
function cache_remember(string $name = null, $value = '', $tag = null, $options = null){
diff --git a/niucloud/app/dict/diy/PagesDict.php b/niucloud/app/dict/diy/PagesDict.php
index d140aaa76..a61f23ed3 100644
--- a/niucloud/app/dict/diy/PagesDict.php
+++ b/niucloud/app/dict/diy/PagesDict.php
@@ -23,18 +23,19 @@ class PagesDict
/**
* 获取页面数据
- * @param string $type
+ * @param array $params
* @return array|string|null
*/
- public static function getPages($type = '')
+ public static function getPages($params = [])
{
$system_pages = [
'DIY_INDEX' => [
'default_index' => [ // 页面标识
"title" => "首页", // 页面名称
- 'cover' => '', // 页面封面图
+ 'cover' => 'static/resource/images/diy/template/default_index_cover.png', // 页面封面图
'preview' => '', // 页面预览图
- 'desc' => '', // 页面描述
+ 'desc' => '官方推出的系统首页', // 页面描述
+ 'mode' => 'diy', // 页面模式:diy:自定义,fixed:固定
// 页面数据源
"data" => [
"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' => [
'default_member_index_one' => [
"title" => "个人中心(风格一)", // 页面名称
- 'cover' => '', // 页面封面图
+ 'cover' => 'static/resource/images/diy/template/default_member_index_one_cover.png', // 页面封面图
'preview' => '', // 页面预览图
- 'desc' => '', // 页面描述
+ 'desc' => '官方推出个人中心(风格一)', // 页面描述
+ 'mode' => 'diy',
// 页面数据源
"data" => [
"global" => [
@@ -583,9 +596,10 @@ class PagesDict
],
'default_member_index_two' => [
"title" => "个人中心(风格二)", // 页面名称
- 'cover' => '', // 页面封面图
+ 'cover' => 'static/resource/images/diy/template/default_member_index_two_cover.png', // 页面封面图
'preview' => '', // 页面预览图
- 'desc' => '', // 页面描述
+ 'desc' => '官方推出个人中心(风格二)', // 页面描述
+ 'mode' => 'diy',
// 页面数据源
"data" => [
"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);
- if (empty($type)) {
- return $pages;
+ if (!empty($params[ 'type' ])) {
+ 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;
}
}
\ No newline at end of file
diff --git a/niucloud/app/dict/diy/TemplateDict.php b/niucloud/app/dict/diy/TemplateDict.php
index 573533422..9cb6f05c7 100644
--- a/niucloud/app/dict/diy/TemplateDict.php
+++ b/niucloud/app/dict/diy/TemplateDict.php
@@ -23,30 +23,47 @@ class TemplateDict
/**
* 获取页面模板
- * @param string $type
- * @return array|string
+ * @param array $params
+ * @return array|string|null
*/
- public static function getTemplate($type = '')
+ public static function getTemplate($params = [])
{
$system_pages = [
'DIY_INDEX' => [
'title' => get_lang('dict_diy.page_index'),
'page' => 'pages/index/index',
+ 'action' => 'decorate' // 页面是否装修标识,为空标识不装修,decorate:装修
],
'DIY_MEMBER_INDEX' => [
'title' => get_lang('dict_diy.page_member_index'),
'page' => 'pages/member/index',
+ 'action' => 'decorate'
],
'DIY_PAGE' => [
'title' => get_lang('dict_diy.page_diy'),
'page' => 'pages/index/diy',
+ 'action' => ''
]
];
- $pages = (new DictLoader("UniappTemplate"))->load($system_pages);
- if (empty($type)) {
- return $pages;
+
+ $pages = ( new DictLoader("UniappTemplate") )->load($system_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;
}
}
\ No newline at end of file
diff --git a/niucloud/app/dict/menu/admin.php b/niucloud/app/dict/menu/admin.php
index 4824fb02a..8949f9642 100644
--- a/niucloud/app/dict/menu/admin.php
+++ b/niucloud/app/dict/menu/admin.php
@@ -525,6 +525,19 @@
'sort' => 50,
'status' => 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,
]
]
],
diff --git a/niucloud/app/dict/menu/site.php b/niucloud/app/dict/menu/site.php
index 26bf034e6..93e18493b 100644
--- a/niucloud/app/dict/menu/site.php
+++ b/niucloud/app/dict/menu/site.php
@@ -28,8 +28,8 @@ return
'is_show' => 1,
'children' => [
[
- 'menu_name' => '首页装修',
- 'menu_key' => 'diy_page_index',
+ 'menu_name' => '页面装修',
+ 'menu_key' => 'diy_page_decorate',
'menu_type' => 1,
'icon' => 'element-House',
'api_url' => '',
@@ -40,19 +40,6 @@ return
'status' => 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_key' => 'diy_page_update',
@@ -62,12 +49,12 @@ return
'router_path' => '',
'view_path' => '',
'methods' => 'post',
- 'sort' => 80,
+ 'sort' => 95,
'status' => 1,
'is_show' => 1,
],
[
- 'menu_name' => '页面管理',
+ 'menu_name' => '微页面',
'menu_key' => 'diy_page_list',
'menu_type' => 1,
'icon' => 'iconfont-icondianpuzhuangxiu',
@@ -75,7 +62,20 @@ return
'router_path' => 'list',
'view_path' => 'diy/list',
'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,
'is_show' => 1,
],
@@ -88,25 +88,24 @@ return
'router_path' => 'tabbar',
'view_path' => 'diy/tabbar',
'methods' => 'get',
- 'sort' => 60,
+ 'sort' => 80,
'status' => 1,
'is_show' => 1,
- 'children' =>
+ 'children' => [
[
- [
- 'menu_name' => '保存',
- 'menu_key' => 'diy_tabbar_update',
- 'menu_type' => 2,
- 'icon' => '',
- 'api_url' => 'diy/bottom',
- 'router_path' => '',
- 'view_path' => '',
- 'methods' => 'post',
- 'sort' => 100,
- 'status' => 1,
- 'is_show' => 1,
- ],
+ 'menu_name' => '保存',
+ 'menu_key' => 'diy_tabbar_update',
+ 'menu_type' => 2,
+ 'icon' => '',
+ 'api_url' => 'diy/bottom',
+ 'router_path' => '',
+ 'view_path' => '',
+ 'methods' => 'post',
+ 'sort' => 100,
+ 'status' => 1,
+ 'is_show' => 1,
],
+ ],
],
[
'menu_name' => '素材管理',
@@ -117,7 +116,7 @@ return
'router_path' => 'attachment',
'view_path' => 'tools/attachment',
'methods' => 'get',
- 'sort' => 50,
+ 'sort' => 75,
'status' => 1,
'is_show' => 1,
]
@@ -148,6 +147,19 @@ return
'sort' => 0,
'status' => 1,
'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,
'is_show' => 1,
'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_key' => 'cash_out_list',
@@ -484,7 +509,7 @@ return
'sort' => 99,
'status' => 1,
'is_show' => 1,
- ]
+ ],
]
],
[
@@ -887,7 +912,7 @@ return
'sort' => 100,
'status' => 1,
'is_show' => 1,
-
+
],
[
'menu_name' => '协议管理',
@@ -997,7 +1022,7 @@ return
'sort' => 90,
'status' => 1,
'is_show' => 1,
- 'children' => [
+ 'children' => [
[
'menu_name' => '设置',
'menu_key' => 'setting_pay_transfer_set',
@@ -1010,7 +1035,7 @@ return
'sort' => 90,
'status' => 1,
'is_show' => 1,
-
+
],
]
],
@@ -1151,7 +1176,7 @@ return
'sort' => 12,
'status' => 1,
'is_show' => 1,
-
+
],
[
'menu_name' => '发送记录',
diff --git a/niucloud/app/dict/notice/notice.php b/niucloud/app/dict/notice/notice.php
index b8b4e910c..85b8da2b3 100644
--- a/niucloud/app/dict/notice/notice.php
+++ b/niucloud/app/dict/notice/notice.php
@@ -2,7 +2,7 @@
return [
'verify_code' => [
'key' => 'verify_code',
- 'receiver_type' => 1,
+ 'receiver_type' => 0,
'name' => '手机验证码',
'title' => '管理端验证码登录',
'async' => false,
@@ -13,7 +13,7 @@ return [
//手机验证码,站点应用发送
'member_verify_code' => [
'key' => 'member_verify_code',
- 'receiver_type' => 2,
+ 'receiver_type' => 1,
'name' => '手机验证码',
'title' => '前端验证码登录,注册,手机验证',
'async' => false,
@@ -25,7 +25,7 @@ return [
'recharge_success' => [
'key' => 'recharge_success',
- 'receiver_type' => 2,
+ 'receiver_type' => 1,
'name' => '充值成功通知',
'title' => '会员充值成功后发送',
'async' => true,
diff --git a/niucloud/app/dict/sys/CronDict.php b/niucloud/app/dict/schedule/ScheduleDict.php
similarity index 56%
rename from niucloud/app/dict/sys/CronDict.php
rename to niucloud/app/dict/schedule/ScheduleDict.php
index dd297b76d..4d22b83a9 100644
--- a/niucloud/app/dict/sys/CronDict.php
+++ b/niucloud/app/dict/schedule/ScheduleDict.php
@@ -9,41 +9,35 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
-namespace app\dict\sys;
+namespace app\dict\schedule;
-class CronDict
+class ScheduleDict
{
const CRON = 'cron';//定时任务
const CROND = 'crond';//周期任务
- const MINUTE = 'minute';//分钟
-
- const DAY = 'day';//天
- const WEEK = 'week';//星期
- const MONTH = 'month';//月份
+ const ON = 1;
+ const OFF = 2;
/**
* 任务模式
* @return array
*/
public static function getType(){
return [
- self::CRON => get_lang('dict_cron.type_cron'),//定时任务
- self::CROND => get_lang('dict_cron.type_crond'),//周期任务
+ self::CRON => get_lang('dict_schedule.type_cron'),//定时任务
+ self::CROND => get_lang('dict_schedule.type_crond'),//周期任务
];
}
+
/**
- * 周期类型
+ * 任务启用状态
* @return array
*/
- public static function getCrondType(){
+ public static function getStatus(){
return [
- self::MINUTE => get_lang('dict_cron.type_minute'),//分钟
- self::DAY => get_lang('dict_cron.type_day'),//天
- self::WEEK => get_lang('dict_cron.type_week'),//星期
- self::MONTH => get_lang('dict_cron.type_month'),//月份
+ self::ON => get_lang('dict_schedule.on'),//启用
+ self::OFF => get_lang('dict_schedule.off'),//关闭
];
}
-
-
}
\ No newline at end of file
diff --git a/niucloud/app/dict/schedule/schedule.php b/niucloud/app/dict/schedule/schedule.php
index 2219e0181..9f71cd3a9 100644
--- a/niucloud/app/dict/schedule/schedule.php
+++ b/niucloud/app/dict/schedule/schedule.php
@@ -4,8 +4,10 @@ return [
[
'key' => 'order_close',
'name' => '未支付订单自动关闭',
+ 'desc' => '',
'time' => [
'type' => 'min',
+ 'min' => 1
],
'class' => '',
'function' => ''
@@ -13,10 +15,14 @@ return [
[
'key' => 'site_expire_close',
'name' => '站点到期自动关闭',
+ 'desc' => '',
'time' => [
- 'type' => 'min',
+ 'type' => 'day',
+ 'day' => 1,
+ 'hour' => 1,
+ 'min' => 1
],
- 'class' => '',
+ 'class' => 'app\job\schedule\SiteExpireClose',
'function' => ''
]
];
diff --git a/niucloud/app/dict/site/SiteAccountLogDict.php b/niucloud/app/dict/site/SiteAccountLogDict.php
new file mode 100644
index 000000000..0bf013f4b
--- /dev/null
+++ b/niucloud/app/dict/site/SiteAccountLogDict.php
@@ -0,0 +1,32 @@
+ get_lang('dict_site.pay'),//支付
+ self::REFUND => get_lang('dict_site.refund'),//退款
+ self::TRANSFER => get_lang('dict_site.transfer'),//转账
+ ];
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/dict/sys/DateDict.php b/niucloud/app/dict/sys/DateDict.php
new file mode 100644
index 000000000..a23c783d5
--- /dev/null
+++ b/niucloud/app/dict/sys/DateDict.php
@@ -0,0 +1,78 @@
+ 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月
+ ];
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/dict/sys/SmsDict.php b/niucloud/app/dict/sys/SmsDict.php
index bc933e4c6..68ac9cd6e 100644
--- a/niucloud/app/dict/sys/SmsDict.php
+++ b/niucloud/app/dict/sys/SmsDict.php
@@ -53,7 +53,7 @@ class SmsDict
const SUCCESS = 'success';
const FAIL = 'fail';
- public function getStatusType(){
+ public static function getStatusType(){
return [
self::SENDING => 'dict_sms.status_sending',
self::SUCCESS => 'dict_sms.status_success',
diff --git a/niucloud/app/event.php b/niucloud/app/event.php
index 0a5009b33..7b255d26f 100644
--- a/niucloud/app/event.php
+++ b/niucloud/app/event.php
@@ -39,17 +39,23 @@ $system_event = [
//退款成功
'RefundSuccess' => [ 'app\listener\pay\RefundSuccessListener' ],
//转账成功
- 'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ],
+ 'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ], 'SiteIndex' => [
+ 'app\listener\system\SiteIndexListener'
+ ],
// 任务失败统一回调,有四种定义方式
'queue_failed'=> [
['app\listener\job\QueueFailedLoggerListener', 'report'],
],
+ //系统应用管理加载
'AppManage' => [
'app\listener\system\AppManageListener'
],
-
+ //站点首页加载
+ 'siteIndex' => [
+ 'app\listener\system\SiteIndexListener'
+ ],
//消息模板数据内容
'NoticeData' => [
'app\listener\notice_template\VerifyCode',//手机验证码
diff --git a/niucloud/app/install/controller/Index.php b/niucloud/app/install/controller/Index.php
index c24c613fb..5dde6a6ae 100644
--- a/niucloud/app/install/controller/Index.php
+++ b/niucloud/app/install/controller/Index.php
@@ -8,6 +8,7 @@ use app\model\sys\SysUser;
use app\service\admin\install\InstallSystemService;
use app\service\admin\site\SiteGroupService;
use app\service\admin\site\SiteService;
+use app\service\core\schedule\CoreScheduleInstallService;
use think\facade\Cache;
use think\facade\Db;
use think\facade\View;
@@ -320,6 +321,13 @@ class Index extends BaseInstall
$this->setSuccessLog([ '菜单初始化失败', 'error' ]);
return fail('菜单初始化失败');
}
+ //初始化计划任务
+ $res = ( new CoreScheduleInstallService())->installSystemSchedule();
+ if (!$res) {
+ $this->setSuccessLog([ '计划任务初始化失败', 'error' ]);
+ return fail('计划任务初始化失败');
+ }
+
$user = ( new SysUser() )->where([ [ 'uid', '=', 1 ] ])->findOrEmpty();
if (!$user->isEmpty()) {
diff --git a/niucloud/app/install/source/database.sql b/niucloud/app/install/source/database.sql
index 785b685f6..7df2d7252 100644
--- a/niucloud/app/install/source/database.sql
+++ b/niucloud/app/install/source/database.sql
@@ -1,4 +1,5 @@
-SET NAMES 'utf8mb4';
+
+SET NAMES 'utf8mb4';
DROP TABLE IF EXISTS addon;
@@ -34,14 +35,6 @@ DROP TABLE IF EXISTS member_label;
DROP TABLE IF EXISTS member_level;
-DROP TABLE IF EXISTS `order`;
-
-DROP TABLE IF EXISTS order_item;
-
-DROP TABLE IF EXISTS order_item_refund;
-
-DROP TABLE IF EXISTS order_log;
-
DROP TABLE IF EXISTS pay;
DROP TABLE IF EXISTS pay_channel;
@@ -50,8 +43,18 @@ DROP TABLE IF EXISTS pay_refund;
DROP TABLE IF EXISTS pay_transfer;
+DROP TABLE IF EXISTS recharge_order;
+
+DROP TABLE IF EXISTS recharge_order_item;
+
+DROP TABLE IF EXISTS recharge_order_item_refund;
+
+DROP TABLE IF EXISTS recharge_order_log;
+
DROP TABLE IF EXISTS site;
+DROP TABLE IF EXISTS site_account_log;
+
DROP TABLE IF EXISTS site_group;
DROP TABLE IF EXISTS sys_agreement;
@@ -76,6 +79,8 @@ DROP TABLE IF EXISTS sys_notice_sms_log;
DROP TABLE IF EXISTS sys_role;
+DROP TABLE IF EXISTS sys_schedule;
+
DROP TABLE IF EXISTS sys_user;
DROP TABLE IF EXISTS sys_user_log;
@@ -88,9 +93,6 @@ DROP TABLE IF EXISTS wechat_media;
DROP TABLE IF EXISTS wechat_reply;
---
--- `ns_wechat_reply`
---
CREATE TABLE wechat_reply (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
name varchar(64) NOT NULL DEFAULT '' COMMENT '规则名称',
@@ -102,13 +104,12 @@ CREATE TABLE wechat_reply (
content text NOT NULL COMMENT '回复内容',
status tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '启动状态:1-启动;0-关闭',
sort int(10) UNSIGNED NOT NULL DEFAULT 50 COMMENT '排序',
- create_time int(11) NOT NULL COMMENT '创建时间',
- update_time int(11) NOT NULL COMMENT '更新时间',
- delete_time int(11) NOT NULL COMMENT '删除时间',
+ create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
+ update_time int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
+ delete_time int(11) NOT NULL DEFAULT 0 COMMENT '删除时间',
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '公众号消息回调表';
@@ -116,9 +117,6 @@ COMMENT = '公众号消息回调表';
ALTER TABLE wechat_reply
ADD INDEX keyword (keyword, reply_type);
---
--- `ns_wechat_media`
---
CREATE TABLE wechat_media (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -130,7 +128,6 @@ CREATE TABLE wechat_media (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 1872,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '微信素材表';
@@ -138,9 +135,6 @@ COMMENT = '微信素材表';
ALTER TABLE wechat_media
ADD INDEX type (type, site_id);
---
--- `ns_wechat_fans`
---
CREATE TABLE wechat_fans (
fans_id int(11) NOT NULL AUTO_INCREMENT COMMENT '粉丝ID',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -165,7 +159,6 @@ CREATE TABLE wechat_fans (
PRIMARY KEY (fans_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '微信粉丝列表';
@@ -176,9 +169,6 @@ ADD INDEX openid (openid, site_id);
ALTER TABLE wechat_fans
ADD INDEX unionid (unionid, site_id);
---
--- `ns_sys_user_role`
---
CREATE TABLE sys_user_role (
id int(11) NOT NULL AUTO_INCREMENT,
uid int(11) NOT NULL DEFAULT 0 COMMENT '用户id',
@@ -189,6 +179,7 @@ CREATE TABLE sys_user_role (
PRIMARY KEY (id)
)
ENGINE = INNODB,
+AUTO_INCREMENT = 2,
AVG_ROW_LENGTH = 481,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
@@ -203,9 +194,6 @@ ADD INDEX site_id (site_id);
ALTER TABLE sys_user_role
ADD INDEX uid (uid);
---
--- `ns_sys_user_log`
---
CREATE TABLE sys_user_log (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '管理员操作记录ID',
ip varchar(16) NOT NULL DEFAULT '' COMMENT '登录IP',
@@ -219,11 +207,9 @@ CREATE TABLE sys_user_log (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 857,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '管理员操作记录表',
-ROW_FORMAT = COMPACT;
+COMMENT = '管理员操作记录表';
ALTER TABLE sys_user_log
ADD INDEX create_time (create_time);
@@ -234,9 +220,6 @@ ADD INDEX site_id (site_id);
ALTER TABLE sys_user_log
ADD INDEX uid (uid);
---
--- `ns_sys_user`
---
CREATE TABLE sys_user (
uid smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '系统用户ID',
username varchar(255) NOT NULL DEFAULT '' COMMENT '用户账号',
@@ -255,11 +238,11 @@ CREATE TABLE sys_user (
INDEX uid (uid)
)
ENGINE = INNODB,
+AUTO_INCREMENT = 2,
AVG_ROW_LENGTH = 372,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '后台管理员表',
-ROW_FORMAT = COMPACT;
+COMMENT = '后台管理员表';
ALTER TABLE sys_user
ADD INDEX delete_time (delete_time);
@@ -273,12 +256,27 @@ ADD INDEX password (password);
ALTER TABLE sys_user
ADD INDEX update_time (update_time);
-ALTER TABLE sys_user
-ADD INDEX username (username (191));
+CREATE TABLE sys_schedule (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ site_id int(11) NOT NULL DEFAULT 0,
+ addon varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件',
+ `key` varchar(255) NOT NULL DEFAULT '' COMMENT '计划任务模板key',
+ status int(11) NOT NULL DEFAULT 1 COMMENT '任务状态 是否启用',
+ time varchar(500) NOT NULL DEFAULT '' COMMENT '任务周期 json结构',
+ count int(11) NOT NULL DEFAULT 0 COMMENT '执行次数',
+ last_time int(11) NOT NULL DEFAULT 0 COMMENT '最后执行时间',
+ next_time int(11) NOT NULL DEFAULT 0 COMMENT '下次执行时间',
+ create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
+ delete_time int(11) NOT NULL DEFAULT 0 COMMENT '删除时间',
+ update_time int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
+ sort int(11) NOT NULL DEFAULT 0 COMMENT '排序',
+ PRIMARY KEY (id)
+)
+ENGINE = INNODB,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci,
+COMMENT = '系统任务';
---
--- `ns_sys_role`
---
CREATE TABLE sys_role (
role_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '角色id',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -290,11 +288,9 @@ CREATE TABLE sys_role (
PRIMARY KEY (role_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 1638,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '角色表',
-ROW_FORMAT = COMPACT;
+COMMENT = '角色表';
ALTER TABLE sys_role
ADD INDEX site_id (site_id);
@@ -302,9 +298,6 @@ ADD INDEX site_id (site_id);
ALTER TABLE sys_role
ADD INDEX status (status);
---
--- `ns_sys_notice_sms_log`
---
CREATE TABLE sys_notice_sms_log (
id int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
site_id int(11) NOT NULL DEFAULT 0,
@@ -323,14 +316,10 @@ CREATE TABLE sys_notice_sms_log (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 496,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '短信发送表';
---
--- `ns_sys_notice_log`
---
CREATE TABLE sys_notice_log (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '通知记录ID',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -350,24 +339,19 @@ CREATE TABLE sys_notice_log (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 712,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '通知记录表',
-ROW_FORMAT = COMPACT;
+COMMENT = '通知记录表';
ALTER TABLE sys_notice_log
ADD INDEX member_id (member_id);
ALTER TABLE sys_notice_log
-ADD INDEX message_key (`key` (191));
+ADD INDEX message_key (`key`);
ALTER TABLE sys_notice_log
ADD INDEX uid (uid);
---
--- `ns_sys_notice`
---
CREATE TABLE sys_notice (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点ID',
@@ -385,18 +369,13 @@ CREATE TABLE sys_notice (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 2048,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '通知模型',
-ROW_FORMAT = COMPACT;
+COMMENT = '通知模型';
ALTER TABLE sys_notice
ADD INDEX message_key (`key`, site_id);
---
--- `ns_sys_menu`
---
CREATE TABLE sys_menu (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '菜单ID',
app_type varchar(255) NOT NULL DEFAULT 'admin' COMMENT '应用类型',
@@ -421,21 +400,17 @@ ENGINE = INNODB,
AVG_ROW_LENGTH = 406,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '菜单表',
-ROW_FORMAT = COMPACT;
+COMMENT = '菜单表';
ALTER TABLE sys_menu
ADD INDEX is_show (is_show);
ALTER TABLE sys_menu
-ADD INDEX menu_key (menu_key (191), app_type (191));
+ADD INDEX menu_key (menu_key, app_type);
ALTER TABLE sys_menu
-ADD INDEX parent_key (parent_key (191));
+ADD INDEX parent_key (parent_key);
---
--- `ns_sys_cron_task`
---
CREATE TABLE sys_cron_task (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0,
@@ -457,14 +432,10 @@ CREATE TABLE sys_cron_task (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = ' 系统任务';
---
--- `ns_sys_config`
---
CREATE TABLE sys_config (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -477,18 +448,13 @@ CREATE TABLE sys_config (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 910,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '系统配置表',
-ROW_FORMAT = COMPACT;
+COMMENT = '系统配置表';
ALTER TABLE sys_config
-ADD INDEX config_key (config_key (191), site_id);
+ADD INDEX config_key (config_key, site_id);
---
--- `ns_sys_attachment_category`
---
CREATE TABLE sys_attachment_category (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -501,11 +467,9 @@ CREATE TABLE sys_attachment_category (
UNIQUE INDEX id (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '附件分类表',
-ROW_FORMAT = COMPACT;
+COMMENT = '附件分类表';
ALTER TABLE sys_attachment_category
ADD INDEX pid (pid);
@@ -513,9 +477,6 @@ ADD INDEX pid (pid);
ALTER TABLE sys_attachment_category
ADD INDEX sort (sort);
---
--- `ns_sys_attachment`
---
CREATE TABLE sys_attachment (
att_id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -533,11 +494,9 @@ CREATE TABLE sys_attachment (
PRIMARY KEY (att_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 702,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '附件管理表',
-ROW_FORMAT = COMPACT;
+COMMENT = '附件管理表';
ALTER TABLE sys_attachment
ADD INDEX cate_id (cate_id);
@@ -548,9 +507,6 @@ ADD INDEX create_time (create_time);
ALTER TABLE sys_attachment
ADD INDEX site_id (site_id);
---
--- `ns_sys_area`
---
CREATE TABLE sys_area (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
pid int(11) NOT NULL DEFAULT 0 COMMENT '父级',
@@ -582,9 +538,6 @@ ADD INDEX longitude (longitude, latitude);
ALTER TABLE sys_area
ADD INDEX pid (pid);
---
--- `ns_sys_agreement`
---
CREATE TABLE sys_agreement (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -596,7 +549,6 @@ CREATE TABLE sys_agreement (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 6553,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '协议表';
@@ -607,9 +559,6 @@ ADD INDEX agreement_key (agreement_key);
ALTER TABLE sys_agreement
ADD INDEX site_id (site_id);
---
--- `ns_site_group`
---
CREATE TABLE site_group (
group_id int(11) NOT NULL AUTO_INCREMENT COMMENT '分组ID',
group_name varchar(255) NOT NULL DEFAULT '' COMMENT '分组名称',
@@ -621,16 +570,27 @@ CREATE TABLE site_group (
PRIMARY KEY (group_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 2048,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '店铺分组(分组权限)';
---
--- `ns_site`
---
+CREATE TABLE site_account_log (
+ id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
+ type varchar(255) NOT NULL DEFAULT 'pay' COMMENT '账单类型pay,refund,transfer',
+ money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '交易金额',
+ trade_no varchar(255) NOT NULL DEFAULT '' COMMENT '对应类型交易单号',
+ create_time varchar(255) NOT NULL DEFAULT '0' COMMENT '添加时间',
+ PRIMARY KEY (id)
+)
+ENGINE = INNODB,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci,
+COMMENT = '站点账单记录';
+
CREATE TABLE site (
site_id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ site_code varchar(32) NOT NULL DEFAULT '' COMMENT '站点code码',
site_name varchar(50) NOT NULL DEFAULT '' COMMENT '站点名称',
group_id int(11) NOT NULL DEFAULT 0 COMMENT '分组ID(0:不限制)',
keywords varchar(255) NOT NULL DEFAULT '' COMMENT '关键字',
@@ -648,7 +608,7 @@ CREATE TABLE site (
phone varchar(255) NOT NULL DEFAULT '' COMMENT '客服电话',
business_hours varchar(255) NOT NULL DEFAULT '' COMMENT '营业时间',
create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
- expire_time BIGINT NOT NULL DEFAULT 0 COMMENT '到期时间(如果是0 无限期)',
+ expire_time bigint(20) NOT NULL DEFAULT 0 COMMENT '到期时间(如果是0 无限期)',
front_end_name varchar(50) NOT NULL DEFAULT '' COMMENT '前台名称',
front_end_logo varchar(255) NOT NULL DEFAULT '' COMMENT '前台logo',
icon varchar(255) NOT NULL DEFAULT '' COMMENT '网站图标',
@@ -656,11 +616,11 @@ CREATE TABLE site (
PRIMARY KEY (site_id)
)
ENGINE = INNODB,
+AUTO_INCREMENT = 2,
AVG_ROW_LENGTH = 1365,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '站点表',
-ROW_FORMAT = COMPACT;
+COMMENT = '站点表';
ALTER TABLE site
ADD INDEX create_time (create_time);
@@ -668,9 +628,99 @@ ADD INDEX create_time (create_time);
ALTER TABLE site
ADD INDEX group_id (group_id);
---
--- `ns_pay_transfer`
---
+CREATE TABLE recharge_order_log (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ order_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
+ site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
+ action varchar(255) NOT NULL DEFAULT '' COMMENT '操作内容',
+ uid int(11) NOT NULL DEFAULT 0 COMMENT '操作人id',
+ nick_name varchar(50) NOT NULL DEFAULT '' COMMENT '操作人名称',
+ order_status int(11) NOT NULL DEFAULT 0 COMMENT '订单状态,操作后',
+ action_way bigint(20) NOT NULL DEFAULT 2 COMMENT '操作类型1买家2卖家 3 系统任务',
+ order_status_name varchar(255) NOT NULL DEFAULT '' COMMENT '订单状态名称,操作后',
+ action_time int(11) NOT NULL DEFAULT 0 COMMENT '操作时间',
+ PRIMARY KEY (id)
+)
+ENGINE = INNODB,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci,
+COMMENT = '订单操作记录表';
+
+CREATE TABLE recharge_order_item_refund (
+ refund_id int(11) NOT NULL AUTO_INCREMENT,
+ order_item_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
+ order_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
+ order_no varchar(255) NOT NULL DEFAULT '' COMMENT '订单编号',
+ refund_no varchar(255) NOT NULL DEFAULT '0' COMMENT '退款单号',
+ site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
+ member_id int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
+ num decimal(10, 3) NOT NULL DEFAULT 0.000 COMMENT '退货数量',
+ money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '总退款',
+ status int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
+ create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
+ audit_time int(11) NOT NULL DEFAULT 0 COMMENT '审核时间',
+ transfer_time int(11) NOT NULL DEFAULT 0 COMMENT '转账时间',
+ item_type varchar(255) NOT NULL DEFAULT '' COMMENT '项目类型',
+ PRIMARY KEY (refund_id)
+)
+ENGINE = INNODB,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci,
+COMMENT = '订单退款表';
+
+CREATE TABLE recharge_order_item (
+ order_item_id int(11) NOT NULL AUTO_INCREMENT,
+ order_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
+ site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
+ member_id int(11) NOT NULL DEFAULT 0 COMMENT '购买会员id',
+ item_id int(11) NOT NULL DEFAULT 0 COMMENT '项目id',
+ item_type varchar(255) NOT NULL DEFAULT '' COMMENT '项目类型',
+ item_name varchar(400) NOT NULL DEFAULT '' COMMENT '项目名称',
+ item_image varchar(2000) NOT NULL DEFAULT '' COMMENT '项目图片',
+ price decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '项目单价',
+ num decimal(10, 3) NOT NULL DEFAULT 0.000 COMMENT '购买数量',
+ item_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '项目总价',
+ is_refund int(11) NOT NULL DEFAULT 0 COMMENT '是否退款',
+ refund_no varchar(255) NOT NULL DEFAULT '' COMMENT '退款编号',
+ refund_status int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
+ create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
+ PRIMARY KEY (order_item_id)
+)
+ENGINE = INNODB,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci,
+COMMENT = '订单商品表';
+
+CREATE TABLE recharge_order (
+ order_id int(11) NOT NULL AUTO_INCREMENT,
+ site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
+ order_no varchar(50) NOT NULL DEFAULT '' COMMENT '订单编号',
+ order_from varchar(55) NOT NULL DEFAULT '' COMMENT '订单来源',
+ order_type varchar(50) NOT NULL DEFAULT '' COMMENT '订单类型',
+ out_trade_no varchar(50) NOT NULL DEFAULT '' COMMENT '支付流水号',
+ order_status int(11) NOT NULL DEFAULT 0 COMMENT '订单状态',
+ refund_status int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
+ member_id int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
+ ip varchar(20) NOT NULL DEFAULT '' COMMENT '会员ip',
+ member_message varchar(50) NOT NULL DEFAULT '' COMMENT '会员留言信息',
+ order_item_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单项目金额',
+ order_discount_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单优惠金额',
+ order_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单金额',
+ create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
+ pay_time int(11) NOT NULL DEFAULT 0 COMMENT '订单支付时间',
+ close_time int(11) NOT NULL DEFAULT 0 COMMENT '订单关闭时间',
+ is_delete int(11) NOT NULL DEFAULT 0 COMMENT '是否删除(针对后台)',
+ is_enable_refund int(11) NOT NULL DEFAULT 0 COMMENT '是否允许退款',
+ remark varchar(255) NOT NULL DEFAULT '' COMMENT '商家留言',
+ invoice_id int(11) NOT NULL DEFAULT 0 COMMENT '发票id,0表示不开发票',
+ close_reason varchar(255) NOT NULL DEFAULT '' COMMENT '关闭原因',
+ PRIMARY KEY (order_id)
+)
+ENGINE = INNODB,
+CHARACTER SET utf8mb4,
+COLLATE utf8mb4_general_ci,
+COMMENT = '订单表';
+
CREATE TABLE pay_transfer (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -697,7 +747,6 @@ CREATE TABLE pay_transfer (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 3276,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '转账表';
@@ -714,19 +763,19 @@ ADD INDEX member_withdraw_site_id (site_id, main_id);
ALTER TABLE pay_transfer
ADD INDEX member_withdraw_status (transfer_status);
---
--- `ns_pay_refund`
---
+ALTER TABLE pay_transfer
+ADD UNIQUE INDEX UK_ns_pay_transfer_transfer_no (transfer_no);
+
CREATE TABLE pay_refund (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
- refund_no varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '退款单号',
- out_trade_no varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付流水号',
- type varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付方式',
+ refund_no varchar(255) NOT NULL DEFAULT '' COMMENT '退款单号',
+ out_trade_no varchar(255) NOT NULL DEFAULT '' COMMENT '支付流水号',
+ type varchar(255) NOT NULL DEFAULT '' COMMENT '支付方式',
channel varchar(50) NOT NULL DEFAULT '' COMMENT '支付渠道',
money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '支付金额',
- reason varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '退款原因',
- status varchar(255) NOT NULL DEFAULT '0' COMMENT '支付状态(0.待退款 1. 退款中中 2. 已退款 -1已关闭)',
+ reason varchar(255) NOT NULL DEFAULT '' COMMENT '退款原因',
+ status varchar(255) NOT NULL DEFAULT '0' COMMENT '支付状态(0.待退款 1. 退款中 2. 已退款 -1已关闭)',
create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
refund_time int(11) NOT NULL DEFAULT 0 COMMENT '支付时间',
close_time int(11) NOT NULL DEFAULT 0 COMMENT '关闭时间',
@@ -734,19 +783,18 @@ CREATE TABLE pay_refund (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '支付记录表';
---
--- `ns_pay_channel`
---
+ALTER TABLE pay_refund
+ADD UNIQUE INDEX UK_ns_pay_refund_refund_no (refund_no);
+
CREATE TABLE pay_channel (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
- site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
- type varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付类型',
- channel varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '支付渠道',
+ site_id int(11) NOT NULL DEFAULT 1 COMMENT '站点id',
+ type varchar(255) NOT NULL DEFAULT '' COMMENT '支付类型',
+ channel varchar(255) NOT NULL DEFAULT '' COMMENT '支付渠道',
config text NOT NULL COMMENT '支付配置',
create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
update_time int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
@@ -755,14 +803,10 @@ CREATE TABLE pay_channel (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 496,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '支付渠道配置表';
---
--- `ns_pay`
---
CREATE TABLE pay (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -785,7 +829,6 @@ CREATE TABLE pay (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '支付记录表';
@@ -793,122 +836,6 @@ COMMENT = '支付记录表';
ALTER TABLE pay
ADD UNIQUE INDEX UK_ns_pay_out_trade_no (out_trade_no);
---
--- `ns_recharge_order_log`
---
-CREATE TABLE recharge_order_log (
- id int(11) NOT NULL AUTO_INCREMENT,
- order_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
- site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
- action varchar(255) NOT NULL DEFAULT '' COMMENT '操作内容',
- uid int(11) NOT NULL DEFAULT 0 COMMENT '操作人id',
- nick_name varchar(50) NOT NULL DEFAULT '' COMMENT '操作人名称',
- order_status int(11) NOT NULL DEFAULT 0 COMMENT '订单状态,操作后',
- action_way bigint(20) NOT NULL DEFAULT 2 COMMENT '操作类型1买家2卖家 3 系统任务',
- order_status_name varchar(255) NOT NULL DEFAULT '' COMMENT '订单状态名称,操作后',
- action_time int(11) NOT NULL DEFAULT 0 COMMENT '操作时间',
- PRIMARY KEY (id)
-)
-ENGINE = INNODB,
-AVG_ROW_LENGTH = 223,
-CHARACTER SET utf8mb4,
-COLLATE utf8mb4_general_ci,
-COMMENT = '订单操作记录表',
-ROW_FORMAT = COMPACT;
-
---
--- `ns_recharge_order_item_refund`
---
-CREATE TABLE recharge_order_item_refund (
- refund_id int(11) NOT NULL AUTO_INCREMENT,
- order_item_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
- order_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
- order_no varchar(255) NOT NULL DEFAULT '' COMMENT '订单编号',
- refund_no varchar(255) NOT NULL DEFAULT '0' COMMENT '退款单号',
- site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
- member_id int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
- num decimal(10, 3) NOT NULL DEFAULT 0.000 COMMENT '退货数量',
- money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '总退款',
- status int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
- create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
- audit_time int(11) NOT NULL DEFAULT 0 COMMENT '审核时间',
- transfer_time int(11) NOT NULL DEFAULT 0 COMMENT '转账时间',
- item_type varchar(255) NOT NULL DEFAULT '' COMMENT '项目类型',
- PRIMARY KEY (refund_id)
-)
-ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
-CHARACTER SET utf8mb4,
-COLLATE utf8mb4_general_ci,
-COMMENT = '订单退款表',
-ROW_FORMAT = COMPACT;
-
---
--- `recharge_order_item`
---
-CREATE TABLE recharge_order_item (
- order_item_id int(11) NOT NULL AUTO_INCREMENT,
- order_id int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
- site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
- member_id int(11) NOT NULL DEFAULT 0 COMMENT '购买会员id',
- item_id int(11) NOT NULL DEFAULT 0 COMMENT '项目id',
- item_type varchar(255) NOT NULL DEFAULT '' COMMENT '项目类型',
- item_name varchar(400) NOT NULL DEFAULT '' COMMENT '项目名称',
- item_image varchar(2000) NOT NULL DEFAULT '' COMMENT '项目图片',
- price decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '项目单价',
- num decimal(10, 3) NOT NULL DEFAULT 0.000 COMMENT '购买数量',
- item_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '项目总价',
- is_refund int(11) NOT NULL DEFAULT 0 COMMENT '是否退款',
- refund_no varchar(255) NOT NULL DEFAULT '' COMMENT '退款编号',
- refund_status int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
- create_time int(11) NOT NULL DEFAULT 0,
- PRIMARY KEY (order_item_id)
-)
-ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
-CHARACTER SET utf8mb4,
-COLLATE utf8mb4_general_ci,
-COMMENT = '订单商品表',
-ROW_FORMAT = COMPACT;
-
---
--- `recharge_order`
---
-CREATE TABLE `recharge_order` (
- order_id int(11) NOT NULL AUTO_INCREMENT,
- site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
- order_no varchar(50) NOT NULL DEFAULT '' COMMENT '订单编号',
- order_from varchar(55) NOT NULL DEFAULT '' COMMENT '订单来源',
- order_type varchar(50) NOT NULL DEFAULT '' COMMENT '订单类型',
- out_trade_no varchar(50) NOT NULL DEFAULT '' COMMENT '支付流水号',
- order_status int(11) NOT NULL DEFAULT 0 COMMENT '订单状态',
- refund_status int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
- member_id int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
- ip varchar(20) NOT NULL DEFAULT '' COMMENT '会员ip',
- member_message varchar(50) NOT NULL DEFAULT '' COMMENT '会员留言信息',
- order_item_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单项目金额',
- order_discount_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单优惠金额',
- order_money decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单金额',
- create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
- pay_time int(11) NOT NULL DEFAULT 0 COMMENT '订单支付时间',
- close_time int(11) NOT NULL DEFAULT 0 COMMENT '订单关闭时间',
- is_delete int(11) NOT NULL DEFAULT 0 COMMENT '是否删除(针对后台)',
- is_enable_refund int(11) NOT NULL DEFAULT 0 COMMENT '是否允许退款',
- remark varchar(255) NOT NULL DEFAULT '' COMMENT '商家留言',
- invoice_id int(11) NOT NULL DEFAULT 0 COMMENT '发票id,0表示不开发票',
- close_reason varchar(255) NOT NULL DEFAULT '' COMMENT '关闭原因',
- PRIMARY KEY (order_id)
-)
-ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
-CHARACTER SET utf8mb4,
-COLLATE utf8mb4_general_ci,
-COMMENT = '订单表',
-ROW_FORMAT = COMPACT;
-
---
--- `ns_member_level`
---
CREATE TABLE member_level (
level_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '会员等级',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -921,11 +848,9 @@ CREATE TABLE member_level (
PRIMARY KEY (level_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '会员等级',
-ROW_FORMAT = COMPACT;
+COMMENT = '会员等级';
ALTER TABLE member_level
ADD INDEX site_id (site_id);
@@ -933,9 +858,6 @@ ADD INDEX site_id (site_id);
ALTER TABLE member_level
ADD INDEX status (status);
---
--- `ns_member_label`
---
CREATE TABLE member_label (
label_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '标签id',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -948,11 +870,9 @@ CREATE TABLE member_label (
INDEX label_id (label_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '会员标签',
-ROW_FORMAT = COMPACT;
+COMMENT = '会员标签';
ALTER TABLE member_label
ADD INDEX site_id (site_id);
@@ -960,13 +880,10 @@ ADD INDEX site_id (site_id);
ALTER TABLE member_label
ADD INDEX sort (sort);
---
--- `ns_member_cash_out_account`
---
CREATE TABLE member_cash_out_account (
account_id int(11) NOT NULL AUTO_INCREMENT,
- site_id int(11) NOT NULL COMMENT '站点id',
- member_id int(11) NOT NULL COMMENT '会员id',
+ site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
+ member_id int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
account_type varchar(255) NOT NULL DEFAULT '' COMMENT '账户类型',
bank_name varchar(255) NOT NULL DEFAULT '' COMMENT '银行名称',
realname varchar(255) NOT NULL DEFAULT '' COMMENT '真实名称',
@@ -976,14 +893,10 @@ CREATE TABLE member_cash_out_account (
PRIMARY KEY (account_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '会员提现账户';
---
--- `ns_member_cash_out`
---
CREATE TABLE member_cash_out (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -1014,7 +927,6 @@ CREATE TABLE member_cash_out (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 297,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '会员提现表';
@@ -1034,9 +946,6 @@ ADD INDEX member_withdraw_status (status);
ALTER TABLE member_cash_out
ADD INDEX member_withdraw_withdraw_no (cash_out_no);
---
--- `ns_member_address`
---
CREATE TABLE member_address (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
member_id int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
@@ -1057,18 +966,13 @@ CREATE TABLE member_address (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 16384,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '会员收货地址',
-ROW_FORMAT = COMPACT;
+COMMENT = '会员收货地址';
ALTER TABLE member_address
ADD INDEX IDX_member_address (member_id, site_id);
---
--- `ns_member_account_log`
---
CREATE TABLE member_account_log (
id int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
member_id int(11) NOT NULL DEFAULT 0 COMMENT '用户id',
@@ -1083,27 +987,22 @@ CREATE TABLE member_account_log (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '会员账单表',
-ROW_FORMAT = COMPACT;
+COMMENT = '会员账单表';
ALTER TABLE member_account_log
-ADD INDEX account_type (account_type (191));
+ADD INDEX account_type (account_type);
ALTER TABLE member_account_log
ADD INDEX create_time (create_time);
ALTER TABLE member_account_log
-ADD INDEX from_type (from_type (191));
+ADD INDEX from_type (from_type);
ALTER TABLE member_account_log
ADD INDEX member_id (member_id);
---
--- `ns_member`
---
CREATE TABLE member (
member_id int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
member_no varchar(255) NOT NULL DEFAULT '' COMMENT '会员编码',
@@ -1145,7 +1044,7 @@ CREATE TABLE member (
growth_get int(11) NOT NULL DEFAULT 0 COMMENT '累计获得成长值',
commission decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '当前佣金',
commission_get decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '佣金获取',
- commission_cash_outing decimal(10, 2) NOT NULL COMMENT '提现中佣金',
+ commission_cash_outing decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '提现中佣金',
is_member tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否是会员',
member_time int(11) NOT NULL DEFAULT 0 COMMENT '成为会员时间',
is_del tinyint(4) NOT NULL DEFAULT 0 COMMENT '0正常 1已删除',
@@ -1159,36 +1058,31 @@ CREATE TABLE member (
PRIMARY KEY (member_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 4096,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
-COMMENT = '会员表',
-ROW_FORMAT = COMPACT;
+COMMENT = '会员表';
ALTER TABLE member
ADD INDEX mobile (mobile);
ALTER TABLE member
-ADD INDEX password (password (191));
+ADD INDEX password (password);
ALTER TABLE member
ADD INDEX site_id (site_id);
ALTER TABLE member
-ADD INDEX username (username (191));
+ADD INDEX username (username);
ALTER TABLE member
-ADD INDEX weapp_openid (weapp_openid (191));
+ADD INDEX weapp_openid (weapp_openid);
ALTER TABLE member
-ADD INDEX wx_openid (wx_openid (191));
+ADD INDEX wx_openid (wx_openid);
ALTER TABLE member
-ADD INDEX wx_unionid (wx_unionid (191));
+ADD INDEX wx_unionid (wx_unionid);
---
--- `ns_jobs_failed`
---
CREATE TABLE jobs_failed (
id int(11) NOT NULL AUTO_INCREMENT,
`connection` text NOT NULL,
@@ -1203,9 +1097,6 @@ CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '消息队列任务失败记录表';
---
--- `ns_jobs`
---
CREATE TABLE jobs (
id int(11) NOT NULL AUTO_INCREMENT,
queue varchar(255) NOT NULL,
@@ -1217,16 +1108,13 @@ CREATE TABLE jobs (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '消息队列任务表';
-ALTER TABLE jobs ADD INDEX queue (queue);
+ALTER TABLE jobs
+ADD INDEX queue (queue);
---
--- `ns_generate_table`
---
CREATE TABLE generate_table (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
table_name varchar(255) NOT NULL DEFAULT '' COMMENT '表名',
@@ -1238,14 +1126,10 @@ CREATE TABLE generate_table (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 780,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '代码生成表';
---
--- `ns_generate_column`
---
CREATE TABLE generate_column (
id int(11) NOT NULL AUTO_INCREMENT COMMENT 'id',
table_id int(11) NOT NULL DEFAULT 0 COMMENT '表id',
@@ -1263,18 +1147,14 @@ CREATE TABLE generate_column (
view_type varchar(100) DEFAULT 'input' COMMENT '显示类型',
dict_type varchar(255) DEFAULT '' COMMENT '字典类型',
create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
- update_time int(11) NOT NULL DEFAULT 0 NULL COMMENT '修改时间',
+ update_time int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 321,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '代码生成表字段信息表';
---
--- `ns_diy_route`
---
CREATE TABLE diy_route (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
@@ -1287,22 +1167,21 @@ CREATE TABLE diy_route (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 2730,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '自定义路由';
---
--- `ns_diy_page`
---
CREATE TABLE diy_page (
id int(11) NOT NULL AUTO_INCREMENT,
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
title varchar(255) NOT NULL DEFAULT '' COMMENT '页面名称',
name varchar(255) NOT NULL DEFAULT '' COMMENT '页面标识',
type varchar(255) NOT NULL DEFAULT '' COMMENT '页面模板',
+ template varchar(255) NOT NULL DEFAULT '' COMMENT '模板名称',
+ mode varchar(255) NOT NULL DEFAULT 'diy' COMMENT '页面展示模式,diy:自定义,fixed:固定',
value longtext DEFAULT NULL COMMENT '页面数据,json格式',
is_default int(11) NOT NULL DEFAULT 0 COMMENT '是否默认页面,1:是,0:否',
+ is_change int(11) NOT NULL DEFAULT 0 COMMENT '数据是否发生过变化,1:变化了,2:没有',
share varchar(1000) NOT NULL DEFAULT '' COMMENT '分享内容',
visit_count int(11) NOT NULL DEFAULT 0 COMMENT '访问量',
create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
@@ -1310,14 +1189,10 @@ CREATE TABLE diy_page (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '自定义页面';
---
--- `ns_article_category`
---
CREATE TABLE article_category (
category_id int(11) NOT NULL AUTO_INCREMENT COMMENT '文章分类id',
site_id int(11) NOT NULL DEFAULT 0 COMMENT '站点ID',
@@ -1329,7 +1204,6 @@ CREATE TABLE article_category (
PRIMARY KEY (category_id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 8192,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '文章分类表';
@@ -1346,9 +1220,6 @@ ADD INDEX site_id (site_id);
ALTER TABLE article_category
ADD INDEX sort (sort);
---
--- `ns_article`
---
CREATE TABLE article (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '文章id',
category_id int(11) NOT NULL COMMENT '文章分类',
@@ -1368,7 +1239,6 @@ CREATE TABLE article (
PRIMARY KEY (id)
)
ENGINE = INNODB,
-AVG_ROW_LENGTH = 5461,
CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '文章表';
@@ -1388,9 +1258,6 @@ ADD INDEX IDX_article_site_id (site_id);
ALTER TABLE article
ADD INDEX IDX_ns_article_sort (sort);
---
--- `ns_addon_log`
---
CREATE TABLE addon_log (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
action varchar(40) NOT NULL DEFAULT '' COMMENT '操作类型 install 安装 uninstall 卸载 update 更新',
@@ -1405,18 +1272,15 @@ CHARACTER SET utf8mb4,
COLLATE utf8mb4_general_ci,
COMMENT = '插件日志表';
---
--- `ns_addon`
---
CREATE TABLE addon (
id int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
- title varchar(40) NOT NULL DEFAULT '' COMMENT '插件名称',
- icon varchar(255) NOT NULL DEFAULT '' COMMENT '插件图标',
- `key` varchar(20) NOT NULL DEFAULT '' COMMENT '插件标识',
- `desc` text DEFAULT NULL COMMENT '插件描述',
+ title varchar(40) NOT NULL DEFAULT '' COMMENT '插件名称',
+ icon varchar(255) NOT NULL DEFAULT '' COMMENT '插件图标',
+ `key` varchar(20) NOT NULL DEFAULT '' COMMENT '插件标识',
+ `desc` text DEFAULT NULL COMMENT '插件描述',
status tinyint(4) NOT NULL DEFAULT 1 COMMENT '状态',
- author varchar(40) NOT NULL DEFAULT '' COMMENT '作者',
- version varchar(20) NOT NULL DEFAULT '' COMMENT '版本号',
+ author varchar(40) NOT NULL DEFAULT '' COMMENT '作者',
+ version varchar(20) NOT NULL DEFAULT '' COMMENT '版本号',
create_time int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
install_time int(11) NOT NULL DEFAULT 0 COMMENT '安装时间',
update_time int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
@@ -1431,9 +1295,12 @@ COMMENT = '插件表';
ALTER TABLE addon
ADD UNIQUE INDEX UK_title (title);
---
--- Dumping data for table ns_sys_area
---
+INSERT INTO sys_user_role VALUES
+(1, 1, 0, '', 0, 1);
+
+INSERT INTO sys_user VALUES
+(1, '', '', '', '', '', 0, 0, 0, 1, 0, 0, 0);
+
INSERT INTO sys_area VALUES
(110000, 0, '北京市', '北京', '116.40529', '39.904987', 1, 0, 1),
(110100, 110000, '北京市', '北京', '116.40529', '39.904987', 2, 0, 1),
@@ -5081,10 +4948,5 @@ INSERT INTO sys_area VALUES
(460400499, 460400, '洋浦经济开发区', '洋浦经济开发区', '109.202064', '19.736941', 3, 0, 1),
(460400500, 460400, '华南热作学院', '华南热作学院', '109.494073', '19.505382', 3, 0, 1);
-INSERT INTO sys_user_role(id, uid, site_id, is_admin) VALUE
-(1, 1, 0, 1);
-
-INSERT INTO sys_user(uid, username) VALUE
-(1, '');
-INSERT INTO site(site_id, site_name, app_type) VALUE
-(1, 'niucloud-admin', 'admin');
+INSERT INTO site VALUES
+(1, '', 'niucloud-admin', 0, '', 'admin', '', '', 1, '', '', 0, 0, 0, '', '', '', '', 0, 0, '', '', '', '0');
diff --git a/niucloud/app/job/schedule/SiteExpireClose.php b/niucloud/app/job/schedule/SiteExpireClose.php
index d8c3cbe0c..0204238dc 100644
--- a/niucloud/app/job/schedule/SiteExpireClose.php
+++ b/niucloud/app/job/schedule/SiteExpireClose.php
@@ -13,6 +13,7 @@ namespace app\job\schedule;
use app\service\core\site\CoreSiteService;
use core\base\BaseJob;
+use think\facade\Log;
/**
* 站点到期自动关闭
@@ -28,7 +29,7 @@ class SiteExpireClose extends BaseJob
$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;
}
}
diff --git a/niucloud/app/lang/en/dict.php b/niucloud/app/lang/en/dict.php
index 20d00b82d..8a9eefd0b 100644
--- a/niucloud/app/lang/en/dict.php
+++ b/niucloud/app/lang/en/dict.php
@@ -98,14 +98,11 @@ return [
'status_off' => 'off'
],
//自动任务时间间隔
- 'dict_cron' => [
- 'type_minute' => 'minute',
- 'type_day' => 'day',
- 'type_week' => 'week',
- 'type_month' => 'month',
-
+ 'dict_schedule' => [
'type_cron' => 'time work',
- 'type_crond' => 'period work'
+ 'type_crond' => 'period work',
+ 'on' => 'on',
+ 'off' => 'off'
],
//支付相关
'dict_pay' => [
@@ -270,4 +267,27 @@ return [
'sms_notice_records' => 'send log',
'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',
+ ],
];
diff --git a/niucloud/app/lang/zh-cn/api.php b/niucloud/app/lang/zh-cn/api.php
index 832ee5ea6..bbc3b9242 100644
--- a/niucloud/app/lang/zh-cn/api.php
+++ b/niucloud/app/lang/zh-cn/api.php
@@ -38,6 +38,7 @@ return [
'ADDON_INSTALL_NOT_EXIST' => '未找到插件安装任务',
'ADDON_INSTALL_EXECUTED' => '插件安装任务已执行',
'INSTALL_CHECK_NOT_PASS' => '安装校验未通过',
+ 'SITE_INDEX_VIEW_PATH_NOT_EXIST' => '当前首页路径不存在',
//登录注册重置账号....
diff --git a/niucloud/app/lang/zh-cn/dict.php b/niucloud/app/lang/zh-cn/dict.php
index aa64e5d45..d916f9c17 100644
--- a/niucloud/app/lang/zh-cn/dict.php
+++ b/niucloud/app/lang/zh-cn/dict.php
@@ -42,7 +42,15 @@ return [
'status_on' => '正常',
'status_experience' => '体验期',
'status_expire' => '已到期',
- 'status_close' => '已停止'
+ 'status_close' => '已停止',
+ 'pay' => '收款',
+ 'refund' => '退款',
+ 'transfer' => '转账',
+ ],
+ // 站点
+ 'dict_site_index' => [
+ //站点类型
+ 'system' => '框架首页',
],
'dict_notice' => [
'type_sms' => '短信',
@@ -125,14 +133,11 @@ return [
'status_off' => '停用'
],
//自动任务时间间隔
- 'dict_cron' => [
- 'type_minute' => '分钟',
- 'type_day' => '天',
- 'type_week' => '星期',
- 'type_month' => '月',
-
+ 'dict_schedule' => [
'type_cron' => '定时任务',
- 'type_crond' => '周期任务'
+ 'type_crond' => '周期任务',
+ 'on' => '启用',
+ 'off' => '关闭'
],
//支付相关
'dict_pay' => [
@@ -263,6 +268,31 @@ return [
'mysql_ask' => '大于等于5.7',
'php_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月',
+
+ ],
];
diff --git a/niucloud/app/listener/pay/PaySuccessListener.php b/niucloud/app/listener/pay/PaySuccessListener.php
index 120c407b6..ab637f9d8 100644
--- a/niucloud/app/listener/pay/PaySuccessListener.php
+++ b/niucloud/app/listener/pay/PaySuccessListener.php
@@ -12,6 +12,7 @@
namespace app\listener\pay;
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 CoreSiteAccountService())->addPayLog($pay_info);
+
}
}
\ No newline at end of file
diff --git a/niucloud/app/listener/pay/RefundSuccessListener.php b/niucloud/app/listener/pay/RefundSuccessListener.php
index 48be20575..c453b0c8e 100644
--- a/niucloud/app/listener/pay/RefundSuccessListener.php
+++ b/niucloud/app/listener/pay/RefundSuccessListener.php
@@ -11,8 +11,10 @@
namespace app\listener\pay;
+use app\model\site\SiteAccountLog;
use app\service\core\order\recharge\CoreRechargeOrderService;
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)
{
+ //添加账单记录
+ (new CoreSiteAccountService())->addRefundLog($refund_info['site_id'], $refund_info['refund_no']);
+ //交易单据处理
$trade_type = $refund_info['trade_type'] ?? '';
if($trade_type == 'recharge')
{
(new CoreRechargeRefundService())->refundComplete($refund_info['refund_no']);
}
+
}
}
\ No newline at end of file
diff --git a/niucloud/app/listener/pay/TransferSuccessListener.php b/niucloud/app/listener/pay/TransferSuccessListener.php
index 6e68b05b5..48701ffe1 100644
--- a/niucloud/app/listener/pay/TransferSuccessListener.php
+++ b/niucloud/app/listener/pay/TransferSuccessListener.php
@@ -13,6 +13,7 @@ namespace app\listener\pay;
use app\dict\cash_out\CashOutTypeDict;
use app\service\core\member\CoreMemberCashOutService;
+use app\service\core\site\CoreSiteAccountService;
/**
* 转账事件
@@ -21,6 +22,8 @@ class TransferSuccessListener
{
public function handle(array $info)
{
+ //添加账单记录
+ (new CoreSiteAccountService())->addTransferLog($info['site_id'], $info['transfer_no']);
//会员零钱提现
if($info['trade_type'] == CashOutTypeDict::MEMBER_CASH_OUT)
{
diff --git a/niucloud/app/listener/system/AppManageListener.php b/niucloud/app/listener/system/AppManageListener.php
index 36dc283c2..22aa56f0a 100644
--- a/niucloud/app/listener/system/AppManageListener.php
+++ b/niucloud/app/listener/system/AppManageListener.php
@@ -20,7 +20,7 @@ class AppManageListener
{
public function handle()
{
- $data = [
+ return [
"category" =>[
[
@@ -45,9 +45,8 @@ class AppManageListener
"desc" => get_lang('dict_app_manage.member_recharge'),
"icon" => "static/resource/images/app/recharge_icon.png",
"cover" => "static/resource/images/app/recharge_cover.png",
- "url" => "/finance/recharge"
+ "url" => "/order/recharge/order"
],
];
- return $data;
}
}
\ No newline at end of file
diff --git a/niucloud/app/listener/system/SiteIndexListener.php b/niucloud/app/listener/system/SiteIndexListener.php
new file mode 100644
index 000000000..114276e04
--- /dev/null
+++ b/niucloud/app/listener/system/SiteIndexListener.php
@@ -0,0 +1,30 @@
+ get_lang("dict_site_index.system"),
+ "view_path" => "index/site_index"
+ ]
+ ];
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/model/addon/Addon.php b/niucloud/app/model/addon/Addon.php
index 271a58cd5..8df9e59fe 100644
--- a/niucloud/app/model/addon/Addon.php
+++ b/niucloud/app/model/addon/Addon.php
@@ -45,7 +45,7 @@ class Addon extends BaseModel
*/
public function getStatusNameAttr($value, $data)
{
- return AddonDict::getStatus()[ $data[ 'status' ] ?? '' ] ?? '';
+ return AddonDict::getStatus()[ $data[ 'status' ]] ?? '';
}
/**
diff --git a/niucloud/app/model/article/Article.php b/niucloud/app/model/article/Article.php
index 945f55f8b..2e8c9ed2f 100644
--- a/niucloud/app/model/article/Article.php
+++ b/niucloud/app/model/article/Article.php
@@ -11,6 +11,7 @@
namespace app\model\article;
+use app\model\site\Site;
use core\base\BaseModel;
use think\db\Query;
use think\model\relation\HasOne;
@@ -99,12 +100,16 @@ class Article extends BaseModel
}
public function getArticleUrlAttr($value, $data) {
- $site_tag = $data['site_id'] == 1 ? '' : '/s' . $data['site_id'];
- $data = [
- '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']}"
+ $site = Site::find($data['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();
+
+ 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;
}
}
diff --git a/niucloud/app/model/diy/Diy.php b/niucloud/app/model/diy/Diy.php
index 295c2107f..1ca8bfe7f 100644
--- a/niucloud/app/model/diy/Diy.php
+++ b/niucloud/app/model/diy/Diy.php
@@ -47,7 +47,10 @@ class Diy extends BaseModel
*/
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 '';
}
/**
diff --git a/niucloud/app/model/member/Member.php b/niucloud/app/model/member/Member.php
index 51e942e41..883a5fa74 100644
--- a/niucloud/app/model/member/Member.php
+++ b/niucloud/app/model/member/Member.php
@@ -72,7 +72,9 @@ class Member extends BaseModel
*/
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)
{
- 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)
{
- 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)
{
- 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)
{
- 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)
{
- return CommonDict::getSexType()[ $data[ 'sex' ] ?? '' ] ?? '';
+ if(empty($data['sex']))
+ return '';
+ return CommonDict::getSexType()[ $data[ 'sex' ]] ?? '';
}
/**
diff --git a/niucloud/app/model/member/MemberAccountLog.php b/niucloud/app/model/member/MemberAccountLog.php
index 9dbaaf515..45f7c707b 100644
--- a/niucloud/app/model/member/MemberAccountLog.php
+++ b/niucloud/app/model/member/MemberAccountLog.php
@@ -44,7 +44,9 @@ class MemberAccountLog extends BaseModel
*/
public function getAccountTypeNameAttr($value,$data)
{
- return MemberAccountTypeDict::getType()[$data['account_type'] ?? ''] ?? '';
+ if(empty($data['account_type']))
+ return '';
+ return MemberAccountTypeDict::getType()[$data['account_type']] ?? '';
}
/**
diff --git a/niucloud/app/model/member/MemberCashOut.php b/niucloud/app/model/member/MemberCashOut.php
index c650d5f00..c535b4248 100644
--- a/niucloud/app/model/member/MemberCashOut.php
+++ b/niucloud/app/model/member/MemberCashOut.php
@@ -76,7 +76,9 @@ class MemberCashOut extends BaseModel
* @return mixed|string
*/
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
*/
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)
{
- 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
*/
public function getTransferStatusNameAttr($value, $data){
- return TransferDict::getStatus()[ $data[ 'transfer_status' ] ?? '' ] ?? '';
+ if(empty($data[ 'transfer_status' ]))
+ return '';
+ return TransferDict::getStatus()[ $data[ 'transfer_status' ]] ?? '';
}
/**
* 会员搜索
diff --git a/niucloud/app/model/member/MemberCashOutAccount.php b/niucloud/app/model/member/MemberCashOutAccount.php
index 5f099c1ab..c1e22a690 100644
--- a/niucloud/app/model/member/MemberCashOutAccount.php
+++ b/niucloud/app/model/member/MemberCashOutAccount.php
@@ -39,7 +39,10 @@ class MemberCashOutAccount extends BaseModel
* @return mixed|string
*/
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'] ?? '';
}
/**
diff --git a/niucloud/app/model/order/RechargeOrderItemRefund.php b/niucloud/app/model/order/RechargeOrderItemRefund.php
index f7f24c59d..0b991459f 100644
--- a/niucloud/app/model/order/RechargeOrderItemRefund.php
+++ b/niucloud/app/model/order/RechargeOrderItemRefund.php
@@ -49,7 +49,10 @@ class RechargeOrderItemRefund extends BaseModel
*/
public function getStatusNameAttr($value, $data)
{
- return RechargeOrderDict::getRefundStatus()[$data['status'] ?? '']['name'] ?? '';
+ if(empty($data['status']))
+ return '';
+ $temp = RechargeOrderDict::getRefundStatus()[$data['status']] ?? [];
+ return $temp['name'] ?? '';
}
/**
diff --git a/niucloud/app/model/pay/Pay.php b/niucloud/app/model/pay/Pay.php
index d010a003d..40fe79096 100644
--- a/niucloud/app/model/pay/Pay.php
+++ b/niucloud/app/model/pay/Pay.php
@@ -53,7 +53,9 @@ class Pay extends BaseModel
*/
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)
{
- return PayDict::getPayType()[$data['type'] ?? '']['name'] ?? '';
+ if(empty($data['type']))
+ return '';
+ $temp = PayDict::getPayType()[$data['type']] ?? [];
+ return $temp['name'] ?? '';
}
}
diff --git a/niucloud/app/model/pay/PayChannel.php b/niucloud/app/model/pay/PayChannel.php
index a745f3389..da24a7864 100644
--- a/niucloud/app/model/pay/PayChannel.php
+++ b/niucloud/app/model/pay/PayChannel.php
@@ -47,7 +47,9 @@ class PayChannel extends BaseModel
*/
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)
{
- return ChannelDict::getType()[$data['channel'] ?? ''] ?? '';
+ if(empty($data['channel'])) return '';
+ return ChannelDict::getType()[$data['channel']] ?? '';
}
}
diff --git a/niucloud/app/model/pay/Refund.php b/niucloud/app/model/pay/Refund.php
index 9eaef4ee3..446c3dcc4 100644
--- a/niucloud/app/model/pay/Refund.php
+++ b/niucloud/app/model/pay/Refund.php
@@ -47,7 +47,8 @@ class Refund extends BaseModel
*/
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)
{
- return RefundDict::getType()[$data['type'] ?? ''] ?? '';
+ if(empty($data['type'])) return '';
+ return RefundDict::getType()[$data['type']] ?? '';
}
}
diff --git a/niucloud/app/model/pay/Transfer.php b/niucloud/app/model/pay/Transfer.php
index 9d88c91d6..eb5edfa40 100644
--- a/niucloud/app/model/pay/Transfer.php
+++ b/niucloud/app/model/pay/Transfer.php
@@ -48,7 +48,8 @@ class Transfer extends BaseModel
*/
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)
{
- return TransferDict::getTransferType()[$data['transfer_type'] ?? '']['name'] ?? '';
+ if(empty($data['transfer_type'])) return '';
+ $temp = TransferDict::getTransferType()[$data['transfer_type']] ?? [];
+ return $temp['name'] ?? '';
}
}
diff --git a/niucloud/app/model/site/Site.php b/niucloud/app/model/site/Site.php
index 4bbe2ad74..285a1b1d4 100644
--- a/niucloud/app/model/site/Site.php
+++ b/niucloud/app/model/site/Site.php
@@ -46,7 +46,9 @@ class Site extends BaseModel
*/
public function getStatusNameAttr($value, $data)
{
- return SiteDict::getStatus()[$data['status'] ?? ''] ?? '';
+ if(empty($data['status']))
+ return '';
+ return SiteDict::getStatus()[$data['status']] ?? '';
}
/**
* 关键字搜索
diff --git a/niucloud/app/model/site/SiteAccountLog.php b/niucloud/app/model/site/SiteAccountLog.php
new file mode 100644
index 000000000..6f795bbe7
--- /dev/null
+++ b/niucloud/app/model/site/SiteAccountLog.php
@@ -0,0 +1,118 @@
+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 ] ]);
+ }
+ }
+
+
+}
diff --git a/niucloud/app/model/sys/SysAgreement.php b/niucloud/app/model/sys/SysAgreement.php
index f1e9b4aa5..c41f2c9f8 100644
--- a/niucloud/app/model/sys/SysAgreement.php
+++ b/niucloud/app/model/sys/SysAgreement.php
@@ -12,6 +12,7 @@
namespace app\model\sys;
use app\dict\sys\AgreementDict;
+use app\dict\sys\StorageDict;
use core\base\BaseModel;
/**
@@ -45,6 +46,7 @@ class SysAgreement extends BaseModel
*/
public function getAgreementKeyNameAttr($value, $data)
{
- return AgreementDict::getType()[$data['agreement_key'] ?? ''] ?? '';
+ if(empty($data['agreement_key'])) return '';
+ return AgreementDict::getType()[$data['agreement_key']] ?? '';
}
}
diff --git a/niucloud/app/model/sys/SysMenu.php b/niucloud/app/model/sys/SysMenu.php
index b6c34306a..f9b050daa 100644
--- a/niucloud/app/model/sys/SysMenu.php
+++ b/niucloud/app/model/sys/SysMenu.php
@@ -58,7 +58,9 @@ class SysMenu extends BaseModel
*/
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)
{
- return MenuDict::getStatus()[$data['status'] ?? ''] ?? '';
+ if(empty($data['status']))
+ return '';
+ return MenuDict::getStatus()[$data['status']] ?? '';
}
}
diff --git a/niucloud/app/model/sys/SysNoticeLog.php b/niucloud/app/model/sys/SysNoticeLog.php
index 87050ba0a..4354d4fba 100644
--- a/niucloud/app/model/sys/SysNoticeLog.php
+++ b/niucloud/app/model/sys/SysNoticeLog.php
@@ -11,7 +11,9 @@
namespace app\model\sys;
+use app\dict\notice\NoticeDict;
use app\dict\notice\NoticeTypeDict;
+use app\dict\sys\SmsDict;
use core\base\BaseModel;
use think\db\Query;
@@ -52,7 +54,9 @@ class SysNoticeLog extends BaseModel
*/
public function getContentAttr($value,$data)
{
- $temp = json_decode($value);
+ if($value){
+ $temp = json_decode($value, true);
+ }
if(!$temp){
$temp = $value;
}
@@ -66,8 +70,12 @@ class SysNoticeLog extends BaseModel
*/
public function getNameAttr($value,$data)
{
- $temp = \app\dict\notice\NoticeDict::getNotice()[$data['key'] ?? ''] ?? '';
- return $temp['name'] ?? '';
+ $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)
{
- $temp = NoticeTypeDict::getType()[$data['notice_type'] ?? ''] ?? '';
- return $temp['name'] ?? '';
+ $name = '';
+ if (!empty($data['notice_type'])) {
+ $temp = NoticeTypeDict::getType()[$data['notice_type']] ?? [];
+ $name = $temp['name'] ?? '';
+ }
+ return $name;
}
/**
* 消息类型
diff --git a/niucloud/app/model/sys/SysNoticeSmsLog.php b/niucloud/app/model/sys/SysNoticeSmsLog.php
index 3ca06646a..110191131 100644
--- a/niucloud/app/model/sys/SysNoticeSmsLog.php
+++ b/niucloud/app/model/sys/SysNoticeSmsLog.php
@@ -11,12 +11,13 @@
namespace app\model\sys;
+use app\dict\notice\NoticeDict;
use app\dict\sys\SmsDict;
use core\base\BaseModel;
/**
* 系统短信消息发送记录
- * Class SysMessageLog
+ * Class SysNoticeSmsLog
* @package app\model\sys
*/
class SysNoticeSmsLog extends BaseModel
@@ -35,7 +36,7 @@ class SysNoticeSmsLog extends BaseModel
protected $name = 'sys_notice_sms_log';
protected $type = [
- 'send_time' => 'timestamp',
+ 'send_time' => 'timestamp',
];
// 设置json类型字段
@@ -49,24 +50,31 @@ class SysNoticeSmsLog extends BaseModel
* @param $data
* @return string
*/
- public function getResultAttr($value,$data)
+ public function getResultAttr($value, $data)
{
- $temp = json_decode($value);
- if(!$temp){
+ if ($value) {
+ $temp = json_decode($value, true);
+ }
+ if (empty($temp)) {
$temp = $value;
}
- return $temp;
+ return $temp ?? '';
}
+
/**
* 名称
* @param $value
* @param $data
* @return string
*/
- public function getNameAttr($value,$data)
+ public function getNameAttr($value, $data)
{
- $temp = \app\dict\notice\NoticeDict::getNotice()[$data['key'] ?? ''];
- return $temp['name'] ?? '';
+ $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
* @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
* @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'] ?? '';
}
+
+ /**
+ * 消息标识
+ * @param $value
+ * @return mixed
+ */
+ public function searchKeyAttr($query, $value)
+ {
+ if ($value) {
+ $query->where('key', $value);
+ }
+ }
+
/**
* 短信方式
* @param $value
diff --git a/niucloud/app/model/sys/SysRole.php b/niucloud/app/model/sys/SysRole.php
index 9d6bdbd7a..194cd660f 100644
--- a/niucloud/app/model/sys/SysRole.php
+++ b/niucloud/app/model/sys/SysRole.php
@@ -45,7 +45,8 @@ class SysRole extends BaseModel
* @return string
*/
public function getStatusNameAttr($value, $data){
- return RoleStatusDict::getStatus()[$data['status'] ?? ''] ?? '';
+ if(empty($data['status'])) return '';
+ return RoleStatusDict::getStatus()[$data['status']] ?? '';
}
diff --git a/niucloud/app/model/sys/SysCronTask.php b/niucloud/app/model/sys/SysSchedule.php
similarity index 71%
rename from niucloud/app/model/sys/SysCronTask.php
rename to niucloud/app/model/sys/SysSchedule.php
index 61baf4d3c..e97eb7bd5 100644
--- a/niucloud/app/model/sys/SysCronTask.php
+++ b/niucloud/app/model/sys/SysSchedule.php
@@ -11,16 +11,14 @@
namespace app\model\sys;
-use app\dict\sys\CronDict;
+use app\dict\schedule\ScheduleDict;
use core\base\BaseModel;
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
*/
- protected $name = 'sys_cron_task';
+ protected $name = 'sys_schedule';
protected $type = [
'last_time' => 'timestamp',
@@ -42,50 +40,47 @@ class SysCronTask extends BaseModel
];
// 设置json类型字段
- protected $json = ['data'];
+ protected $json = ['time'];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
+
+
/**
- * 任务模式
+ * 启用状态
* @param $value
* @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
*/
- public function searchTypeAttr(Query $query, $value, $data)
+ public function searchKeyAttr(Query $query, $value, $data)
{
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
diff --git a/niucloud/app/model/sys/SysUser.php b/niucloud/app/model/sys/SysUser.php
index 56236aad8..8aaabd3fb 100644
--- a/niucloud/app/model/sys/SysUser.php
+++ b/niucloud/app/model/sys/SysUser.php
@@ -72,7 +72,8 @@ class SysUser extends BaseModel
*/
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)
diff --git a/niucloud/app/service/admin/aliapp/AliappConfigService.php b/niucloud/app/service/admin/aliapp/AliappConfigService.php
index 34c95d5cd..5014da58f 100644
--- a/niucloud/app/service/admin/aliapp/AliappConfigService.php
+++ b/niucloud/app/service/admin/aliapp/AliappConfigService.php
@@ -27,9 +27,7 @@ class AliappConfigService extends BaseAdminService
*/
public function getAliappConfig()
{
- $config_info = (new CoreAliappConfigService())->getAliappConfig($this->site_id);
- return $config_info;
-
+ return (new CoreAliappConfigService())->getAliappConfig($this->site_id);
}
/**
diff --git a/niucloud/app/service/admin/article/ArticleCategoryService.php b/niucloud/app/service/admin/article/ArticleCategoryService.php
index f99b5e648..ffe610e87 100644
--- a/niucloud/app/service/admin/article/ArticleCategoryService.php
+++ b/niucloud/app/service/admin/article/ArticleCategoryService.php
@@ -38,8 +38,7 @@ class ArticleCategoryService extends BaseAdminService
$field = 'category_id, site_id, name, sort, is_show, create_time, update_time';
$order = 'create_time desc';
$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 $list;
+ return $this->pageQuery($search_model);
}
/**
@@ -50,8 +49,7 @@ class ArticleCategoryService extends BaseAdminService
$field = 'category_id, site_id, name, sort';
$order = 'sort desc';
- $list = $this->model->where([['site_id', '=', $this->site_id], ['is_show', '=', 1]])->field($field)->order($order)->select()->toArray();
- return $list;
+ return $this->model->where([['site_id', '=', $this->site_id], ['is_show', '=', 1]])->field($field)->order($order)->select()->toArray();
}
/**
@@ -62,8 +60,7 @@ class ArticleCategoryService extends BaseAdminService
{
$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 $info;
+ return $this->model->field($field)->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->append(["article_num"])->findOrEmpty()->toArray();
}
/**
@@ -96,8 +93,7 @@ class ArticleCategoryService extends BaseAdminService
*/
public function del(int $id)
{
- $res = $this->model->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->delete();
- return $res;
+ return $this->model->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->delete();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/article/ArticleService.php b/niucloud/app/service/admin/article/ArticleService.php
index e7babdc85..ab2c4c504 100644
--- a/niucloud/app/service/admin/article/ArticleService.php
+++ b/niucloud/app/service/admin/article/ArticleService.php
@@ -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';
$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']);
- $list = $this->pageQuery($search_model);
- return $list;
+ return $this->pageQuery($search_model);
}
/**
@@ -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';
- $info = $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->findOrEmpty()->toArray();
- return $info;
+ return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->findOrEmpty()->toArray();
}
/**
@@ -86,8 +84,7 @@ class ArticleService extends BaseAdminService
*/
public function del(int $id)
{
- $res = $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->delete();
- return $res;
+ return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->delete();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/auth/AuthService.php b/niucloud/app/service/admin/auth/AuthService.php
index ab25ad248..5e397602e 100644
--- a/niucloud/app/service/admin/auth/AuthService.php
+++ b/niucloud/app/service/admin/auth/AuthService.php
@@ -19,6 +19,7 @@ use app\service\admin\sys\MenuService;
use app\service\admin\sys\RoleService;
use app\service\admin\user\UserRoleService;
use app\service\admin\user\UserService;
+use app\service\core\site\CoreSiteService;
use core\base\BaseAdminService;
use core\exception\AuthException;
use Exception;
@@ -35,21 +36,15 @@ class AuthService extends BaseAdminService
* @param $site_id
*/
public function checkSiteAuth(Request $request){
- $site_id = $request->adminSiteId();
- //没有当前站点的信息
- if(!$this->getAuthRole($site_id))
- {
- throw new AuthException('NO_SITE_PERMISSION');
- }
-
- //查询站点信息并返回
- $site_service = new SiteService();
- $site_info = $site_service->getSiteCache($site_id);
+ $site_code = $request->adminSiteId();
+ //todo 将站点编号转化为站点id
+ $site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
//站点不存在
- if(empty($site_info))
- {
- throw new AuthException('SITE_NOT_EXIST');
- }
+ if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
+ $site_id = $site_info['site_id'];
+ //没有当前站点的信息
+ if(!$this->getAuthRole($site_id)) throw new AuthException('NO_SITE_PERMISSION');
+
$request->siteId($site_id);
$request->appType($site_info['app_type']);
return true;
diff --git a/niucloud/app/service/admin/auth/AuthSiteService.php b/niucloud/app/service/admin/auth/AuthSiteService.php
index 3063ff1a8..09ef67db8 100644
--- a/niucloud/app/service/admin/auth/AuthSiteService.php
+++ b/niucloud/app/service/admin/auth/AuthSiteService.php
@@ -12,7 +12,11 @@
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\sys\SysMenu;
use app\service\admin\site\SiteService;
use core\base\BaseAdminService;
use think\facade\Cache;
@@ -50,18 +54,11 @@ class AuthSiteService extends BaseAdminService
$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;
+ return $this->model->where([['site_id', 'in', $site_ids]])->field('app_type,site_name,logo')->column('site_id, site_name, logo, app_type');
},
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 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();
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/auth/ConfigService.php b/niucloud/app/service/admin/auth/ConfigService.php
index df339059c..1d21743f3 100644
--- a/niucloud/app/service/admin/auth/ConfigService.php
+++ b/niucloud/app/service/admin/auth/ConfigService.php
@@ -37,13 +37,12 @@ class ConfigService extends BaseAdminService
public function getConfig()
{
$info = (new CoreConfigService())->getConfig($this->request->defaultSiteId(), ConfigKeyDict::ADMIN_LOGIN)['value'] ?? [];
- $config = [
+ return [
'is_captcha' => $info['is_captcha'] ?? 0,//是否启用验证码
'is_site_captcha' => $info['is_site_captcha'] ?? 0,//是否启用站点验证码
'bg' => $info['bg'] ?? '',//平台登录端 背景
'site_bg' => $info['site_bg'] ?? '',//站点登录端 背景
];
- return $config;
}
/**
diff --git a/niucloud/app/service/admin/auth/LoginService.php b/niucloud/app/service/admin/auth/LoginService.php
index ffd924ab6..eab3f884d 100644
--- a/niucloud/app/service/admin/auth/LoginService.php
+++ b/niucloud/app/service/admin/auth/LoginService.php
@@ -70,7 +70,6 @@ class LoginService extends BaseAdminService
throw new AuthException('USER_LOCK');
}
-
if($app_type == AppTypeDict::ADMIN){
$default_site_id = $this->request->defaultSiteId();
$userrole = (new UserRoleService())->getUserRole($default_site_id, $userinfo->uid);
diff --git a/niucloud/app/service/admin/cron/CronService.php b/niucloud/app/service/admin/cron/CronService.php
deleted file mode 100644
index e4fe5ee95..000000000
--- a/niucloud/app/service/admin/cron/CronService.php
+++ /dev/null
@@ -1,55 +0,0 @@
-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);
-
- }
-
-
-
-}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/diy/DiyRouteService.php b/niucloud/app/service/admin/diy/DiyRouteService.php
index 84adeea48..907004176 100644
--- a/niucloud/app/service/admin/diy/DiyRouteService.php
+++ b/niucloud/app/service/admin/diy/DiyRouteService.php
@@ -143,6 +143,7 @@ class DiyRouteService extends BaseAdminService
public function modifyShare($data)
{
$field = 'id';
+ $data[ 'site_id' ] = $this->site_id;
$info = $this->model->field($field)->where([ [ 'name', '=', $data[ 'name' ] ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
if (!empty($info)) {
$this->model->where([ [ 'id', '=', $info[ 'id' ] ], [ 'site_id', '=', $this->site_id ] ])->update([ 'share' => $data[ 'share' ] ]);
diff --git a/niucloud/app/service/admin/diy/DiyService.php b/niucloud/app/service/admin/diy/DiyService.php
index 9b3d700bf..d130be811 100644
--- a/niucloud/app/service/admin/diy/DiyService.php
+++ b/niucloud/app/service/admin/diy/DiyService.php
@@ -16,6 +16,7 @@ use app\dict\diy\LinkDict;
use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict;
use app\model\diy\Diy;
+use app\model\site\Site;
use app\service\admin\sys\SystemService;
use core\base\BaseAdminService;
use Exception;
@@ -36,14 +37,14 @@ class DiyService extends BaseAdminService
}
/**
- * 获取自定义页面列表
+ * 获取自定义页面分页列表
* @param array $where
* @return array
*/
public function getPage(array $where = [])
{
$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";
$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);
@@ -51,17 +52,19 @@ class DiyService extends BaseAdminService
}
/**
+ * 获取自定义页面列表
* @param array $where
+ * @param string $field
* @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";
- $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;
-
}
/**
@@ -71,19 +74,29 @@ class DiyService extends BaseAdminService
*/
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();
return $info;
}
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();
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
@@ -147,7 +160,7 @@ class DiyService extends BaseAdminService
}
Db::startTrans();
$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();
return true;
} catch (\Exception $e) {
@@ -163,7 +176,7 @@ class DiyService extends BaseAdminService
*/
public function getInit(array $params = [])
{
- $page_template = TemplateDict::getTemplate();
+ $template = $this->getTemplate();
$time = time();
$data = [];
@@ -175,61 +188,80 @@ class DiyService extends BaseAdminService
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[ 'page' ] = $page[ 'page' ];
}
} 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 = '';
- $name = $params[ 'name' ];
- $page_route = '';
+ $template_name = $params[ 'template' ] ?? ''; // 页面模板名称
+ $page_route = ''; // 页面路径
+ $mode = 'diy'; // 页面模式,diy:自定义,fixed:固定
$value = '';
- if (isset($page_template[ $params[ 'template' ] ])) {
- $page = $page_template[ $params[ 'template' ] ];
- $name = $params[ 'template' ] == 'DIY_PAGE' ? 'DIY_PAGE_RANDOM_' . $time : $params[ 'template' ];
- $type = $params[ 'template' ];
+ $is_default = 0;
+
+ // 查询默认第一个页面模板数据
+ if (isset($template[ $params[ 'name' ] ])) {
+ $page = $template[ $params[ 'name' ] ];
+ $name = $params[ 'name' ];
+ $type = $params[ 'name' ];
+ $title = $page[ 'title' ];
$type_name = $page[ 'title' ];
$page_route = $page[ 'page' ];
- // 查询指定页面数据
- $page_data = $this->getPageData($params[ 'template' ], $params[ 'template_name' ]);
+ $page_data = $this->getFirstPageData($type);
if (!empty($page_data)) {
$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 = [
'name' => $name,
- 'title' => $params[ 'title' ] ? $params[ 'title' ] : '页面' . $time,
+ 'title' => $title,
'type' => $type,
'type_name' => $type_name,
+ 'template' => $template_name,
'page' => $page_route,
+ 'mode' => $mode,
'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[ 'site_id' ] = $this->site_id;
+ $site = Site::find($this->site_id);
+ $data[ 'site_id' ] = $site[ 'site_code' ];
return $data;
}
@@ -279,7 +311,7 @@ class DiyService extends BaseAdminService
// 查询自定义页面
if ($k == 'DIY_PAGE') {
$diy_service = new DiyService();
- $list = $diy_service->getList([ [ 'type', '=', 'DIY_PAGE' ] ]);
+ $list = $diy_service->getList([ 'type' => 'DIY_PAGE' ]);
foreach ($list as $ck => $cv) {
$link[ $k ][ 'child_list' ][] = [
'name' => $cv[ 'name' ],
@@ -312,28 +344,32 @@ class DiyService extends BaseAdminService
/**
* 获取页面模板
- * @param string $type
+ * @param array $params
* @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) {
// 查询页面数据
- $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;
}
/**
* 获取页面数据
- * @param $template
+ * @param $type
* @param $name
* @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 ])) {
return $pages[ $name ];
}
@@ -342,18 +378,207 @@ class DiyService extends BaseAdminService
/**
* 获取默认页面数据
- * @param $template
+ * @param $type
* @return array|mixed
*/
- public function getFirstPageData($template)
+ public function getFirstPageData($type)
{
- $pages = PagesDict::getPages($template);
+ $pages = PagesDict::getPages([ 'type' => $type ]);
if (!empty($pages)) {
+ $template = array_key_first($pages);
$page = array_shift($pages);
$page[ 'template' ] = $template;
+ $page[ 'type' ] = $type;
return $page;
}
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;
+ }
+
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/generator/core/ModelGenerator.php b/niucloud/app/service/admin/generator/core/ModelGenerator.php
index 330a7e46d..f06f036dc 100644
--- a/niucloud/app/service/admin/generator/core/ModelGenerator.php
+++ b/niucloud/app/service/admin/generator/core/ModelGenerator.php
@@ -115,7 +115,7 @@ class ModelGenerator extends BaseGenerator
if (!$column['is_search']) {
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 .= '{'.PHP_EOL;
$function_str .= ' if ($value) {'.PHP_EOL;
diff --git a/niucloud/app/service/admin/generator/core/ServiceGenerator.php b/niucloud/app/service/admin/generator/core/ServiceGenerator.php
index fd07d4e50..e93bd1b88 100644
--- a/niucloud/app/service/admin/generator/core/ServiceGenerator.php
+++ b/niucloud/app/service/admin/generator/core/ServiceGenerator.php
@@ -70,7 +70,7 @@ class ServiceGenerator extends BaseGenerator
{
$field = [];
foreach ($this->tableColumn as $column) {
- if ($column['is_lists'] || $column['is_insert'] || $column['is_update']) {
+ if ($column['is_query']) {
$field[] = $column['column_name'];
}
}
diff --git a/niucloud/app/service/admin/generator/core/WebIndexGenerator.php b/niucloud/app/service/admin/generator/core/WebIndexGenerator.php
index 577953972..040b996e5 100644
--- a/niucloud/app/service/admin/generator/core/WebIndexGenerator.php
+++ b/niucloud/app/service/admin/generator/core/WebIndexGenerator.php
@@ -101,7 +101,7 @@ class WebIndexGenerator extends BaseGenerator
$file_name = str_replace('_', '-', Str::lower($this->getTableName())).'-edit';
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" />';
diff --git a/niucloud/app/service/admin/generator/vm/admin_api_route.vm b/niucloud/app/service/admin/generator/vm/admin_api_route.vm
index af5842563..7d38b5d5f 100644
--- a/niucloud/app/service/admin/generator/vm/admin_api_route.vm
+++ b/niucloud/app/service/admin/generator/vm/admin_api_route.vm
@@ -28,7 +28,7 @@ Route::group('{MODULE_NAME}', function () {
//添加{NOTES}
Route::post('{ROUTE_NAME}', '{MODULE_NAME}.{UCASE_CLASS_NAME}/add');
//编辑{NOTES}
- Route::put('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/update');
+ Route::put('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/edit');
//删除{NOTES}
Route::delete('{ROUTE_NAME}/:id', '{MODULE_NAME}.{UCASE_CLASS_NAME}/del');
diff --git a/niucloud/app/service/admin/member/MemberAccountService.php b/niucloud/app/service/admin/member/MemberAccountService.php
index 45633e110..b695016fb 100644
--- a/niucloud/app/service/admin/member/MemberAccountService.php
+++ b/niucloud/app/service/admin/member/MemberAccountService.php
@@ -61,7 +61,7 @@ class MemberAccountService extends BaseAdminService
public function getInfo(int $id)
{
$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();
}
/**
diff --git a/niucloud/app/service/admin/notice/NoticeSmsLogService.php b/niucloud/app/service/admin/notice/NoticeSmsLogService.php
index 16aee5514..8f5da5fe9 100644
--- a/niucloud/app/service/admin/notice/NoticeSmsLogService.php
+++ b/niucloud/app/service/admin/notice/NoticeSmsLogService.php
@@ -17,7 +17,7 @@ use app\service\core\notice\CoreNoticeSmsLogService;
use core\base\BaseAdminService;
/**
- * 消息管理服务层
+ * 短信消息管理服务层
*/
class NoticeSmsLogService extends BaseAdminService
{
@@ -40,8 +40,8 @@ class NoticeSmsLogService extends BaseAdminService
* 获取消息内容
* @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);
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/schedule/ScheduleService.php b/niucloud/app/service/admin/schedule/ScheduleService.php
new file mode 100644
index 000000000..ca2dfdaa5
--- /dev/null
+++ b/niucloud/app/service/admin/schedule/ScheduleService.php
@@ -0,0 +1,93 @@
+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);
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/site/SiteAccountLogService.php b/niucloud/app/service/admin/site/SiteAccountLogService.php
new file mode 100644
index 000000000..7d2b81d26
--- /dev/null
+++ b/niucloud/app/service/admin/site/SiteAccountLogService.php
@@ -0,0 +1,79 @@
+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,
+ ];
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/site/SiteGroupService.php b/niucloud/app/service/admin/site/SiteGroupService.php
index 45912a021..caedec93f 100644
--- a/niucloud/app/service/admin/site/SiteGroupService.php
+++ b/niucloud/app/service/admin/site/SiteGroupService.php
@@ -128,9 +128,6 @@ class SiteGroupService extends BaseAdminService
},
[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 ?? [];
-// });
}
/**
diff --git a/niucloud/app/service/admin/site/SiteService.php b/niucloud/app/service/admin/site/SiteService.php
index 624589654..7bd908e0f 100644
--- a/niucloud/app/service/admin/site/SiteService.php
+++ b/niucloud/app/service/admin/site/SiteService.php
@@ -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,
- 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');
$list = $this->pageQuery($search_model);
return $list;
@@ -60,7 +60,7 @@ class SiteService extends BaseAdminService
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,
- 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();
}
@@ -88,6 +88,7 @@ class SiteService extends BaseAdminService
try {
$site = $this->model->create($data_site);
$site_id = $site->site_id;
+ //$this->model->where([['site_id', '=', $site_id]])->update(['site_code' => $this->createSiteCodeBySiteId($site_id)]);
//添加用户
$data_user = [
'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
@@ -149,24 +168,11 @@ class SiteService extends BaseAdminService
$where = [
[ '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();
- if (!$site->isEmpty()) {
- $site->append([ 'status_name' ]);
- }
+ $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();
return $site->toArray();
},
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
* @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);
if (empty($site_info))
diff --git a/niucloud/app/service/admin/stat/SiteStatService.php b/niucloud/app/service/admin/stat/SiteStatService.php
index 736fc13fe..f062673db 100644
--- a/niucloud/app/service/admin/stat/SiteStatService.php
+++ b/niucloud/app/service/admin/stat/SiteStatService.php
@@ -99,6 +99,10 @@ class SiteStatService extends BaseAdminService
$woman_count = (new MemberService())->getCount([ ['sex', '=', '2'] ]);
$data['member_stat']['value'] = [$man_count, $woman_count, (int)($member_count - $man_count - $woman_count)];
$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;
}
diff --git a/niucloud/app/service/admin/sys/AreaService.php b/niucloud/app/service/admin/sys/AreaService.php
index f05aca81f..16601a4bc 100644
--- a/niucloud/app/service/admin/sys/AreaService.php
+++ b/niucloud/app/service/admin/sys/AreaService.php
@@ -41,16 +41,10 @@ class AreaService extends BaseAdminService
return cache_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;
+ return $this->model->where([['pid', '=', $pid]])->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
},
[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,
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;
+ return list_to_tree($list, 'id', 'pid');
},
[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'];
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/sys/AttachmentService.php b/niucloud/app/service/admin/sys/AttachmentService.php
index 40d19c0f0..ba9f48cb0 100644
--- a/niucloud/app/service/admin/sys/AttachmentService.php
+++ b/niucloud/app/service/admin/sys/AttachmentService.php
@@ -174,8 +174,7 @@ class AttachmentService extends BaseAdminService
['id', '=', $id]
);
$category_model = new SysAttachmentCategory();
- $res = $category_model->where($where)->update($data);
- return $res;
+ return $category_model->where($where)->update($data);
}
/**
@@ -191,8 +190,7 @@ class AttachmentService extends BaseAdminService
throw new AdminException('ATTACHMENT_GROUP_HAS_IMAGE');
//下级存在图片不能删除
- $res = $category->delete();
- return $res;
+ return $category->delete();
}
diff --git a/niucloud/app/service/admin/sys/ConfigService.php b/niucloud/app/service/admin/sys/ConfigService.php
index 2b30d03d4..0859d18eb 100644
--- a/niucloud/app/service/admin/sys/ConfigService.php
+++ b/niucloud/app/service/admin/sys/ConfigService.php
@@ -15,6 +15,7 @@ use app\service\admin\site\SiteService;
use app\service\core\sys\CoreConfigService;
use app\service\core\sys\CoreSysConfigService;
use core\base\BaseAdminService;
+use core\exception\AdminException;
/**
* 配置服务层
@@ -58,8 +59,7 @@ class ConfigService extends BaseAdminService
'copyright_link' => $value['copyright_link'],
'copyright_desc' => $value['copyright_desc']
];
- $res = $this->core_config_service->setConfig(0,'COPYRIGHT', $data);
- return $res;
+ return $this->core_config_service->setConfig(0,'COPYRIGHT', $data);
}
/**
@@ -120,8 +120,7 @@ class ConfigService extends BaseAdminService
"enterprise_wechat" => $value['enterprise_wechat'],
"tel" => $value['tel']
];
- $res = $this->core_config_service->setConfig(0,'SERVICE_INFO', $data);
- return $res;
+ return $this->core_config_service->setConfig(0,'SERVICE_INFO', $data);
}
/**
@@ -134,8 +133,7 @@ class ConfigService extends BaseAdminService
$data = [
'key' => $value['key'],
];
- $res = $this->core_config_service->setConfig($this->site_id,'MAPKEY', $data);
- return $res;
+ return $this->core_config_service->setConfig($this->site_id,'MAPKEY', $data);
}
/**
@@ -148,9 +146,100 @@ class ConfigService extends BaseAdminService
{
$info = [];
$info['value'] = [
- 'key' => '',
+ 'key' => 'IZQBZ-3UHEU-WTCVD-2464U-I5N4V-ZFFU3',
];
}
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;
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/sys/MenuService.php b/niucloud/app/service/admin/sys/MenuService.php
index 05f866a65..48668f316 100644
--- a/niucloud/app/service/admin/sys/MenuService.php
+++ b/niucloud/app/service/admin/sys/MenuService.php
@@ -142,12 +142,63 @@ class MenuService extends BaseAdminService
{
$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;
}
+ /**
+ * 获取所有接口菜单
+ */
+ 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组获取接口数组
* @param array $menu_keys
@@ -173,19 +224,6 @@ class MenuService extends BaseAdminService
},
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
);
-// 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
);
-// 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
);
}
- /**
- * 获取所有接口菜单
- */
- 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
);
-// 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);
+ }
+ }
+
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/sys/RoleService.php b/niucloud/app/service/admin/sys/RoleService.php
index 974b33d8b..9ba8ab04a 100644
--- a/niucloud/app/service/admin/sys/RoleService.php
+++ b/niucloud/app/service/admin/sys/RoleService.php
@@ -55,7 +55,7 @@ class RoleService extends BaseAdminService
* @return mixed
*/
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]
);
-// 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
*/
public function getMenuIdsByRoleIds(int $site_id, array $role_ids){
- $menu_keys = (new SiteService())->getMenuIdsBySiteId($site_id, true, 1);
- $allow_role_ids = array_intersect($role_ids, $menu_keys);
+ $menu_keys = (new SiteService())->getMenuIdsBySiteId($site_id, 1);
+ $allow_role_ids = array_merge($role_ids, $menu_keys);
sort($allow_role_ids);
$cache_name = 'user_role_'.$site_id.'_'.md5(implode('_', $allow_role_ids));
return cache_remember(
$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();
if(!empty($rules)){
$temp = [];
foreach($rules as $k => $v){
$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 [];
},
diff --git a/niucloud/app/service/admin/sys/SystemService.php b/niucloud/app/service/admin/sys/SystemService.php
index 8edce31d6..306dfbf38 100644
--- a/niucloud/app/service/admin/sys/SystemService.php
+++ b/niucloud/app/service/admin/sys/SystemService.php
@@ -12,6 +12,7 @@
namespace app\service\admin\sys;
use app\job\sys\CheckJob;
+use app\model\site\Site;
use core\base\BaseAdminService;
use think\facade\Db;
@@ -47,11 +48,16 @@ class SystemService extends BaseAdminService
*/
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 = [
'wap_domain' => env("system.wap_domain"),
- 'wap_url' => ( !empty(env("system.wap_domain")) ? env("system.wap_domain") : request()->domain() ) . "/wap" . $site_tag,
- 'web_url' => ( !empty(env("system.web_domain")) ? env("system.web_domain") : request()->domain() ) . "/web" . $site_tag,
+ 'wap_url' => $wap_domain . "/wap/" . $site_tag,
+ 'web_url' => $web_domain . "/web/" . $site_tag,
];
return $data;
}
diff --git a/niucloud/app/service/admin/user/UserRoleService.php b/niucloud/app/service/admin/user/UserRoleService.php
index 3a25837bf..8a908f657 100644
--- a/niucloud/app/service/admin/user/UserRoleService.php
+++ b/niucloud/app/service/admin/user/UserRoleService.php
@@ -102,14 +102,6 @@ class UserRoleService extends BaseAdminService
},
[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]
);
-// 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)){
-//
-// }
-// }
-// }
+
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/user/UserService.php b/niucloud/app/service/admin/user/UserService.php
index c2cea50b4..600eb098e 100644
--- a/niucloud/app/service/admin/user/UserService.php
+++ b/niucloud/app/service/admin/user/UserService.php
@@ -54,11 +54,8 @@ class UserService extends BaseAdminService
['uid', '=', $uid],
);
$field = 'uid, username, head_img, real_name, last_ip, last_time, create_time, login_count, status, delete_time, update_time';
- $user = $this->model->where($where)->field($field)->findOrEmpty();
- if($user->isEmpty()){
- return [];
- }
- return $user->append(['status_name'])->toArray();
+ $user = $this->model->where($where)->field($field)->append(['status_name'])->findOrEmpty();
+ return $user->toArray();
}
/**
@@ -248,7 +245,7 @@ class UserService extends BaseAdminService
* @return SysUser|array|mixed|\think\Model
*/
public function getUserInfoByUsername(string $username){
- return $this->model->withSearch(['username'], ['username' => $username])->findOrEmpty();
+ return $this->model->where([['username', '=',$username]])->findOrEmpty();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/api/article/ArticleCategoryService.php b/niucloud/app/service/api/article/ArticleCategoryService.php
index ee2531c22..827f30ed0 100644
--- a/niucloud/app/service/api/article/ArticleCategoryService.php
+++ b/niucloud/app/service/api/article/ArticleCategoryService.php
@@ -36,8 +36,7 @@ class ArticleCategoryService extends BaseApiService
$field = 'category_id, site_id, name, sort, is_show, create_time, update_time';
$order = 'create_time desc';
$search_model = $this->model->where([['site_id', '=', $this->site_id]])->withSearch(['name'], $where)->field($field)->order($order);
- $list = $this->pageQuery($search_model);
- return $list;
+ return $this->pageQuery($search_model);
}
/**
@@ -47,8 +46,6 @@ class ArticleCategoryService extends BaseApiService
public function getInfo(int $id)
{
$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]])->findOrEmpty()->toArray();
- return $info;
+ return $this->model->field($field)->where([['category_id', '=', $id], ['site_id', '=', $this->site_id]])->findOrEmpty()->toArray();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/api/article/ArticleService.php b/niucloud/app/service/api/article/ArticleService.php
index c99438cba..0c7277caf 100644
--- a/niucloud/app/service/api/article/ArticleService.php
+++ b/niucloud/app/service/api/article/ArticleService.php
@@ -39,8 +39,7 @@ class ArticleService extends BaseApiService
$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';
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id'], $where)->with('articleCategory')->field($field)->order($order);
- $list = $this->pageQuery($search_model);
- return $list;
+ return $this->pageQuery($search_model);
}
/**
@@ -55,8 +54,7 @@ class ArticleService extends BaseApiService
$where[] = [ 'site_id', '=', $this->site_id ];
$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';
- $list = $this->model->where([ [ 'site_id', '=', $this->site_id ] , ['is_show', '=', 1]])->withSearch([ 'title', 'category_id', 'ids' ], $where)->limit($limit)->with('articleCategory')->field($field)->order($order)->select()->toArray();
- return $list;
+ return $this->model->where([ [ 'site_id', '=', $this->site_id ] , ['is_show', '=', 1]])->withSearch([ 'title', 'category_id', 'ids' ], $where)->limit($limit)->with('articleCategory')->field($field)->order($order)->select()->toArray();
}
/**
@@ -67,8 +65,7 @@ class ArticleService extends BaseApiService
{
$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->with('articleCategory')->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
- return $info;
+ return $this->model->with('articleCategory')->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/api/diy/DiyService.php b/niucloud/app/service/api/diy/DiyService.php
index 129e8da53..0d7ac986f 100644
--- a/niucloud/app/service/api/diy/DiyService.php
+++ b/niucloud/app/service/api/diy/DiyService.php
@@ -46,7 +46,7 @@ class DiyService extends BaseApiService
$condition[] = [ 'is_default', '=', 1 ];
}
- $field = 'id,site_id,title,name,type,value,is_default,share,visit_count';
+ $field = 'id,site_id,title,name,type,template, mode,value,is_default,share,visit_count';
$info = $this->model->field($field)->where($condition)->findOrEmpty()->toArray();
if (empty($info)) {
@@ -57,8 +57,10 @@ class DiyService extends BaseApiService
$info = [
'site_id' => $this->site_id,
'title' => $page_data[ 'title' ],
- 'name' => $page_data[ 'template' ],
- 'type' => $page_data[ 'template' ],
+ 'name' => $page_data[ 'type' ],
+ 'type' => $page_data[ 'type' ],
+ 'template' => $page_data[ 'template' ],
+ 'mode' => $page_data[ 'mode' ],
'value' => json_encode($page_data[ 'data' ], JSON_UNESCAPED_UNICODE),
'is_default' => 1,
'share' => '',
@@ -72,15 +74,17 @@ class DiyService extends BaseApiService
/**
* 获取默认页面数据
- * @param $template
+ * @param $type
* @return array|mixed
*/
- public function getFirstPageData($template)
+ public function getFirstPageData($type)
{
- $pages = PagesDict::getPages($template);
+ $pages = PagesDict::getPages([ 'type' => $type ]);
if (!empty($pages)) {
+ $template = array_key_first($pages);
$page = array_shift($pages);
$page[ 'template' ] = $template;
+ $page[ 'type' ] = $type;
return $page;
}
return [];
diff --git a/niucloud/app/service/api/login/AuthService.php b/niucloud/app/service/api/login/AuthService.php
index dfcfb4e78..1e547d531 100644
--- a/niucloud/app/service/api/login/AuthService.php
+++ b/niucloud/app/service/api/login/AuthService.php
@@ -50,13 +50,14 @@ class AuthService extends BaseApiService
* @return true
*/
public function checkSite(Request $request){
- $site_id = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id
- $site_info = (new CoreSiteService())->getSiteCache($site_id);
+ $site_code = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id
+ $site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
if($site_info['status'] == SiteDict::CLOSE){
$rule = trim(strtolower($request->rule()->getRule()));
if($rule != 'site') throw new AuthException('SITE_CLOSE_NOT_ALLOW');
}
+ $site_id = $site_info['site_id'];
$request->siteId($site_id);
return true;
}
diff --git a/niucloud/app/service/api/member/MemberService.php b/niucloud/app/service/api/member/MemberService.php
index 1bc904dda..c28dd2593 100644
--- a/niucloud/app/service/api/member/MemberService.php
+++ b/niucloud/app/service/api/member/MemberService.php
@@ -67,7 +67,7 @@ class MemberService extends BaseApiService
public function getInfo()
{
$field = 'member_id, site_id, username, member_no, mobile, register_channel, nickname, headimg, member_level, member_label, login_ip, login_type, login_time, create_time, last_visit_time, last_consum_time, sex, status, birthday, point, balance, growth, is_member, member_time, is_del, province_id, city_id, district_id, address, location, money, money_get, wx_openid, weapp_openid, commission, commission_get, commission_cash_outing';
- return $this->model->where([['member_id', '=', $this->member_id]])->field($field)->findOrEmpty()->append(['sex_name'])->toArray();
+ return $this->model->where([['member_id', '=', $this->member_id]])->field($field)->append(['sex_name'])->findOrEmpty()->toArray();
}
/**
@@ -76,7 +76,7 @@ class MemberService extends BaseApiService
public function center()
{
$field = 'member_id, site_id, username, member_no, mobile, register_channel, nickname, headimg, member_level, member_label, login_ip, login_type, login_time, create_time, last_visit_time, last_consum_time, sex, status, birthday, point, balance, growth, is_member, member_time, is_del, province_id, city_id, district_id, address, location, money, money_get, commission, commission_get, commission_cash_outing';
- return $this->model->where([['member_id', '=', $this->member_id]])->field($field)->findOrEmpty()->append(['sex_name'])->toArray();
+ return $this->model->where([['member_id', '=', $this->member_id]])->field($field)->append(['sex_name'])->findOrEmpty()->toArray();
}
/**
diff --git a/niucloud/app/service/core/addon/CoreAddonBaseService.php b/niucloud/app/service/core/addon/CoreAddonBaseService.php
index 67c84abec..0dad616b7 100644
--- a/niucloud/app/service/core/addon/CoreAddonBaseService.php
+++ b/niucloud/app/service/core/addon/CoreAddonBaseService.php
@@ -81,8 +81,7 @@ class CoreAddonBaseService extends BaseCoreService
{
if (file_exists($json_file_path)) {
$content_json = @file_get_contents($json_file_path);
- $content_array = json_decode($content_json, true);
- return $content_array;
+ return json_decode($content_json, true);
}else
return [];
}
diff --git a/niucloud/app/service/core/addon/CoreAddonInstallService.php b/niucloud/app/service/core/addon/CoreAddonInstallService.php
index 9bb3d4984..bfbc5730b 100644
--- a/niucloud/app/service/core/addon/CoreAddonInstallService.php
+++ b/niucloud/app/service/core/addon/CoreAddonInstallService.php
@@ -16,6 +16,7 @@ use app\job\sys\AddonInstall;
use app\service\admin\sys\MenuService;
use app\service\admin\sys\SystemService;
use app\service\core\menu\CoreMenuService;
+use app\service\core\schedule\CoreScheduleInstallService;
use core\exception\AddonException;
use core\exception\CommonException;
use core\util\Terminal;
@@ -72,6 +73,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
const SQL_INSTALLED = 'sql_installed';
const MENU_INSTALLED = 'menu_installed';
+ const SCHEDULE_INSTALLED = 'schedule_installed';
const WAIT_DEPEND = 'wait_depend';
@@ -269,6 +271,13 @@ class CoreAddonInstallService extends CoreAddonBaseService
'desc' => '安装插件菜单',
'state' => AddonDict::INSTALL_UNEXECUTED
],
+ 'installSchedule' => [//安装计划任务
+ 'addon' => $this->addon,
+ 'step' => 'installSchedule',
+ 'command' => "php think addon:install {$this->addon} --step installSchedule",
+ 'desc' => '安装插件计划任务',
+ 'state' => AddonDict::INSTALL_UNEXECUTED
+ ],
'installWap' => [
'addon' => $this->addon,
'step' => 'installWap',
@@ -552,7 +561,8 @@ class CoreAddonInstallService extends CoreAddonBaseService
if (!$this->uninstallDir()) throw new AddonException();
// 卸载菜单
$this->uninstallMenu();
-
+ // 卸载计划任务
+ $this->uninstallSchedule();
// 卸载wap
$this->uninstallWap();
@@ -660,6 +670,9 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 编译 diy-group 自定义组件代码文件
$this->compileDiyComponentsCode($this->root_path . "uni-app" . DIRECTORY_SEPARATOR);
+ // 编译 fixed-group 固定模板组件代码文件
+ $this->compileFixedComponentsCode($this->root_path . "uni-app" . DIRECTORY_SEPARATOR);
+
// 编译 pages.json 页面路由代码文件
$this->installPageCode($this->root_path . "uni-app" . DIRECTORY_SEPARATOR);
@@ -674,6 +687,9 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 编译 diy-group 自定义组件代码文件
$this->compileDiyComponentsCode($this->root_path . "uni-app" . DIRECTORY_SEPARATOR);
+ // 编译 fixed-group 固定模板组件代码文件
+ $this->compileFixedComponentsCode($this->root_path . "uni-app" . DIRECTORY_SEPARATOR);
+
// 编译 pages.json 页面路由代码文件
$this->uninstallPageCode($this->root_path . "uni-app" . DIRECTORY_SEPARATOR);
}
@@ -749,4 +765,26 @@ class CoreAddonInstallService extends CoreAddonBaseService
return true;
}
+
+ /**
+ * 安装计划任务
+ * @return true
+ */
+ public function installSchedule()
+ {
+ ( new CoreScheduleInstallService())->installAddonSchedule($this->addon);
+ $this->state = self::SCHEDULE_INSTALLED;
+ return true;
+ }
+
+ /**
+ * 卸载计划任务
+ * @return true
+ */
+ public function uninstallSchedule()
+ {
+ ( new CoreScheduleInstallService())->uninstallAddonSchedule($this->addon);
+ return true;
+ }
+
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/addon/CoreAddonService.php b/niucloud/app/service/core/addon/CoreAddonService.php
index e259280fe..1a1579231 100644
--- a/niucloud/app/service/core/addon/CoreAddonService.php
+++ b/niucloud/app/service/core/addon/CoreAddonService.php
@@ -83,8 +83,7 @@ class CoreAddonService extends CoreAddonBaseService
public function getPage(array $where){
$field = 'id, title, key, desc, version, status, icon, create_time, install_time';
$search_model = $this->model->where([])->withSearch(['title'],$where)->field($field)->order('id desc');
- $data = $this->pageQuery($search_model);
- return $data;
+ return $this->pageQuery($search_model);
}
/**
diff --git a/niucloud/app/service/core/addon/WapTrait.php b/niucloud/app/service/core/addon/WapTrait.php
index 31d825850..b6efe10eb 100644
--- a/niucloud/app/service/core/addon/WapTrait.php
+++ b/niucloud/app/service/core/addon/WapTrait.php
@@ -128,6 +128,66 @@ trait WapTrait
return $res;
}
+ /**
+ * 编译 fixed-group 固定模板组件代码文件
+ * @param $compile_path
+ * @param $addon_name
+ * @return string
+ */
+ public function compileFixedComponentsCode($compile_path)
+ {
+ $content = "\n";
+ $content .= " \n";
+
+ $root_path = $compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'components/fixed'); // 扩展组件根目录
+ $file_arr = getFileMap($root_path);
+
+ if (!empty($file_arr)) {
+ foreach ($file_arr as $ck => $cv) {
+ if (strpos($cv, 'index.vue') !== false) {
+
+ $path = str_replace($root_path . '/', '', $ck);
+ $path = str_replace('/index.vue', '', $path);
+ if ($path == 'group') {
+ continue;
+ }
+
+ // 获取自定义组件 key 关键词
+ $name_arr = explode('-', $path);
+ foreach ($name_arr as $k => $v) {
+ // 首字母大写
+ $name_arr[ $k ] = strtoupper(substr($v, 0, 1)) . substr($v, 1);
+ }
+ $name = implode('', $name_arr);
+ $file_name = 'fixed-' . $path;
+
+ $content .= " \n";
+ $content .= " <$file_name :data=\"data\">$file_name>\n";
+ $content .= " \n";
+ }
+ }
+ }
+
+ $content .= " \n";
+ $content .= "\n";
+
+ $content .= "\n";
+
+ $content .= "\n";
+
+ $res = file_put_contents($compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'components/fixed/group/index.vue'), $content);
+ return $res;
+ }
+
/**
* 编译 pages.json 页面路由代码文件
* @param $compile_path
diff --git a/niucloud/app/service/core/aliapp/CoreAliappConfigService.php b/niucloud/app/service/core/aliapp/CoreAliappConfigService.php
index cd1674cf2..ff4b5c6f4 100644
--- a/niucloud/app/service/core/aliapp/CoreAliappConfigService.php
+++ b/niucloud/app/service/core/aliapp/CoreAliappConfigService.php
@@ -31,7 +31,7 @@ class CoreAliappConfigService extends BaseCoreService
*/
public function getAliappConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::ALIAPP)['value'] ?? [];
- $config = [
+ return [
'name' => $info['name'] ?? '',
'app_id' => $info['app_id'] ?? '',
'private_key' => $info['private_key'] ?? '',
@@ -41,8 +41,6 @@ class CoreAliappConfigService extends BaseCoreService
'alipay_with_crt' => $info['alipay_with_crt'] ?? '',
'qrcode' => $info['qrcode'] ?? ''
];
-
- return $config;
}
/**
diff --git a/niucloud/app/service/core/member/CoreMemberAccountService.php b/niucloud/app/service/core/member/CoreMemberAccountService.php
index 8258beed2..78aec8e02 100644
--- a/niucloud/app/service/core/member/CoreMemberAccountService.php
+++ b/niucloud/app/service/core/member/CoreMemberAccountService.php
@@ -34,7 +34,7 @@ class CoreMemberAccountService extends BaseCoreService
[ 'member_id', '=', $member_id ],
[ 'site_id', '=', $site_id ]
])->field($account_type .','.$account_type."_get" .', username, mobile, nickname')->lock(true)->find();
- if(empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST');;
+ if(empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST');
$account_new_data = round((float) $member_info[ $account_type ] + (float) $account_data, 2);
if ($account_new_data < 0) {
diff --git a/niucloud/app/service/core/member/CoreMemberConfigService.php b/niucloud/app/service/core/member/CoreMemberConfigService.php
index 2624808ed..0d0be8215 100644
--- a/niucloud/app/service/core/member/CoreMemberConfigService.php
+++ b/niucloud/app/service/core/member/CoreMemberConfigService.php
@@ -32,14 +32,13 @@ class CoreMemberConfigService extends BaseCoreService
*/
public function getLoginConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, 'LOGIN')['value'] ?? [];
- $config = [
+ return [
'is_username' => $info['is_username'] ?? 1,//是否用户名密码登录
'is_mobile' => $info['is_mobile'] ?? 0,//是否手机验证码登录
'is_auth_register' => $info['is_auth_register'] ?? 1,//是否第三方自动注册
'is_bind_mobile' => $info['is_bind_mobile'] ?? 0,//是否强制绑定手机
'agreement_show' => $info['agreement_show'] ?? 0 // 政策协议是否展示
];
- return $config;
}
/**
@@ -66,11 +65,10 @@ class CoreMemberConfigService extends BaseCoreService
*/
public function getMemberConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, 'MEMBER')['value'] ?? [];
- $config = [
+ return [
'prefix' => $info['prefix'] ?? '',// 会员编码前缀
'length' => $info['length'] ?? 4, // 会员编码长度
];
- return $config;
}
/**
diff --git a/niucloud/app/service/core/member/CoreMemberLabelService.php b/niucloud/app/service/core/member/CoreMemberLabelService.php
index e730f2615..ff8674f2e 100644
--- a/niucloud/app/service/core/member/CoreMemberLabelService.php
+++ b/niucloud/app/service/core/member/CoreMemberLabelService.php
@@ -48,9 +48,6 @@ class CoreMemberLabelService extends BaseCoreService
},
self::$cache_tag_name.$site_id
);
-// return Cache::tag(self::$cache_tag_name.$site_id)->remember($cache_name, function () use ($site_id, $label_ids) {
-// return array_keys_search($this->getAll($site_id), $label_ids, 'label_id');
-// });
}
/**
@@ -72,11 +69,6 @@ class CoreMemberLabelService extends BaseCoreService
},
self::$cache_tag_name.$site_id
);
-// return Cache::tag(self::$cache_tag_name.$site_id)->remember($cache_name, function () use ($site_id) {
-// $field = 'label_id, label_name';
-// return $this->model->where([['site_id', '=', $site_id]])->field($field)->select()->toArray();
-//
-// });
}
/**
diff --git a/niucloud/app/service/core/notice/CoreNoticeLogService.php b/niucloud/app/service/core/notice/CoreNoticeLogService.php
index 06cbb98b2..27f03bc85 100644
--- a/niucloud/app/service/core/notice/CoreNoticeLogService.php
+++ b/niucloud/app/service/core/notice/CoreNoticeLogService.php
@@ -49,6 +49,6 @@ class CoreNoticeLogService extends BaseCoreService
public function getInfo(int $site_id, int $id){
$field = 'id, site_id, key, notice_type, uid, member_id, nickname, receiver, is_click, is_visit, visit_time, create_time, params, content';
- return $this->model->where([['site_id', '=', $site_id], ['id', '=', $id]])->field($field)->findOrEmpty()->append(['name', 'notice_type_name'])->toArray();
+ return $this->model->where([['site_id', '=', $site_id], ['id', '=', $id]])->field($field)->append(['name', 'notice_type_name'])->findOrEmpty()->toArray();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/notice/CoreNoticeSmsLogService.php b/niucloud/app/service/core/notice/CoreNoticeSmsLogService.php
index c3a7bc399..f80802a3b 100644
--- a/niucloud/app/service/core/notice/CoreNoticeSmsLogService.php
+++ b/niucloud/app/service/core/notice/CoreNoticeSmsLogService.php
@@ -35,25 +35,21 @@ class CoreNoticeSmsLogService extends BaseCoreService
*/
public function getPage(int $site_id, array $where = [])
{
-
- $field = 'mobile, sms_type, key, content, data, status, result, create_time, send_time, update_time';
+ $field = 'id,mobile,sms_type,key,template_id,content,params,status,result,create_time,send_time,update_time';
$order = 'create_time desc';
- $search_model = $this->model->where([['site_id', '=', $site_id]])->withSearch(['name'], $where)->field($field)->order($order)->append(['name', 'app_type_name', 'status_name']);
- $list = $this->pageQuery($search_model);
- return $list;
+ $search_model = $this->model->where([['site_id', '=', $site_id]])->withSearch(['name', 'key', 'mobile', 'sms_type'], $where)->field($field)->order($order)->append(['name', 'sms_type_name', 'status_name']);
+ return $this->pageQuery($search_model);
}
-
/**
* 获取短信发送记录信息
* @param int $id
*/
public function getInfo(int $site_id, int $id)
{
- $field = 'mobile, sms_type, key, content, data, status, result, create_time, send_time, update_time';
- $info = $this->model->field($field)->where([['id', '=', $id], ['site_id', '=', $site_id]])->findOrEmpty()->append(['name', 'app_type_name', 'status_name'])->toArray();
- return $info;
+ $field = 'id, mobile,sms_type,key,template_id,content,params,status,result,create_time,send_time,update_time';
+ return $this->model->field($field)->where([['id', '=', $id], ['site_id', '=', $site_id]])->append(['name', 'sms_type_name', 'status_name'])->findOrEmpty()->toArray();
}
/**
@@ -88,8 +84,7 @@ class CoreNoticeSmsLogService extends BaseCoreService
*/
public function del(int $site_id, int $id)
{
- $res = $this->model->where([['id', '=', $id], ['site_id', '=', $site_id]])->delete();
- return $res;
+ return $this->model->where([['id', '=', $id], ['site_id', '=', $site_id]])->delete();
}
diff --git a/niucloud/app/service/core/pay/CorePayEventService.php b/niucloud/app/service/core/pay/CorePayEventService.php
index 2f7d8b261..e00ebb9ef 100644
--- a/niucloud/app/service/core/pay/CorePayEventService.php
+++ b/niucloud/app/service/core/pay/CorePayEventService.php
@@ -91,7 +91,8 @@ class CorePayEventService extends BaseCoreService
'refund_url' => $refund_url,
'quit_url' => $quit_url,
'buyer_id' => $buyer_id,
- 'openid' => $openid
+ 'openid' => $openid,
+ 'site_id' => $this->site_id
);
switch ($this->type) {
case PayDict::WECHATPAY:
@@ -116,7 +117,7 @@ class CorePayEventService extends BaseCoreService
$pay_fun = 'app';
break;
}
-
+ if (empty($pay_fun)) throw new PayException('PAYMENT_METHOD_NOT_SCENE');
break;
case PayDict::ALIPAY:
switch ($this->channel) {
@@ -133,8 +134,12 @@ class CorePayEventService extends BaseCoreService
$pay_fun = 'wap';
break;
}
+ if (empty($pay_fun)) throw new PayException('PAYMENT_METHOD_NOT_SCENE');
+ break;
}
- if (empty($pay_fun)) throw new PayException('PAYMENT_METHOD_NOT_SCENE');
+
+ if (empty($pay_fun)) $pay_fun = 'pay';
+
return $this->app('pay')->$pay_fun($params);
}
@@ -158,7 +163,7 @@ class CorePayEventService extends BaseCoreService
$money = $money * 100;
break;
case PayDict::ALIPAY:
-
+ break;
}
return $this->app('transfer')->transfer([
'transfer_no' => $transfer_no,
diff --git a/niucloud/app/service/core/pay/CorePayService.php b/niucloud/app/service/core/pay/CorePayService.php
index 418bb13e0..1f4b72814 100644
--- a/niucloud/app/service/core/pay/CorePayService.php
+++ b/niucloud/app/service/core/pay/CorePayService.php
@@ -45,7 +45,7 @@ class CorePayService extends BaseCoreService
* @return string|null
*/
public function create($site_id, string $main_type, int $main_id, float $money, string $trade_type, string $body){
- $out_trade_no = create_no('pay', $main_id);
+ $out_trade_no = create_no();
$data = array(
'site_id' => $site_id,
'money' => $money,
@@ -262,7 +262,8 @@ class CorePayService extends BaseCoreService
return (new CoreRefundService())->refundNotify($site_id, $out_trade_no, $type, $params);
break;
}
-
+ //找不到对应的业务
+ return true;
} catch (PayException $e) {
return false;
}
@@ -292,9 +293,8 @@ class CorePayService extends BaseCoreService
if(!$money){
$money = $pay->money;
}
- $new_out_trade_no = $this->create($site_id, $pay->main_type, $pay->main_id, $money, $pay->trade_type, $pay->body);
//todo 需要考虑是业务调用重置支付,还是支付重置反馈业务
- return $new_out_trade_no;
+ return $this->create($site_id, $pay->main_type, $pay->main_id, $money, $pay->trade_type, $pay->body);
}
/**
diff --git a/niucloud/app/service/core/pay/CoreRefundService.php b/niucloud/app/service/core/pay/CoreRefundService.php
index ffb54ac08..b93d631c2 100644
--- a/niucloud/app/service/core/pay/CoreRefundService.php
+++ b/niucloud/app/service/core/pay/CoreRefundService.php
@@ -45,7 +45,7 @@ class CoreRefundService extends BaseCoreService
if($pay->isEmpty()) throw new PayException();//单据不存在
//校验当前数据是否存在
//存在就修改,不存在就创建
- $refund_no = create_no('refund', $pay->id);
+ $refund_no = create_no();
$data = array(
'site_id' => $site_id,
'money' => $money,
@@ -217,7 +217,7 @@ class CoreRefundService extends BaseCoreService
['site_id', '=', $site_id],
['refund_no', '=', $refund_no]
])->update([
- 'status' => RefundDict::SUCCESS,
+ 'status' => RefundDict::FAIL,
'fail_reason' => $data['fail_reason']
]);
return true;
diff --git a/niucloud/app/service/core/pay/CoreTransferService.php b/niucloud/app/service/core/pay/CoreTransferService.php
index 4b188ba8e..e52bc8a62 100644
--- a/niucloud/app/service/core/pay/CoreTransferService.php
+++ b/niucloud/app/service/core/pay/CoreTransferService.php
@@ -44,7 +44,7 @@ class CoreTransferService extends BaseCoreService
* @return string|null
*/
public function create(int $site_id, string $main_type, int $main_id, float $money, string $trade_type, string $remark){
- $transfer_no = create_no('pay', $main_id);
+ $transfer_no = create_no();
$transfer_data = array(
'site_id' => $site_id,
'money' => $money,
diff --git a/niucloud/app/service/core/paytype/CoreBalanceService.php b/niucloud/app/service/core/paytype/CoreBalanceService.php
index d5698a384..97c434835 100644
--- a/niucloud/app/service/core/paytype/CoreBalanceService.php
+++ b/niucloud/app/service/core/paytype/CoreBalanceService.php
@@ -42,11 +42,15 @@ class CoreBalanceService extends BaseCoreService
// if(empty($password)){
//
// }
- $site_id = $params['site_id'];
- $main_id = $params['main_id'];
- $main_type = $params['main_type'];
- $money = $params['money'];
$out_trade_no = $params['out_trade_no'];//交易流水号
+ $site_id = $params['site_id'];
+
+ $pay = (new CorePayService())->findPayInfoByOutTradeNo($site_id, $out_trade_no);
+
+ $main_id = $pay['main_id'];
+ $main_type = $pay['main_type'];
+ $money = $params['money'];
+
switch($main_type){
case 'member':
diff --git a/niucloud/app/service/core/schedule/CoreCronService.php b/niucloud/app/service/core/schedule/CoreCronService.php
deleted file mode 100644
index acdf91505..000000000
--- a/niucloud/app/service/core/schedule/CoreCronService.php
+++ /dev/null
@@ -1,203 +0,0 @@
-model = new SysCronTask();
- }
-
- public function add(int $site_id, array $data){
- $data['site_id'] = $site_id;
- return $this->model->create($data);
- }
-
- public function find(int $site_id, int $id){
- $where = array(
- ['site_id', '=', $site_id],
- ['id', '=', $id]
- );
- $cron = $this->model->where($where)->findOrEmpty();
- return $cron;
- }
-
- /**
- * 更新
- * @param $site_id
- * @param $id
- * @param $data
- * @return SysCronTask
- */
- public function edit(int $site_id, int $id, array $data){
- $where = array(
- ['site_id', '=', $site_id],
- ['id', '=', $id]
- );
- return $this->model->where($where)->update($data);
- }
-
- public function del(int $site_id, int $id){
-
- }
-
- /**
- * 发布计划任务
- * @return true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function execute(){
- $now = time();
-// $between = $now + 60;
- //查询未执行的任务
- $where = array(
- ['status', '=', 1],
-// ['next_time', '<', $between]
- );
- $list = self::$model->where($where)->select()->toArray();
- if(!empty($list)){
-// $job_handler_classname = 'app\job\sys\Cronexecute';
- foreach($list as $k => $v){
- $next_time = $v['next_time'];
- if($next_time < $now){
-
-// create_job($job_handler_classname, $v ?? []);
- }else{
-// create_job($job_handler_classname, $v ?? [], $next_time - time());
- }
- }
- }
- return true;
- }
-
- /**
- * 任务后续操作 根据任务的周期来计算下一次的任务
- * @param $data
- * @return void
- */
- public function after(array $data){
- $type = $data['cron'];
- $id = $data['id'];
- $site_id = $data['site_id'];
- $now = time();
- $next_time = $data['next_time'];
- $update_data = array(
- 'last_time' => $next_time,
- 'update_time' => $now
- );
-
- //查询任务
- if($type == 'crond'){
-
- $crond_length = $data['crond_length'];
- //计算下次执行的时间
- switch ( $data[ 'crond_type' ] ) {
- case 'minute'://分
-
- $execute_time = $next_time + $crond_length * 60;
- break;
- case 1://天
-
- $execute_time = strtotime('+' . $crond_length . 'day', $next_time);
- break;
- case 2://周
-
- $execute_time = strtotime('+' . $crond_length . 'week', $next_time);
- break;
- case 3://月
-
- $execute_time = strtotime('+' . $crond_length . 'month', $next_time);
- break;
- }
- $update_data['next_time'] = $execute_time;
- }else{
- $update_data['delete_time'] = $now;
- }
- $this->edit($site_id, $id, $update_data);
- }
-
-
- /**
- * 消息队列
- * @param $data
- * @return false|float|int
- */
- public function getNextTime($data){
- $crond_length = $data['crond_length'];
- $next_time = $data['next_time'];
- $now = time();
- if($now > $next_time){
- $next_time = $now;
- }
- //计算下次执行的时间
- switch ( $data[ 'crond_type' ] ) {
- case 'minute'://分
- $execute_time = $next_time + $crond_length * 60;
- break;
- case 1://天
-
- $execute_time = strtotime('+' . $crond_length . 'day', $next_time);
- break;
- case 2://周
-
- $execute_time = strtotime('+' . $crond_length . 'week', $next_time);
- break;
- case 3://月
-
- $execute_time = strtotime('+' . $crond_length . 'month', $next_time);
- break;
- }
- return $execute_time;
- }
- /**
- * 获取自动任务列表
- * @param array $where
- * @return mixed
- */
- public function getPage(int $site_id, array $where)
- {
- $field = 'id, title, count, type, crond_type, crond_length, data, status_desc, last_time, next_time, create_time, delete_time, update_time, sort';
- $order = 'last_time desc';
- $search_model = $this->model->where('site_id', $site_id)->withSearch(['last_time', 'type', 'title'], $where)->field($field)->order($order)->append(['type_name', 'crond_type_name']);
- $list = $this->pageQuery($search_model);
- return $list;
- }
-
- /**
- * 任务详情
- * @param int $id
- * @return array
- */
- public function getInfo(int $site_id, int $id){
- $where = array(
- ['id', '=', $id],
- ['site_id', '=', $site_id]
- );
- $field = 'title, count, type, crond_type, crond_length, data, status_desc, last_time, next_time, create_time, delete_time, update_time, sort';
- $info = $this->model->where($where)->field($field)->findOrEmpty()->append(['type_name', 'crond_type_name'])->toArray();
- return $info;
- }
-}
\ No newline at end of file
diff --git a/niucloud/app/service/core/schedule/CoreScheduleInstallService.php b/niucloud/app/service/core/schedule/CoreScheduleInstallService.php
new file mode 100644
index 000000000..a4a73dfff
--- /dev/null
+++ b/niucloud/app/service/core/schedule/CoreScheduleInstallService.php
@@ -0,0 +1,85 @@
+model = new SysSchedule();
+
+ }
+
+ /**
+ * 安装系统内置计划任务
+ * @return true
+ */
+ public function installSystemSchedule(){
+ //安装系统计划任务
+ $list = (new CoreScheduleService())->getTemplateList('system');
+ $this->install($list);
+ return true;
+ }
+
+ /**
+ * 安装插件计划任务
+ * @param string $addon
+ * @return true
+ */
+ public function installAddonSchedule(string $addon){
+ //安装系统计划任务
+ $list = (new CoreScheduleService())->getTemplateList($addon);
+ $this->install($list, $addon);
+ return true;
+ }
+
+ /**
+ * 卸载插件的计划任务
+ * @param string $addon
+ * @return true
+ */
+ public function uninstallAddonSchedule(string $addon){
+ //安装系统计划任务
+ $this->model->where([['addon', '=', $addon]])->delete();
+ return true;
+ }
+ /**
+ * 安装计划任务
+ * @param array $data
+ * @param string $addon
+ * @return true
+ */
+ public function install(array $data, string $addon = ''){
+ $schedule_list = [];
+ foreach($data as $v){
+ $schedule_list[] = array(
+ 'key' => $v['key'],
+ 'status' => ScheduleDict::ON,
+ 'time' => $v['time'],
+ 'addon' => $addon
+ );
+ }
+ $this->model->replace()->insertAll($schedule_list);
+ return true;
+ }
+
+
+}
\ No newline at end of file
diff --git a/niucloud/app/service/core/schedule/CoreScheduleService.php b/niucloud/app/service/core/schedule/CoreScheduleService.php
index 7ae3512fc..10fffba50 100644
--- a/niucloud/app/service/core/schedule/CoreScheduleService.php
+++ b/niucloud/app/service/core/schedule/CoreScheduleService.php
@@ -11,23 +11,25 @@
namespace app\service\core\schedule;
-use app\model\sys\SysCronTask;
+use app\dict\sys\DateDict;
+use app\model\sys\SysSchedule;
use core\base\BaseCoreService;
use core\dict\DictLoader;
+use core\exception\CommonException;
+use think\Container;
+use think\facade\Log;
+use think\helper\Str;
/**
* 计划任务服务层
- * Class CoreCronService
- * @package app\service\core\cron
*/
class CoreScheduleService extends BaseCoreService
{
- CONST CROND_LENGTH = 60;
public function __construct()
{
parent::__construct();
- $this->model = new SysCronTask();
+ $this->model = new SysSchedule();
}
@@ -36,12 +38,169 @@ class CoreScheduleService extends BaseCoreService
* @param array $where
* @return mixed
*/
- public function getList()
+ public function getList(array $where = [])
{
- $addon_load = new DictLoader('Schedule');
- $list = $addon_load->load([]);
+ $field = 'id, addon, key, status, time, count, last_time, next_time, create_time, delete_time, update_time';
+ $list = $this->model->withSearch(['key','status'],$where)->field($field)->order('id desc')->append(['status_name'])->select()->toArray();
+ $template_list = array_column($this->getTemplateList(), null, 'key');
+ foreach($list as &$item){
+ $item = array_merge($template_list[$item['key']], $item);
+ }
return $list;
}
+ /**
+ * 任务分页列表
+ * @param array $where
+ * @return mixed
+ */
+ public function getPage(array $where = [])
+ {
+ $field = 'id, addon, key, status, time, count, last_time, next_time, create_time, delete_time, update_time';
+ $search_model = $this->model->withSearch(['key','status'],$where)->field($field)->order('id desc')->append(['status_name']);
+ $template_list = array_column($this->getTemplateList(), null, 'key');
+ return $this->pageQuery($search_model, function ($item, $key) use($template_list){
+ $item['crontab_content'] = $this->getCrontabContent($item['time']);
+ foreach($template_list[$item['key']] as $k => $v){
+ if($k != 'time'){
+ $item->$k = $v;
+ }
+ }
+ });
+ }
+ /**
+ * 获取信息
+ * @param int $id
+ */
+ public function getInfo(int $id)
+ {
+ $field = 'id, addon, key, status, time, count, last_time, next_time, create_time, delete_time, update_time';
+ $info = $this->model->where([['id', '=', $id]])->field($field)->append(['status_name'])->findOrEmpty()->toArray();
+ if(!empty($info)){
+ $template_list = array_column($this->getTemplateList(), null, 'key');
+ $info = array_merge($template_list[$info['key']], $info);
+ }
+ return $info;
+ }
+
+ /**
+ * 计划任务模板
+ * @return array|null
+ */
+ public function getTemplateList(string $addon = ''){
+ $addon_load = new DictLoader('Schedule');
+ return $addon_load->load([
+ 'addon' => $addon
+ ]);
+ }
+ /**
+ * 计划任务的时间间隔
+ * @param $data
+ * @return string
+ */
+ protected function getCrontabContent($data): string
+ {
+ $content = '';
+ switch ($data['type']) {
+ case 'min':// 每隔几分
+ $content = '每隔'.$data['min'].'分钟执行一次';
+ break;
+ case 'hour':// 每隔几时第几分钟执行
+ $content = '每隔'.$data['hour'].'小时的'.$data['min'].'分执行一次';
+ break;
+ case 'day':// 每隔几日几时几分几秒执行
+ $content = '每隔'.$data['day'].'天的'.$data['hour'].'时'.$data['min'].'分执行一次';
+ break;
+ case 'week':// 每周一次,周几具体时间执行
+ $week_day = DateDict::getWeek()[$data['week']] ?? '';
+ $content = '每周的'.$week_day.'的'.$data['hour'].'时'.$data['min'].'分执行一次';
+ break;
+ case 'month':// 每月一次,某日具体时间执行
+ $content = '每月的'.$data['day'].'号的'.$data['hour'].'时'.$data['min'].'分执行一次';
+ break;
+ }
+ return $content;
+ }
+
+ /**
+ * 查询对象实例
+ * @param int $id
+ * @return SysSchedule|array|mixed|\think\Model
+ */
+ public function find(int $id){
+ return $this->model->findOrEmpty($id);
+ }
+
+ /**
+ * 设置状态(启用和关闭)
+ * @param int $id
+ * @param $status
+ * @return true
+ */
+ public function modifyStatus(int $id, $status){
+ $schedule = $this->find($id);
+ if($schedule->isEmpty()) throw new CommonException();
+ $schedule->save([
+ 'status' => $status
+ ]);
+ return true;
+ }
+
+
+ /**
+ * 添加任务
+ * @param array $data
+ */
+ public function add(array $data)
+ {
+ $data[ 'create_time' ] = time();
+ $this->model->create($data);
+ return true;
+
+ }
+
+ /**
+ * 任务编辑
+ * @param int $id
+ * @param array $data
+ */
+ public function edit(int $id, array $data)
+ {
+ $data[ 'update_time' ] = time();
+ $this->model->where([ [ 'id', '=', $id ]])->update($data);
+ return true;
+ }
+
+ /**
+ * 删除任务
+ * @param int $id
+ */
+ public function del(int $id)
+ {
+ return $this->model->where([ [ 'id', '=', $id ]])->delete();
+ }
+
+ /**
+ * 执行任务
+ * @param array $schedule
+ * @return true
+ */
+ public function execute(array $schedule){
+ $class = $schedule['class'] ?: 'app\\job\\schedule\\'.Str::studly($schedule['key']);
+ $function = $schedule['function'] ?: 'doJob';
+ try {
+ $result = Container::getInstance()->invoke([$class, $function ?? 'doJob']);
+ }catch(\Throwable $e){
+ Log::write('计划任务:'.$schedule['name'].'发生错误, 错误原因:'.$e->getMessage());
+ }
+ $schedule = $this->find($schedule['id']);
+ if(!$schedule->isEmpty()){
+ $schedule->save([
+ 'last_time' => time(),
+ 'count' => $schedule['count'] + 1,
+ ]);
+ }
+ return true;
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/site/CoreSiteAccountService.php b/niucloud/app/service/core/site/CoreSiteAccountService.php
new file mode 100644
index 000000000..aa1b2bb78
--- /dev/null
+++ b/niucloud/app/service/core/site/CoreSiteAccountService.php
@@ -0,0 +1,86 @@
+where([['out_trade_no', '=', $pay_info['out_trade_no']], ['site_id', '=', $pay_info['site_id']]])->findOrEmpty()->toArray();
+ $data = [
+ 'site_id' => $pay_info['site_id'],
+ 'type' => 'pay',
+ 'money' => $pay_info['money'],
+ 'trade_no' => $pay_info['out_trade_no'],
+ ];
+ $res = (new SiteAccountLog())->create($data);
+ return $res->id;
+ }
+
+ /**
+ * 添加退款账单记录
+ * @param string $refund_no
+ * @return mixed
+ */
+ public function addRefundLog(int $site_id, string $refund_no)
+ {
+ $refund_info = (new Refund())->where([['refund_no', '=', $refund_no], ['site_id', '=', $site_id]])->findOrEmpty()->toArray();
+ $data = [
+ 'site_id' => $refund_info['site_id'],
+ 'type' => 'refund',
+ 'money' => $refund_info['money'] *(-1),
+ 'trade_no' => $refund_info['refund_no'],
+ ];
+ $res = (new SiteAccountLog())->create($data);
+ return $res->id;
+ }
+
+ /**
+ * 添加转账账单记录
+ * @param string $refund_no
+ * @return mixed
+ */
+ public function addTransferLog(int $site_id, string $transfer_no)
+ {
+ $transfer_info = (new Transfer())->where([['transfer_no', '=', $transfer_no], ['site_id', '=', $site_id]])->findOrEmpty()->toArray();
+ $data = [
+ 'site_id' => $transfer_info['site_id'],
+ 'type' => 'transfer',
+ 'money' => $transfer_info['money'] *(-1),
+ 'trade_no' => $transfer_info['transfer_no'],
+ ];
+ $res = (new SiteAccountLog())->create($data);
+ return $res->id;
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/service/core/site/CoreSiteService.php b/niucloud/app/service/core/site/CoreSiteService.php
index 3f09e4ec3..c0d88a185 100644
--- a/niucloud/app/service/core/site/CoreSiteService.php
+++ b/niucloud/app/service/core/site/CoreSiteService.php
@@ -24,66 +24,69 @@ use core\exception\CommonException;
class CoreSiteService extends BaseCoreService
{
public static $cache_tag_name = 'site_cash';
+
public function __construct()
{
parent::__construct();
$this->model = new Site();
}
-
-
/**
* 获取授权当前站点信息(用做缓存)
- * @return mixed
+ * @param $site_id
+ * @return mixed|string
*/
- public function getSiteCache(int $site_id){
+ public function getSiteCache($site_id)
+ {
$cache_name = 'site_info_cache';
return cache_remember(
- $cache_name.$site_id,
- function () use ($site_id) {
+ $cache_name . $site_id,
+ function() use ($site_id) {
$where = [
- ['site_id', '=', $site_id],
+ [ 'site_id', '=', $site_id ],
];
- $site = $this->model->where($where)->field('app_type,site_name,logo,front_end_name,front_end_logo,group_id, status, expire_time')->findOrEmpty();
- if(!$site->isEmpty()){
- $site->append(['status_name']);
- }
+ $site = $this->model->where($where)->field('site_id, app_type,site_name,logo,front_end_name,front_end_logo,group_id, status, expire_time, site_code')->append([ 'status_name' ])->findOrEmpty();
return $site->toArray();
},
- self::$cache_tag_name.$site_id
+ self::$cache_tag_name . $site_id
);
}
/**
* 模型实例
- * @param int $site_id
+ * @param $site_id
* @return Site|array|mixed|\think\Model
*/
- public function find(int $site_id){
+ public function find($site_id)
+ {
return $this->model->findOrEmpty($site_id);
}
+
/**
* 获取过期的站点
* @return void
*/
- public function getExpireSiteList(){
+ public function getExpireSiteList()
+ {
return $this->model->where([
- ['status', '<>', SiteDict::EXPIRE],
- ['expire_time', 'between', [1,time()]],
+ [ 'status', '<>', SiteDict::EXPIRE ],
+ [ 'expire_time', 'between', [ 1, time() ] ],
])->field('site_id,status,site_name')->select()->toArray();
}
+
/**
* 站点到期(计划任务专用,切勿调用)
- * @param int $site_id
- * @return void
+ * @param $site_id
+ * @return bool
*/
- public function expire(int $site_id){
+ public function expire(int $site_id)
+ {
$site = $this->find($site_id);
- if($site->isEmpty())throw new CommonException('SITE_NOT_EXIST');
- if($site->status == SiteDict::EXPIRE) throw new CommonException('SITE_EXPIRE');
- $this->model->where([[
+ if ($site->isEmpty()) throw new CommonException('SITE_NOT_EXIST');
+ if ($site->status == SiteDict::EXPIRE) throw new CommonException('SITE_EXPIRE');
+ $this->model->where([ [
'site_id', '=', $site_id
- ]])->update(
+ ] ])->update(
[
'status' => SiteDict::EXPIRE,
]
@@ -91,4 +94,26 @@ class CoreSiteService extends BaseCoreService
return true;
}
+ /**
+ * 通过站点编号获取站点信息
+ * @param $site_code
+ * @return mixed|string
+ */
+ public function getSiteInfoBySiteCode($site_code){
+ $cache_name = 'site_id_cache';
+ return cache_remember(
+ $cache_name . $site_code,
+ function() use ($site_code) {
+ $site_info = $this->model->where([[
+ 'site_code', '=', $site_code
+ ]])->findOrEmpty();
+ if(!$site_info->isEmpty()){
+ return $site_info->toArray();
+ }
+ return [];
+ }
+ );
+
+ }
+
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/sys/CoreAgreementService.php b/niucloud/app/service/core/sys/CoreAgreementService.php
index 7a440fbd2..64ed16c21 100644
--- a/niucloud/app/service/core/sys/CoreAgreementService.php
+++ b/niucloud/app/service/core/sys/CoreAgreementService.php
@@ -65,8 +65,7 @@ class CoreAgreementService extends BaseCoreService
['agreement_key', '=', $key],
['site_id', '=', $site_id]
);
- $agreement = $this->model->where($where)->findOrEmpty();
- return $agreement;
+ return $this->model->where($where)->findOrEmpty();
}
/**
* 设置协议
diff --git a/niucloud/app/service/core/sys/CoreAreaService.php b/niucloud/app/service/core/sys/CoreAreaService.php
index 4dc5f75da..b08b73833 100644
--- a/niucloud/app/service/core/sys/CoreAreaService.php
+++ b/niucloud/app/service/core/sys/CoreAreaService.php
@@ -41,8 +41,7 @@ class CoreAreaService extends BaseCoreService
*/
public function getInfo($id)
{
- $info = $this->model->where('id', $id)->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->find()->toArray();
- return $info;
+ return $this->model->where('id', $id)->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->find()->toArray();
}
/**
@@ -55,8 +54,7 @@ class CoreAreaService extends BaseCoreService
*/
public function getListByPid(int $pid)
{
- $list = $this->model->where('pid', $pid)->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
- return $list;
+ return $this->model->where('pid', $pid)->field('id, pid, name, shortname, longitude, latitude, level, sort, status')->select()->toArray();
}
/**
@@ -70,7 +68,21 @@ class CoreAreaService extends BaseCoreService
public function getTree(int $level = 3)
{
$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', 'child', 0);
- return $tree;
+ return list_to_tree($list, 'id', 'pid', 'child', 0);
+ }
+ /**
+ * 通过对应省市区县,地址,返回完整地址
+ * @param $province_id
+ * @param $city_id
+ * @param $district_id
+ * @param $address
+ * @param string $tag 分隔符
+ */
+ public function getFullAddress($province_id, $city_id, $district_id, $address, $tag = ' ')
+ {
+ $province_name = ($this->model->where([['id', '=', $province_id]])->field("name")->findOrEmpty()->toArray())['name'] ?? '';
+ $city_name = ($this->model->where([['id', '=', $city_id]])->field("name")->findOrEmpty()->toArray())['name'] ?? '';
+ $district_name = ($this->model->where([['id', '=', $district_id]])->field("name")->findOrEmpty()->toArray())['name'] ?? '';
+ return $province_name.$tag.$city_name.$tag. $district_name. $tag. $address;
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/sys/CoreAttachmentService.php b/niucloud/app/service/core/sys/CoreAttachmentService.php
index 47279aee8..f7fc2e69b 100644
--- a/niucloud/app/service/core/sys/CoreAttachmentService.php
+++ b/niucloud/app/service/core/sys/CoreAttachmentService.php
@@ -90,8 +90,7 @@ class CoreAttachmentService extends BaseCoreService
['site_id', '=', $site_id],
['att_id', '=', $att_id]
);
- $res = $this->model->update($data, $where);
- return $res;
+ return $this->model->update($data, $where);
}
/**
@@ -102,8 +101,7 @@ class CoreAttachmentService extends BaseCoreService
public function del(int $site_id, int $att_id){
//查询是否有下级菜单或按钮
$menu = $this->find($site_id, $att_id);
- $res = $menu->delete();
- return $res;
+ return $menu->delete();
}
diff --git a/niucloud/app/service/core/sys/CoreConfigService.php b/niucloud/app/service/core/sys/CoreConfigService.php
index 8d27ebbc9..c831b37bb 100644
--- a/niucloud/app/service/core/sys/CoreConfigService.php
+++ b/niucloud/app/service/core/sys/CoreConfigService.php
@@ -38,8 +38,7 @@ class CoreConfigService extends BaseCoreService
['config_key', '=', $key],
['site_id', '=', $site_id]
);
- $info = $this->model->where($where)->field('id,site_id,config_key,value,status,create_time,update_time')->findOrEmpty()->toArray();
- return $info;
+ return $this->model->where($where)->field('id,site_id,config_key,value,status,create_time,update_time')->findOrEmpty()->toArray();
}
/**
@@ -86,7 +85,6 @@ class CoreConfigService extends BaseCoreService
$data = array(
'status' => $status,
);
- $res = $this->model->where($where)->save($data);
- return $res;
+ return $this->model->where($where)->save($data);
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/sys/CoreSysConfigService.php b/niucloud/app/service/core/sys/CoreSysConfigService.php
index e1c2dc93e..220fcc9d5 100644
--- a/niucloud/app/service/core/sys/CoreSysConfigService.php
+++ b/niucloud/app/service/core/sys/CoreSysConfigService.php
@@ -11,6 +11,7 @@
namespace app\service\core\sys;
+use app\model\site\Site;
use core\base\BaseCoreService;
/**
@@ -32,17 +33,15 @@ class CoreSysConfigService extends BaseCoreService
* @return array
*/
public function getSceneDomain(int $site_id){
- //todo 如果是默认站点
- $domain = env('system.wap_domain') ?: $this->request->domain();
- $wap_domain = $domain.'/wap';
- $web_domain = $domain.'/web';
- if($site_id != $this->request->defaultSiteId()){
- $wap_domain = $wap_domain.'/'.$site_id.'/' ;
- $web_domain = $web_domain.'/'.$site_id.'/' ;
- }
- return [
- 'wap_domain' => $wap_domain,
- 'web_domain' => $web_domain,
+ $site = Site::find($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();
+
+ return [
+ 'wap_url' => $wap_domain . "/wap/" . $site_tag . "/",
+ 'web_url' => $web_domain . "/web/" . $site_tag . "/"
];
}
diff --git a/niucloud/app/service/core/upload/CoreImageService.php b/niucloud/app/service/core/upload/CoreImageService.php
index 35e8c0ef2..fb618eab4 100644
--- a/niucloud/app/service/core/upload/CoreImageService.php
+++ b/niucloud/app/service/core/upload/CoreImageService.php
@@ -51,8 +51,7 @@ class CoreImageService extends CoreFileService
}
//如果是网络图片,可以将网络图片拉取到本地
try {
- $thumb_list = $this->upload_driver->thumb($file_path, $thumb_type);
- return $thumb_list;
+ return $this->upload_driver->thumb($file_path, $thumb_type);
} catch (\Throwable $e) {
throw new UploadFileException($e->getMessage());
}
diff --git a/niucloud/app/service/core/weapp/CoreWeappConfigService.php b/niucloud/app/service/core/weapp/CoreWeappConfigService.php
index c7b47d05a..4c4c63d6f 100644
--- a/niucloud/app/service/core/weapp/CoreWeappConfigService.php
+++ b/niucloud/app/service/core/weapp/CoreWeappConfigService.php
@@ -31,7 +31,7 @@ class CoreWeappConfigService extends BaseCoreService
*/
public function getWeappConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::WEAPP)['value'] ?? [];
- $config = [
+ return [
'weapp_name' => $info['weapp_name'] ?? '',//小程序名称
'weapp_original' => $info['weapp_original'] ?? '',//原始ID
'app_id' => $info['app_id'] ?? '',//AppID
@@ -41,7 +41,6 @@ class CoreWeappConfigService extends BaseCoreService
'encoding_aes_key' => $info['encoding_aes_key'] ?? '',
'encryption_type' => $info['encryption_type'] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全
];
- return $config;
}
/**
diff --git a/niucloud/app/service/core/weapp/CoreWeappService.php b/niucloud/app/service/core/weapp/CoreWeappService.php
index 0a3ef3796..cfc890135 100644
--- a/niucloud/app/service/core/weapp/CoreWeappService.php
+++ b/niucloud/app/service/core/weapp/CoreWeappService.php
@@ -79,8 +79,7 @@ class CoreWeappService extends BaseCoreService
// 'base_uri' => 'https://api.weixin.qq.com/', // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
],
);
- $app = Factory::miniProgram($config);
- return $app;
+ return Factory::miniProgram($config);
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/wechat/CoreWechatConfigService.php b/niucloud/app/service/core/wechat/CoreWechatConfigService.php
index 1acb41b97..fa2f7b6b9 100644
--- a/niucloud/app/service/core/wechat/CoreWechatConfigService.php
+++ b/niucloud/app/service/core/wechat/CoreWechatConfigService.php
@@ -32,7 +32,7 @@ class CoreWechatConfigService extends BaseCoreService
*/
public function getWechatConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::WECHAT)['value'] ?? [];
- $config = [
+ return [
'wechat_name' => $info['wechat_name'] ?? '',//公众号名称
'wechat_original' => $info['wechat_original'] ?? '',//原始ID
'app_id' => $info['app_id'] ?? '',//AppID
@@ -42,7 +42,6 @@ class CoreWechatConfigService extends BaseCoreService
'encoding_aes_key' => $info['encoding_aes_key'] ?? '',
'encryption_type' => $info['encryption_type'] ?? 'not_encrypt',//加解密模式 not_encrypt 明文 compatible 兼容 safe 安全
];
- return $config;
}
/**
diff --git a/niucloud/app/service/core/wechat/CoreWechatServeService.php b/niucloud/app/service/core/wechat/CoreWechatServeService.php
index 5132a2e49..19ffe8dea 100644
--- a/niucloud/app/service/core/wechat/CoreWechatServeService.php
+++ b/niucloud/app/service/core/wechat/CoreWechatServeService.php
@@ -92,7 +92,7 @@ class CoreWechatServeService extends BaseCoreService
// ...
});
$response = $app->server->serve();
- $response->send();
+ return $response->send();
}
public function jssdkConfig(int $site_id, string $url = '')
diff --git a/niucloud/app/validate/diy/Diy.php b/niucloud/app/validate/diy/Diy.php
index 6a61eacab..2f5411f27 100644
--- a/niucloud/app/validate/diy/Diy.php
+++ b/niucloud/app/validate/diy/Diy.php
@@ -24,7 +24,7 @@ class Diy extends \think\Validate
protected $rule = [
'title' => 'require',
'name' => 'require',
- 'type' => 'checkType',
+ 'type' => 'require',
'value' => 'require',
'is_default' => 'number|between:0,1',
];
@@ -36,16 +36,4 @@ class Diy extends \think\Validate
"edit" => [ 'title', 'name', 'value', 'is_default' ],
];
- /**
- * 自定义验证 性别
- * @param $value
- * @param $rule
- * @param array $data
- * @return bool|string
- */
- protected function checkType($value, $rule, $data = [])
- {
- return isset(TemplateDict::getTemplate()[ $value ]) ? true : get_lang("validate_diy.type_not_exist");
- }
-
}
\ No newline at end of file
diff --git a/niucloud/app/validate/message/AliSms.php b/niucloud/app/validate/message/AliSms.php
deleted file mode 100644
index 4e8400bb4..000000000
--- a/niucloud/app/validate/message/AliSms.php
+++ /dev/null
@@ -1,42 +0,0 @@
- 'require',
- 'menu_key' => 'unique:sys_menu',//防止key值重复
- 'menu_type' => 'require|checkMenuType',
- 'methods' => 'requireWith:api_url|checkMethodType',
- 'router_path' => 'requireIf:menu_type,0|requireIf:menu_type,1',
- 'view_path' => 'requireIf:menu_type,1'
-
- ];
-
- protected $message = [
- 'menu_name.require' => 'validate_menu.menu_name_require',
- 'router_path.requireIf' => 'validate_menu.router_path_requireif',
- 'view_path.requireIf' => 'validate_menu.view_path_requireif',
-
- 'methods.requireWith' => 'validate_menu.methods_requirewith',
- ];
-
-}
\ No newline at end of file
diff --git a/niucloud/composer.json b/niucloud/composer.json
index 826f68d2b..23a88fa9c 100644
--- a/niucloud/composer.json
+++ b/niucloud/composer.json
@@ -49,7 +49,8 @@
"yansongda/pay": "v3.2.14",
"symfony/psr-http-message-bridge": "v2.2.0",
"fastknife/ajcaptcha": "v1.2.1",
- "yzh52521/schedule": "^1.0"
+ "kosinix/grafika": "dev-master",
+ "yunwuxin/think-cron": "v3.0.5"
},
"require-dev": {
"symfony/var-dumper": "v4.4.47",
diff --git a/niucloud/composer.lock b/niucloud/composer.lock
index d8ca58f4e..f75149476 100644
--- a/niucloud/composer.lock
+++ b/niucloud/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "c28d105402847e957afdd94104f190aa",
+ "content-hash": "f7b6e94eac121eb357defdcb7669d03e",
"packages": [
{
"name": "adbario/php-dot-notation",
@@ -1296,6 +1296,58 @@
],
"time": "2022-05-21T17:30:32+00:00"
},
+ {
+ "name": "kosinix/grafika",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/kosinix/grafika.git",
+ "reference": "211f61fc334b8b36616b23e8af7c5727971d96ee"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/kosinix/grafika/zipball/211f61fc334b8b36616b23e8af7c5727971d96ee",
+ "reference": "211f61fc334b8b36616b23e8af7c5727971d96ee",
+ "shasum": "",
+ "mirrors": [
+ {
+ "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
+ "preferred": true
+ }
+ ]
+ },
+ "require": {
+ "php": ">=5.3"
+ },
+ "default-branch": true,
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Grafika\\": "src/Grafika"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT",
+ "GPL-2.0+"
+ ],
+ "authors": [
+ {
+ "name": "Nico Amarilla",
+ "homepage": "https://www.kosinix.com"
+ }
+ ],
+ "description": "An image manipulation library for PHP.",
+ "homepage": "http://kosinix.github.io/grafika",
+ "keywords": [
+ "grafika"
+ ],
+ "support": {
+ "issues": "https://github.com/kosinix/grafika/issues",
+ "source": "https://github.com/kosinix/grafika/tree/2.0.8"
+ },
+ "time": "2017-06-20T03:13:49+00:00"
+ },
{
"name": "laravel/serializable-closure",
"version": "v1.2.2",
@@ -5258,17 +5310,17 @@
"time": "2022-03-28T10:25:04+00:00"
},
{
- "name": "yzh52521/schedule",
- "version": "v1.0.0",
+ "name": "yunwuxin/think-cron",
+ "version": "v3.0.5",
"source": {
"type": "git",
- "url": "https://github.com/yzh52521/schedule.git",
- "reference": "4c8f537f0c08417e785f84b8b91bf16b083cb163"
+ "url": "https://github.com/yunwuxin/think-cron.git",
+ "reference": "a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/yzh52521/schedule/zipball/4c8f537f0c08417e785f84b8b91bf16b083cb163",
- "reference": "4c8f537f0c08417e785f84b8b91bf16b083cb163",
+ "url": "https://api.github.com/repos/yunwuxin/think-cron/zipball/a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca",
+ "reference": "a5e5c679b7f5daedab9fb4bb00b641b6c4a054ca",
"shasum": "",
"mirrors": [
{
@@ -5278,33 +5330,46 @@
]
},
"require": {
- "nesbot/carbon": "^2.0",
- "php": ">=7.1"
+ "dragonmantank/cron-expression": "^3.0",
+ "nesbot/carbon": "^2.28",
+ "symfony/process": "^4.4|^5.0",
+ "topthink/framework": "^6.0"
+ },
+ "require-dev": {
+ "topthink/think-swoole": "^4.0"
},
"type": "library",
+ "extra": {
+ "think": {
+ "config": {
+ "cron": "src/config.php"
+ },
+ "services": [
+ "yunwuxin\\cron\\Service"
+ ]
+ }
+ },
"autoload": {
"psr-4": {
- "schedule\\": "src/"
+ "yunwuxin\\cron\\": "src/cron"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
- "MIT"
+ "Apache-2.0"
],
- "description": "task schedule,schedule,thinkphp schedule,任务调度",
- "keywords": [
- "schedule",
- "task schedule",
- "think-schedule",
- "thinkphp",
- "thinkphp5.1",
- "thinkphp6"
+ "authors": [
+ {
+ "name": "yunwuxin",
+ "email": "448901948@qq.com"
+ }
],
+ "description": "计划任务",
"support": {
- "issues": "https://github.com/yzh52521/schedule/issues",
- "source": "https://github.com/yzh52521/schedule/tree/v1.0.0"
+ "issues": "https://github.com/yunwuxin/think-cron/issues",
+ "source": "https://github.com/yunwuxin/think-cron/tree/v3.0.5"
},
- "time": "2020-07-02T01:34:32+00:00"
+ "time": "2021-12-22T09:25:54+00:00"
}
],
"packages-dev": [
@@ -5545,7 +5610,9 @@
],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {
+ "kosinix/grafika": 20
+ },
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
diff --git a/niucloud/config/console.php b/niucloud/config/console.php
index a2794549e..b408a7c17 100644
--- a/niucloud/config/console.php
+++ b/niucloud/config/console.php
@@ -11,6 +11,5 @@ return [
'queue:listen' => 'think\queue\command\Listen',
'addon:install' => 'app\command\Addon\Install',
'addon:uninstall' => 'app\command\Addon\Uninstall',
- 'schedule:run'=> 'app\command\Schedule',
],
];
diff --git a/niucloud/config/cron.php b/niucloud/config/cron.php
deleted file mode 100644
index bb6c59b8a..000000000
--- a/niucloud/config/cron.php
+++ /dev/null
@@ -1,9 +0,0 @@
- [
- CronTask::class, //任务的完整类名
- ]
-];
\ No newline at end of file
diff --git a/niucloud/config/pay.php b/niucloud/config/pay.php
index c3aba6c7c..8b76e26e1 100644
--- a/niucloud/config/pay.php
+++ b/niucloud/config/pay.php
@@ -19,8 +19,8 @@ return [
//支付宝
'alipay' => [],
//余额
-// 'balance' => [
-// 'driver' => 'app\service\core\paytype\CoreBalanceService', //反射类的名字
-// ],
+ 'balancepay' => [
+ 'driver' => 'app\service\core\paytype\CoreBalanceService', //反射类的名字
+ ],
]
];
diff --git a/niucloud/core/dict/BaseDict.php b/niucloud/core/dict/BaseDict.php
index 7d2eb02e0..2c14d9ec3 100644
--- a/niucloud/core/dict/BaseDict.php
+++ b/niucloud/core/dict/BaseDict.php
@@ -93,7 +93,7 @@ abstract class BaseDict extends Storage
*/
protected function getDictPath()
{
- return root_path(). "app". DIRECTORY_SEPARATOR. "dict". DIRECTORY_SEPARATOR;;
+ return root_path(). 'app'. DIRECTORY_SEPARATOR. 'dict'. DIRECTORY_SEPARATOR;
}
/**
@@ -102,7 +102,7 @@ abstract class BaseDict extends Storage
*/
protected function getAddonDictPath(string $addon)
{
- return $this->getAddonPath($addon). "app". DIRECTORY_SEPARATOR. "dict". DIRECTORY_SEPARATOR;
+ return $this->getAddonPath($addon). 'app'. DIRECTORY_SEPARATOR. 'dict'. DIRECTORY_SEPARATOR;
}
/**
@@ -111,7 +111,7 @@ abstract class BaseDict extends Storage
*/
protected function getAddonConfigPath(string $addon)
{
- return $this->getAddonPath($addon). "config". DIRECTORY_SEPARATOR;
+ return $this->getAddonPath($addon). 'config'. DIRECTORY_SEPARATOR;
}
/**
diff --git a/niucloud/core/dict/Schedule.php b/niucloud/core/dict/Schedule.php
index 76c896ada..0d03849fb 100644
--- a/niucloud/core/dict/Schedule.php
+++ b/niucloud/core/dict/Schedule.php
@@ -20,28 +20,49 @@ class Schedule extends BaseDict
*/
public function load(array $data = [])
{
+ $addon = $data['addon'] ?? '';
$schedule_files = [];
- $system_path = $this->getDictPath(). "schedule". DIRECTORY_SEPARATOR. "schedule.php";
- if(is_file($system_path))
+ if(empty($addon))
{
- $schedule_files[] = $system_path;
- }
- $addons = $this->getLocalAddons();
- foreach ($addons as $k => $v)
- {
- $addon_path = $this->getAddonDictPath($v). "schedule". DIRECTORY_SEPARATOR. "schedule.php";
- if(is_file($addon_path))
+ $system_path = $this->getDictPath(). 'schedule'. DIRECTORY_SEPARATOR. 'schedule.php';
+ if(is_file($system_path))
{
- $schedule_files[] = $addon_path;
+ $schedule_files[] = $system_path;
}
+ $addons = $this->getLocalAddons();
+ foreach ($addons as $k => $v)
+ {
+ $addon_path = $this->getAddonDictPath($v). 'schedule'. DIRECTORY_SEPARATOR. 'schedule.php';
+ if(is_file($addon_path))
+ {
+ $schedule_files[] = $addon_path;
+ }
+ }
+ }else{
+ $schedule_files = [];
+ if($addon == 'system'){
+ $schedule_files = [];
+ $system_path = $this->getDictPath(). 'schedule'. DIRECTORY_SEPARATOR. 'schedule.php';
+ if(is_file($system_path))
+ {
+ $schedule_files[] = $system_path;
+ }
+ }else{
+ $addon_path = $this->getAddonDictPath($addon). 'schedule'. DIRECTORY_SEPARATOR. 'schedule.php';
+ if(is_file($addon_path))
+ {
+ $schedule_files[] = $addon_path;
+ }
+ }
+
}
$schedule_files_data = $this->loadFiles($schedule_files);
-
$schedule_data_array = [];
foreach ($schedule_files_data as $file_data)
{
$schedule_data_array = empty($schedule_data_array) ? $file_data : array_merge($schedule_data_array, $file_data);
}
return $schedule_data_array;
+
}
}
\ No newline at end of file
diff --git a/niucloud/core/upload/Aliyun.php b/niucloud/core/upload/Aliyun.php
index e094fe93f..e46d04a41 100644
--- a/niucloud/core/upload/Aliyun.php
+++ b/niucloud/core/upload/Aliyun.php
@@ -24,8 +24,7 @@ class Aliyun extends BaseUpload
$access_key_secret = $this->config['secret_key'];
$endpoint = $this->config['endpoint'];// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
- $oss_client = new OssClient($access_key_id, $access_key_secret, $endpoint);
- return $oss_client;
+ return new OssClient($access_key_id, $access_key_secret, $endpoint);
}
/**
diff --git a/niucloud/core/util/Snowflake.php b/niucloud/core/util/Snowflake.php
new file mode 100644
index 000000000..c5f4cbe58
--- /dev/null
+++ b/niucloud/core/util/Snowflake.php
@@ -0,0 +1,86 @@
+ self::MAX_DATA_CENTER_ID || $data_center_id < 0) {
+// throw new Exception('Data center ID can not be greater than ' . self::MAX_DATA_CENTER_ID . ' or less than 0');
+// }
+//
+// if ($machine_id > self::MAX_MACHINE_ID || $machine_id < 0) {
+// throw new Exception('Machine ID can not be greater than ' . self::MAX_MACHINE_ID . ' or less than 0');
+// }
+
+ $this->data_center_id = $data_center_id;
+ $this->machine_id = $machine_id;
+ $this->last_timestamp = 0;
+ $this->sequence = 0;
+ }
+
+ public function generateId()
+ {
+ $timestamp = $this->getTimestamp();
+
+ // 当前时间小于上一次生成时间,发生时钟回拨
+ if ($timestamp < $this->last_timestamp) {
+ throw new Exception('Clock moved backwards.');
+ }
+
+ // 当前时间与上一次生成时间相同
+ if ($timestamp == $this->last_timestamp) {
+ $this->sequence = ($this->sequence + 1) & self::MAX_SEQUENCE;
+
+ // 当前毫秒的序列已经达到最大值,等待下一毫秒
+ if ($this->sequence == 0) {
+ $timestamp = $this->nextMillis($this->last_timestamp);
+ }
+ } else {
+ // 新的一毫秒,序列从0开始
+ $this->sequence = 0;
+ }
+
+ $this->last_timestamp = $timestamp;
+
+ $id = (($timestamp - self::START_EPOCH) << (self::SEQUENCE_BITS + self::MACHINE_ID_BITS + self::DATA_CENTER_ID_BITS))
+ | ($this->data_center_id << (self::SEQUENCE_BITS + self::MACHINE_ID_BITS))
+ | ($this->machine_id << self::SEQUENCE_BITS)
+ | $this->sequence;
+
+ return $id;
+ }
+
+ private function getTimestamp()
+ {
+ return floor(microtime(true) * 1000);
+ }
+
+ private function nextMillis($last_timestamp)
+ {
+ $timestamp = $this->getTimestamp();
+
+ while ($timestamp <= $last_timestamp) {
+ $timestamp = $this->getTimestamp();
+ }
+
+ return $timestamp;
+ }
+}
\ No newline at end of file
diff --git a/niucloud/public/.gitignore b/niucloud/public/.gitignore
index 8b0144799..f6301082f 100644
--- a/niucloud/public/.gitignore
+++ b/niucloud/public/.gitignore
@@ -1,4 +1,6 @@
/.htaccess
upload
nginx.htaccess
-.htaccess
\ No newline at end of file
+.htaccess
+admin
+wap
\ No newline at end of file
diff --git a/niucloud/public/static/resource/images/diy/template/default_index_cover.png b/niucloud/public/static/resource/images/diy/template/default_index_cover.png
new file mode 100644
index 000000000..f7cb41093
Binary files /dev/null and b/niucloud/public/static/resource/images/diy/template/default_index_cover.png differ
diff --git a/niucloud/public/static/resource/images/diy/template/default_member_index_one_cover.png b/niucloud/public/static/resource/images/diy/template/default_member_index_one_cover.png
new file mode 100644
index 000000000..81f6813bb
Binary files /dev/null and b/niucloud/public/static/resource/images/diy/template/default_member_index_one_cover.png differ
diff --git a/niucloud/public/static/resource/images/diy/template/default_member_index_two_cover.png b/niucloud/public/static/resource/images/diy/template/default_member_index_two_cover.png
new file mode 100644
index 000000000..008b2da40
Binary files /dev/null and b/niucloud/public/static/resource/images/diy/template/default_member_index_two_cover.png differ
diff --git a/niucloud/public/static/resource/images/diy/template/tourism_cover.png b/niucloud/public/static/resource/images/diy/template/tourism_cover.png
new file mode 100644
index 000000000..ad4a8f684
Binary files /dev/null and b/niucloud/public/static/resource/images/diy/template/tourism_cover.png differ
diff --git a/niucloud/public/static/resource/images/diy/template/tourism_member_index_cover.png b/niucloud/public/static/resource/images/diy/template/tourism_member_index_cover.png
new file mode 100644
index 000000000..5e65ca1fa
Binary files /dev/null and b/niucloud/public/static/resource/images/diy/template/tourism_member_index_cover.png differ
diff --git a/niucloud/public/static/resource/images/member/public_money_bg.png b/niucloud/public/static/resource/images/member/public_money_bg.png
deleted file mode 100644
index 07fc53d34..000000000
Binary files a/niucloud/public/static/resource/images/member/public_money_bg.png and /dev/null differ