From e0b9bb5804744b5507da5273b81e12680b9f4442 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=85=A8=E6=A0=88=E5=B0=8F=E5=AD=A6=E7=94=9F?=
<1518079521@qq.com>
Date: Sat, 1 Jul 2023 16:20:54 +0800
Subject: [PATCH] update niucloud
---
.../hello_world/app/dict/notice/weapp.php | 4 +-
.../controller/applet/SiteVersion.php | 56 +++++++
.../adminapi/controller/applet/Version.php | 110 ++++++++++++
.../controller/applet/VersionDownload.php | 33 ++++
niucloud/app/adminapi/controller/diy/Diy.php | 6 +-
.../adminapi/controller/sys/Attachment.php | 72 +++++---
.../app/adminapi/controller/sys/Common.php | 39 +++++
.../app/adminapi/controller/sys/Schedule.php | 19 ++-
.../adminapi/controller/upload/Storage.php | 2 +-
.../app/adminapi/controller/upload/Upload.php | 6 +-
.../app/adminapi/controller/weapp/Package.php | 35 ++++
niucloud/app/adminapi/route/applet.php | 54 ++++++
niucloud/app/adminapi/route/sys.php | 12 +-
niucloud/app/api/controller/upload/Upload.php | 13 +-
niucloud/app/api/controller/weapp/Weapp.php | 7 +
niucloud/app/api/middleware/ApiChannel.php | 5 +-
niucloud/app/api/route/route.php | 2 +
niucloud/app/common.php | 81 ++++++++-
niucloud/app/dict/applet/AppletlDict.php | 43 +++++
niucloud/app/dict/diy/ComponentDict.php | 4 -
niucloud/app/dict/diy/LinkDict.php | 4 -
niucloud/app/dict/diy/PagesDict.php | 77 +++++++--
niucloud/app/dict/diy/TemplateDict.php | 5 -
niucloud/app/dict/menu/admin.php | 13 ++
niucloud/app/dict/menu/site.php | 2 +-
niucloud/app/dict/notice/weapp.php | 4 +-
niucloud/app/dict/schedule/ScheduleDict.php | 17 ++
niucloud/app/dict/sys/FileDict.php | 19 ++-
niucloud/app/dict/sys/IconDict.php | 31 ++++
niucloud/app/event.php | 3 +-
niucloud/app/install/controller/Index.php | 2 +-
niucloud/app/install/source/database.sql | 99 +++++++----
niucloud/app/install/view/index/step-4.html | 4 +-
niucloud/app/job/notice/Notice.php | 2 +-
niucloud/app/lang/en/api.php | 5 +-
niucloud/app/lang/en/dict.php | 8 +-
niucloud/app/lang/en/validate.php | 7 +-
niucloud/app/lang/zh-cn/api.php | 11 +-
niucloud/app/lang/zh-cn/dict.php | 9 +-
niucloud/app/lang/zh-cn/validate.php | 8 +-
niucloud/app/listener/notice/Weapp.php | 6 +-
niucloud/app/listener/notice/Wechat.php | 62 ++++---
.../app/model/applet/AppletSiteVersion.php | 45 +++++
niucloud/app/model/applet/AppletVersion.php | 38 +++++
niucloud/app/model/article/Article.php | 24 ++-
niucloud/app/model/diy/Diy.php | 12 ++
niucloud/app/model/sys/SysMenu.php | 2 +
.../admin/applet/AppletDownloadService.php | 44 +++++
.../admin/applet/AppletVersionService.php | 124 ++++++++++++++
.../admin/applet/AppletVersionSiteService.php | 73 ++++++++
.../service/admin/article/ArticleService.php | 4 +-
.../app/service/admin/auth/AuthService.php | 5 +-
niucloud/app/service/admin/diy/DiyService.php | 46 +++--
.../service/admin/generator/vm/controller.vm | 2 +-
.../service/admin/generator/vm/web_index.vm | 2 +-
.../admin/install/InstallSystemService.php | 4 +-
.../admin/schedule/ScheduleService.php | 15 +-
.../app/service/admin/site/SiteService.php | 25 +--
.../service/admin/stat/SiteStatService.php | 57 +------
.../app/service/admin/sys/AreaService.php | 2 +-
.../service/admin/sys/AttachmentService.php | 157 +++++++++++++-----
.../app/service/admin/sys/ConfigService.php | 38 ++++-
.../app/service/admin/sys/MenuService.php | 3 +-
.../app/service/admin/sys/SystemService.php | 7 +-
.../{file => upload}/StorageConfigService.php | 2 +-
.../{file => upload}/UploadConfigService.php | 2 +-
.../admin/{file => upload}/UploadService.php | 12 +-
.../admin/weapp/WeappPackageService.php | 35 ++++
.../admin/weapp/WeappTemplateService.php | 6 +-
.../service/api/article/ArticleService.php | 6 +-
.../app/service/api/login/AuthService.php | 5 +-
.../app/service/api/notice/NoticeService.php | 11 ++
.../app/service/api/upload/UploadService.php | 11 +-
.../core/addon/CoreAddonInstallService.php | 61 +++++--
niucloud/app/service/core/addon/WapTrait.php | 25 ++-
.../core/applet/CoreAppletDownloadService.php | 106 ++++++++++++
.../applet/CoreAppletSiteVersionService.php | 118 +++++++++++++
.../core/applet/CoreAppletVersionService.php | 67 ++++++++
.../app/service/core/menu/CoreMenuService.php | 7 +-
.../app/service/core/notice/NoticeService.php | 2 +-
.../service/core/pay/CorePayEventService.php | 1 +
.../service/core/pay/CoreRefundService.php | 2 +-
.../core/paytype/CoreBalanceService.php | 22 ++-
.../core/schedule/CoreScheduleService.php | 3 +-
.../app/service/core/site/CoreSiteService.php | 24 +--
.../service/core/sys/CoreSysConfigService.php | 7 +-
.../service/core/upload/CoreBase64Service.php | 10 +-
.../service/core/upload/CoreFileService.php | 4 +-
.../service/core/upload/CoreImageService.php | 33 ++--
.../core/upload/CoreStorageService.php | 6 +-
.../core/upload/CoreUploadConfigService.php | 2 +-
.../service/core/upload/CoreUploadService.php | 20 +--
niucloud/app/validate/sys/Schedule.php | 49 ++++++
niucloud/config/upload.php | 20 ++-
niucloud/config/version.php | 4 +-
niucloud/core/dict/BaseDict.php | 2 +-
niucloud/core/dict/Icon.php | 50 ++++++
niucloud/core/template/TemplateLoader.php | 8 +-
niucloud/core/template/Weapp.php | 2 +-
niucloud/core/upload/Aliyun.php | 2 +-
niucloud/core/upload/BaseUpload.php | 40 ++---
niucloud/core/upload/Local.php | 11 +-
niucloud/core/upload/Qiniu.php | 2 +-
niucloud/core/upload/Tencent.php | 2 +-
104 files changed, 2053 insertions(+), 479 deletions(-)
create mode 100644 niucloud/app/adminapi/controller/applet/SiteVersion.php
create mode 100644 niucloud/app/adminapi/controller/applet/Version.php
create mode 100644 niucloud/app/adminapi/controller/applet/VersionDownload.php
create mode 100644 niucloud/app/adminapi/controller/sys/Common.php
create mode 100644 niucloud/app/adminapi/controller/weapp/Package.php
create mode 100644 niucloud/app/adminapi/route/applet.php
create mode 100644 niucloud/app/dict/applet/AppletlDict.php
create mode 100644 niucloud/app/dict/sys/IconDict.php
create mode 100644 niucloud/app/model/applet/AppletSiteVersion.php
create mode 100644 niucloud/app/model/applet/AppletVersion.php
create mode 100644 niucloud/app/service/admin/applet/AppletDownloadService.php
create mode 100644 niucloud/app/service/admin/applet/AppletVersionService.php
create mode 100644 niucloud/app/service/admin/applet/AppletVersionSiteService.php
rename niucloud/app/service/admin/{file => upload}/StorageConfigService.php (98%)
rename niucloud/app/service/admin/{file => upload}/UploadConfigService.php (97%)
rename niucloud/app/service/admin/{file => upload}/UploadService.php (88%)
create mode 100644 niucloud/app/service/admin/weapp/WeappPackageService.php
create mode 100644 niucloud/app/service/core/applet/CoreAppletDownloadService.php
create mode 100644 niucloud/app/service/core/applet/CoreAppletSiteVersionService.php
create mode 100644 niucloud/app/service/core/applet/CoreAppletVersionService.php
create mode 100644 niucloud/app/validate/sys/Schedule.php
create mode 100644 niucloud/core/dict/Icon.php
diff --git a/niucloud/addon/hello_world/app/dict/notice/weapp.php b/niucloud/addon/hello_world/app/dict/notice/weapp.php
index 823650272..86e0c9a18 100644
--- a/niucloud/addon/hello_world/app/dict/notice/weapp.php
+++ b/niucloud/addon/hello_world/app/dict/notice/weapp.php
@@ -1,9 +1,11 @@
[
- 'temp_key' => '111',
+ 'tid' => '111',
'content' => [
['消息内容', '{name}', 'keyword1'],
],
+ 'kid_list' => [1, 3, 4, 2],
+ 'scene_desc' => ''
]
];
\ No newline at end of file
diff --git a/niucloud/app/adminapi/controller/applet/SiteVersion.php b/niucloud/app/adminapi/controller/applet/SiteVersion.php
new file mode 100644
index 000000000..93a5e85ae
--- /dev/null
+++ b/niucloud/app/adminapi/controller/applet/SiteVersion.php
@@ -0,0 +1,56 @@
+request->params([
+
+ ]);
+ return success(( new AppletVersionSiteService())->getPage($data));
+ }
+
+ /**
+ * 详情
+ * @param int $id
+ */
+ public function info(int $id)
+ {
+ return success(( new AppletVersionSiteService() )->getInfo($id));
+ }
+
+ /**
+ * 查询最后一个下载或升级的版本
+ * @param string $type
+ * @return Response
+ */
+ public function getLastVersion(string $type){
+ return success(( new AppletVersionSiteService() )->getLastVersion($type));
+ }
+
+
+}
diff --git a/niucloud/app/adminapi/controller/applet/Version.php b/niucloud/app/adminapi/controller/applet/Version.php
new file mode 100644
index 000000000..2f1948333
--- /dev/null
+++ b/niucloud/app/adminapi/controller/applet/Version.php
@@ -0,0 +1,110 @@
+request->params([
+
+ ]);
+ return success(( new AppletVersionService() )->getPage($data));
+ }
+
+ /**
+ * 详情
+ * @param int $id
+ */
+ public function info(int $id)
+ {
+ return success(( new AppletVersionService() )->getInfo($id));
+ }
+
+ /**
+ * 添加
+ * @return Response
+ */
+ public function add()
+ {
+ $data = $this->request->params([
+ [ 'type', '' ],
+ [ 'desc', '' ],
+ [ 'status', '' ],
+ [ 'path', '' ],
+ [ 'version', '' ],
+ ]);
+ $id = ( new AppletVersionService() )->add($data);
+ return success('ADD_SUCCESS');
+ }
+
+ /**
+ * 编辑
+ * @param int $id
+ * @return Response
+ */
+ public function edit(int $id)
+ {
+ $data = $this->request->params([
+ [ 'desc', '' ],
+ [ 'status', '' ],
+ [ 'path', '' ],
+ [ 'version', '' ],
+ ]);
+
+ ( new AppletVersionService() )->edit($id, $data);
+ return success('EDIT_SUCCESS');
+ }
+
+ /**
+ * 删除
+ * @param int $id
+ */
+ public function del(int $id)
+ {
+ ( new AppletVersionService() )->del($id);
+ return success('DELETE_SUCCESS');
+ }
+
+ /**
+ * 设置状态
+ * @param int $id
+ * @param $type
+ * @return Response
+ */
+ public function setStatus(int $id, $status){
+ ( new AppletVersionService() )->setStatus($id, $status);
+ return success('EDIT_SUCCESS');
+ }
+ /**
+ * 小程序包上传
+ * @return Response
+ * @throws \Exception
+ */
+ public function upload(){
+ $data = $this->request->params([
+ ['file', 'file'],
+ ], true);
+ return success(data:( new AppletVersionService() )->upload($data['file']));
+ }
+}
diff --git a/niucloud/app/adminapi/controller/applet/VersionDownload.php b/niucloud/app/adminapi/controller/applet/VersionDownload.php
new file mode 100644
index 000000000..fe34d72df
--- /dev/null
+++ b/niucloud/app/adminapi/controller/applet/VersionDownload.php
@@ -0,0 +1,33 @@
+download($id);
+ }
+
+
+}
diff --git a/niucloud/app/adminapi/controller/diy/Diy.php b/niucloud/app/adminapi/controller/diy/Diy.php
index ee693bcf2..4cc147cc8 100644
--- a/niucloud/app/adminapi/controller/diy/Diy.php
+++ b/niucloud/app/adminapi/controller/diy/Diy.php
@@ -31,6 +31,7 @@ class Diy extends BaseAdminController
$data = $this->request->params([
[ "title", "" ],
[ "type", "" ],
+ [ 'mode', '' ]
]);
return success(( new DiyService() )->getPage($data));
}
@@ -70,9 +71,10 @@ class Diy extends BaseAdminController
[ "name", "" ],
[ "type", "" ],
[ 'template', '' ],
- [ 'mode', 'diy' ],
+ [ 'mode', 'diy' ], // 页面展示模式,diy:自定义,fixed:固定
[ "value", "" ],
- [ 'is_default', 0 ]
+ [ 'is_default', 0 ],
+ [ 'is_change', '' ]
]);
$this->validate($data, 'app\validate\diy\Diy.add');
diff --git a/niucloud/app/adminapi/controller/sys/Attachment.php b/niucloud/app/adminapi/controller/sys/Attachment.php
index ca51b1f63..50dd47012 100644
--- a/niucloud/app/adminapi/controller/sys/Attachment.php
+++ b/niucloud/app/adminapi/controller/sys/Attachment.php
@@ -25,13 +25,13 @@ class Attachment extends BaseAdminController
public function lists()
{
$data = $this->request->params([
- ['att_type', ''],
- ['cate_id', 0],
- ['real_name', ''],
- ['page', 0],
- ['limit', 0],
+ [ 'att_type', '' ],
+ [ 'cate_id', 0 ],
+ [ 'real_name', '' ],
+ [ 'page', 0 ],
+ [ 'limit', 0 ],
]);
- return success((new AttachmentService())->getPage($data));
+ return success(( new AttachmentService() )->getPage($data));
}
/**
@@ -48,11 +48,12 @@ class Attachment extends BaseAdminController
* 批量删除
* @return Response
*/
- public function batchDel(){
+ public function batchDel()
+ {
$data = $this->request->params([
- ['att_ids', []],
+ [ 'att_ids', [] ],
]);
- (new AttachmentService())->delAll($data['att_ids']);
+ ( new AttachmentService() )->delAll($data[ 'att_ids' ]);
return success('DELETE_SUCCESS');
}
@@ -63,11 +64,11 @@ class Attachment extends BaseAdminController
public function addCategory()
{
$data = $this->request->params([
- ['type', FileDict::IMAGE],
- ['name', '']
+ [ 'type', FileDict::IMAGE ],
+ [ 'name', '' ]
]);
$this->validate($data, 'app\validate\sys\AttachmentCategory.add');
- (new AttachmentService())->addCategory($data);
+ ( new AttachmentService() )->addCategory($data);
return success('ADD_SUCCESS');
}
@@ -77,10 +78,10 @@ class Attachment extends BaseAdminController
public function categoryLists()
{
$data = $this->request->params([
- ['type', ''],
- ['name', ''],
+ [ 'type', '' ],
+ [ 'name', '' ],
]);
- return success((new AttachmentService())->getCategoryList($data));
+ return success(( new AttachmentService() )->getCategoryList($data));
}
/**
@@ -90,10 +91,10 @@ class Attachment extends BaseAdminController
public function editCategory($id)
{
$data = $this->request->params([
- ['name', '']
+ [ 'name', '' ]
]);
$this->validate($data, 'app\validate\sys\AttachmentCategory.edit');
- (new AttachmentService())->editCategory($id, $data);
+ ( new AttachmentService() )->editCategory($id, $data);
return success('EDIT_SUCCESS');
}
@@ -104,7 +105,7 @@ class Attachment extends BaseAdminController
*/
public function deleteCategory($id)
{
- (new AttachmentService())->delCategory($id);
+ ( new AttachmentService() )->delCategory($id);
return success('DELETE_SUCCESS');
}
@@ -115,9 +116,9 @@ class Attachment extends BaseAdminController
public function moveCategory($att_id)
{
$data = $this->request->params([
- ['cate_id', '']
+ [ 'cate_id', '' ]
]);
- (new AttachmentService())->modifyCategory($att_id, $data['cate_id']);
+ ( new AttachmentService() )->modifyCategory($att_id, $data[ 'cate_id' ]);
return success('SUCCESS');
}
@@ -129,11 +130,36 @@ class Attachment extends BaseAdminController
public function batchMoveCategory()
{
$data = $this->request->params([
- ['cate_id', ''],
- ['att_ids', []]
+ [ 'cate_id', '' ],
+ [ 'att_ids', [] ]
]);
- (new AttachmentService())->batchModifyCategory($data['att_ids'], $data['cate_id']);
+ ( new AttachmentService() )->batchModifyCategory($data[ 'att_ids' ], $data[ 'cate_id' ]);
return success('SUCCESS');
}
+ /**
+ * 获取图标库分类列表
+ */
+ public function getIconCategoryList()
+ {
+ $data = $this->request->params([
+ [ 'name', '' ],
+ ]);
+ return success(( new AttachmentService() )->getIconCategoryList($data));
+ }
+
+ /**
+ * 获取图标库列表
+ */
+ public function getIconList()
+ {
+ $data = $this->request->params([
+ [ 'page', 0 ],
+ [ 'limit', 0 ],
+ [ 'cate_id', 0 ],
+ [ 'real_name', '' ],
+ ]);
+ return success(( new AttachmentService() )->getIconList($data));
+ }
+
}
diff --git a/niucloud/app/adminapi/controller/sys/Common.php b/niucloud/app/adminapi/controller/sys/Common.php
new file mode 100644
index 000000000..9916cce90
--- /dev/null
+++ b/niucloud/app/adminapi/controller/sys/Common.php
@@ -0,0 +1,39 @@
+getMonth());
+ }
+
+ /**
+ * 星期
+ * @return \think\Response
+ */
+ public function getWeek(){
+ return success((new DateDict())->getWeek());
+ }
+
+
+}
diff --git a/niucloud/app/adminapi/controller/sys/Schedule.php b/niucloud/app/adminapi/controller/sys/Schedule.php
index b91c15086..dcf516c66 100644
--- a/niucloud/app/adminapi/controller/sys/Schedule.php
+++ b/niucloud/app/adminapi/controller/sys/Schedule.php
@@ -33,6 +33,13 @@ class Schedule extends BaseAdminController
}
+ /**
+ * 计划任务模板
+ * @return \think\Response
+ */
+ public function template(){
+ return success(data:(new ScheduleService())->getTemplateList());
+ }
/**
* 获取任务模式
@@ -62,6 +69,7 @@ class Schedule extends BaseAdminController
[ 'time', [] ],
[ 'status', ScheduleDict::OFF ],
]);
+ $this->validate($data, 'app\validate\sys\Schedule.add');
( new ScheduleService() )->add($data);
return success('ADD_SUCCESS');
}
@@ -74,7 +82,7 @@ class Schedule extends BaseAdminController
public function edit(int $id)
{
$data = $this->request->params([
- [ 'key', '' ],
+// [ 'key', '' ],
[ 'time', [] ],
[ 'status', ScheduleDict::OFF ],
]);
@@ -100,8 +108,15 @@ class Schedule extends BaseAdminController
*/
public function del(int $id)
{
-
( new ScheduleService() )->del($id);
return success('DELETE_SUCCESS');
}
+
+ /**
+ * 时间间隔类型
+ * @return \think\Response
+ */
+ public function getDateType(){
+ return success(data:ScheduleDict::getDateType());
+ }
}
diff --git a/niucloud/app/adminapi/controller/upload/Storage.php b/niucloud/app/adminapi/controller/upload/Storage.php
index 8930987ce..6a486e396 100644
--- a/niucloud/app/adminapi/controller/upload/Storage.php
+++ b/niucloud/app/adminapi/controller/upload/Storage.php
@@ -12,7 +12,7 @@
namespace app\adminapi\controller\upload;
use app\dict\sys\StorageDict;
-use app\service\admin\file\StorageConfigService;
+use app\service\admin\upload\StorageConfigService;
use core\base\BaseAdminController;
use core\exception\AdminException;
use think\Response;
diff --git a/niucloud/app/adminapi/controller/upload/Upload.php b/niucloud/app/adminapi/controller/upload/Upload.php
index 132c7d066..dd4f1a913 100644
--- a/niucloud/app/adminapi/controller/upload/Upload.php
+++ b/niucloud/app/adminapi/controller/upload/Upload.php
@@ -11,8 +11,8 @@
namespace app\adminapi\controller\upload;
-use app\service\admin\file\UploadConfigService;
-use app\service\admin\file\UploadService;
+use app\service\admin\upload\UploadConfigService;
+use app\service\admin\upload\UploadService;
use core\base\BaseAdminController;
use think\Response;
@@ -56,7 +56,7 @@ class Upload extends BaseAdminController
['file', 'file'],
], true);
$upload_service = new UploadService();
- return success($upload_service->document($data['file'], $type, true));
+ return success($upload_service->document($data['file'], $type));
}
/**
diff --git a/niucloud/app/adminapi/controller/weapp/Package.php b/niucloud/app/adminapi/controller/weapp/Package.php
new file mode 100644
index 000000000..098579f41
--- /dev/null
+++ b/niucloud/app/adminapi/controller/weapp/Package.php
@@ -0,0 +1,35 @@
+request->params([
+ ['version', ''],
+ ['path', ''],
+ ['desc', ''],
+ ['config', []],
+ ]);
+
+ }
+
+}
diff --git a/niucloud/app/adminapi/route/applet.php b/niucloud/app/adminapi/route/applet.php
new file mode 100644
index 000000000..e3e33785e
--- /dev/null
+++ b/niucloud/app/adminapi/route/applet.php
@@ -0,0 +1,54 @@
+middleware([
+ AdminCheckToken::class,
+ AdminCheckRole::class,
+ AdminLog::class
+]);
\ No newline at end of file
diff --git a/niucloud/app/adminapi/route/sys.php b/niucloud/app/adminapi/route/sys.php
index c9792f679..263c9c553 100644
--- a/niucloud/app/adminapi/route/sys.php
+++ b/niucloud/app/adminapi/route/sys.php
@@ -122,6 +122,10 @@ Route::group('sys', function () {
Route::put('upload/config', 'upload.Upload/setUploadConfig');
//获取上传设置
Route::get('upload/config', 'upload.Upload/getUploadConfig');
+ // 获取图标库列表
+ Route::get('attachment/icon_category', 'sys.Attachment/getIconCategoryList');
+ // 获取图标库列表
+ Route::get('attachment/icon', 'sys.Attachment/getIconList');
/***************************************************** 协议管理 ****************************************************/
//消息列表
Route::get('agreement', 'sys.Agreement/lists');
@@ -167,13 +171,19 @@ Route::group('sys', function () {
Route::delete('schedule/:id', 'sys.Schedule/del');
//任务模式
Route::get('schedule/type', 'sys.Schedule/getType');
+ //任务模板
+ Route::get('schedule/template', 'sys.Schedule/template');
+ //任务时间间隔
+ Route::get('schedule/datetype', 'sys.Schedule/getDateType');
/***************************************************** 应用管理 ****************************************************/
Route::get('applist', 'sys.App/getAppList');
/***************************************************** 清理缓存-刷新菜单 ****************************************************/
Route::post('schema/clear', 'sys.System/schemaCache');
-
+ /***************************************************** 公共字典数据 ****************************************************/
+ Route::get('date/month', 'sys.Common/getMonth');
+ Route::get('date/week', 'sys.Common/getWeek');
})->middleware([
AdminCheckToken::class,
diff --git a/niucloud/app/api/controller/upload/Upload.php b/niucloud/app/api/controller/upload/Upload.php
index de37b02af..83e6187c6 100644
--- a/niucloud/app/api/controller/upload/Upload.php
+++ b/niucloud/app/api/controller/upload/Upload.php
@@ -19,6 +19,10 @@ use core\base\BaseApiController;
class Upload extends BaseApiController
{
+ /**
+ * 图片上传
+ * @return \think\Response
+ */
public function image(){
$data = $this->request->params([
['file', 'file'],
@@ -27,6 +31,10 @@ class Upload extends BaseApiController
return success($upload_service->image($data['file']));
}
+ /**
+ * 远程图片拉取
+ * @return \think\Response
+ */
public function imageFetch(){
$data = $this->request->params([
['url', ''],
@@ -36,7 +44,10 @@ class Upload extends BaseApiController
}
-
+ /**
+ * base64图片上传
+ * @return \think\Response
+ */
public function imageBase64(){
$data = $this->request->params([
['content', ''],
diff --git a/niucloud/app/api/controller/weapp/Weapp.php b/niucloud/app/api/controller/weapp/Weapp.php
index 102c8823e..b5e564a51 100644
--- a/niucloud/app/api/controller/weapp/Weapp.php
+++ b/niucloud/app/api/controller/weapp/Weapp.php
@@ -11,6 +11,7 @@
namespace app\api\controller\weapp;
+use app\service\api\notice\NoticeService;
use app\service\api\weapp\WeappAuthService;
use core\base\BaseApiController;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
@@ -44,4 +45,10 @@ class Weapp extends BaseApiController
$weapp_auth_service = new WeappAuthService();
return success($weapp_auth_service->register($data['openid'], $data['mobile'], $data['mobile_code']));
}
+
+
+ public function subscribeMessage(){
+ $data = $this->request->params([ ['keys', ''] ]);
+ return success((new NoticeService())->getWeappNoticeTemplateId($data['keys']));
+ }
}
diff --git a/niucloud/app/api/middleware/ApiChannel.php b/niucloud/app/api/middleware/ApiChannel.php
index e78513184..c3850ed31 100644
--- a/niucloud/app/api/middleware/ApiChannel.php
+++ b/niucloud/app/api/middleware/ApiChannel.php
@@ -40,10 +40,7 @@ class ApiChannel
if (in_array($request->rule()->getRule(), $channel_rules)) {
$site_id = $request->param('site_id', -1);
if ($site_id != -1) {
- $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 ]);
+ $request->pushHeader([ system_name('api_site_id_name') => $site_id ]);
}
}
return $next($request);
diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php
index e7c6f0087..7f263c747 100644
--- a/niucloud/app/api/route/route.php
+++ b/niucloud/app/api/route/route.php
@@ -40,6 +40,8 @@ Route::group(function() {
Route::post('weapp/login', 'weapp.Weapp/login');
//小程序通过code注册
Route::post('weapp/register', 'weapp.Weapp/register');
+ // 获取小程序订阅消息模板id
+ Route::get('weapp/subscribemsg', 'weapp.Weapp/subscribeMessage');
//登录
Route::get('login', 'login.Login/login');
//第三方绑定
diff --git a/niucloud/app/common.php b/niucloud/app/common.php
index 37c2931d6..54d44d0e9 100644
--- a/niucloud/app/common.php
+++ b/niucloud/app/common.php
@@ -6,6 +6,7 @@ use think\facade\Lang;
use think\facade\Queue;
use think\facade\Cache;
use core\util\Snowflake;
+use app\service\core\upload\CoreImageService;
// 应用公共文件
/**
@@ -369,11 +370,11 @@ function filter($string)
*/
function create_no(string $prefix = '', string $tag = '')
{
- $dataCenterId = 1;
- $machineId = 2;
- $snowflake = new Snowflake($dataCenterId, $machineId);
+ $data_center_id = 1;
+ $machine_id = 2;
+ $snowflake = new Snowflake($data_center_id, $machine_id);
$id = $snowflake->generateId();
- return $prefix.$tag.$id;
+ return $prefix.date('YmdHi').$tag.$id;
}
/**
@@ -706,4 +707,74 @@ function cache_remember(string $name = null, $value = '', $tag = null, $options
*/
function project_path() {
return dirname(root_path()) . DIRECTORY_SEPARATOR;
-}
\ No newline at end of file
+}
+
+/**
+ * 图片转base64
+ * @param string $path
+ * @param $is_delete 转换后是否删除原图
+ * @return void
+ */
+function image_to_base64(string $path, $is_delete = false) {
+ if (!file_exists($path)) return 'image not exist';
+
+ $mime = getimagesize($path)['mime'];
+ $image_data = file_get_contents($path);
+ // 将图片转换为 base64
+ $base64_data = base64_encode($image_data);
+
+ if ($is_delete) @unlink($path);
+
+ return "data:{$mime};base64,{$base64_data}";
+}
+/**
+ * 获取缩略图
+ * @param $site_id
+ * @param $image
+ * @param $thumb_type
+ * @return mixed
+ * @throws Exception
+ */
+function get_thumb_images($site_id, $image, $thumb_type = 'all', bool $is_throw_exception = false){
+
+ return (new CoreImageService())->thumb($site_id, $image, $thumb_type, $is_throw_exception);
+}
+/**
+ * 版本号转整数 例如1.0.0=001.000.000=001000000=1000000
+ * @param string $ver
+ * @return int
+ */
+function version_to_int($version) {
+ $version_array = explode(".", $version);
+
+ $v1 = sprintf('%03s', (int) $version_array[0] ?? 0);
+ $v2 = sprintf('%03s', (int) $version_array[1] ?? 0);
+ $v3 = sprintf('%03s', (int) $version_array[2] ?? 0);
+ return (int) "{$v1}{$v2}{$v3}";
+}
+
+/**
+ * 整数版本号转字符串例如 1000000=001000000=001.000.000=1.0.0
+ * @param int $ver
+ * @return string
+ */
+function version_to_string($ver) {
+ if($ver > 999) {
+ if($ver > 999999) {
+ $ver = $ver . "";
+ $v3 = (int) substr($ver, -3);
+ $v2 = (int) substr($ver, -6, 3);
+ $v1 = (int) substr($ver, 0, strlen($ver) - 6);
+ } else {
+ $ver = $ver . "";
+ $v3 = (int) substr($ver, -3);
+ $v2 = (int) substr($ver, 0, strlen($ver) - 3);
+ $v1 = 0;
+ }
+ } else {
+ $v3 = $ver;
+ $v2 = 0;
+ $v1 = 0;
+ }
+ return "{$v1}.{$v2}.{$v3}";
+}
diff --git a/niucloud/app/dict/applet/AppletlDict.php b/niucloud/app/dict/applet/AppletlDict.php
new file mode 100644
index 000000000..e782a258b
--- /dev/null
+++ b/niucloud/app/dict/applet/AppletlDict.php
@@ -0,0 +1,43 @@
+ get_lang('dict_applet.channel_weapp'),//启用
+ self::OFF => get_lang('dict_applet.channel_wechat'),//下架
+ ];
+ return $data;
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/dict/diy/ComponentDict.php b/niucloud/app/dict/diy/ComponentDict.php
index c1d6ad05d..2955b02f4 100644
--- a/niucloud/app/dict/diy/ComponentDict.php
+++ b/niucloud/app/dict/diy/ComponentDict.php
@@ -21,10 +21,6 @@ use core\dict\DictLoader;
class ComponentDict
{
- /**
- * 获取组件
- * @return array|null
- */
public static function getComponent()
{
$system_components = [
diff --git a/niucloud/app/dict/diy/LinkDict.php b/niucloud/app/dict/diy/LinkDict.php
index f8a82d21c..404529a89 100644
--- a/niucloud/app/dict/diy/LinkDict.php
+++ b/niucloud/app/dict/diy/LinkDict.php
@@ -20,10 +20,6 @@ use core\dict\DictLoader;
*/
class LinkDict
{
- /**
- * 获取链接
- * @return array
- */
public static function getLink()
{
$system_links = [
diff --git a/niucloud/app/dict/diy/PagesDict.php b/niucloud/app/dict/diy/PagesDict.php
index a61f23ed3..ee55ffbe6 100644
--- a/niucloud/app/dict/diy/PagesDict.php
+++ b/niucloud/app/dict/diy/PagesDict.php
@@ -21,11 +21,6 @@ use core\dict\DictLoader;
class PagesDict
{
- /**
- * 获取页面数据
- * @param array $params
- * @return array|string|null
- */
public static function getPages($params = [])
{
$system_pages = [
@@ -258,14 +253,74 @@ class PagesDict
]
],
// 'tourism' => [
-// "title" => "旅游", // 页面名称
+// "title" => "固定模板示例", // 页面名称
// 'cover' => 'static/resource/images/diy/template/tourism_cover.png', // 页面封面图
// 'preview' => '', // 页面预览图
-// 'desc' => '酒店旅游住宿门票景点', // 页面描述
+// 'desc' => '描述固定模板', // 页面描述
// 'mode' => 'fixed', // 页面模式:diy:自定义,fixed:固定
// 'data' => [
-// 'component' => 'tourism-index', // 模板组件名称
-// 'link' => '' // 装修链接
+// "global" => [
+// "title" => "固定模板示例",
+// "pageBgColor" => "#F8F8F8",
+// 'bgUrl' => '',
+// 'imgWidth' => '',
+// 'imgHeight' => '',
+// "bottomTabBarSwitch" => true,
+// "template" => [
+// 'textColor' => "#303133",
+// "pageBgColor" => "",
+// "componentBgColor" => "",
+// "topRounded" => 0,
+// "bottomRounded" => 0,
+// "elementBgColor" => "",
+// "topElementRounded" => 0,
+// "bottomElementRounded" => 0,
+// "margin" => [
+// "top" => 0,
+// "bottom" => 0,
+// "both" => 0
+// ]
+// ],
+// 'topStatusBar' => [
+// 'bgColor' => "#ffffff",
+// 'isTransparent' => false,
+// 'isShow' => true,
+// 'style' => 'style-1',
+// 'textColor' => "#333333",
+// 'textAlign' => 'center',
+// ],
+// 'popWindow' => [
+// 'imgUrl' => "",
+// 'imgWidth' => '',
+// 'imgHeight' => '',
+// 'count' => -1,
+// 'show' => 0,
+// 'link' => [
+// 'name' => ""
+// ],
+// ]
+// ],
+// "value" => [
+// [
+// "id" => "524jcssmp8c0",
+// "componentName" => "DemoIndex",
+// "componentTitle" => "固定模板示例",
+// "uses" => 0,
+// "ignore" => [],
+// "pageBgColor" => "",
+// "componentBgColor" => "rgba(255, 255, 255, 1)",
+// "topRounded" => 0,
+// "bottomRounded" => 0,
+// "elementBgColor" => "",
+// "topElementRounded" => 0,
+// "bottomElementRounded" => 0,
+// "margin" => [
+// "top" => 0,
+// "bottom" => 0,
+// "both" => 0
+// ]
+// ]
+// ]
// ]
// ]
],
@@ -932,6 +987,7 @@ class PagesDict
// ]
]
];
+
$pages = ( new DictLoader("UniappPages") )->load($system_pages);
if (!empty($params[ 'type' ])) {
if (!empty($pages[ $params[ 'type' ] ])) {
@@ -943,12 +999,11 @@ class PagesDict
}
}
}
+ return $temp;
} else {
-
return [];
}
- return $temp;
}
return $pages;
diff --git a/niucloud/app/dict/diy/TemplateDict.php b/niucloud/app/dict/diy/TemplateDict.php
index 9cb6f05c7..78be3dd33 100644
--- a/niucloud/app/dict/diy/TemplateDict.php
+++ b/niucloud/app/dict/diy/TemplateDict.php
@@ -21,11 +21,6 @@ use core\dict\DictLoader;
class TemplateDict
{
- /**
- * 获取页面模板
- * @param array $params
- * @return array|string|null
- */
public static function getTemplate($params = [])
{
$system_pages = [
diff --git a/niucloud/app/dict/menu/admin.php b/niucloud/app/dict/menu/admin.php
index 8949f9642..467835e3c 100644
--- a/niucloud/app/dict/menu/admin.php
+++ b/niucloud/app/dict/menu/admin.php
@@ -458,6 +458,19 @@
'sort' => 20,
'status' => 1,
'is_show' => 1,
+ ],
+ [
+ 'menu_name' => '小程序平台',
+ 'menu_key' => 'setting_oplatform',
+ 'menu_type' => 1,
+ 'icon' => 'iconfont-iconweixin',
+ 'api_url' => 'sys/weapp',
+ 'router_path' => 'weapp',
+ 'view_path' => 'setting/weapp',
+ 'methods' => 'get',
+ 'sort' => 20,
+ 'status' => 1,
+ 'is_show' => 1,
]
]
],
diff --git a/niucloud/app/dict/menu/site.php b/niucloud/app/dict/menu/site.php
index 93e18493b..4bb857ed5 100644
--- a/niucloud/app/dict/menu/site.php
+++ b/niucloud/app/dict/menu/site.php
@@ -485,7 +485,7 @@ return
'is_show' => 1,
'children' => [
[
- 'menu_name' => '账单管理',
+ 'menu_name' => '财务流水',
'menu_key' => 'site_account_list',
'menu_type' => 1,
'icon' => 'element-Postcard',
diff --git a/niucloud/app/dict/notice/weapp.php b/niucloud/app/dict/notice/weapp.php
index 6040cbcd8..c07c422b1 100644
--- a/niucloud/app/dict/notice/weapp.php
+++ b/niucloud/app/dict/notice/weapp.php
@@ -1,12 +1,14 @@
[
- 'temp_key' => '755',
+ 'tid' => '755',
'content' => [
['交易单号', '{trade_no}', 'keyword1'],
['充值金额', '{price}', 'keyword2'],
['账户余额', '{balance}', 'keyword3'],
['充值时间', '{time}', 'keyword4'],
],
+ 'kid_list' => [1, 3, 4, 2],
+ 'scene_desc' => ''
]
];
\ No newline at end of file
diff --git a/niucloud/app/dict/schedule/ScheduleDict.php b/niucloud/app/dict/schedule/ScheduleDict.php
index 4d22b83a9..99b5f1cec 100644
--- a/niucloud/app/dict/schedule/ScheduleDict.php
+++ b/niucloud/app/dict/schedule/ScheduleDict.php
@@ -19,6 +19,8 @@ class ScheduleDict
const ON = 1;
const OFF = 2;
+
+
/**
* 任务模式
* @return array
@@ -40,4 +42,19 @@ class ScheduleDict
self::OFF => get_lang('dict_schedule.off'),//关闭
];
}
+
+ const MIN = 'min';//每隔几分钟
+ const HOUR = 'hour';//每隔几小时
+ const DAY = 'day';//每隔几天
+ const WEEK = 'week';//每周
+ const MONTH = 'month';//每月
+ public static function getDateType(){
+ return [
+ self::MIN => get_lang('dict_schedule.min'),
+ self::HOUR => get_lang('dict_schedule.hour'),
+ self::DAY => get_lang('dict_schedule.day'),
+ self::WEEK => get_lang('dict_schedule.week'),
+ self::MONTH => get_lang('dict_schedule.month'),
+ ];
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/dict/sys/FileDict.php b/niucloud/app/dict/sys/FileDict.php
index 4cd2f4668..a65adadab 100644
--- a/niucloud/app/dict/sys/FileDict.php
+++ b/niucloud/app/dict/sys/FileDict.php
@@ -50,7 +50,7 @@ class FileDict
const WECHAT = 'wechat';//微信支付
-
+ const APPLET = 'applet';//小程序上传
/**
* 获取上传的场景
@@ -62,6 +62,23 @@ class FileDict
self::ALIYUN,//阿里云相关上传
self::IMAGE,//图片上传
self::VIDEO,//视频上传
+ self::APPLET,//小程序包上传
+ ];
+ }
+
+ const BIG = 'big';
+ const MID = 'mid';
+ const SMALL = 'small';
+
+ /**
+ * 缩略图规格
+ * @return string[]
+ */
+ public static function getThumbType(){
+ return [
+ self::BIG,//微信相关上传
+ self::MID,//阿里云相关上传
+ self::SMALL,//图片上传
];
}
}
\ No newline at end of file
diff --git a/niucloud/app/dict/sys/IconDict.php b/niucloud/app/dict/sys/IconDict.php
new file mode 100644
index 000000000..9e553da5a
--- /dev/null
+++ b/niucloud/app/dict/sys/IconDict.php
@@ -0,0 +1,31 @@
+load($system_pages);
+ return $pages;
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/event.php b/niucloud/app/event.php
index 7b255d26f..6b32f7289 100644
--- a/niucloud/app/event.php
+++ b/niucloud/app/event.php
@@ -39,7 +39,8 @@ $system_event = [
//退款成功
'RefundSuccess' => [ 'app\listener\pay\RefundSuccessListener' ],
//转账成功
- 'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ], 'SiteIndex' => [
+ 'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ],
+ 'SiteIndex' => [
'app\listener\system\SiteIndexListener'
],
diff --git a/niucloud/app/install/controller/Index.php b/niucloud/app/install/controller/Index.php
index 5dde6a6ae..b9751c23d 100644
--- a/niucloud/app/install/controller/Index.php
+++ b/niucloud/app/install/controller/Index.php
@@ -344,7 +344,7 @@ class Index extends BaseInstall
]);
}
//修改自增主键默认值
- Db::execute("alter table ".env('database.prefix', '')."site auto_increment = 1");
+ Db::execute("alter table ".env('database.prefix', '')."site auto_increment = 100000");
//获取默认套餐
$group_id = (new SiteGroupService())->addAllMenuGroup();
diff --git a/niucloud/app/install/source/database.sql b/niucloud/app/install/source/database.sql
index 5cb53e3fd..b80de1e71 100644
--- a/niucloud/app/install/source/database.sql
+++ b/niucloud/app/install/source/database.sql
@@ -28,6 +28,36 @@ CREATE TABLE `addon_log` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='插件日志表';
+DROP TABLE IF EXISTS `applet_site_version`;
+CREATE TABLE `applet_site_version` (
+ `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
+ `version_id` int(11) NOT NULL DEFAULT '0' COMMENT '版本id',
+ `type` varchar(20) NOT NULL DEFAULT '' COMMENT '小程序类型',
+ `action` varchar(20) NOT NULL DEFAULT '' COMMENT '操作方式 download 下载 upgrade 更新',
+ `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站点小程序版本表';
+
+DROP TABLE IF EXISTS `applet_version`;
+CREATE TABLE `applet_version` (
+ `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `config` varchar(255) NOT NULL DEFAULT '' COMMENT '配置信息',
+ `type` varchar(20) NOT NULL DEFAULT '' COMMENT '小程序类型',
+ `desc` text COMMENT '插件描述',
+ `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 下架 上架',
+ `uid` varchar(40) NOT NULL DEFAULT '' COMMENT '发布者',
+ `path` varchar(255) NOT NULL DEFAULT '' COMMENT '小程序包地址',
+ `version` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号',
+ `version_num` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号数字(用于排序)',
+ `release_version` varchar(20) NOT NULL DEFAULT '' 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 '更新时间',
+ `site_id` int(11) NOT NULL DEFAULT '0',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小程序版本表';
+
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '文章id',
@@ -88,6 +118,7 @@ CREATE TABLE `diy_page` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='自定义页面';
+
DROP TABLE IF EXISTS `diy_route`;
CREATE TABLE `diy_route` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@@ -108,13 +139,13 @@ CREATE TABLE `generate_column` (
`column_name` varchar(100) NOT NULL DEFAULT '' COMMENT '字段名称',
`column_comment` varchar(300) NOT NULL DEFAULT '' COMMENT '字段描述',
`column_type` varchar(100) NOT NULL DEFAULT '' COMMENT '字段类型',
- `is_required` tinyint(4) DEFAULT '0' COMMENT '是否必填 0-非必填 1-必填',
- `is_pk` tinyint(4) DEFAULT '0' COMMENT '是否为主键 0-不是 1-是',
- `is_insert` tinyint(4) DEFAULT '0' COMMENT '是否为插入字段 0-不是 1-是',
- `is_update` tinyint(4) DEFAULT '0' COMMENT '是否为更新字段 0-不是 1-是',
- `is_lists` tinyint(4) DEFAULT '1' COMMENT '是否为列表字段 0-不是 1-是',
- `is_query` tinyint(4) DEFAULT '1' COMMENT '是否为查询字段 0-不是 1-是',
- `is_search` tinyint(4) DEFAULT '1' COMMENT '是否搜索字段',
+ `is_required` tinyint(1) DEFAULT '0' COMMENT '是否必填 0-非必填 1-必填',
+ `is_pk` tinyint(1) DEFAULT '0' COMMENT '是否为主键 0-不是 1-是',
+ `is_insert` tinyint(1) DEFAULT '0' COMMENT '是否为插入字段 0-不是 1-是',
+ `is_update` tinyint(1) DEFAULT '0' COMMENT '是否为更新字段 0-不是 1-是',
+ `is_lists` tinyint(1) DEFAULT '1' COMMENT '是否为列表字段 0-不是 1-是',
+ `is_query` tinyint(1) DEFAULT '1' COMMENT '是否为查询字段 0-不是 1-是',
+ `is_search` tinyint(1) DEFAULT '1' COMMENT '是否搜索字段',
`query_type` varchar(100) DEFAULT '=' COMMENT '查询类型',
`view_type` varchar(100) DEFAULT 'input' COMMENT '显示类型',
`dict_type` varchar(255) DEFAULT '' COMMENT '字典类型',
@@ -140,10 +171,10 @@ CREATE TABLE `jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`queue` varchar(255) NOT NULL,
`payload` longtext NOT NULL,
- `attempts` tinyint(3) unsigned NOT NULL DEFAULT '0',
- `reserve_time` int(10) unsigned DEFAULT '0',
- `available_time` int(10) unsigned NOT NULL DEFAULT '0',
- `create_time` int(10) unsigned NOT NULL DEFAULT '0',
+ `attempts` tinyint(4) unsigned NOT NULL DEFAULT '0',
+ `reserve_time` int(11) unsigned DEFAULT '0',
+ `available_time` int(11) unsigned DEFAULT '0',
+ `create_time` int(11) unsigned DEFAULT '0',
PRIMARY KEY (`id`),
KEY `queue` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息队列任务表';
@@ -350,6 +381,7 @@ CREATE TABLE `pay` (
`main_id` int(11) NOT NULL DEFAULT '0' COMMENT '支付会员id',
`out_trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '支付流水号',
`trade_type` varchar(255) NOT NULL DEFAULT '' COMMENT '业务类型',
+ `trade_id` int(11) NOT NULL DEFAULT '0' COMMENT '业务id',
`trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '交易单号',
`body` varchar(1000) NOT NULL DEFAULT '' COMMENT '支付主体',
`money` decimal(10,2) NOT NULL COMMENT '支付金额',
@@ -516,7 +548,6 @@ CREATE TABLE `recharge_order_log` (
DROP TABLE IF EXISTS `site`;
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 '关键字',
@@ -542,9 +573,9 @@ CREATE TABLE `site` (
PRIMARY KEY (`site_id`),
KEY `create_time` (`create_time`),
KEY `group_id` (`group_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=1365 COMMENT='站点表';
+) ENGINE=InnoDB AUTO_INCREMENT=100000 DEFAULT CHARSET=utf8mb4 COMMENT='站点表';
-INSERT INTO `site` VALUES ('1', '11000001', 'niucloud-admin', '0', '', 'admin', '', '', '1', '', '', '0', '0', '0', '', '', '', '', '0', '0', '', '', '', '0');
+INSERT INTO `site` VALUES ('1', 'niucloud-admin', '0', '', 'admin', '', '', '1', '', '', '0', '0', '0', '', '', '', '', '0', '0', '', '', '', '0');
DROP TABLE IF EXISTS `site_account_log`;
CREATE TABLE `site_account_log` (
@@ -4333,7 +4364,7 @@ CREATE TABLE `sys_menu` (
`view_path` varchar(255) NOT NULL DEFAULT '' COMMENT '菜单文件地址',
`methods` varchar(10) NOT NULL DEFAULT '' COMMENT '提交方式POST GET PUT DELETE',
`sort` tinyint(4) NOT NULL DEFAULT '1' COMMENT '排序',
- `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '正常,禁用(禁用后不允许访问)',
+ `status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '正常,禁用(禁用后不允许访问)',
`is_show` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否显示',
`create_time` int(11) NOT NULL DEFAULT '0',
`delete_time` int(11) NOT NULL DEFAULT '0',
@@ -4342,7 +4373,7 @@ CREATE TABLE `sys_menu` (
KEY `is_show` (`is_show`),
KEY `menu_key` (`menu_key`,`app_type`),
KEY `parent_key` (`parent_key`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=406 COMMENT='菜单表';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
DROP TABLE IF EXISTS `sys_notice`;
CREATE TABLE `sys_notice` (
@@ -4369,15 +4400,15 @@ CREATE TABLE `sys_notice_log` (
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`key` varchar(255) DEFAULT '' COMMENT '消息key',
`notice_type` varchar(50) DEFAULT 'sms' COMMENT '消息类型(sms,wechat.weapp)',
- `uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '通知的用户id',
+ `uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '通知的用户id',
`member_id` int(11) NOT NULL DEFAULT '0' COMMENT '消息的会员id',
`nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人用户昵称或姓名',
`receiver` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人(对应手机号,openid)',
`content` text COMMENT '消息数据',
- `is_click` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
- `is_visit` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '访问次数',
+ `is_click` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
+ `is_visit` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '访问次数',
`visit_time` int(11) NOT NULL DEFAULT '0' COMMENT '访问时间',
- `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '消息时间',
+ `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息时间',
`result` varchar(1000) NOT NULL DEFAULT '' COMMENT '结果',
`params` text,
PRIMARY KEY (`id`),
@@ -4411,7 +4442,7 @@ CREATE TABLE `sys_role` (
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`role_name` varchar(255) NOT NULL DEFAULT '' COMMENT '角色名称',
`rules` text COMMENT '角色权限(menus_id)',
- `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
+ `status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后修改时间',
PRIMARY KEY (`role_id`),
@@ -4445,11 +4476,11 @@ CREATE TABLE `sys_user` (
`password` varchar(100) NOT NULL DEFAULT '' COMMENT '用户密码',
`real_name` varchar(16) NOT NULL DEFAULT '' COMMENT '实际姓名',
`last_ip` varchar(16) NOT NULL DEFAULT '' COMMENT '最后一次登录ip',
- `last_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后一次登录时间',
- `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
- `login_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录次数',
- `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '后台管理员状态 1有效0无效',
- `is_del` tinyint(3) unsigned NOT NULL DEFAULT '0',
+ `last_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后一次登录时间',
+ `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
+ `login_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '登录次数',
+ `status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '后台管理员状态 1有效0无效',
+ `is_del` tinyint(4) unsigned NOT NULL DEFAULT '0',
`delete_time` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`uid`),
@@ -4458,7 +4489,7 @@ CREATE TABLE `sys_user` (
KEY `is_del` (`is_del`),
KEY `password` (`password`),
KEY `update_time` (`update_time`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=372 COMMENT='后台管理员表';
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='后台管理员表';
INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
@@ -4467,12 +4498,12 @@ CREATE TABLE `sys_user_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '管理员操作记录ID',
`ip` varchar(16) NOT NULL DEFAULT '' COMMENT '登录IP',
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
- `uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员id',
+ `uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '管理员id',
`username` varchar(64) NOT NULL DEFAULT '' COMMENT '管理员姓名',
`url` varchar(128) NOT NULL DEFAULT '' COMMENT '链接',
`params` text COMMENT '参数',
`type` varchar(32) NOT NULL DEFAULT '' COMMENT '请求方式',
- `create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间',
+ `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间',
PRIMARY KEY (`id`),
KEY `create_time` (`create_time`),
KEY `site_id` (`site_id`),
@@ -4491,7 +4522,7 @@ CREATE TABLE `sys_user_role` (
KEY `create_time` (`create_time`),
KEY `site_id` (`site_id`),
KEY `uid` (`uid`)
-) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=481 COMMENT='用户权限表';
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='用户权限表';
INSERT INTO `sys_user_role` VALUES ('1', '1', '0', '', '0', '1');
@@ -4542,11 +4573,11 @@ CREATE TABLE `wechat_reply` (
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`keyword` varchar(64) NOT NULL DEFAULT '' COMMENT '关键词',
`reply_type` tinyint(4) NOT NULL COMMENT '回复类型 subscribe-关注回复 keyword-关键字回复 default-默认回复',
- `matching_type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '匹配方式:1-全匹配;2-模糊匹配',
- `content_type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '内容类型:1-文本',
+ `matching_type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '匹配方式:1-全匹配;2-模糊匹配',
+ `content_type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '内容类型:1-文本',
`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 '排序',
+ `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '启动状态:1-启动;0-关闭',
+ `sort` int(11) unsigned NOT NULL DEFAULT '50' 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 '删除时间',
diff --git a/niucloud/app/install/view/index/step-4.html b/niucloud/app/install/view/index/step-4.html
index e2eaa9306..094f05a1b 100644
--- a/niucloud/app/install/view/index/step-4.html
+++ b/niucloud/app/install/view/index/step-4.html
@@ -44,13 +44,13 @@
站点后台
-
+
站点电脑端
-
+
diff --git a/niucloud/app/job/notice/Notice.php b/niucloud/app/job/notice/Notice.php
index 51629f2db..e71553ffd 100644
--- a/niucloud/app/job/notice/Notice.php
+++ b/niucloud/app/job/notice/Notice.php
@@ -31,7 +31,7 @@ class Notice extends BaseJob
//通过业务获取模板变量属于以及发送对象
$result = event('NoticeData', ['site_id' => $site_id, 'key' => $key, 'data' => $data, 'template' => $template]);
$notice_data = array_values(array_filter($result))[0] ?? [];
- if(empty($notice_data)) throw new NoticeException();
+ if(empty($notice_data)) throw new NoticeException('NOTICE_TEMPLATE_IS_NOT_EXIST');
event('Notice', ['site_id' => $site_id, 'key' => $key, 'to' => $notice_data['to'], 'vars' => $notice_data['vars'], 'template' => $template]);
return true;
}
diff --git a/niucloud/app/lang/en/api.php b/niucloud/app/lang/en/api.php
index c05b08bb9..14b2ace70 100644
--- a/niucloud/app/lang/en/api.php
+++ b/niucloud/app/lang/en/api.php
@@ -76,7 +76,7 @@ return [
'OSS_TYPE_NOT_EXIST' => '云存储类型不存在',
'URL_FILE_NOT_EXIST' => '获取不到网址指向的文件',
'PLEACE_SELECT_IMAGE' => '请选择要删除的图片',
- 'CERT_TYPE_ERROR' => '不是有效的证书类型',
+ 'UPLOAD_TYPE_ERROR' => '不是有效的上传类型',
//消息管理
@@ -121,5 +121,6 @@ return [
500000 => '你选择的支付方式未启用',
//站点相关
'SITE_GROUP_IS_EXIST' => '站点分组已存在站点,请调整站点后重试',
-
+ //小程序版本
+ 'APPLET_VERSION_NOT_EXISTS' => 'applet version not exists',
];
diff --git a/niucloud/app/lang/en/dict.php b/niucloud/app/lang/en/dict.php
index 8a9eefd0b..c9fbbf5ad 100644
--- a/niucloud/app/lang/en/dict.php
+++ b/niucloud/app/lang/en/dict.php
@@ -102,7 +102,13 @@ return [
'type_cron' => 'time work',
'type_crond' => 'period work',
'on' => 'on',
- 'off' => 'off'
+ 'off' => 'off',
+ //时间间隔
+ 'min' => 'every few minutes',
+ 'hour' => 'every few hours',
+ 'day' => 'every few day',
+ 'week' => 'weekly',
+ 'month' => 'monthly',
],
//支付相关
'dict_pay' => [
diff --git a/niucloud/app/lang/en/validate.php b/niucloud/app/lang/en/validate.php
index c23755572..e64687380 100644
--- a/niucloud/app/lang/en/validate.php
+++ b/niucloud/app/lang/en/validate.php
@@ -131,5 +131,10 @@ return [
'appid_require' => 'appid is require',
'appsecret_require' => 'appsecret is require',
],
-
+ //计划任务
+ 'validate_schedule' => [
+ 'schedule_require' => 'schedule is require',
+ 'schedule_unique' => 'schedule is exist',
+ 'not_exit_schedule_type' => 'not exit schedule type',
+ ],
];
diff --git a/niucloud/app/lang/zh-cn/api.php b/niucloud/app/lang/zh-cn/api.php
index bbc3b9242..3b9022993 100644
--- a/niucloud/app/lang/zh-cn/api.php
+++ b/niucloud/app/lang/zh-cn/api.php
@@ -88,7 +88,7 @@ return [
'OSS_TYPE_NOT_EXIST' => '云存储类型不存在',
'URL_FILE_NOT_EXIST' => '获取不到网址指向的文件',
'PLEACE_SELECT_IMAGE' => '请选择要删除的图片',
- 'CERT_TYPE_ERROR' => '不是有效的上传类型',
+ 'UPLOAD_TYPE_ERROR' => '不是有效的上传类型',
'OSS_FILE_URL_NOT_EXIST' => '远程资源文件地址不能为空',
'BASE_IMAGE_FILE_NOT_EXIST' => 'base图片资源不能为空',
'UPLOAD_TYPE_NOT_SUPPORT' => '不支持的上传类型',
@@ -108,6 +108,7 @@ return [
'NOTICE_NOT_OPEN_SMS' => '当前消息未开启短信发送',
'NOTICE_SMS_EMPTY' => '手机号为空',
'NOTICE_SMS_NOT_OPEN' => '短信未启用',
+ 'NOTICE_TEMPLATE_IS_NOT_EXIST' => '消息不存在',
//会员相关
'MOBILE_IS_EXIST' => '当前手机号已绑定账号',
@@ -159,8 +160,6 @@ return [
'WEAPP_EMPOWER_NOT_EXIST' => '微信小程序授信信息不存在',
'WEAPP_EMPOWER_TEL_NOT_EXIST' => '微信小程序授信手机号不存在',
- //支付相关
-
//站点相关
'SITE_GROUP_IS_EXIST' => '当前套餐存在站点,请调整站点对应套餐后重试',
'SITE_EXPIRE' => '站点已过期',
@@ -185,11 +184,13 @@ return [
'CHANNEL_MARK_INVALID' => '无效的渠道标识',
'TEMPLATE_NOT_EXIST' => '模板不存在',
'IS_EXIST_TEMPLATE_NOT_MODIFY' => '已存在的支付模板不支持修改支付类型',
+ 'ONLY_PAYING_CAN_PAY' => '只有待支付的订单可以支付',
//退款相关
'REFUND_NOT_EXIST' => '退款单据不存在',
//订单相关 8***
'ORDER_NOT_EXIST' => '订单不存在',
'ORDER_CLOSED' => '订单已关闭',
+ 'DOCUMENT_IS_PAID' => '单据已支付',
// 退款相关
'NOT_ALLOW_APPLY_REFUND' => '该订单不允许退款',
@@ -207,4 +208,8 @@ return [
'JOB_NOT_EXISTS' => '任务类不存在',
'JOB_CREATE_FAIL' => '任务创建失败',
+ //小程序版本
+ 'APPLET_VERSION_NOT_EXISTS' => '小程序版本不存在',
+
+
];
diff --git a/niucloud/app/lang/zh-cn/dict.php b/niucloud/app/lang/zh-cn/dict.php
index d916f9c17..673538b8d 100644
--- a/niucloud/app/lang/zh-cn/dict.php
+++ b/niucloud/app/lang/zh-cn/dict.php
@@ -137,7 +137,14 @@ return [
'type_cron' => '定时任务',
'type_crond' => '周期任务',
'on' => '启用',
- 'off' => '关闭'
+ 'off' => '关闭',
+
+ 'min' => '每隔几分钟',
+ 'hour' => '每隔几小时',
+ 'day' => '每隔几天',
+ 'week' => '每周',
+ 'month' => '每月',
+
],
//支付相关
'dict_pay' => [
diff --git a/niucloud/app/lang/zh-cn/validate.php b/niucloud/app/lang/zh-cn/validate.php
index e7cd59c76..0400581fd 100644
--- a/niucloud/app/lang/zh-cn/validate.php
+++ b/niucloud/app/lang/zh-cn/validate.php
@@ -171,5 +171,11 @@ return [
'not_support_account_type' => '该账户不支持提现',
'not_support_transfer_type' => '不支持该提现方式',
'account_id_require' => '请选择提现账户'
- ]
+ ],
+ //计划任务
+ 'validate_schedule' => [
+ 'schedule_require' => '计划任务必须选择',
+ 'schedule_unique' => '当前计划任务已存在',
+ 'not_exit_schedule_type' => '不是有效的任务类型',
+ ],
];
diff --git a/niucloud/app/listener/notice/Weapp.php b/niucloud/app/listener/notice/Weapp.php
index 7a829e238..b85ddf57e 100644
--- a/niucloud/app/listener/notice/Weapp.php
+++ b/niucloud/app/listener/notice/Weapp.php
@@ -39,11 +39,7 @@ class Weapp
}
$weapp_data[$v[2]]['value'] = $search_content;
}
- $url = '';
- if(!empty($url)){
- //todo 拼装h5端的链接
- $url = $vars['__weapp_page'];
- }
+ $url = $vars['__weapp_page'] ?? '';
$log_data = array(
'key' => $key,
'message_type' => NoticeTypeDict::WEAPP,
diff --git a/niucloud/app/listener/notice/Wechat.php b/niucloud/app/listener/notice/Wechat.php
index 6d4dddd03..706ffb50d 100644
--- a/niucloud/app/listener/notice/Wechat.php
+++ b/niucloud/app/listener/notice/Wechat.php
@@ -5,6 +5,7 @@ namespace app\listener\notice;
use app\dict\notice\NoticeTypeDict;
use app\service\core\member\CoreMemberService;
use app\service\core\notice\CoreNoticeLogService;
+use app\service\core\weapp\CoreWeappConfigService;
use core\exception\NoticeException;
use core\template\TemplateLoader;
@@ -20,36 +21,33 @@ class Wechat
$to = $data['to'];//发送对象主题
//完全信任消息的设置, 不再依赖support_type
- if($template['is_wechat']){
+ if ($template['is_wechat']) {
$member_id = $to['member_id'] ?? 0;
//会员的
- if($member_id > 0){//查询openid
+ if ($member_id > 0) {//查询openid
$info = (new CoreMemberService())->getInfoByMemberId($site_id, $member_id);
$openid = $info['wx_openid'] ?? '';
$nickname = $info['nickname'] ?? '';
}
//或者还有用户的
- if(!empty($openid)){
+ if (!empty($openid)) {
$wechat_template_id = $template['wechat_template_id'];
$wechat = $template['wechat'];
$wechat_content = $wechat['content'];
$wechat_data = [];
- foreach($wechat_content as $k => $v){
+ foreach ($wechat_content as $k => $v) {
$search_content = $v[1];
- foreach($vars as $item_k => $item_v){
- $search_content = str_replace('{'.$item_k.'}', $item_v, $search_content);
+ foreach ($vars as $item_k => $item_v) {
+ $search_content = str_replace('{' . $item_k . '}', $item_v, $search_content);
}
$wechat_data[$v[2]] = $search_content;
}
$first = $wechat['wechat_first'] ?? '';
$remark = $wechat['wechat_remark'] ?? '';
- if(!empty($first)) $vars['first'] = $first;
- if(!empty($remark)) $vars['remark'] = $remark;
- $url = '';
- if(!empty($url)){
- //todo 拼装h5端的链接
- $url = $vars['__wechat_page'];
- }
+ if (!empty($first)) $vars['first'] = $first;
+ if (!empty($remark)) $vars['remark'] = $remark;
+ //todo 拼装h5端的链接
+ $url = $vars['__wechat_page'] ?? '';
//消息日志
$log_data = array(
'key' => $key,
@@ -62,23 +60,35 @@ class Wechat
'content' => $wechat
);
- try{
- (new TemplateLoader(NoticeTypeDict::WECHAT, ['site_id' => $site_id]))->send(
- [
- 'template_id' => $wechat_template_id,
- 'first' => $remark,
- 'remark' => $remark,
- 'data' => $wechat_data,
- 'openid' => $openid,
- 'url' => $url,
- 'miniprogram' => $miniprogram ?? '',
- ]);
+ $weapp_page = $vars['__weapp_page'] ?? '';
+ if (!empty($weapp_page)) {
+ $appid = (new CoreWeappConfigService())->getWeappConfig($site_id)['app_id'] ?? '';
+ if (!empty($appid)) {
+ $miniprogram = array(
+ 'appid' => $appid,
+ 'pagepath' => $weapp_page
+ );
+ }
+ }
+ try {
+ $send_data = [
+ 'template_id' => $wechat_template_id,
+ 'first' => $remark,
+ 'remark' => $remark,
+ 'data' => $wechat_data,
+ 'openid' => $openid,
+ 'url' => $url,
+ ];
+ if (!empty($miniprogram)) {
+ $send_data['miniprogram'] = $miniprogram;
+ }
+ (new TemplateLoader(NoticeTypeDict::WECHAT, ['site_id' => $site_id]))->send($send_data);
(new CoreNoticeLogService())->add($site_id, $log_data);
- }catch(NoticeException $e){
+ } catch ( NoticeException $e ) {
$log_data['result'] = $e->getMessage();
(new CoreNoticeLogService())->add($site_id, $log_data);
//这儿决定要不要抛出
- if(!$template['async']){
+ if (!$template['async']) {
throw new NoticeException($e->getMessage());
}
}
diff --git a/niucloud/app/model/applet/AppletSiteVersion.php b/niucloud/app/model/applet/AppletSiteVersion.php
new file mode 100644
index 000000000..9620cb53a
--- /dev/null
+++ b/niucloud/app/model/applet/AppletSiteVersion.php
@@ -0,0 +1,45 @@
+hasOne( AppletVersion::class, 'id', 'version_id')->joinType('left')
+ ->withField('desc, status, version, version_num, release_version')
+ ->bind([ 'desc', 'status', 'version', 'version_num', 'release_version']);
+ }
+}
diff --git a/niucloud/app/model/applet/AppletVersion.php b/niucloud/app/model/applet/AppletVersion.php
new file mode 100644
index 000000000..80b68555b
--- /dev/null
+++ b/niucloud/app/model/applet/AppletVersion.php
@@ -0,0 +1,38 @@
+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']}"
+ 'wap_url' => $wap_domain . "/wap/" . $data['site_id'] . "/pages/article/detail?id={$data['id']}",
+ 'web_url' => $web_domain . "/web/" . $data['site_id'] . "/article/detail?id={$data['id']}"
];
}
+ public function getImageThumbBigAttr($value, $data) {
+ if($data['image'] != ''){
+ return get_thumb_images($data['site_id'], $data['image'], FileDict::BIG);
+ }
+ }
+
+ public function getImageThumbMidAttr($value, $data) {
+ if($data['image'] != ''){
+ return get_thumb_images($data['site_id'], $data['image'], FileDict::MID);
+ }
+ }
+
+ public function getImageThumbSmallAttr($value, $data) {
+ if($data['image'] != ''){
+ return get_thumb_images($data['site_id'], $data['image'], FileDict::SMALL);
+ }
+ }
}
diff --git a/niucloud/app/model/diy/Diy.php b/niucloud/app/model/diy/Diy.php
index 1ca8bfe7f..b2fb6dbd0 100644
--- a/niucloud/app/model/diy/Diy.php
+++ b/niucloud/app/model/diy/Diy.php
@@ -136,6 +136,18 @@ class Diy extends BaseModel
}
}
+ /**
+ * 搜索器:页面展示模式,diy:自定义,fixed:固定
+ * @param $value
+ * @param $data
+ */
+ public function searchModeAttr($query, $value, $data)
+ {
+ if ($value) {
+ $query->where("mode", $value);
+ }
+ }
+
/**
* 搜索器:自定义页面数据,json格式
* @param $value
diff --git a/niucloud/app/model/sys/SysMenu.php b/niucloud/app/model/sys/SysMenu.php
index f9b050daa..9710ecfe0 100644
--- a/niucloud/app/model/sys/SysMenu.php
+++ b/niucloud/app/model/sys/SysMenu.php
@@ -14,6 +14,7 @@ namespace app\model\sys;
use app\dict\sys\MenuDict;
use app\dict\sys\MenuTypeDict;
use core\base\BaseModel;
+use think\model\concern\SoftDelete;
/**
* 菜单模型
@@ -22,6 +23,7 @@ use core\base\BaseModel;
*/
class SysMenu extends BaseModel
{
+ use SoftDelete;
/**
* 数据表主键
* @var string
diff --git a/niucloud/app/service/admin/applet/AppletDownloadService.php b/niucloud/app/service/admin/applet/AppletDownloadService.php
new file mode 100644
index 000000000..d08298168
--- /dev/null
+++ b/niucloud/app/service/admin/applet/AppletDownloadService.php
@@ -0,0 +1,44 @@
+download($this->site_id);
+ }
+
+
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/applet/AppletVersionService.php b/niucloud/app/service/admin/applet/AppletVersionService.php
new file mode 100644
index 000000000..5e6946411
--- /dev/null
+++ b/niucloud/app/service/admin/applet/AppletVersionService.php
@@ -0,0 +1,124 @@
+model = new AppletVersion();
+ $this->core_applet_version_service = new CoreAppletVersionService;
+ }
+
+ /**
+ * 获取列表
+ * @param array $where
+ * @param string $order
+ */
+ public function getPage(array $where = [])
+ {
+ return $this->core_applet_version_service->getPage($where);
+ }
+
+ /**
+ * 获取信息
+ * @param int $id
+ */
+ public function getInfo(int $id)
+ {
+ return $this->core_applet_version_service->getInfo($id);
+ }
+
+ /**
+ * 添加
+ * @param array $data
+ * @return true
+ */
+ public function add(array $data)
+ {
+ $data['version_num'] = version_to_int($data['version']);//版本号数字
+ $data['uid'] = $this->uid;//发布者
+ $data['status'] = AppletlDict::OFF;
+ $this->model->create($data);
+ return true;
+ }
+ /**
+ * 上传小程序包
+ * @param $file
+ * @return true
+ * @throws \Exception
+ */
+ public function upload($file){
+ $core_upload_service = new CoreUploadService();
+ $type = FileDict::APPLET;
+ $dir = '/applet/'.$type.'/version/';
+ return $core_upload_service->document($file, $this->site_id, $type, $dir, FileDict::LOCAL);
+ }
+
+ /**
+ * 设置版本状态
+ * @param $id
+ * @param $status
+ * @return true
+ */
+ public function setStatus(int $id, $status){
+ $data = array(
+ 'status' => $status
+ );
+ $where = array(
+ ['id', '=', $id]
+ );
+ $this->model->where($where)->update($data);
+ return true;
+ }
+ /**
+ * 编辑
+ * @param int $id
+ * @param array $data
+ */
+ public function edit(int $id, array $data)
+ {
+ $data['version_num'] = version_to_int($data['version']);//版本号数字
+ $data['status'] = AppletlDict::OFF;
+ $data['update_time'] = time();
+ $this->model->where([['id', '=', $id]])->create($data);
+ return true;
+ }
+
+ /**
+ * 删除
+ * @param int $id
+ * @return true
+ */
+ public function del(int $id){
+ $this->model->where([['id', '=', $id]])->delete();
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/applet/AppletVersionSiteService.php b/niucloud/app/service/admin/applet/AppletVersionSiteService.php
new file mode 100644
index 000000000..46b3b8caa
--- /dev/null
+++ b/niucloud/app/service/admin/applet/AppletVersionSiteService.php
@@ -0,0 +1,73 @@
+core_applet_site_version_service = new CoreAppletSiteVersionService();
+ }
+
+ /**
+ * 获取列表
+ * @param array $where
+ * @return mixed
+ */
+ public function getPage(array $where = [])
+ {
+ return $this->core_applet_site_version_service->getPage($this->site_id, $where);
+ }
+
+ /**
+ * 获取信息
+ * @param int $id
+ * @return array
+ */
+ public function getInfo(int $id)
+ {
+ return $this->core_applet_site_version_service->getInfo($this->site_id, $id);
+ }
+
+ /**
+ * 查询最后一个下载或升级的版本
+ * @param string $type
+ * @return mixed|string
+ */
+ public function getLastVersion(string $type){
+ return $this->core_applet_site_version_service->getLastVersion($this->site_id, $type);
+ }
+
+ /**
+ * 查询可升级的版本
+ * @param string $type
+ * @return null
+ */
+ public function getUpgradeVersion(string $type){
+ return $this->core_applet_site_version_service->getUpgradeVersion($this->site_id, $type);
+ }
+}
\ 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 ab2c4c504..473d09a14 100644
--- a/niucloud/app/service/admin/article/ArticleService.php
+++ b/niucloud/app/service/admin/article/ArticleService.php
@@ -38,7 +38,7 @@ class ArticleService extends BaseAdminService
$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';
- $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id', 'is_show'], $where)->with('articleCategory')->field($field)->order($order)->append(['article_url']);
+ $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id', 'is_show'], $where)->with('articleCategory')->field($field)->order($order)->append(['article_url','image_thumb_small']);
return $this->pageQuery($search_model);
}
@@ -50,7 +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';
- return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->findOrEmpty()->toArray();
+ return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->append(['image_thumb_small'])->findOrEmpty()->toArray();
}
/**
diff --git a/niucloud/app/service/admin/auth/AuthService.php b/niucloud/app/service/admin/auth/AuthService.php
index 5e397602e..58173cd48 100644
--- a/niucloud/app/service/admin/auth/AuthService.php
+++ b/niucloud/app/service/admin/auth/AuthService.php
@@ -36,12 +36,11 @@ class AuthService extends BaseAdminService
* @param $site_id
*/
public function checkSiteAuth(Request $request){
- $site_code = $request->adminSiteId();
+ $site_id = $request->adminSiteId();
//todo 将站点编号转化为站点id
- $site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
+ $site_info = (new CoreSiteService())->getSiteCache($site_id);
//站点不存在
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');
diff --git a/niucloud/app/service/admin/diy/DiyService.php b/niucloud/app/service/admin/diy/DiyService.php
index d130be811..0046e21a9 100644
--- a/niucloud/app/service/admin/diy/DiyService.php
+++ b/niucloud/app/service/admin/diy/DiyService.php
@@ -16,7 +16,6 @@ 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;
@@ -45,8 +44,8 @@ class DiyService extends BaseAdminService
{
$where[] = [ 'site_id', '=', $this->site_id ];
$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' ]);
+ $order = "update_time desc";
+ $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->order($order)->append([ 'type_name' ]);
$list = $this->pageQuery($search_model);
return $list;
}
@@ -62,7 +61,7 @@ class DiyService extends BaseAdminService
*/
public function getList(array $where = [], $field = 'id,site_id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time')
{
- $order = "is_default desc,update_time desc";
+ $order = "update_time desc";
$list = $this->model->where([ [ [ 'site_id', '=', $this->site_id ] ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->select()->order($order)->toArray();
return $list;
}
@@ -74,14 +73,14 @@ class DiyService extends BaseAdminService
*/
public function getInfo(int $id)
{
- $field = 'id,site_id,title,name,template,type,mode,value,is_default,share,visit_count';
+ $field = 'id,site_id,title,name,template,type,mode,value,is_default,is_change,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,template,type,mode,value,is_default,share,visit_count';
+ $field = 'id,site_id,title,name,template,type,mode,value,is_default,is_change,share,visit_count';
$info = $this->model->field($field)->where([ [ 'name', '=', $name ], [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ])->findOrEmpty()->toArray();
return $info;
}
@@ -188,7 +187,6 @@ class DiyService extends BaseAdminService
if (!empty($data)) {
// 编辑赋值
-
if (isset($template[ $data[ 'type' ] ])) {
$page = $template[ $data[ 'type' ] ];
$data[ 'type_name' ] = $page[ 'title' ];
@@ -260,8 +258,6 @@ class DiyService extends BaseAdminService
}
$data[ 'component' ] = $this->getComponentList($data[ 'type' ]);
$data[ 'domain_url' ] = ( new SystemService() )->getUrl();
- $site = Site::find($this->site_id);
- $data[ 'site_id' ] = $site[ 'site_code' ];
return $data;
}
@@ -408,7 +404,7 @@ class DiyService extends BaseAdminService
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 ][ 'my_page' ] = $this->getList([ 'type' => $k ], 'id,title,name,template,type,is_default,mode');
$template[ $k ][ 'domain_url' ] = ( new SystemService() )->getUrl();
// 查询默认页面数据
@@ -432,28 +428,30 @@ class DiyService extends BaseAdminService
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[ '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' ];
+ if ($info[ 'is_change' ] == 1) {
+ // 修改过模板,预览实际内容
+ $use_template[ 'url' ] = '/' . $v[ 'page' ] . '?id=' . $info[ 'id' ];
+ } else {
+ $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' ];
+ $use_template[ 'url' ] = '/pages/index/diy?id=' . $info[ 'id' ];
+ // 清空模板信息
+ $use_template[ 'cover' ] = ''; // 默认图
+ $use_template[ 'template' ] = '';
+ $use_template[ 'mode' ] = 'diy';
+ $use_template[ 'hope' ] = $use_template[ 'mode' ];
}
}
$template[ $k ][ 'use_template' ] = $use_template;
diff --git a/niucloud/app/service/admin/generator/vm/controller.vm b/niucloud/app/service/admin/generator/vm/controller.vm
index b965bb004..6af3994e8 100644
--- a/niucloud/app/service/admin/generator/vm/controller.vm
+++ b/niucloud/app/service/admin/generator/vm/controller.vm
@@ -15,7 +15,7 @@
/**
* {CLASS_COMMENT}
- * Class {UCASE_NAME}Controller
+ * Class {UCASE_CLASS_NAME}
* @package app\adminapi\controller{PACKAGE_NAME}
*/
class {UCASE_CLASS_NAME} extends BaseAdminController
diff --git a/niucloud/app/service/admin/generator/vm/web_index.vm b/niucloud/app/service/admin/generator/vm/web_index.vm
index 09e53db9e..abe1cc53b 100644
--- a/niucloud/app/service/admin/generator/vm/web_index.vm
+++ b/niucloud/app/service/admin/generator/vm/web_index.vm
@@ -3,7 +3,7 @@
- {{pageName}}
+ {{pageName}}
{{ t('addArticle') }}
diff --git a/niucloud/app/service/admin/install/InstallSystemService.php b/niucloud/app/service/admin/install/InstallSystemService.php
index ff8d9ce5a..040c9b504 100644
--- a/niucloud/app/service/admin/install/InstallSystemService.php
+++ b/niucloud/app/service/admin/install/InstallSystemService.php
@@ -17,6 +17,7 @@ use app\service\admin\sys\MenuService;
use app\service\core\menu\CoreMenuService;
use core\base\BaseAdminService;
use think\facade\Cache;
+use think\facade\Db;
/**
* 系统安装
@@ -48,7 +49,8 @@ class InstallSystemService extends BaseAdminService
$admin_menus = $this->loadMenu(AppTypeDict::ADMIN);
$site_menus = $this->loadMenu(AppTypeDict::SITE);
$menus = array_merge($admin_menus, $site_menus);
- $sys_menu->where([ [ 'id', '>', 0 ] ])->delete();
+ Db::name("sys_menu")->where([ [ 'id', '>', 0 ] ])->delete();
+ //$sys_menu->where([ [ 'id', '>', 0 ] ])->force(true)->delete();
$sys_menu->replace()->insertAll($menus);
//插件菜单
(new CoreMenuService())->refreshAllAddonMenu();
diff --git a/niucloud/app/service/admin/schedule/ScheduleService.php b/niucloud/app/service/admin/schedule/ScheduleService.php
index ca2dfdaa5..4a0077a82 100644
--- a/niucloud/app/service/admin/schedule/ScheduleService.php
+++ b/niucloud/app/service/admin/schedule/ScheduleService.php
@@ -67,7 +67,7 @@ class ScheduleService extends BaseAdminService
public function add(array $data)
{
$res = (new CoreScheduleService())->add($data);
- return $res->id;
+ return true;
}
@@ -75,6 +75,7 @@ class ScheduleService extends BaseAdminService
* 编辑
* @param int $id
* @param array $data
+ * @return true
*/
public function edit(int $id, array $data)
{
@@ -85,9 +86,19 @@ class ScheduleService extends BaseAdminService
/**
* 删除
* @param int $id
+ * @return true
*/
public function del(int $id)
{
- return (new CoreScheduleService())->del($id);
+ (new CoreScheduleService())->del($id);
+ return true;
+ }
+
+ /**
+ * 计划任务模板
+ * @return array|null
+ */
+ public function getTemplateList(){
+ return (new CoreScheduleService())->getTemplateList();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/site/SiteService.php b/niucloud/app/service/admin/site/SiteService.php
index 38660d821..ccd000795 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, site_code';
+ district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id';
$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, site_code';
+ district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id';
return $this->model->where([ [ 'site_id', '=', $site_id ] ])->with('groupName')->field($field)->append([ 'status_name' ])->findOrEmpty()->toArray();
}
@@ -88,7 +88,6 @@ 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' ],
@@ -112,24 +111,6 @@ class SiteService extends BaseAdminService
}
}
- /**
- * 通过站点id生成站点code
- * @param int $site_id
- */
- public function createSiteCodeBySiteId(int $site_id)
- {
- return ( $site_id + 1000000 ) * 11 + 1;
- }
-
- /**
- * 通过站点code获取站点id
- * @param $site_code
- */
- public function getSiteIdBySiteCode($site_code)
- {
- return ( $site_code - 1 ) / 11 - 1000000;
- }
-
/**
* 修改站点
* @param int $site_id
@@ -168,7 +149,7 @@ class SiteService extends BaseAdminService
$where = [
[ 'site_id', '=', $site_id ],
];
- $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();
+ $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')->append([ 'status_name' ])->findOrEmpty();
return $site->toArray();
},
self::$cache_tag_name . $site_id
diff --git a/niucloud/app/service/admin/stat/SiteStatService.php b/niucloud/app/service/admin/stat/SiteStatService.php
index f062673db..c5b746b1f 100644
--- a/niucloud/app/service/admin/stat/SiteStatService.php
+++ b/niucloud/app/service/admin/stat/SiteStatService.php
@@ -40,64 +40,9 @@ class SiteStatService extends BaseAdminService
*/
public function getIndexData(){
$data = [
-
- 'today_data' => [
- 'member_count' => 1,
- 'order_money' => 1388.5,
- 'visit_count' => 650,
- 'total_member_count' => 0,
- 'total_order_money' => 13851.12,
- 'total_visit_count' => 6580,
- 'total_order_count' => 29
- ],
- 'system' => [],
- 'version' => [],
- 'visit_stat' => [
- 'date' => [],
- 'value' => []
- ],
- 'member_stat' => [
- 'type' => ['男','女','未知'],
- 'value' => []
- ],
'site_info' => '',
- 'about' => [
- [
- 'name' => 'Niucloud官方公众号',
- 'image' => 'static/resource/icon/index_icon/wx_qrcode.jpg',
- 'desc' => '微信扫码关注'
- ],
- [
- 'name' => '添加企业微信群',
- 'image' => 'static/resource/icon/index_icon/wework_qrcode.png',
- 'desc' => '更多内容请扫码加入'
- ]
- ]
+
];
- $data['today_data']['total_member_count'] = (new MemberService())->getCount([['create_time', '>=', Carbon::today()->timestamp]]);
- $data['today_data']['total_order_money'] = $this->orderMoney(Carbon::today()->timestamp, time());
- $data['today_data']['total_order_count'] = $this->orderCount(Carbon::today()->timestamp, time());
- $data['today_data']['total_visit_count'] = (new MemberService())->getCount([['last_visit_time', '>=', Carbon::today()->timestamp]]);
- $data['today_data']['today_member_visit_count'] = (new CoreMemberService())->getCount(['site_id' => $this->site_id,'last_visit_time' => get_start_and_end_time_by_day()]);
-
- $data['total_data']['total_member_count'] = (new MemberService())->getCount();
- $data['total_data']['total_order_money'] = number_format($this->orderMoney(0, time()), 2);
- $data['total_data']['total_order_count'] = $this->orderCount(0, time());
- $data['total_data']['total_visit_count'] = (new MemberService())->getCount();
-
- $data['system'] = (new SystemService())->getInfo();
- $data['version'] = $data['system']['version'] ?? [];
- $time = time();
- for ($i=1; $i<=7; $i++){
- $time_data = date('Y-m-d', strtotime( '+' . $i-7 .' days', $time));
- $data['visit_stat']['date'][] = $time_data;
- $time_arr = get_start_and_end_time_by_day($time_data);
- $data['visit_stat']['value'][] = (new MemberService())->getCount([[ '', 'exp', Db::raw('(`create_time` >= ' . $time_arr[0] . ') and (`create_time` < ' . $time_arr[1] . ')') ]]);
- }
- $member_count = (new MemberService())->getCount();
- $man_count = (new MemberService())->getCount([ ['sex', '=', '1'] ]);
- $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']);
diff --git a/niucloud/app/service/admin/sys/AreaService.php b/niucloud/app/service/admin/sys/AreaService.php
index 16601a4bc..94beee2ae 100644
--- a/niucloud/app/service/admin/sys/AreaService.php
+++ b/niucloud/app/service/admin/sys/AreaService.php
@@ -124,7 +124,7 @@ class AreaService extends BaseAdminService
public function getAreaId($name, $level){
$field = 'id';
$info = $this->model->field($field)->where([['name', 'like', '%' . $name . '%' ], ['level', '=', $level]])->findOrEmpty()->toArray();
- return $info;
+ return $info['id'];
}
/**
diff --git a/niucloud/app/service/admin/sys/AttachmentService.php b/niucloud/app/service/admin/sys/AttachmentService.php
index ba9f48cb0..690940b1c 100644
--- a/niucloud/app/service/admin/sys/AttachmentService.php
+++ b/niucloud/app/service/admin/sys/AttachmentService.php
@@ -11,6 +11,8 @@
namespace app\service\admin\sys;
+use app\dict\sys\FileDict;
+use app\dict\sys\IconDict;
use app\model\sys\SysAttachment;
use app\model\sys\SysAttachmentCategory;
use app\service\core\sys\CoreAttachmentService;
@@ -39,7 +41,7 @@ class AttachmentService extends BaseAdminService
*/
public function add(array $data)
{
- $data['site_id'] = $this->site_id;
+ $data[ 'site_id' ] = $this->site_id;
return $this->core_attachment_service->add($data);
}
@@ -63,11 +65,11 @@ class AttachmentService extends BaseAdminService
*/
public function modifyCategory($att_id, $cate_id)
{
- $where = array(
- ['att_id', '=', $att_id],
- ['site_id', '=', $this->site_id],
+ $where = array (
+ [ 'att_id', '=', $att_id ],
+ [ 'site_id', '=', $this->site_id ],
);
- $this->model->where($where)->update(['cate_id' => $cate_id, 'update_time' => time()]);
+ $this->model->where($where)->update([ 'cate_id' => $cate_id, 'update_time' => time() ]);
return true;
}
@@ -80,11 +82,11 @@ class AttachmentService extends BaseAdminService
public function batchModifyCategory($att_ids, $cate_id)
{
- $where = array(
- ['att_id', 'in', is_string($att_ids) ? explode($att_ids) : $att_ids],
- ['site_id', '=', $this->site_id],
+ $where = array (
+ [ 'att_id', 'in', is_string($att_ids) ? explode($att_ids) : $att_ids ],
+ [ 'site_id', '=', $this->site_id ],
);
- $this->model->where($where)->update(['cate_id' => $cate_id, 'update_time' => time()]);
+ $this->model->where($where)->update([ 'cate_id' => $cate_id, 'update_time' => time() ]);
return true;
}
@@ -115,19 +117,22 @@ class AttachmentService extends BaseAdminService
*/
public function getPage(array $data)
{
- $where = array(
- ['site_id', '=', $this->site_id]
+ $where = array (
+ [ 'site_id', '=', $this->site_id ]
);
- if (!empty($data['att_type'])) {
- $where[] = ['att_type', '=', $data['att_type']];
+ if (!empty($data[ 'att_type' ])) {
+ $where[] = [ 'att_type', '=', $data[ 'att_type' ] ];
}
- if (!empty($data['cate_id'])) {
- $where[] = ['cate_id', '=', $data['cate_id']];
+ if (!empty($data[ 'cate_id' ])) {
+ $where[] = [ 'cate_id', '=', $data[ 'cate_id' ] ];
}
- if (!empty($data['real_name'])) {
- $where[] = ['real_name', 'like', '%' . $data['real_name'] . '%'];
+ if (!empty($data[ 'real_name' ])) {
+ $where[] = [ 'real_name', 'like', '%' . $data[ 'real_name' ] . '%' ];
}
- return $this->getPageList($this->model, $where, 'att_id,path,real_name,att_type,url', 'att_id desc');
+ return $this->getPageList($this->model, $where, 'att_id,path,real_name,att_type,url', 'att_id desc', each:function($item, $key)
+ {
+ $item[ 'thumb' ] = get_thumb_images($this->site_id, $item[ 'url' ], FileDict::SMALL);
+ });
}
/**
@@ -136,7 +141,7 @@ class AttachmentService extends BaseAdminService
*/
public function addCategory(array $data)
{
- $data['site_id'] = $this->site_id;
+ $data[ 'site_id' ] = $this->site_id;
$category_model = new SysAttachmentCategory();
$attachment = $category_model->create($data);
if (!$attachment->id)
@@ -151,9 +156,9 @@ class AttachmentService extends BaseAdminService
*/
public function findCategory(int $site_id, int $id)
{
- $where = array(
- ['site_id', '=', $site_id],
- ['id', '=', $id]
+ $where = array (
+ [ 'site_id', '=', $site_id ],
+ [ 'id', '=', $id ]
);
$category_model = new SysAttachmentCategory();
$category = $category_model->where($where)->findOrEmpty();
@@ -169,9 +174,9 @@ class AttachmentService extends BaseAdminService
*/
public function editCategory(int $id, array $data)
{
- $where = array(
- ['site_id', '=', $this->site_id],
- ['id', '=', $id]
+ $where = array (
+ [ 'site_id', '=', $this->site_id ],
+ [ 'id', '=', $id ]
);
$category_model = new SysAttachmentCategory();
return $category_model->where($where)->update($data);
@@ -186,7 +191,7 @@ class AttachmentService extends BaseAdminService
{
//查询是否有下级菜单或按钮
$category = $this->findCategory($this->site_id, $id);
- if ($this->model->where([['cate_id', '=', $id]])->count() > 0)
+ if ($this->model->where([ [ 'cate_id', '=', $id ] ])->count() > 0)
throw new AdminException('ATTACHMENT_GROUP_HAS_IMAGE');
//下级存在图片不能删除
@@ -203,16 +208,16 @@ class AttachmentService extends BaseAdminService
*/
public function getCategoryPage(array $data)
{
- $where = array(
- ['site_id', '=', $this->site_id]
+ $where = array (
+ [ 'site_id', '=', $this->site_id ]
);
- if (!empty($data['type'])) {
- $where[] = ['type', '=', $data['type']];
+ if (!empty($data[ 'type' ])) {
+ $where[] = [ 'type', '=', $data[ 'type' ] ];
}
- if (!empty($data['name'])) {
- $where[] = ['name', 'like', '%' . $data['name'] . '%'];
+ if (!empty($data[ 'name' ])) {
+ $where[] = [ 'name', 'like', '%' . $data[ 'name' ] . '%' ];
}
- return $this->getPageList((new SysAttachmentCategory()), $where, 'id,name', 'id desc');
+ return $this->getPageList(( new SysAttachmentCategory() ), $where, 'id,name', 'id desc');
}
/**
@@ -222,16 +227,90 @@ class AttachmentService extends BaseAdminService
*/
public function getCategoryList(array $data)
{
- $where = array(
- ['site_id', '=', $this->site_id]
+ $where = array (
+ [ 'site_id', '=', $this->site_id ]
);
- if (!empty($data['type'])) {
- $where[] = ['type', '=', $data['type']];
+ if (!empty($data[ 'type' ])) {
+ $where[] = [ 'type', '=', $data[ 'type' ] ];
}
- if (!empty($data['name'])) {
- $where[] = ['name', 'like', '%' . $data['name'] . '%'];
+ if (!empty($data[ 'name' ])) {
+ $where[] = [ 'name', 'like', '%' . $data[ 'name' ] . '%' ];
}
return SysAttachmentCategory::where($where)->field('id,name,type')->order('id desc')->select()->toArray();
}
+ /**
+ * 获取图标库分类列表
+ * @param array $data
+ * @return array|null
+ */
+ public function getIconCategoryList(array $data)
+ {
+ $icon_list = IconDict::getIcon();
+ foreach ($icon_list as $k => $v) {
+ unset($icon_list[ $k ][ 'glyphs' ]);
+ if (!empty($data[ 'name' ]) && strpos($v[ 'name' ], $data[ 'name' ]) === false) {
+ unset($icon_list[ $k ]);
+ }
+ }
+ $icon_list = array_values($icon_list);
+ return $icon_list;
+ }
+
+ /**
+ * 获取图标库列表
+ * @param array $data
+ * @return array|null
+ */
+ public function getIconList(array $data)
+ {
+ $icon_list = IconDict::getIcon();
+
+ $res = [
+ 'current_page' => intval($data[ 'page' ]),
+ 'per_page' => intval($data[ 'limit' ]),
+ 'data' => [],
+ 'total' => 0
+ ];
+
+ $temp_data = [];
+
+ foreach ($icon_list as $k => $v) {
+
+ $icon = $icon_list[ $k ][ 'glyphs' ]; // 图标列表
+
+ foreach ($icon as $ck => $cv) {
+ // 素材表中数据保持要一致
+ $icon[ $ck ][ 'att_id' ] = $cv[ 'icon_id' ];
+ $icon[ $ck ][ 'url' ] = $icon_list[ $k ][ 'font_family' ] . '-' . $icon_list[ $k ][ 'css_prefix_text' ] . $cv[ 'font_class' ];
+ $icon[ $ck ][ 'real_name' ] = $cv[ 'name' ];
+
+ // 查询名称
+ if (!empty($data[ 'real_name' ]) && strpos($cv[ 'name' ], $data[ 'real_name' ]) === false) {
+ unset($icon[ $ck ]);
+ }
+ }
+
+ $icon = array_values($icon);
+
+ if (!empty($data[ 'cate_id' ]) && $data[ 'cate_id' ] == $v[ 'id' ]) {
+ // 查询指定分类下的图标
+ $temp_data = $icon;
+ break;
+ } else {
+ // 查询全部图标
+ $temp_data = array_merge($temp_data, $icon);
+ }
+ }
+
+ // 手动分页
+ $res[ 'total' ] = count($temp_data); // 总数量
+ $start = ( $res[ 'current_page' ] - 1 ) * $res[ 'per_page' ]; // 数组下标从0 开始
+ $icon_list = array_slice($temp_data, $start, $res[ 'per_page' ]);
+
+ $res[ 'data' ] = $icon_list;
+
+ return $res;
+ }
+
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/sys/ConfigService.php b/niucloud/app/service/admin/sys/ConfigService.php
index 0859d18eb..3e1482993 100644
--- a/niucloud/app/service/admin/sys/ConfigService.php
+++ b/niucloud/app/service/admin/sys/ConfigService.php
@@ -164,6 +164,31 @@ class ConfigService extends BaseAdminService
$config['value'] = [
'view_path' => 'index/site_index'
];
+ }else{
+ $result = event("SiteIndex");
+ $index_list = [];
+ foreach ($result as $k => $v)
+ {
+ $index_list = empty($index_list) ? $v: array_merge($index_list, $v);
+ }
+ $tag = 0;
+ $view_path = $config['value']['view_path'];
+ foreach ($index_list as $k => $v)
+ {
+ $v_view_path = $v['view_path'] ?? '';
+ if($view_path == $v_view_path)
+ {
+ $tag = 1;
+ break;
+ }
+ }
+ if($tag == 0)
+ {
+ $config['value'] = [
+ 'view_path' => 'index/site_index'
+ ];
+ }
+
}
return $config['value']['view_path'];
}
@@ -235,9 +260,16 @@ class ConfigService extends BaseAdminService
$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']);
+ foreach($menu as $k => &$v){
+ $menu_key = $v['menu_key'] ?? '';
+ if($menu_key != ''){
+ $item_router_path = $menu_service->getFullRouterPath($menu_key);
+ if(empty($item_router_path)){
+ unset($v[$k]);
+ }else{
+ $v['router_path'] = $item_router_path;
+ }
+ }
}
}
return $menu;
diff --git a/niucloud/app/service/admin/sys/MenuService.php b/niucloud/app/service/admin/sys/MenuService.php
index 48668f316..0e8d54d1c 100644
--- a/niucloud/app/service/admin/sys/MenuService.php
+++ b/niucloud/app/service/admin/sys/MenuService.php
@@ -380,7 +380,8 @@ class MenuService extends BaseAdminService
* @return string
*/
public function getFullRouterPath($menu_key){
- $menu = $this->find($menu_key);
+ $menu = $this->model->where([['menu_key', '=', $menu_key]])->findOrEmpty($menu_key);
+ if($menu->isEmpty()) return '';
$parents = [];
$this->getParentDirectory($menu, $parents);
$parents = array_reverse($parents);
diff --git a/niucloud/app/service/admin/sys/SystemService.php b/niucloud/app/service/admin/sys/SystemService.php
index 306dfbf38..7474ddfe0 100644
--- a/niucloud/app/service/admin/sys/SystemService.php
+++ b/niucloud/app/service/admin/sys/SystemService.php
@@ -48,16 +48,13 @@ class SystemService extends BaseAdminService
*/
public function getUrl()
{
- $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' => $wap_domain . "/wap/" . $site_tag,
- 'web_url' => $web_domain . "/web/" . $site_tag,
+ 'wap_url' => $wap_domain . "/wap/" . $this->site_id,
+ 'web_url' => $web_domain . "/web/" . $this->site_id,
];
return $data;
}
diff --git a/niucloud/app/service/admin/file/StorageConfigService.php b/niucloud/app/service/admin/upload/StorageConfigService.php
similarity index 98%
rename from niucloud/app/service/admin/file/StorageConfigService.php
rename to niucloud/app/service/admin/upload/StorageConfigService.php
index 326dda844..5a1daa02a 100644
--- a/niucloud/app/service/admin/file/StorageConfigService.php
+++ b/niucloud/app/service/admin/upload/StorageConfigService.php
@@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
-namespace app\service\admin\file;
+namespace app\service\admin\upload;
use app\dict\sys\StorageDict;
use app\service\core\upload\CoreStorageService;
diff --git a/niucloud/app/service/admin/file/UploadConfigService.php b/niucloud/app/service/admin/upload/UploadConfigService.php
similarity index 97%
rename from niucloud/app/service/admin/file/UploadConfigService.php
rename to niucloud/app/service/admin/upload/UploadConfigService.php
index bb18ec8a4..5af2842f8 100644
--- a/niucloud/app/service/admin/file/UploadConfigService.php
+++ b/niucloud/app/service/admin/upload/UploadConfigService.php
@@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
-namespace app\service\admin\file;
+namespace app\service\admin\upload;
use app\model\sys\SysConfig;
use app\service\core\upload\CoreUploadConfigService;
diff --git a/niucloud/app/service/admin/file/UploadService.php b/niucloud/app/service/admin/upload/UploadService.php
similarity index 88%
rename from niucloud/app/service/admin/file/UploadService.php
rename to niucloud/app/service/admin/upload/UploadService.php
index 08af08edb..909c4162d 100644
--- a/niucloud/app/service/admin/file/UploadService.php
+++ b/niucloud/app/service/admin/upload/UploadService.php
@@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
-namespace app\service\admin\file;
+namespace app\service\admin\upload;
use app\dict\sys\FileDict;
use app\dict\sys\StorageDict;
@@ -29,8 +29,8 @@ class UploadService extends BaseAdminService
/**
* 附件库上传图片
+ * @param $file
* @param int $cate_id
- * @param string $dir
* @return array
*/
public function image($file, int $cate_id = 0){
@@ -55,14 +55,14 @@ class UploadService extends BaseAdminService
/**
* 文件上传
* @param $file
- * @param bool $is_local
+ * @param string $type
* @return array
*/
- public function document($file, string $type,bool $is_local = false){
+ public function document($file, string $type){
if(!in_array($type, FileDict::getSceneType()))
- throw new UploadFileException('CERT_TYPE_ERROR');
+ throw new UploadFileException('UPLOAD_TYPE_ERROR');
$dir = $this->root_path.'/document/'.$type.'/'.$this->site_id.'/'.date('Ym').'/'.date('d');
$core_upload_service = new CoreUploadService();
- return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL, true);
+ return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL);
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/weapp/WeappPackageService.php b/niucloud/app/service/admin/weapp/WeappPackageService.php
new file mode 100644
index 000000000..84ae7dc53
--- /dev/null
+++ b/niucloud/app/service/admin/weapp/WeappPackageService.php
@@ -0,0 +1,35 @@
+model = new Applet();
+ }
+
+ public function add(array $data)
+ {
+ $data['version_num'] = version_to_int($data['version']);//版本号数字
+ $data['u'] = $this->uid;//发布者
+ $data['status'] = '';
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/weapp/WeappTemplateService.php b/niucloud/app/service/admin/weapp/WeappTemplateService.php
index 03f202f70..50434361f 100644
--- a/niucloud/app/service/admin/weapp/WeappTemplateService.php
+++ b/niucloud/app/service/admin/weapp/WeappTemplateService.php
@@ -69,15 +69,15 @@ class WeappTemplateService extends BaseAdminService
public function syncItem($item){
$key = $item['key'] ?? '';
$weapp = $item['weapp'] ?? [];
- $temp_key = $weapp['temp_key'] ?? '';
- if(empty($temp_key)) $error = 'WECHAT_TEMPLATE_NEED_NO';
+ $tid = $weapp['tid'] ?? '';
+ if(empty($tid)) $error = 'WECHAT_TEMPLATE_NEED_NO';
$weapp_template_id = $item['weapp_template_id'];
//删除原来的消息模板
$template_loader = (new TemplateLoader(NoticeTypeDict::WEAPP, ['site_id' => $this->site_id]));
$template_loader->delete(['template_id' => $weapp_template_id ]);
// (new CoreWeappTemplateService())->deleteTemplate($this->site_id, $weapp_template_id);
//新的消息模板
- $tid = $weapp['tid'] ?? '';
+
$kid_list = $weapp['kid_list'] ?? [];
$scene_desc = $weapp['scene_desc'] ?? '';
// $res = (new CoreWeappTemplateService())->addTemplate($this->site_id, $tid, $kid_list, $scene_desc);
diff --git a/niucloud/app/service/api/article/ArticleService.php b/niucloud/app/service/api/article/ArticleService.php
index 0c7277caf..78eb0d7f4 100644
--- a/niucloud/app/service/api/article/ArticleService.php
+++ b/niucloud/app/service/api/article/ArticleService.php
@@ -38,7 +38,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';
- $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id'], $where)->with('articleCategory')->field($field)->order($order);
+ $search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id'], $where)->with('articleCategory')->field($field)->order($order)->append(['image_thumb_mid']);
return $this->pageQuery($search_model);
}
@@ -54,7 +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';
- 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();
+ return $this->model->where([ [ 'site_id', '=', $this->site_id ] , ['is_show', '=', 1]])->withSearch([ 'title', 'category_id', 'ids' ], $where)->limit($limit)->with('articleCategory')->field($field)->append(['image_thumb_mid'])->order($order)->select()->toArray();
}
/**
@@ -65,7 +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';
- return $this->model->with('articleCategory')->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
+ return $this->model->with('articleCategory')->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->append(['image_thumb_big'])->findOrEmpty()->toArray();
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/api/login/AuthService.php b/niucloud/app/service/api/login/AuthService.php
index 1e547d531..dfcfb4e78 100644
--- a/niucloud/app/service/api/login/AuthService.php
+++ b/niucloud/app/service/api/login/AuthService.php
@@ -50,14 +50,13 @@ class AuthService extends BaseApiService
* @return true
*/
public function checkSite(Request $request){
- $site_code = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id
- $site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
+ $site_id = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id
+ $site_info = (new CoreSiteService())->getSiteCache($site_id);
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/notice/NoticeService.php b/niucloud/app/service/api/notice/NoticeService.php
index fc662bdb5..1aa8149e5 100644
--- a/niucloud/app/service/api/notice/NoticeService.php
+++ b/niucloud/app/service/api/notice/NoticeService.php
@@ -11,6 +11,7 @@
namespace app\service\api\notice;
+use app\model\sys\SysNotice;
use core\base\BaseApiService;
/**
@@ -36,4 +37,14 @@ class NoticeService extends BaseApiService
{
return ( new \app\service\core\notice\NoticeService() )->send($this->site_id, $key, $data);
}
+
+ /**
+ * 获取微信小程序订阅消息模板id
+ * @param string $keywords
+ * @return void
+ */
+ public function getWeappNoticeTemplateId(string $keys) {
+ $column = (new SysNotice())->where([ ['site_id', '=', $this->site_id], ['key', 'in', explode(',', $keys) ], ['weapp_template_id', '<>', ''], ['is_weapp', '=', 1] ])->column('weapp_template_id');
+ return $column;
+ }
}
\ No newline at end of file
diff --git a/niucloud/app/service/api/upload/UploadService.php b/niucloud/app/service/api/upload/UploadService.php
index 103d03f09..be58b7cb5 100644
--- a/niucloud/app/service/api/upload/UploadService.php
+++ b/niucloud/app/service/api/upload/UploadService.php
@@ -11,9 +11,11 @@
namespace app\service\api\upload;
+use app\dict\sys\FileDict;
use app\dict\sys\StorageDict;
use app\service\core\upload\CoreUploadService;
use core\base\BaseApiService;
+use core\exception\UploadFileException;
/**
* 用户服务层
@@ -54,13 +56,14 @@ class UploadService extends BaseApiService
/**
* 文件上传
* @param $file
- * @param bool $is_local
* @return array
*/
- public function document($file, bool $is_local = false)
+ public function document($file, string $type = '')
{
- $dir = $this->root_path . '/' . 'document' . '/' . $this->site_id . '/' . date('Ym') . '/' . date('d');
+ if(!in_array($type, FileDict::getSceneType()))
+ throw new UploadFileException('UPLOAD_TYPE_ERROR');
+ $dir = $this->root_path.'/document/'.$type.'/'.$this->site_id.'/'.date('Ym').'/'.date('d');
$core_upload_service = new CoreUploadService();
- return $core_upload_service->document($file, $this->site_id, '', $dir, StorageDict::LOCAL);
+ return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL);
}
}
\ No newline at end of file
diff --git a/niucloud/app/service/core/addon/CoreAddonInstallService.php b/niucloud/app/service/core/addon/CoreAddonInstallService.php
index bfbc5730b..7cf636f1f 100644
--- a/niucloud/app/service/core/addon/CoreAddonInstallService.php
+++ b/niucloud/app/service/core/addon/CoreAddonInstallService.php
@@ -40,13 +40,13 @@ class CoreAddonInstallService extends CoreAddonBaseService
'wap' => [],
'resource' => []
];
- //安装流程
+
+ // 安装流程
private $flow_path = [
'file',
'sql',
'menu',
- 'diy',
- ''
+ 'diy'
];
/**
@@ -60,12 +60,12 @@ class CoreAddonInstallService extends CoreAddonBaseService
];
private $addon;
- private $install_addon_path;//待安装的插件目录
+ private $install_addon_path;// 待安装的插件目录
- //对象实例
+ // 对象实例
public static $instance;
- //状态关键字
+ // 状态关键字
const WAIT_INSTALL = 'wait_install';
const DIR_INSTALLED = 'dir_installed';
@@ -73,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';
@@ -101,7 +102,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
return self::$instance;
}
-
public function __construct($addon)
{
parent::__construct();
@@ -122,11 +122,13 @@ class CoreAddonInstallService extends CoreAddonBaseService
$from_web_dir = $this->install_addon_path . "web" . DIRECTORY_SEPARATOR;
$from_wap_dir = $this->install_addon_path . "uni-app" . DIRECTORY_SEPARATOR;
$from_resource_dir = $this->install_addon_path . "resource" . DIRECTORY_SEPARATOR;
+
// 放入的文件
$to_admin_dir = $this->root_path . "admin" . DIRECTORY_SEPARATOR;
$to_web_dir = $this->root_path . "web" . DIRECTORY_SEPARATOR;
$to_wap_dir = $this->root_path . "uni-app" . DIRECTORY_SEPARATOR;
$to_resource_dir = public_path() . "addon" . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
+
// 配置文件
$package_path = $this->install_addon_path . 'package' . DIRECTORY_SEPARATOR;
$package_file = [];
@@ -172,7 +174,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
array_column($data[ 'runtime' ], 'status'),
[ $data[ 'job_normal' ] ]
);
- if (count($data['conflict_files'])) array_push($check_res, false);
+ if (count($data[ 'conflict_files' ])) array_push($check_res, false);
// 是否通过校验
$data[ 'is_pass' ] = !in_array(false, $check_res);
@@ -216,7 +218,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
}
}
-
//检测wap的uniapp文件
if (is_dir($from_wap_dir)) {
search_dir($from_wap_dir, $this->install_files[ "wap" ]);
@@ -441,6 +442,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
$from_web_dir = $this->install_addon_path . "web" . DIRECTORY_SEPARATOR;
$from_wap_dir = $this->install_addon_path . "uni-app" . DIRECTORY_SEPARATOR;
$from_resource_dir = $this->install_addon_path . "resource" . DIRECTORY_SEPARATOR;
+
// 放入的文件
$to_admin_dir = $this->root_path . "admin" . DIRECTORY_SEPARATOR;
$to_web_dir = $this->root_path . "web" . DIRECTORY_SEPARATOR;
@@ -450,6 +452,8 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 安装admin管理端
if (file_exists($from_admin_dir)) {
dir_copy($from_admin_dir, $to_admin_dir, $this->files[ 'admin' ]);
+ // 编译后台图标库文件
+ $this->compileAdminIcon();
}
// 安装电脑端
@@ -466,6 +470,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
if (file_exists($from_resource_dir)) {
dir_copy($from_resource_dir, $to_resource_dir, $this->files[ 'resource' ]);
}
+
$this->state = self::DIR_INSTALLED;
return true;
}
@@ -502,7 +507,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
}
}
Db::commit();
- // 返回订单信息
return true;
} catch (PDOException $e) {
Db::rollback();
@@ -559,16 +563,20 @@ class CoreAddonInstallService extends CoreAddonBaseService
if (empty($core_addon_service->getInfoByKey($this->addon))) throw new AddonException('NOT_UNINSTALL');
if (!$this->uninstallSql()) throw new AddonException();
if (!$this->uninstallDir()) throw new AddonException();
+
// 卸载菜单
$this->uninstallMenu();
+
// 卸载计划任务
$this->uninstallSchedule();
+
// 卸载wap
$this->uninstallWap();
$core_addon_service = new CoreAddonService();
$core_addon_service->delByKey($this->addon);
Cache::set("local_install_addons", []);
+
//清理缓存
Cache::tag(self::$cache_tag_name)->clear();
return true;
@@ -585,12 +593,10 @@ class CoreAddonInstallService extends CoreAddonBaseService
$from_web_dir = $this->install_addon_path . "web" . DIRECTORY_SEPARATOR;
$from_wap_dir = $this->install_addon_path . "uni-app" . DIRECTORY_SEPARATOR;
-
search_dir($from_admin_dir, $from_admin_dirs, $from_admin_dir);
search_dir($from_web_dir, $from_web_dirs, $from_web_dir);
search_dir($from_wap_dir, $from_wap_dirs, $from_wap_dir);
-
// 将要删除的根目录
$to_admin_dir = $this->root_path . "admin" . DIRECTORY_SEPARATOR;
$to_web_dir = $this->root_path . "web" . DIRECTORY_SEPARATOR;
@@ -600,6 +606,8 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 卸载admin管理端
if (file_exists($from_admin_dir)) {
dir_remove($to_admin_dir, $from_admin_dirs ?? []);
+ // 编译后台图标库文件
+ $this->compileAdminIcon();
}
// 卸载pc端
@@ -772,7 +780,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
*/
public function installSchedule()
{
- ( new CoreScheduleInstallService())->installAddonSchedule($this->addon);
+ ( new CoreScheduleInstallService() )->installAddonSchedule($this->addon);
$this->state = self::SCHEDULE_INSTALLED;
return true;
}
@@ -783,7 +791,32 @@ class CoreAddonInstallService extends CoreAddonBaseService
*/
public function uninstallSchedule()
{
- ( new CoreScheduleInstallService())->uninstallAddonSchedule($this->addon);
+ ( new CoreScheduleInstallService() )->uninstallAddonSchedule($this->addon);
+ return true;
+ }
+
+ /**
+ * 编译后台图标库文件
+ * 图标开发注意事项,不能占用 iconfont、icon 关键词(会跟系统图标冲突),建议增加业务前缀,比如 旅游业:tourism
+ * @return bool
+ */
+ public function compileAdminIcon()
+ {
+ $compile_path = $this->root_path . str_replace('/', DIRECTORY_SEPARATOR, 'admin/src/styles/icon/');
+
+ $content = "";
+ $root_path = $compile_path . 'addon'; // 插件图标根目录
+ $file_arr = getFileMap($root_path);
+ if (!empty($file_arr)) {
+ foreach ($file_arr as $ck => $cv) {
+ if (strpos($cv, '.css') !== false) {
+ $path = str_replace($root_path . '/', '', $ck);
+ $path = str_replace('/.css', '', $path);
+ $content .= "@import \"addon/{$path}\";\n";
+ }
+ }
+ }
+ $res = file_put_contents($compile_path . 'addon-iconfont.css', $content);
return true;
}
diff --git a/niucloud/app/service/core/addon/WapTrait.php b/niucloud/app/service/core/addon/WapTrait.php
index b6efe10eb..03f9858d8 100644
--- a/niucloud/app/service/core/addon/WapTrait.php
+++ b/niucloud/app/service/core/addon/WapTrait.php
@@ -35,6 +35,7 @@ trait WapTrait
$content .= " \n";
+ $content .= " \n";
$root_path = $compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'components/diy'); // 扩展组件根目录
$file_arr = getFileMap($root_path);
@@ -58,9 +59,9 @@ trait WapTrait
$name = implode('', $name_arr);
$file_name = 'diy-' . $path;
- $content .= " \n";
- $content .= " <$file_name :component=\"component\" :index=\"index\">$file_name>\n";
- $content .= " \n";
+ $content .= " \n";
+ $content .= " <$file_name :component=\"component\" :index=\"index\" :pullDownRefresh=\"props.pullDownRefresh\">$file_name>\n";
+ $content .= " \n";
}
}
}
@@ -75,11 +76,11 @@ trait WapTrait
$content .= "\n";
$content .= "