From 504b4c96a84a1c25cf5ae2dcb9cb268be9aab96a 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: Fri, 20 Mar 2026 15:59:18 +0800
Subject: [PATCH] up
---
.../app/adminapi/controller/addon/Addon.php | 76 +++----
.../app/adminapi/controller/notice/NiuSms.php | 26 +--
.../app/adminapi/controller/sys/Config.php | 6 +-
.../app/adminapi/controller/sys/Ueditor.php | 2 -
.../app/adminapi/controller/user/User.php | 66 +-----
niucloud/app/adminapi/route/addon.php | 2 -
niucloud/app/adminapi/route/notice.php | 1 -
niucloud/app/adminapi/route/sys.php | 11 +-
niucloud/app/api/controller/sys/Index.php | 28 ---
niucloud/app/api/controller/upload/Upload.php | 34 +++
niucloud/app/api/middleware/ApiCheckToken.php | 2 +-
niucloud/app/api/route/file.php | 1 +
niucloud/app/api/route/pay.php | 1 -
niucloud/app/command/Addon/Install.php | 2 +-
niucloud/app/command/Addon/Uninstall.php | 2 +-
niucloud/app/command/refreshAreaCommand.php | 2 +-
niucloud/app/common.php | 28 ++-
niucloud/app/dict/common/CommonActiveDict.php | 35 ++-
.../app/dict/member/account_change_type.php | 12 +
niucloud/app/dict/menu/admin.php | 12 +-
niucloud/app/dict/notice/NoticeTypeDict.php | 34 +--
niucloud/app/dict/pay/PayChannelDict.php | 4 +
niucloud/app/dict/schedule/schedule.php | 22 +-
niucloud/app/install/controller/Index.php | 12 +-
niucloud/app/install/source/database.sql | 15 +-
niucloud/app/install/view/index/step-3.html | 15 +-
.../app/job/schedule/AutoClearLogFiles.php | 163 ++++++++++++++
.../job/schedule/AutoClearPosterAndQrcode.php | 74 +++++--
.../wxoplatform/GetVersionUploadResult.php | 34 ---
.../job/wxoplatform/VersionUploadSuccess.php | 34 ---
niucloud/app/lang/en/api.php | 2 +-
niucloud/app/lang/zh-cn/api.php | 7 +-
.../listener/member/MemberLoginListener.php | 3 +-
.../app/listener/pay/PayNotifyListener.php | 3 +-
.../app/service/admin/addon/AddonService.php | 205 ++++--------------
.../app/service/admin/auth/AuthService.php | 34 +++
.../app/service/admin/auth/LoginService.php | 8 +-
niucloud/app/service/admin/diy/DiyService.php | 43 ++--
.../admin/generator/GenerateService.php | 2 +-
.../generator/core/AdminApiRouteGenerator.php | 2 +-
.../admin/generator/core/WebEditGenerator.php | 12 +-
.../generator/core/WebEditPageGenerator.php | 6 +-
.../generator/core/WebIndexGenerator.php | 4 +-
.../service/admin/member/AddressService.php | 1 -
.../service/admin/member/MemberService.php | 27 ++-
.../admin/member/MemberSignService.php | 17 +-
.../admin/niucloud/NiucloudService.php | 2 +
.../service/admin/notice/NiuSmsService.php | 47 +++-
.../app/service/admin/pay/RefundService.php | 8 +-
.../app/service/admin/sys/ConfigService.php | 10 +-
.../app/service/admin/sys/PosterService.php | 12 +-
.../app/service/admin/sys/RoleService.php | 4 +-
.../service/admin/upgrade/UpgradeService.php | 97 +++++++--
.../admin/weapp/WeappVersionService.php | 2 -
.../admin/wechat/WechatTemplateService.php | 5 +-
niucloud/app/service/api/diy/DiyService.php | 6 +-
.../app/service/api/login/AuthService.php | 6 +-
.../app/service/api/sys/ConfigService.php | 28 ++-
.../service/api/weapp/WeappAuthService.php | 3 +-
.../service/api/wechat/WechatAuthService.php | 15 +-
.../core/addon/CoreAddonInstallService.php | 4 +-
.../service/core/addon/CoreAddonService.php | 18 +-
niucloud/app/service/core/addon/WapTrait.php | 22 +-
.../service/core/channel/CoreAppService.php | 21 --
.../app/service/core/diy/CoreDiyService.php | 2 +-
.../app/service/core/map/CoreMapService.php | 99 +++++++++
.../core/member/CoreMemberAccountService.php | 6 +-
.../service/core/niucloud/CoreAuthService.php | 5 +
.../core/niucloud/CoreCloudBuildService.php | 6 +-
.../app/service/core/notice/NoticeService.php | 17 +-
.../app/service/core/pay/CorePayService.php | 9 +-
.../core/pay/CoreTransferSceneService.php | 10 +-
.../service/core/pay/CoreTransferService.php | 2 -
.../core/sys/CoreAttachmentService.php | 27 ++-
.../service/core/sys/CoreExportService.php | 18 +-
.../core/weapp/CoreWeappCloudService.php | 8 +-
.../core/wechat/CoreWechatServeService.php | 5 +-
niucloud/app/upgrade/v158/Upgrade.php | 85 ++++++++
niucloud/app/upgrade/v158/upgrade.sql | 2 +
niucloud/config/console.php | 6 +-
niucloud/config/version.php | 4 +-
niucloud/core/pay/Alipay.php | 8 +-
niucloud/core/pay/Wechatpay.php | 3 +-
niucloud/core/sms/Niuyun.php | 2 +-
niucloud/core/template/Weapp.php | 12 +-
niucloud/core/util/http/HttpClient.php | 100 +++++++++
.../core/util/http/src/HasHttpRequests.php | 183 ++++++++++++++++
niucloud/core/util/niucloud/CloudService.php | 3 +
.../core/util/niucloud/http/AccessToken.php | 8 +-
.../util/niucloud/http/HasHttpRequests.php | 5 +-
90 files changed, 1390 insertions(+), 687 deletions(-)
delete mode 100644 niucloud/app/api/controller/sys/Index.php
create mode 100644 niucloud/app/job/schedule/AutoClearLogFiles.php
delete mode 100644 niucloud/app/job/wxoplatform/GetVersionUploadResult.php
delete mode 100644 niucloud/app/job/wxoplatform/VersionUploadSuccess.php
create mode 100644 niucloud/app/service/core/map/CoreMapService.php
create mode 100644 niucloud/app/upgrade/v158/Upgrade.php
create mode 100644 niucloud/app/upgrade/v158/upgrade.sql
create mode 100644 niucloud/core/util/http/HttpClient.php
create mode 100644 niucloud/core/util/http/src/HasHttpRequests.php
diff --git a/niucloud/app/adminapi/controller/addon/Addon.php b/niucloud/app/adminapi/controller/addon/Addon.php
index 7bdb7981e..97075ffb4 100644
--- a/niucloud/app/adminapi/controller/addon/Addon.php
+++ b/niucloud/app/adminapi/controller/addon/Addon.php
@@ -34,7 +34,7 @@ class Addon extends BaseAdminController
*/
public function init()
{
- return success((new CoreAddonService())->getInitList());
+ return success(( new CoreAddonService() )->getInitList());
}
/**
@@ -43,7 +43,7 @@ class Addon extends BaseAdminController
*/
public function getLocalAddonList()
{
- return success((new CoreAddonService())->getLocalAddonList());
+ return success(( new CoreAddonService() )->getLocalAddonList());
}
/**
@@ -53,7 +53,7 @@ class Addon extends BaseAdminController
*/
public function install($addon)
{
- return success((new AddonService())->install($addon));
+ return success(( new AddonService() )->install($addon));
}
/**
@@ -64,7 +64,7 @@ class Addon extends BaseAdminController
*/
public function cloudInstall($addon)
{
- return success(data:(new AddonService())->cloudInstall($addon));
+ return success(data: ( new AddonService() )->cloudInstall($addon));
}
/**
@@ -72,8 +72,9 @@ class Addon extends BaseAdminController
* @description 获取安装任务
* @return Response
*/
- public function getInstallTask() {
- return success(data:(new AddonService())->getInstallTask());
+ public function getInstallTask()
+ {
+ return success(data: ( new AddonService() )->getInstallTask());
}
/**
@@ -82,8 +83,9 @@ class Addon extends BaseAdminController
* @param $addon
* @return mixed
*/
- public function cloudInstallLog($addon) {
- return success(data:(new AddonService())->cloudInstallLog($addon));
+ public function cloudInstallLog($addon)
+ {
+ return success(data: ( new AddonService() )->cloudInstallLog($addon));
}
/**
@@ -94,7 +96,7 @@ class Addon extends BaseAdminController
*/
public function installCheck($addon)
{
- return success(data:(new AddonService())->installCheck($addon));
+ return success(data: ( new AddonService() )->installCheck($addon));
}
/**
@@ -105,7 +107,7 @@ class Addon extends BaseAdminController
*/
public function cancleInstall($addon)
{
- return success(data:(new AddonService())->cancleInstall($addon));
+ return success(data: ( new AddonService() )->cancleInstall($addon));
}
/**
@@ -115,7 +117,7 @@ class Addon extends BaseAdminController
*/
public function uninstall($addon)
{
- (new AddonService())->uninstall($addon);
+ ( new AddonService() )->uninstall($addon);
return success('ADDON_UNINSTALL_SUCCESS');
}
@@ -127,7 +129,7 @@ class Addon extends BaseAdminController
*/
public function uninstallCheck($addon)
{
- return success(data:(new AddonService())->uninstallCheck($addon));
+ return success(data: ( new AddonService() )->uninstallCheck($addon));
}
/**
@@ -138,9 +140,9 @@ class Addon extends BaseAdminController
public function lists()
{
$data = $this->request->params([
- ['title', ''],
+ [ 'title', '' ],
]);
- return success((new AddonService())->getPage($data));
+ return success(( new AddonService() )->getPage($data));
}
/**
@@ -151,7 +153,7 @@ class Addon extends BaseAdminController
*/
public function info(int $id)
{
- return success((new AddonService())->getInfo($id));
+ return success(( new AddonService() )->getInfo($id));
}
/**
@@ -163,7 +165,7 @@ class Addon extends BaseAdminController
*/
public function setStatus(int $id, int $status)
{
- (new AddonService())->setStatus($id, $status);
+ ( new AddonService() )->setStatus($id, $status);
return success('SET_SUCCESS');
}
@@ -173,11 +175,12 @@ class Addon extends BaseAdminController
* @param $addon
* @return Response
*/
- public function download($addon){
+ public function download($addon)
+ {
$data = $this->request->params([
- ['version', '']
+ [ 'version', '' ]
]);
- (new AddonService())->download($addon, $data['version']);
+ ( new AddonService() )->download($addon, $data[ 'version' ]);
return success('DOWNLOAD_SUCCESS');
}
@@ -186,8 +189,9 @@ class Addon extends BaseAdminController
* @description 查询已安装插件
* @return Response
*/
- public function getInstallList(){
- return success(data:(new AddonService())->getInstallList());
+ public function getInstallList()
+ {
+ return success(data: ( new AddonService() )->getInstallList());
}
/**
@@ -196,7 +200,7 @@ class Addon extends BaseAdminController
*/
public function getAddonList()
{
- return success((new CoreAddonService())->getInstallAddonList());
+ return success(( new CoreAddonService() )->getInstallAddonList());
}
/**
@@ -204,7 +208,8 @@ class Addon extends BaseAdminController
* @description 插件类型
* @return Response
*/
- public function getType(){
+ public function getType()
+ {
return success(AddonDict::getType());
}
@@ -214,32 +219,23 @@ class Addon extends BaseAdminController
* @param $addon
* @return Response
*/
- public function upgrade($addon = ''){
- return success('DOWNLOAD_SUCCESS', (new AddonService())->upgrade($addon));
- }
-
- public function showApp()
+ public function upgrade($addon = '')
{
- return success(data:(new AddonService())->getShowAppTools());
+ return success('DOWNLOAD_SUCCESS', ( new AddonService() )->upgrade($addon));
}
- public function showMarketing()
- {
- return success(( new AddonService() )->getShowMarketingTools());
- }
-
-
/**
* 统一展示 安装的插件 应用 营销工具等。。
* @return Response
*/
public function showCustomer()
{
- return success((new AddonService())->showCustomer());
+ return success(( new AddonService() )->showCustomer());
}
+
public function getSpecialMenuList()
{
- return success('SUCCESS', (new AddonService())->getSpecialMenuList());
+ return success('SUCCESS', ( new AddonService() )->getSpecialMenuList());
}
@@ -249,7 +245,7 @@ class Addon extends BaseAdminController
*/
public function getIndexAddonLabelList()
{
- return success((new CoreAddonService())->getIndexAddonLabelList());
+ return success(( new CoreAddonService() )->getIndexAddonLabelList());
}
/**
@@ -260,9 +256,9 @@ class Addon extends BaseAdminController
public function getIndexAddonList()
{
$data = $this->request->params([
- ['label_id', ''],
+ [ 'label_id', '' ],
]);
- return success((new CoreAddonService())->getIndexAddonList($data['label_id']));
+ return success(( new CoreAddonService() )->getIndexAddonList($data[ 'label_id' ]));
}
}
diff --git a/niucloud/app/adminapi/controller/notice/NiuSms.php b/niucloud/app/adminapi/controller/notice/NiuSms.php
index e3f6c2a2e..d19428acb 100644
--- a/niucloud/app/adminapi/controller/notice/NiuSms.php
+++ b/niucloud/app/adminapi/controller/notice/NiuSms.php
@@ -208,23 +208,6 @@ class NiuSms extends BaseAdminController
return success($data);
}
- /**
- * 忘记密码
- * @description 忘记密码
- * @param $username
- * @return Response
- */
- public function forgetPassword($username)
- {
- $params = $this->request->params([
- ['mobile', ''],
- ['code', ''],
- ['key', ''],
- ]);
- $data = (new NiuSmsService())->forgetPassword($username, $params);
- return success($data);
- }
-
/**
* 签名列表
* @description 签名列表
@@ -281,6 +264,15 @@ class NiuSms extends BaseAdminController
['signType', ""],
['imgUrl', ""],
['defaultSign', 0],
+
+ //新增字段
+ ['bizLicenseUrl', ''],
+ ['qccUrl', ''],
+ ['tmnetUrl', ''],
+ ['mobileIcpUrl', ''],
+ ['telecomAppstoreUrl', ''],
+ ['idcardFrontUrl', ''],
+ ['idcardBackUrl', ''],
]);
(new NiuSmsService())->signCreate($username, $params);
return success("SUCCESS");
diff --git a/niucloud/app/adminapi/controller/sys/Config.php b/niucloud/app/adminapi/controller/sys/Config.php
index 464c86306..1577cc4f0 100644
--- a/niucloud/app/adminapi/controller/sys/Config.php
+++ b/niucloud/app/adminapi/controller/sys/Config.php
@@ -58,9 +58,9 @@ class Config extends BaseAdminController
[ "front_end_logo", "" ],
[ "front_end_icon", "" ],
[ "icon", "" ],
- [ "meta_title", "" ],
- [ "meta_desc", "" ],
- [ "meta_keyword", "" ],
+ [ "meta_title", "" ], // Meta 标题
+ [ "meta_desc", "" ], // Meta 描述
+ [ "meta_keyword", "" ], // Meta 关键字
]);
( new ConfigService() )->setWebSite($data);
diff --git a/niucloud/app/adminapi/controller/sys/Ueditor.php b/niucloud/app/adminapi/controller/sys/Ueditor.php
index 910dc3d1f..4e125748f 100644
--- a/niucloud/app/adminapi/controller/sys/Ueditor.php
+++ b/niucloud/app/adminapi/controller/sys/Ueditor.php
@@ -128,7 +128,6 @@ class Ueditor extends BaseAdminController
'title' => $upload_res['url'],
'original' => $upload_res['url'],
], 'json', 200);
- break;
case 'video':
$upload_res = $upload_service->video($data['file']);
return Response::create([
@@ -137,7 +136,6 @@ class Ueditor extends BaseAdminController
'title' => $upload_res['url'],
'original' => $upload_res['url'],
], 'json', 200);
- break;
}
}
}
diff --git a/niucloud/app/adminapi/controller/user/User.php b/niucloud/app/adminapi/controller/user/User.php
index f9f05a3f6..4f05af13f 100644
--- a/niucloud/app/adminapi/controller/user/User.php
+++ b/niucloud/app/adminapi/controller/user/User.php
@@ -36,6 +36,8 @@ class User extends BaseAdminController
['realname', ''],
['role', ''],
['create_time', []],
+ ['real_name', ''],
+ ['last_time', []]
]);
$list = (new UserService())->getPage($data);
@@ -129,6 +131,7 @@ class User extends BaseAdminController
['mobile', ''],
['real_name', ''],
['head_img', ''],
+ ['role_ids', []],
]);
(new UserService())->edit($uid, $data);
return success();
@@ -144,67 +147,4 @@ class User extends BaseAdminController
(new UserService())->del($uid);
return success("DELETE_SUCCESS");
}
-
- /**
- * 获取用户站点创建限制
- * @description 获取用户站点创建限制
- * @param $uid
- * @return Response
- */
- public function getUserCreateSiteLimit($uid){
- return success(data:(new UserService())->getUserCreateSiteLimit($uid));
- }
-
- /**
- * 获取用户站点创建限制
- * @description 获取用户站点创建限制
- * @param $id
- * @return Response
- */
- public function getUserCreateSiteLimitInfo($id){
- return success(data:(new UserService())->getUserCreateSiteLimitInfo($id));
- }
-
- /**
- * 添加用户站点创建限制
- * @description 添加用户站点创建限制
- * @param $uid
- * @return Response
- */
- public function addUserCreateSiteLimit($uid){
- $data = $this->request->params([
- ['uid', 0],
- ['group_id', 0],
- ['num', 1],
- ['month', 1],
- ]);
- (new UserService())->addUserCreateSiteLimit($data);
- return success('SUCCESS');
- }
-
- /**
- * 编辑用户站点创建限制
- * @description 编辑用户站点创建限制
- * @param $id
- * @return Response
- */
- public function editUserCreateSiteLimit($id){
- $data = $this->request->params([
- ['num', 1],
- ['month', 1],
- ]);
- (new UserService())->editUserCreateSiteLimit($id, $data);
- return success('SUCCESS');
- }
-
- /**
- * 删除用户站点创建限制
- * @description 删除用户站点创建限制
- * @param $id
- * @return Response
- */
- public function delUserCreateSiteLimit($id){
- (new UserService())->delUserCreateSiteLimit($id);
- return success('SUCCESS');
- }
}
diff --git a/niucloud/app/adminapi/route/addon.php b/niucloud/app/adminapi/route/addon.php
index 836e2f6d2..8eb020e16 100644
--- a/niucloud/app/adminapi/route/addon.php
+++ b/niucloud/app/adminapi/route/addon.php
@@ -92,7 +92,5 @@ Route::group(function () {
Route::group(function () {
//获取已安装插件列表
Route::get('addon/list/install', 'addon.Addon/getInstallList');
- Route::get('addon/list/showApp', 'addon.Addon/showApp');
- Route::get('showMarketing', 'addon.Addon/showMarketing');
});
diff --git a/niucloud/app/adminapi/route/notice.php b/niucloud/app/adminapi/route/notice.php
index 1bcff5e2a..614229ceb 100644
--- a/niucloud/app/adminapi/route/notice.php
+++ b/niucloud/app/adminapi/route/notice.php
@@ -58,7 +58,6 @@ Route::group('notice', function () {
Route::post('login', 'notice.NiuSms/loginAccount');
Route::post('edit/:username', 'notice.NiuSms/editAccount');
Route::post('reset/password/:username', 'notice.NiuSms/resetPassword');
- Route::post('forget/password/:username', 'notice.NiuSms/forgetPassword');
Route::get('send_list/:username', 'notice.NiuSms/accountSendList');
Route::get('info/:username', 'notice.NiuSms/accountInfo');
});
diff --git a/niucloud/app/adminapi/route/sys.php b/niucloud/app/adminapi/route/sys.php
index 72fd159c2..8b4938b8c 100644
--- a/niucloud/app/adminapi/route/sys.php
+++ b/niucloud/app/adminapi/route/sys.php
@@ -82,8 +82,6 @@ Route::group('sys', function() {
//地图设置
Route::put('config/map', 'sys.Config/setMap');
- //地图设置
- Route::get('config/map', 'sys.Config/getMap');
//登录注册设置
Route::get('config/login', 'login.Config/getConfig');
@@ -343,6 +341,15 @@ Route::group('sys', function() {
AdminLog::class
]);
+//系统环境(不效验登录状态)
+Route::group('sys', function() {
+ //地图设置
+ Route::get('config/map', 'sys.Config/getMap');
+})->middleware([
+ AdminCheckToken::class,
+ AdminLog::class
+]);
+
//系统环境(不效验登录状态)
Route::group('sys', function() {
Route::get('web/website', 'sys.Config/getWebsite');
diff --git a/niucloud/app/api/controller/sys/Index.php b/niucloud/app/api/controller/sys/Index.php
deleted file mode 100644
index 39a131f5c..000000000
--- a/niucloud/app/api/controller/sys/Index.php
+++ /dev/null
@@ -1,28 +0,0 @@
-*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }
| *数据库名称: |
@@ -224,7 +230,14 @@
type: "post",
dataType: 'json',
success: function(data){
- inputBoxPointer('dbpwdsta').innerHTML = data.data.message;
+ if (data.data.status == -2) {
+ inputBoxPointer('dbpwdsta').innerHTML = '数据库连接成功'
+ $('.sql-mode-error .message').text(data.data.message)
+ $('.sql-mode-error').show()
+ } else {
+ $('.sql-mode-error').hide()
+ inputBoxPointer('dbpwdsta').innerHTML = data.data.message;
+ }
is_existdb = data.data.status;
message = data.data.message;
}
diff --git a/niucloud/app/job/schedule/AutoClearLogFiles.php b/niucloud/app/job/schedule/AutoClearLogFiles.php
new file mode 100644
index 000000000..49b4b560b
--- /dev/null
+++ b/niucloud/app/job/schedule/AutoClearLogFiles.php
@@ -0,0 +1,163 @@
+clearDirectory($abs_dir);
+ }
+
+ Log::write('AutoClearLogFiles 定时清理日志文件完成 ' . date('Y-m-d H:i:s'));
+ return true;
+ } catch (\Exception $e) {
+ Log::write('AutoClearLogFiles 定时清除异常: ' . $e->getMessage() . ' 位置: ' . $e->getFile() . ':' . $e->getLine() . $e->getTraceAsString());
+ return false;
+ }
+ }
+
+ /**
+ * 清空指定目录下一周前的日志文件和空的子目录
+ *
+ * @param string $directory 目录路径
+ * @param bool $preserveDirectory 是否保留根目录(默认保留)
+ * @return bool 是否成功执行
+ */
+ function clearDirectory(string $directory, bool $preserveDirectory = true): bool
+ {
+ // 规范化目录路径,统一使用DIRECTORY_SEPARATOR
+ $directory = rtrim(realpath($directory), DIRECTORY_SEPARATOR);
+
+ Log::write('AutoClearLogFiles开始清理目录: ' . $directory);
+
+ // 检查目录是否存在
+ if (!is_dir($directory)) {
+ Log::write('AutoClearLogFiles目录不存在或不是有效目录: ' . $directory);
+ return false;
+ }
+
+ // 计算一周前的时间戳(7天 = 7*24*60*60 = 604800秒)
+ $one_week_ago = time() - 604800;
+
+ // 打开目录
+ $handle = opendir($directory);
+ if (!$handle) {
+ Log::write('AutoClearLogFiles无法打开目录: ' . $directory);
+ return false;
+ }
+
+ // 遍历目录内容
+ while (($entry = readdir($handle)) !== false) {
+ // 跳过当前目录和上级目录
+ if ($entry === '.' || $entry === '..') {
+ continue;
+ }
+
+ // 使用DIRECTORY_SEPARATOR确保路径分隔符正确
+ $path = $directory . DIRECTORY_SEPARATOR . $entry;
+
+ // 递归处理子目录
+ if (is_dir($path)) {
+ // 递归清理子目录(只删一周前文件,保留子目录本身)
+ if (!$this->clearDirectory($path, true)) {
+ Log::write('AutoClearLogFiles递归清理子目录失败: ' . $path);
+ closedir($handle);
+ return false;
+ }
+
+ // 检查子目录是否为空,若为空则删除
+ $isEmpty = true;
+ $sub_handle = opendir($path);
+ while (($sub_entry = readdir($sub_handle)) !== false) {
+ if ($sub_entry !== '.' && $sub_entry !== '..') {
+ $isEmpty = false;
+ break;
+ }
+ }
+ closedir($sub_handle);
+
+ if ($isEmpty && !$preserveDirectory) {
+ if (!rmdir($path)) {
+ Log::write('AutoClearLogFiles删除空目录失败: ' . $path);
+ } else {
+ Log::write('AutoClearLogFiles已删除空目录: ' . $path);
+ }
+ }
+ } else {
+ // 过滤日志文件(可选:只清理.log后缀的文件,避免误删其他类型文件)
+ $file_ext = pathinfo($path, PATHINFO_EXTENSION);
+ if ($file_ext !== 'log') {
+ Log::write('AutoClearLogFiles跳过非日志文件: ' . $path);
+ continue;
+ }
+
+ // 获取文件的最后修改时间
+ $file_time = filemtime($path);
+
+ // 校验:文件时间有效 且 早于/等于一周前
+ if ($file_time !== false && $file_time <= $one_week_ago) {
+ // 删除一周前的日志文件
+ if (!unlink($path)) {
+ Log::write('AutoClearLogFiles删除日志文件失败: ' . $path);
+ closedir($handle);
+ return false;
+ }
+ Log::write('AutoClearLogFiles已删除一周前的日志文件: ' . $path);
+ } else {
+ // 跳过近期日志文件
+ Log::write('AutoClearLogFiles跳过近期日志文件: ' . $path);
+ }
+ }
+ }
+
+ // 关闭目录句柄
+ closedir($handle);
+
+ // 根目录是否删除(默认保留,避免目录丢失)
+ if (!$preserveDirectory) {
+ Log::write('AutoClearLogFiles准备删除根目录: ' . $directory);
+ if (!rmdir($directory)) {
+ Log::write('AutoClearLogFiles删除根目录失败: ' . $directory);
+ return false;
+ }
+ Log::write('AutoClearLogFiles成功删除根目录: ' . $directory);
+ } else {
+ Log::write('AutoClearLogFiles保留根目录: ' . $directory);
+ }
+
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/niucloud/app/job/schedule/AutoClearPosterAndQrcode.php b/niucloud/app/job/schedule/AutoClearPosterAndQrcode.php
index 7c7d1edc4..c8447dee9 100644
--- a/niucloud/app/job/schedule/AutoClearPosterAndQrcode.php
+++ b/niucloud/app/job/schedule/AutoClearPosterAndQrcode.php
@@ -24,16 +24,14 @@ class AutoClearPosterAndQrcode extends BaseJob
{
Log::write('AutoClearPosterAndQrcode 定时清除 二维码及海报数据开始' . date('Y-m-d H:i:s'));
try {
- // 清理海报目录
- $dir = 'upload/poster';
- $dir = public_path($dir);
- $res = $this->clearDirectory($dir);
-
- // 清理二维码目录
- $qrcode_dir = 'upload/qrcode';
- $qrcode_dir = public_path($qrcode_dir);
- $res = $this->clearDirectory($qrcode_dir);
-
+ $dirs = [
+ 'upload/poster',
+ 'upload/qrcode',
+ ];
+ foreach ($dirs as $dir) {
+ $dir = public_path($dir);
+ $res = $this->clearDirectory($dir);
+ }
return true;
} catch (\Exception $e) {
Log::write('AutoClearPosterAndQrcode 定时清除异常: ' . $e->getMessage() . ' 位置: ' . $e->getFile() . ':' . $e->getLine() . $e->getTraceAsString());
@@ -42,7 +40,7 @@ class AutoClearPosterAndQrcode extends BaseJob
}
/**
- * 清空指定目录下的所有文件和子目录
+ * 清空指定目录下一周前的文件和空的子目录
*
* @param string $directory 目录路径
* @param bool $preserveDirectory 是否保留根目录(默认保留)
@@ -61,6 +59,9 @@ class AutoClearPosterAndQrcode extends BaseJob
return false;
}
+ // 计算一周前的时间戳(7天 = 7*24*60*60 = 604800秒)
+ $one_week_ago = time() - 604800;
+
// 打开目录
$handle = opendir($directory);
if (!$handle) {
@@ -80,20 +81,47 @@ class AutoClearPosterAndQrcode extends BaseJob
// 递归处理子目录
if (is_dir($path)) {
- // 递归清空子目录
- if (!$this->clearDirectory($path, false)) {
+ // 递归清理子目录(只删一周前文件,保留子目录本身)
+ if (!$this->clearDirectory($path, true)) {
Log::write('AutoClearPosterAndQrcode递归清理子目录失败: ' . $path);
closedir($handle);
return false;
}
- Log::write('AutoClearPosterAndQrcode已递归删除子目录: ' . $path);
- // 子目录已经在递归调用中被删除,不需要再次删除
+
+ // 检查子目录是否为空,若为空则删除(可选逻辑,根据需求调整)
+ $isEmpty = true;
+ $sub_handle = opendir($path);
+ while (($sub_entry = readdir($sub_handle)) !== false) {
+ if ($sub_entry !== '.' && $sub_entry !== '..') {
+ $isEmpty = false;
+ break;
+ }
+ }
+ closedir($sub_handle);
+
+ if ($isEmpty && !$preserveDirectory) {
+ if (!rmdir($path)) {
+ Log::write('AutoClearPosterAndQrcode删除空目录失败: ' . $path);
+ } else {
+ Log::write('AutoClearPosterAndQrcode已删除空目录: ' . $path);
+ }
+ }
} else {
- // 删除文件
- if (!unlink($path)) {
- Log::write('AutoClearPosterAndQrcode删除文件失败: ' . $path);
- closedir($handle);
- return false;
+ // 获取文件的创建/修改时间(优先用修改时间filemtime,更贴合业务)
+ $file_time = filemtime($path);
+
+ // 校验:文件时间有效 且 早于一周前
+ if ($file_time !== false && $file_time <= $one_week_ago) {
+ // 删除一周前的文件
+ if (!unlink($path)) {
+ Log::write('AutoClearPosterAndQrcode删除文件失败: ' . $path);
+ closedir($handle);
+ return false;
+ }
+ Log::write('AutoClearPosterAndQrcode已删除一周前的文件: ' . $path);
+ } else {
+ // 跳过近期文件,记录日志(可选)
+ Log::write('AutoClearPosterAndQrcode跳过近期文件: ' . $path);
}
}
}
@@ -101,7 +129,7 @@ class AutoClearPosterAndQrcode extends BaseJob
// 关闭目录句柄
closedir($handle);
- // 是否删除根目录本身
+ // 根目录是否删除(默认保留,避免目录丢失)
if (!$preserveDirectory) {
Log::write('AutoClearPosterAndQrcode准备删除根目录: ' . $directory);
if (!rmdir($directory)) {
@@ -115,6 +143,4 @@ class AutoClearPosterAndQrcode extends BaseJob
return true;
}
-
-
-}
+}
\ No newline at end of file
diff --git a/niucloud/app/job/wxoplatform/GetVersionUploadResult.php b/niucloud/app/job/wxoplatform/GetVersionUploadResult.php
deleted file mode 100644
index 9097bf09c..000000000
--- a/niucloud/app/job/wxoplatform/GetVersionUploadResult.php
+++ /dev/null
@@ -1,34 +0,0 @@
- '附件组中存在图片不允许删除',
'OSS_TYPE_NOT_EXIST' => '云存储类型不存在',
'URL_FILE_NOT_EXIST' => '获取不到网址指向的文件',
- 'PLEACE_SELECT_IMAGE' => '请选择要删除的图片',
+ 'PLEASE_SELECT_IMAGE' => '请选择要删除的图片',
'UPLOAD_TYPE_ERROR' => '不是有效的上传类型',
diff --git a/niucloud/app/lang/zh-cn/api.php b/niucloud/app/lang/zh-cn/api.php
index b02b8e6dd..8e4091826 100644
--- a/niucloud/app/lang/zh-cn/api.php
+++ b/niucloud/app/lang/zh-cn/api.php
@@ -67,6 +67,7 @@ return [
'CLOUD_BUILD_AUTH_CODE_NOT_FOUND' => '请先填写授权码',
'TASK_CYCLE_ERROR' => '任务周期填写错误',
'UPGRADE_TASK_EXIST' => '有正在执行的升级任务,可以展开正在升级的任务,也可以在开发>更新缓存中清除缓存重新开始升级',
+ 'ZIP_ARCHIVE_NOT_EXIST' => '请先安装或启用zip扩展',
//登录注册重置账号....
'LOGIN_SUCCESS' => '登录成功',
@@ -79,7 +80,6 @@ return [
'OLD_PASSWORD_ERROR' => '原始密码不正确',
'MOBILE_LOGIN_UNOPENED' => '手机号登录注册未开启',
'APP_TYPE_NOT_EXIST' => '无效的登录端口',
- "USER_NOT_ALLOW_DEL" => "该用户是一些站点的管理员不允许删除",
"SUPER_ADMIN_NOT_ALLOW_DEL" => "超级管理员不允许删除",
//用户组权限
@@ -112,7 +112,7 @@ return [
'ATTACHMENT_GROUP_HAS_IMAGE' => '附件组中存在图片不允许删除',
'OSS_TYPE_NOT_EXIST' => '云存储类型不存在',
'URL_FILE_NOT_EXIST' => '获取不到网址指向的文件',
- 'PLEACE_SELECT_IMAGE' => '请选择要删除的图片',
+ 'PLEASE_SELECT_IMAGE' => '请选择要删除的图片',
'UPLOAD_TYPE_ERROR' => '不是有效的上传类型',
'OSS_FILE_URL_NOT_EXIST' => '远程资源文件地址不能为空',
'BASE_IMAGE_FILE_NOT_EXIST' => 'base图片资源不能为空',
@@ -218,6 +218,7 @@ return [
'WEAPP_NOT_EXIST' => '微信小程序未配置完善',
'WEAPP_EMPOWER_NOT_EXIST' => '微信小程序授信信息不存在',
'WEAPP_EMPOWER_TEL_NOT_EXIST' => '微信小程序授信手机号不存在',
+ 'CURR_SITE_IS_NOT_OPEN_SSL' => '微信小程序请求地址只支持https请先配置ssl',
'WECHAT_MINI_PROGRAM_CODE_GENERATION_FAILED' => '微信小程序码生成失败',
@@ -329,8 +330,6 @@ return [
/********************************************************* 微信开放平台 **************************************/
'WECHAT_OPLATFORM_NOT_EXIST' => '未配置微信开放平台',
- 'WEAPP_EXIST' => '该小程序已经授权给其他站点',
- 'WECHAT_EXIST' => '该公众号已经授权给其他站点',
'NOT_YET_PRESENT_TEMPLATE_LIBRARY' => '平台尚未上传小程序到模板库',
'WEAPP_VERSION_NOT_EXIST' => '未获取到小程序版本提交记录',
'NOT_ALLOWED_CANCEL_AUDIT' => '只有审核中的才可以撤回',
diff --git a/niucloud/app/listener/member/MemberLoginListener.php b/niucloud/app/listener/member/MemberLoginListener.php
index b21c91d17..67772186d 100644
--- a/niucloud/app/listener/member/MemberLoginListener.php
+++ b/niucloud/app/listener/member/MemberLoginListener.php
@@ -25,8 +25,7 @@ class MemberLoginListener
public function handle(object $member)
{
// 新人专享活动
- event("MemberLoginAfter", [ 'member_id' => $member[ 'member_id' ] ]);
- return;
+ event("MemberLoginAfter", ['member_id' => $member['member_id']]);
}
}
\ No newline at end of file
diff --git a/niucloud/app/listener/pay/PayNotifyListener.php b/niucloud/app/listener/pay/PayNotifyListener.php
index 5c2fe76bf..7254fb9b8 100644
--- a/niucloud/app/listener/pay/PayNotifyListener.php
+++ b/niucloud/app/listener/pay/PayNotifyListener.php
@@ -20,6 +20,5 @@ class PayNotifyListener
{
public function handle($member)
{
- return;
}
-}
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/addon/AddonService.php b/niucloud/app/service/admin/addon/AddonService.php
index fe71f897d..3ca328271 100644
--- a/niucloud/app/service/admin/addon/AddonService.php
+++ b/niucloud/app/service/admin/addon/AddonService.php
@@ -221,135 +221,82 @@ class AddonService extends BaseAdminService
return $this->model->where([ [ 'key', '=', $key ] ])->field('title, icon, key, desc, status, cover')->findOrEmpty()->toArray();
}
- /**
- * 查询应用列表,todo 完善
- * @return array
- */
- public function getShowAppTools()
- {
- $list = [
- 'tool' => $this->getAllAddonAndTool()[ 'tool' ],
- ];
- return $list;
- }
-
- /**
- * 查询营销列表
- * @return array
- */
- public function getShowMarketingTools()
- {
- $all = $this->getAllAddonAndTool();
- $list = [
- 'marketing' => $all[ 'marketing' ],
- 'addon' => $all[ 'addon' ],
- ];
- return $list;
- }
-
- private function getMarketing()
- {
- $list = [
- 'marketing' => [
- 'title' => '营销活动',
- 'list' => []
- ]
- ];
- $apps = event('ShowMarketing');
-
- $keys = [];
- foreach ($apps as $v) {
- foreach ($v as $ck => $cv) {
- if (!empty($cv)) {
- foreach ($cv as $addon_k => $addon_v) {
- if (in_array($addon_v[ 'key' ], $keys)) {
- continue;
- }
- $list[ $ck ][ 'list' ][] = $addon_v;
- $keys[] = $addon_v[ 'key' ];
- }
- }
-
- }
- }
- return $list;
- }
-
/**
* @return array[]
*/
- public function showCustomer($is_sort=true)
+ public function showCustomer($is_sort = true)
{
$show_list = event('ShowCustomer', []);
$addon_type_list = MenuDict::getAddonChildMenu();
$return = [];
foreach ($show_list as $item) {
foreach ($addon_type_list as $key => $value) {
- if (!isset($return[$key])) {
- $return[$key] = [
- 'title' => $value['name'],
- 'sort' => $value['sort'],
+ if (!isset($return[ $key ])) {
+ $return[ $key ] = [
+ 'title' => $value[ 'name' ],
+ 'sort' => $value[ 'sort' ],
'list' => [],
];
}
- $return[$key]['list'] = array_merge($return[$key]['list'], $item[$key] ?? []);
+ $return[ $key ][ 'list' ] = array_merge($return[ $key ][ 'list' ], $item[ $key ] ?? []);
}
}
//防止有未实现对应事件的插件额外做一次查询 未实现的直接放到 addon_tool 里面
$keys = [];
foreach ($return as $item) {
- foreach ($item['list'] as $value) {
- $keys[] = $value['key'];
+ foreach ($item[ 'list' ] as $value) {
+ $keys[] = $value[ 'key' ];
}
}
- $addon_list = $this->getAddonList([]);
- $menu_model = (new SysMenu());
+ $addon_list = $this->getAddonList();
+ $menu_model = ( new SysMenu() );
$addon_urls = $menu_model
- ->where([['addon', 'in', array_column($addon_list, 'key')], ['addon', 'not in', $keys], ['is_show', '=', 1], ['menu_type', '=', 1]])
+ ->where([ [ 'addon', 'in', array_column($addon_list, 'key') ], [ 'addon', 'not in', $keys ], [ 'is_show', '=', 1 ], [ 'menu_type', '=', 1 ] ])
->order('id asc')
->group('addon')
->column('router_path', 'addon');
if (!empty($addon_list)) {
foreach ($addon_list as $k => $v) {
- if (in_array($v['key'], $keys)) {
+ if (in_array($v[ 'key' ], $keys)) {
continue;
}
- $url = $addon_urls[$v['key']] ?? '';
- $return['addon_tool']['list'][] = [
- 'title' => $v['title'],
- 'desc' => $v['desc'],
- 'icon' => $v['icon'],
- 'key' => $v['key'],
+ $url = $addon_urls[ $v[ 'key' ] ] ?? '';
+ $return[ 'addon_tool' ][ 'list' ][] = [
+ 'title' => $v[ 'title' ],
+ 'desc' => $v[ 'desc' ],
+ 'icon' => $v[ 'icon' ],
+ 'key' => $v[ 'key' ],
'url' => $url ? '/' . $url : ''
];
}
}
- if($is_sort){
+ if ($is_sort) {
usort($return, function (array $a, array $b) {
- $sortA = isset($a['sort']) ? (int)$a['sort'] : 0;
- $sortB = isset($b['sort']) ? (int)$b['sort'] : 0;
+ $sortA = isset($a[ 'sort' ]) ? (int) $a[ 'sort' ] : 0;
+ $sortB = isset($b[ 'sort' ]) ? (int) $b[ 'sort' ] : 0;
return $sortB <=> $sortA;
});
}
return $return;
}
+
//生成菜单数据
public function getSpecialMenuList()
{
- $auth_menu_list = (new AuthService())->getAuthMenuList('all',1);
+ $auth_menu_list = ( new AuthService() )->getAuthMenuList('all', 1);
$auth_menu_list = array_column($auth_menu_list, null, 'menu_key');
- $auth_menu_list = $auth_menu_list['addon']['children'] ?? [];
+ $auth_menu_list = $auth_menu_list[ 'addon' ][ 'children' ] ?? [];
$list = $this->showCustomer(false);//获取对应的需要展示的key
$addon_menu_list = MenuDict::getAddonChildMenu();
$menu_list = [];
foreach ($addon_menu_list as $item) {
- $menu_key_list = array_column($list[$item['key']]['list'] ?? [], 'key');
+ $menu_key_list = array_column($list[ $item[ 'key' ] ][ 'list' ] ?? [], 'key');
$temp_menu = [
- 'app_type'=>'admin',
- 'menu_name' => $item['name'],
- 'menu_key' => $item['key'],
- 'menu_short_name' => $item['short_name'],
+ 'app_type' => 'admin',
+ 'menu_name' => $item[ 'name' ],
+ 'menu_key' => $item[ 'key' ],
+ 'menu_short_name' => $item[ 'short_name' ],
'parent_key' => 'addon',
'menu_type' => '0',
'icon' => 'iconfont iconzhuangxiu3',
@@ -357,22 +304,24 @@ class AddonService extends BaseAdminService
'router_path' => 'app/index',
'view_path' => 'app/index',
'methods' => 'get',
- 'sort' => $item['sort'],
+ 'sort' => $item[ 'sort' ],
'status' => '1',
'is_show' => '1',
];
$children = [];
- foreach ($auth_menu_list as $datum_item) {
- if (in_array($datum_item['menu_key'], $menu_key_list)) {
- $children[] = $datum_item;
+ if (!empty($auth_menu_list)) {
+ foreach ($auth_menu_list as $datum_item) {
+ if (in_array($datum_item[ 'menu_key' ], $menu_key_list)) {
+ $children[] = $datum_item;
+ }
}
}
- $temp_menu['children'] = $children;
+ $temp_menu[ 'children' ] = $children;
$menu_list[] = $temp_menu;
}
usort($menu_list, function (array $a, array $b) {
- $sortA = isset($a['sort']) ? (int)$a['sort'] : 0;
- $sortB = isset($b['sort']) ? (int)$b['sort'] : 0;
+ $sortA = isset($a[ 'sort' ]) ? (int) $a[ 'sort' ] : 0;
+ $sortB = isset($b[ 'sort' ]) ? (int) $b[ 'sort' ] : 0;
return $sortB <=> $sortA;
});
return [
@@ -381,82 +330,4 @@ class AddonService extends BaseAdminService
];
}
- private function getAllAddonAndTool()
- {
- $markting_list = $this->getMarketing() ?? [];
- $markting = $markting_list[ 'marketing' ];
- $marking_addon = $markting_list[ 'tool' ][ 'list' ] ?? [];
-
- $list = [
- 'marketing' => $markting,
- 'addon' => [
- 'title' => '营销工具',
- 'list' => $marking_addon
- ],
- 'tool' => [
- 'title' => '系统工具',
- 'list' => []
- ]
- ];
-
- $apps = event('ShowApp');
-
- $keys = [];
- foreach ($apps as $v) {
- foreach ($v as $ck => $cv) {
- if (!empty($cv)) {
- foreach ($cv as $addon_k => $addon_v) {
- if (in_array($addon_v[ 'key' ], $keys)) {
- continue;
- }
- $list[ $ck ][ 'list' ][] = $addon_v;
- $keys[] = $addon_v[ 'key' ];
- }
- }
-
- }
-
- }
-
- $menu_model = ( new SysMenu() );
- $site_addons = $this->getAddonList();
-
- if (!empty($site_addons)) {
- foreach ($site_addons as $k => $v) {
- if ($v[ 'type' ] == 'app') {
- unset($site_addons[ $k ]);
- }
- }
-
- $addon_urls = $menu_model
- ->where([ [ 'addon', 'in', array_column($site_addons, 'key') ], [ 'is_show', '=', 1 ], [ 'menu_type', '=', 1 ] ])
- ->order('id asc')
- ->group('addon')
- ->column('router_path', 'addon');
-
- foreach ($site_addons as $k => $v) {
- $continue = true;
- if (!empty($markting[ 'list' ])) {
- foreach ($markting[ 'list' ] as $key => $val) {
- if ($v[ 'key' ] == $val[ 'key' ]) {
- unset($site_addons[ $k ]);
- $continue = false;
- }
- }
- }
- if ($continue && !in_array($v[ 'key' ], $keys)) {
- $url = $addon_urls[ $v[ 'key' ] ] ?? '';
- $list[ 'addon' ][ 'list' ][] = [
- 'title' => $v[ 'title' ],
- 'desc' => $v[ 'desc' ],
- 'icon' => $v[ 'icon' ],
- 'key' => $v[ 'key' ],
- 'url' => $url ? '/' . $url : ''
- ];
- }
- }
- }
-
- return $list;
- }
}
diff --git a/niucloud/app/service/admin/auth/AuthService.php b/niucloud/app/service/admin/auth/AuthService.php
index ec9c9c581..75bd64485 100644
--- a/niucloud/app/service/admin/auth/AuthService.php
+++ b/niucloud/app/service/admin/auth/AuthService.php
@@ -15,8 +15,10 @@ use app\Request;
use app\service\admin\sys\MenuService;
use app\service\admin\sys\RoleService;
use app\service\admin\user\UserService;
+use app\service\core\niucloud\CoreAuthService;
use core\base\BaseAdminService;
use core\exception\AuthException;
+use core\exception\CommonException;
use Exception;
/**
@@ -35,10 +37,15 @@ class AuthService extends BaseAdminService
*/
public function checkRole(Request $request)
{
+ $this->checkAuthinfo($request);
$rule = strtolower(trim($request->rule()->getRule()));
$method = strtolower(trim($request->method()));
+ if($method != 'get'){
+// throw new AuthException('演示站禁止操作');
+ }
+
$menu_service = new MenuService();
$all_menu_list = $menu_service->getAllApiList();
//先判断当前访问的接口是否收到权限的限制
@@ -54,6 +61,33 @@ class AuthService extends BaseAdminService
}
+ public function checkAuthinfo(Request $request) {
+ $rule = strtolower(trim($request->rule()->getRule()));
+ $method = strtolower(trim($request->method()));
+
+ if ($method == 'get') return;
+
+ $ignore = ['niucloud/authinfo', 'upgrade', 'niucloud/build', 'sys/cache/clear'];
+ foreach ($ignore as $item) {
+ if (strpos($rule, $item) !== false) return;
+ }
+
+ $authinfo = (new CoreAuthService())->getAuthInfo()['data'] ?? [];;
+ if (empty($authinfo)) return;
+
+ if (!$this->isCheckDomain()) return;
+
+ $site_address = $authinfo['site_address'] ?? '';
+ $domain = request()->domain();
+ if (!empty($site_address) && strpos($domain, $site_address) !== false) return;
+
+ throw new CommonException("授权域名校验失败!请确保当前访问域名与授权码绑定的域名一致");
+ }
+
+ private function isCheckDomain() {
+ return !(request()->ip() == '127.0.0.1' || request()->host() == 'localhost');
+ }
+
/**
* 当前授权用户接口权限
* @return array
diff --git a/niucloud/app/service/admin/auth/LoginService.php b/niucloud/app/service/admin/auth/LoginService.php
index 46d006152..95cfac4e8 100644
--- a/niucloud/app/service/admin/auth/LoginService.php
+++ b/niucloud/app/service/admin/auth/LoginService.php
@@ -20,7 +20,6 @@ use app\service\core\sys\CoreConfigService;
use core\base\BaseAdminService;
use core\exception\AuthException;
use core\util\TokenAuth;
-use Exception;
use Throwable;
/**
@@ -41,7 +40,6 @@ class LoginService extends BaseAdminService
* 用户登录
* @param string $username
* @param string $password
- * @param string $app_type
* @return array|bool
*/
public function login(string $username, string $password)
@@ -88,8 +86,8 @@ class LoginService extends BaseAdminService
//查询权限以及菜单
$data = [
- 'token' => $token_info['token'],
- 'expires_time' => $token_info['params']['exp'],
+ 'token' => $token_info[ 'token' ],
+ 'expires_time' => $token_info[ 'params' ][ 'exp' ],
'userinfo' => [
'uid' => $userinfo->uid,
'username' => $userinfo->username,
@@ -127,7 +125,6 @@ class LoginService extends BaseAdminService
/**
* 清理token
* @param int $uid
- * @param string|null $type
* @param string|null $token
*/
public static function clearToken(int $uid, ?string $token = '')
@@ -151,7 +148,6 @@ class LoginService extends BaseAdminService
$token_info = TokenAuth::parseToken($token, AppTypeDict::ADMIN);
} catch (Throwable $e) {
throw new AuthException('LOGIN_EXPIRE', 401);
-
}
if (!$token_info) {
throw new AuthException('MUST_LOGIN', 401);
diff --git a/niucloud/app/service/admin/diy/DiyService.php b/niucloud/app/service/admin/diy/DiyService.php
index c5ac28c95..593ea02ad 100644
--- a/niucloud/app/service/admin/diy/DiyService.php
+++ b/niucloud/app/service/admin/diy/DiyService.php
@@ -60,24 +60,41 @@ class DiyService extends BaseAdminService
/**
* 获取自定义页面分页列表,轮播搜索组件用
* 查询微页面,数据排除存在轮播搜索组件的
- * @param array $where
* @return array
+ * @throws DbException
*/
public function getPageByCarouselSearch()
{
- $field = 'id,title,page_title,name,template,type,mode,is_default,share,visit_count,create_time,update_time,value';
+ $field = 'id,title,page_title,name,type,create_time,value';
$order = "update_time desc";
- $search_model = $this->model->whereOr([
- [
- [ 'type', '=', 'DIY_PAGE' ],
- [ 'value', 'not in', [ 'top_fixed', 'right_fixed', 'bottom_fixed', 'left_fixed', 'fixed' ] ]
- ],
- [
- [ 'type', '<>', 'DIY_PAGE' ],
- [ 'is_default', '=', 0 ],
- [ 'value', 'not in', [ 'top_fixed', 'right_fixed', 'bottom_fixed', 'left_fixed', 'fixed' ] ]
- ]
- ])->field($field)->order($order)->append([ 'type_name', 'type_page', 'addon_name' ]);
+ $search_model = $this->model
+ ->whereOr([
+ [
+ [ 'type', '=', 'DIY_PAGE' ],
+ [ 'value', 'not like',
+ [
+ '%"position":"top_fixed"%',
+ '%"position":"right_fixed"%',
+ '%"position":"bottom_fixed"%',
+ '%"position":"left_fixed"%',
+ '%"position":"fixed"%'
+ ]
+ ]
+ ],
+ [
+ [ 'type', '<>', 'DIY_PAGE' ],
+ [ 'is_default', '=', 0 ],
+ [ 'value', 'not like',
+ [
+ '%"position":"top_fixed"%',
+ '%"position":"right_fixed"%',
+ '%"position":"bottom_fixed"%',
+ '%"position":"left_fixed"%',
+ '%"position":"fixed"%'
+ ]
+ ]
+ ]
+ ])->field($field)->order($order)->append([ 'type_name', 'type_page', 'addon_name' ]);
return $this->pageQuery($search_model);
}
diff --git a/niucloud/app/service/admin/generator/GenerateService.php b/niucloud/app/service/admin/generator/GenerateService.php
index f116e8b95..96205ef89 100644
--- a/niucloud/app/service/admin/generator/GenerateService.php
+++ b/niucloud/app/service/admin/generator/GenerateService.php
@@ -205,7 +205,7 @@ class GenerateService extends BaseAdminService
$table_id = $res->id;
$add_column_data = [];
- $default_column = ['id', 'create_time', 'update_time'];
+ $default_column = ['id', 'create_time', 'update_time', 'delete_time'];
foreach ($fields as $k => $v){
$required = 0;
if ($v['notnull'] && !$v['primary'] && !in_array($v['name'], $default_column)) {
diff --git a/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php b/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php
index 599354dc1..9607b0e3e 100644
--- a/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php
+++ b/niucloud/app/service/admin/generator/core/AdminApiRouteGenerator.php
@@ -212,7 +212,7 @@ use app\adminapi\middleware\AdminLog;";
{
if(!empty($this->addonName))
{
- $dir = $this->outDir . DIRECTORY_SEPARATOR.'addon'.DIRECTORY_SEPARATOR.'.$this->addonName.'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'adminapi'.DIRECTORY_SEPARATOR.'route'.DIRECTORY_SEPARATOR;
+ $dir = $this->outDir . DIRECTORY_SEPARATOR.'addon'.DIRECTORY_SEPARATOR.$this->addonName.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'adminapi'.DIRECTORY_SEPARATOR.'route'.DIRECTORY_SEPARATOR;
}else{
$dir = $this->outDir . 'niucloud'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'adminapi'.DIRECTORY_SEPARATOR.'route'.DIRECTORY_SEPARATOR;
}
diff --git a/niucloud/app/service/admin/generator/core/WebEditGenerator.php b/niucloud/app/service/admin/generator/core/WebEditGenerator.php
index 8a014fe2c..33f23bf79 100644
--- a/niucloud/app/service/admin/generator/core/WebEditGenerator.php
+++ b/niucloud/app/service/admin/generator/core/WebEditGenerator.php
@@ -106,7 +106,7 @@ class WebEditGenerator extends BaseGenerator
{
$content = '';
foreach ($this->tableColumn as $column) {
- if (!$column['is_insert'] || !$column['is_update'] || $column['is_pk']) {
+ if (!$column['is_insert'] || !$column['is_update'] || $column['is_pk'] || $column['is_delete']) {
continue;
}
@@ -435,7 +435,7 @@ class WebEditGenerator extends BaseGenerator
/**
* 获取文件生成到插件中
- * @return void
+ * @return string
*/
public function getAddonObjectOutDir() {
$dir = $this->rootDir . DIRECTORY_SEPARATOR.'niucloud'.DIRECTORY_SEPARATOR.'addon'.DIRECTORY_SEPARATOR.$this->addonName.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR. $this->moduleName . DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR;
@@ -492,7 +492,7 @@ class WebEditGenerator extends BaseGenerator
/**
* 调用字典方法
- * @return void
+ * @return string
*/
public function getDictList()
{
@@ -518,7 +518,7 @@ class WebEditGenerator extends BaseGenerator
/**
* 调用远程下拉方法
- * @return void
+ * @return string
*/
public function getModelData()
{
@@ -542,7 +542,7 @@ class WebEditGenerator extends BaseGenerator
/**
* 编辑远程下拉方法
- * @return void
+ * @return string
*/
public function getEditWithApiPath()
{
@@ -559,7 +559,7 @@ class WebEditGenerator extends BaseGenerator
/**
* 增加关联方法
- * @return void
+ * @return string
*/
public function getWithApiPath()
{
diff --git a/niucloud/app/service/admin/generator/core/WebEditPageGenerator.php b/niucloud/app/service/admin/generator/core/WebEditPageGenerator.php
index 7576bcec7..9a12c25aa 100644
--- a/niucloud/app/service/admin/generator/core/WebEditPageGenerator.php
+++ b/niucloud/app/service/admin/generator/core/WebEditPageGenerator.php
@@ -156,7 +156,7 @@ class WebEditPageGenerator extends BaseGenerator
{
$content = '';
foreach ($this->tableColumn as $column) {
- if (!$column['is_insert'] || !$column['is_update'] || $column['is_pk']) {
+ if (!$column['is_insert'] || !$column['is_update'] || $column['is_pk'] || $column['is_delete']) {
continue;
}
@@ -505,7 +505,7 @@ class WebEditPageGenerator extends BaseGenerator
/**
* 调用远程下拉方法
- * @return void
+ * @return string
*/
public function getModelData()
{
@@ -528,7 +528,7 @@ class WebEditPageGenerator extends BaseGenerator
/**
* 编辑远程下拉方法
- * @return void
+ * @return string
*/
public function getEditWithApiPath()
{
diff --git a/niucloud/app/service/admin/generator/core/WebIndexGenerator.php b/niucloud/app/service/admin/generator/core/WebIndexGenerator.php
index ccb616e8e..557b6d4bc 100644
--- a/niucloud/app/service/admin/generator/core/WebIndexGenerator.php
+++ b/niucloud/app/service/admin/generator/core/WebIndexGenerator.php
@@ -539,7 +539,7 @@ class WebIndexGenerator extends BaseGenerator
/**
* 增加关联方法
- * @return void
+ * @return string
*/
public function getWithApiPath()
{
@@ -556,7 +556,7 @@ class WebIndexGenerator extends BaseGenerator
/**
* 调用远程下拉方法
- * @return void
+ * @return string
*/
public function getModelData()
{
diff --git a/niucloud/app/service/admin/member/AddressService.php b/niucloud/app/service/admin/member/AddressService.php
index 392ebe0f8..21a0892b2 100644
--- a/niucloud/app/service/admin/member/AddressService.php
+++ b/niucloud/app/service/admin/member/AddressService.php
@@ -15,7 +15,6 @@ use app\model\member\MemberAddress;
use app\service\admin\sys\AreaService;
use app\service\core\member\CoreMemberAddressService;
use core\base\BaseAdminService;
-use core\exception\AdminException;
/**
diff --git a/niucloud/app/service/admin/member/MemberService.php b/niucloud/app/service/admin/member/MemberService.php
index 0942872d0..466202dcf 100644
--- a/niucloud/app/service/admin/member/MemberService.php
+++ b/niucloud/app/service/admin/member/MemberService.php
@@ -22,6 +22,7 @@ use core\exception\AdminException;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
+use think\facade\Db;
/**
* 会员服务层
@@ -80,7 +81,11 @@ class MemberService extends BaseAdminService
public function getInfo(int $member_id)
{
$field = 'member_id,member_no, id_card,remark,username, mobile, password, register_channel, register_type, nickname, headimg, member_level, member_label, wx_openid, weapp_openid, wx_unionid, ali_openid, douyin_openid, login_ip, login_type, login_channel, login_count, login_time, create_time, last_visit_time, last_consum_time, sex, status, birthday, point, point_get, balance, balance_get, growth, growth_get, is_member, member_time, is_del, province_id, city_id, district_id, address, location, delete_time, money, money_get, commission, commission_get, commission_cash_outing';
- return $this->makeUp($this->model->where([ [ 'member_id', '=', $member_id ] ])->field($field)->with('member_level_name_bind')->append([ 'register_channel_name', 'register_type_name', 'sex_name', 'login_channel_name', 'login_type_name', 'status_name' ])->findOrEmpty()->toArray());
+ $info = $this->makeUp($this->model->where([ [ 'member_id', '=', $member_id ] ])->field($field)->with('member_level_name_bind')->append([ 'register_channel_name', 'register_type_name', 'sex_name', 'login_channel_name', 'login_type_name', 'status_name' ])->findOrEmpty()->toArray());
+ if (empty($info[ 'member_level' ])) {
+ $info[ 'member_level' ] = '';
+ }
+ return $info;
}
/**
@@ -149,6 +154,7 @@ class MemberService extends BaseAdminService
* @param int $member_id
* @param string $field
* @param $data
+ * @return Member
*/
public function modify(int $member_id, string $field, $data)
{
@@ -168,6 +174,10 @@ class MemberService extends BaseAdminService
/**
* 组合整理数据
* @param $data
+ * @return mixed
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
*/
public function makeUp($data)
{
@@ -223,7 +233,16 @@ class MemberService extends BaseAdminService
*/
public function getMemberNo()
{
- return ( new CoreMemberService() )->createMemberNo();
+ //开启事务,解决创建会员编码重复
+ try {
+ Db::startTrans();
+ $member_no = ( new CoreMemberService() )->createMemberNo();
+ Db::commit();
+ return $member_no;
+ } catch (AdminException $e) {
+ Db::rollback();
+ throw new AdminException("MEMBER_NO_CREATE_ERROR");
+ }
}
/**
@@ -256,7 +275,7 @@ class MemberService extends BaseAdminService
/**
* 获取会员权益字典
- * @return mixed
+ * @return array|null
*/
public function getMemberBenefitsDict()
{
@@ -302,7 +321,7 @@ class MemberService extends BaseAdminService
/**
* 获取会员礼包内容
- * @param array $benefits
+ * @param array $gifts
* @return array|null
*/
public function getMemberGiftsContent(array $gifts)
diff --git a/niucloud/app/service/admin/member/MemberSignService.php b/niucloud/app/service/admin/member/MemberSignService.php
index 4da3671a3..378955519 100644
--- a/niucloud/app/service/admin/member/MemberSignService.php
+++ b/niucloud/app/service/admin/member/MemberSignService.php
@@ -50,6 +50,7 @@ class MemberSignService extends BaseAdminService
/**
* 组合整理数据
* @param $data
+ * @return mixed
*/
public function makeUp($data)
{
@@ -84,14 +85,14 @@ class MemberSignService extends BaseAdminService
*/
public function setSign(array $value)
{
- if (empty($value[ 'sign_period' ])) throw new AdminException('SIGN_PERIOD_CANNOT_EMPTY');
- if ($value[ 'sign_period' ] < 2 || $value[ 'sign_period' ] > 365) throw new AdminException('SIGN_PERIOD_BETWEEN_2_365_DAYS');
- if (!empty($value[ 'continue_award' ])) {
- foreach ($value[ 'continue_award' ] as $v) {
- if ($v[ 'continue_sign' ] < 2 || $v[ 'continue_sign' ] > 365) throw new AdminException('CONTINUE_SIGN_BETWEEN_2_365_DAYS');
- if ($v[ 'continue_sign' ] > $value[ 'sign_period' ]) throw new AdminException('CONTINUE_SIGN_CANNOT_GREATER_THAN_SIGN_PERIOD');
- }
- }
+// if (empty($value[ 'sign_period' ])) throw new AdminException('SIGN_PERIOD_CANNOT_EMPTY');
+// if ($value[ 'sign_period' ] < 2 || $value[ 'sign_period' ] > 365) throw new AdminException('SIGN_PERIOD_BETWEEN_2_365_DAYS');
+// if (!empty($value[ 'continue_award' ])) {
+// foreach ($value[ 'continue_award' ] as $v) {
+// if ($v[ 'continue_sign' ] < 2 || $v[ 'continue_sign' ] > 365) throw new AdminException('CONTINUE_SIGN_BETWEEN_2_365_DAYS');
+// if ($v[ 'continue_sign' ] > $value[ 'sign_period' ]) throw new AdminException('CONTINUE_SIGN_CANNOT_GREATER_THAN_SIGN_PERIOD');
+// }
+// }
$data = [
'is_use' => $value[ 'is_use' ], //是否开启
'sign_period' => $value[ 'sign_period' ], // 签到周期
diff --git a/niucloud/app/service/admin/niucloud/NiucloudService.php b/niucloud/app/service/admin/niucloud/NiucloudService.php
index 32879fcdf..89b820852 100644
--- a/niucloud/app/service/admin/niucloud/NiucloudService.php
+++ b/niucloud/app/service/admin/niucloud/NiucloudService.php
@@ -17,6 +17,7 @@ use app\service\core\niucloud\CoreModuleService;
use app\service\core\sys\CoreConfigService;
use core\base\BaseAdminService;
use core\exception\CommonException;
+use think\facade\Cache;
/**
* 消息管理服务层
@@ -47,6 +48,7 @@ class NiucloudService extends BaseAdminService
$auth_info = $service->getAuthInfo()['data'] ?? [];
if (empty($auth_info)) throw new CommonException('AUTH_NOT_EXISTS');
$service->clearAccessToken();
+ Cache::set("authinfo", null);
return $this->core_config_service->setConfig(ConfigKeyDict::NIUCLOUD_CONFIG, $data);
}
diff --git a/niucloud/app/service/admin/notice/NiuSmsService.php b/niucloud/app/service/admin/notice/NiuSmsService.php
index aca88da63..d7dea5905 100644
--- a/niucloud/app/service/admin/notice/NiuSmsService.php
+++ b/niucloud/app/service/admin/notice/NiuSmsService.php
@@ -233,10 +233,34 @@ class NiuSmsService extends BaseAdminService
*/
public function signCreate($username, $params)
{
- if (!empty($params['imgUrl']) && strstr($params['imgUrl'], 'http') === false) {
- $params['imgUrl'] = request()->domain() . '/' . $params['imgUrl'];
- } else {
- $params['imgUrl'] = $params['imgUrl'] ?? '';
+ $params['imgUrl'] = $this->formatImageUrl($params['imgUrl']);
+ $params['bizLicenseUrl'] = $this->formatImageUrl($params['bizLicenseUrl']);
+ $params['qccUrl'] = $this->formatImageUrl($params['qccUrl']);
+ $params['tmnetUrl'] = $this->formatImageUrl($params['tmnetUrl']);
+ $params['mobileIcpUrl'] = $this->formatImageUrl($params['mobileIcpUrl']);
+ $params['telecomAppstoreUrl'] = $this->formatImageUrl($params['telecomAppstoreUrl']);
+ $params['idcardFrontUrl'] = $this->formatImageUrl($params['idcardFrontUrl']);
+ $params['idcardBackUrl'] = $this->formatImageUrl($params['idcardBackUrl']);
+ if (empty($params['idcardFrontUrl'])) {
+ throw new ApiException('身份证正面不能为空');
+ }
+ if (empty($params['idcardBackUrl'])) {
+ throw new ApiException('身份证反面不能为空');
+ }
+ if (empty($params['bizLicenseUrl'])) {
+ throw new ApiException('营业执照');
+ }
+ if (in_array($params['signSource'], [4, 5]) && empty($params['telecomAppstoreUrl'])) {
+ throw new ApiException('应用商店/小程序页面开发者截图不能为空');
+ }
+ if (in_array($params['signSource'], [4, 5]) && empty($params['mobileIcpUrl'])) {
+ throw new ApiException('移动ICP截图不能为空');
+ }
+ if (in_array($params['signSource'], [3]) && empty($params['tmnetUrl'])) {
+ throw new ApiException('中国商标网截图不能为空');
+ }
+ if (in_array($params['signSource'], [1, 2]) && $params['signType'] == 1 && empty($params['qccUrl'])) {
+ throw new ApiException('企查查唯一性截图不能为空');
}
$res = $this->niu_service->signCreate($username, $params);
if (!empty($res['failList'])) {
@@ -244,6 +268,21 @@ class NiuSmsService extends BaseAdminService
}
}
+ /**
+ * 格式化图片地址
+ * @param $url
+ * @return string
+ */
+ private function formatImageUrl($url)
+ {
+ if (!empty($url) && strstr($url, 'http') === false) {
+ $url = request()->domain() . '/' . $url;
+ } else {
+ $url = $url ?? '';
+ }
+ return $url;
+ }
+
/**
* 签名创建
* @param $username
diff --git a/niucloud/app/service/admin/pay/RefundService.php b/niucloud/app/service/admin/pay/RefundService.php
index 6825c623e..4b8ee3464 100644
--- a/niucloud/app/service/admin/pay/RefundService.php
+++ b/niucloud/app/service/admin/pay/RefundService.php
@@ -31,11 +31,15 @@ class RefundService extends BaseAdminService
/**
* 退款账户记录
* @param array $where
- * @return mixed
+ * @return array
*/
public function getPage(array $where){
$field = 'id,refund_no,out_trade_no,type,channel,money,reason,status,create_time,refund_time,close_time,fail_reason,voucher,trade_type,trade_id,refund_type,main_type,main_id';
- $search_model = $this->model->where([ [ 'id', '>', 0 ] ])->withSearch([ 'create_time', 'out_trade_no', 'refund_no', 'status' ], $where)->field($field)->append([ 'type_name', 'status_name' ])->order('create_time desc');
+ $search_model = $this->model->where([ [ 'id', '>', 0 ] ])
+ ->withSearch([ 'create_time', 'out_trade_no', 'refund_no', 'status' ], $where)
+ ->field($field)
+ ->append([ 'type_name', 'status_name','trade_type_name' ])
+ ->order('create_time desc');
return $this->pageQuery($search_model);
}
diff --git a/niucloud/app/service/admin/sys/ConfigService.php b/niucloud/app/service/admin/sys/ConfigService.php
index c55051468..6dc1d8bcd 100644
--- a/niucloud/app/service/admin/sys/ConfigService.php
+++ b/niucloud/app/service/admin/sys/ConfigService.php
@@ -87,6 +87,9 @@ class ConfigService extends BaseAdminService
'front_end_logo' => '',
'front_end_icon' => '',
'icon' => '',
+ 'meta_title' => '',
+ 'meta_desc' => '',
+ 'meta_keyword' => '',
];
}
return $info[ 'value' ];
@@ -137,7 +140,6 @@ class ConfigService extends BaseAdminService
"enterprise_wechat" => $value[ 'enterprise_wechat' ],
"tel" => $value[ 'tel' ]
];
-
return $this->core_config_service->setConfig('SERVICE_INFO', $data);
}
@@ -227,9 +229,9 @@ class ConfigService extends BaseAdminService
public function setLayout(array $data)
{
$config_service = new CoreConfigService();
- $config = $config_service->getConfigValue( "LAYOUT_SETTING");
+ $config = $config_service->getConfigValue("LAYOUT_SETTING");
$config[ $data[ 'key' ] ] = $data[ 'value' ];
- return ( new CoreConfigService() )->setConfig( "LAYOUT_SETTING", $config);
+ return ( new CoreConfigService() )->setConfig("LAYOUT_SETTING", $config);
}
/**
@@ -238,7 +240,7 @@ class ConfigService extends BaseAdminService
*/
public function getThemeColor()
{
- return ( new CoreConfigService() )->getConfigValue( "THEMECOLOR_SETTING");
+ return ( new CoreConfigService() )->getConfigValue("THEMECOLOR_SETTING");
}
/**
diff --git a/niucloud/app/service/admin/sys/PosterService.php b/niucloud/app/service/admin/sys/PosterService.php
index 5506f3f41..dc908e3bc 100644
--- a/niucloud/app/service/admin/sys/PosterService.php
+++ b/niucloud/app/service/admin/sys/PosterService.php
@@ -54,7 +54,7 @@ class PosterService extends BaseAdminService
* 获取自定义海报列表
* @param array $where
* @param string $field
- * @return mixed
+ * @return array
*/
public function getList(array $where = [], $field = 'id, name, type, channel, value, status,is_default, create_time, update_time, addon')
{
@@ -66,7 +66,7 @@ class PosterService extends BaseAdminService
* 获取自定义海报信息
* @param int $id
* @param string $field
- * @return mixed
+ * @return array
*/
public function getInfo(int $id, $field = 'id, name, type, channel, value, status,is_default, create_time, update_time, addon')
{
@@ -109,7 +109,7 @@ class PosterService extends BaseAdminService
/**
* 修改自定义海报启用状态
* @param $data
- * @return mixed
+ * @return Poster
*/
public function modifyStatus($data)
{
@@ -126,7 +126,7 @@ class PosterService extends BaseAdminService
/**
* 将自定义海报修改为默认海报
* @param $data
- * @return mixed
+ * @return bool
*/
public function modifyDefault($data)
{
@@ -137,7 +137,7 @@ class PosterService extends BaseAdminService
}
Db::startTrans();
$this->model->where([ [ 'type', '=', $info[ 'type' ] ] ])->update([ 'is_default' => 0 ]);
- $this->model->where([ [ 'id', '=', $data[ 'id' ] ] ])->update([ 'is_default' => 1, 'update_time' => time() ]);
+ $this->model->where([ [ 'id', '=', $data[ 'id' ] ] ])->update([ 'is_default' => 1, 'status' => 1, 'update_time' => time() ]);
Db::commit();
return true;
} catch (Exception $e) {
@@ -241,4 +241,4 @@ class PosterService extends BaseAdminService
return $data;
}
-}
+}
\ No newline at end of file
diff --git a/niucloud/app/service/admin/sys/RoleService.php b/niucloud/app/service/admin/sys/RoleService.php
index 7dd5c4512..d75463c4c 100644
--- a/niucloud/app/service/admin/sys/RoleService.php
+++ b/niucloud/app/service/admin/sys/RoleService.php
@@ -249,8 +249,10 @@ class RoleService extends BaseAdminService
/**
* 角色状态修改
*/
- public function modifyStatus(int $id, int $status)
+ public function modifyStatus($data)
{
+ $id = $data[ 'role_id' ];
+ $status = $data[ 'status' ];
$this->model->where([ [ 'role_id', '=', $id ] ])->update([ 'status' => $status ]);
return true;
}
diff --git a/niucloud/app/service/admin/upgrade/UpgradeService.php b/niucloud/app/service/admin/upgrade/UpgradeService.php
index 7aacb8382..d13f77315 100644
--- a/niucloud/app/service/admin/upgrade/UpgradeService.php
+++ b/niucloud/app/service/admin/upgrade/UpgradeService.php
@@ -127,24 +127,26 @@ class UpgradeService extends BaseAdminService
// 检测全部目录及文件是否可读可写,忽略指定目录
// 忽略指定目录,admin
- $exclude_admin_dir = [ 'dist', 'node_modules', '.git' ];
+ $exclude_admin_dir = [ 'dist', 'node_modules', '.git', '.user.ini' ];
$check_res = checkDirPermissions(project_path() . 'admin', [], $exclude_admin_dir);
// 忽略指定目录,uni-app
- $exclude_uniapp_dir = [ 'dist', 'node_modules', '.git' ];
+ $exclude_uniapp_dir = [ 'dist', 'node_modules', '.git', '.user.ini' ];
$check_res = array_merge2($check_res, checkDirPermissions(project_path() . 'uni-app', [], $exclude_uniapp_dir));
// 忽略指定目录,web
- $exclude_web_dir = [ '.nuxt', '.output', 'dist', 'node_modules', '.git' ];
+ $exclude_web_dir = [ '.nuxt', '.output', 'dist', 'node_modules', '.git', '.user.ini' ];
$check_res = array_merge2($check_res, checkDirPermissions(project_path() . 'web', [], $exclude_web_dir));
// 忽略指定目录,niucloud
$exclude_niucloud_dir = [
'public' . DIRECTORY_SEPARATOR . 'admin',
+ 'public' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR .'niucloud.ico',
'public' . DIRECTORY_SEPARATOR . 'wap',
'public' . DIRECTORY_SEPARATOR . 'web',
'public' . DIRECTORY_SEPARATOR . 'upload',
'public' . DIRECTORY_SEPARATOR . 'file',
+ 'public' . DIRECTORY_SEPARATOR . 'favicon.ico',
'runtime',
'vendor',
'.user.ini',
@@ -313,8 +315,6 @@ class UpgradeService extends BaseAdminService
}
if (!in_array($step, [ 'upgradeComplete', 'restoreComplete' ])) {
Cache::set($this->cache_key, $this->upgrade_task);
- } else {
- $this->clearUpgradeTask(2);
}
} catch (CloudBuildException $e) {
if (strpos($e->getMessage(), '队列') !== false) {
@@ -466,7 +466,7 @@ class UpgradeService extends BaseAdminService
// 覆盖文件
if (is_dir($code_dir . $version_no)) {
// 忽略环境变量文件
- $exclude_files = [ '.env.development', '.env.production', '.env', '.env.dev', '.env.product' ];
+ $exclude_files = [ '.env.development', '.env.production', '.env', '.env.dev', '.env.product', 'favicon.ico', 'niucloud.ico' ];
dir_copy($code_dir . $version_no, $to_dir, exclude_files: $exclude_files);
if ($addon != AddonDict::FRAMEWORK_KEY) {
( new CoreAddonInstallService($addon) )->installDir();
@@ -629,15 +629,57 @@ class UpgradeService extends BaseAdminService
$sql_data = array_filter($this->getSqlQuery($sql_content));
if (!empty($sql_data)) {
+ try {
+ $default_collation = Db::query("SHOW VARIABLES LIKE 'collation_database'")[0]['Value'] ?? 'utf8mb4_general_ci';
+ } catch (\Exception $e) {
+ $default_collation = 'utf8mb4_general_ci';
+ }
foreach ($sql_data as $sql) {
$sql = $prefix ? $this->handleSqlPrefix($sql, $prefix) : $sql;
- Db::query($sql);
+ // 处理成默认排序规则
+ $sql = preg_replace_callback(
+ '/\bCOLLATE\s*(=)?\s*[`"\']?([a-zA-Z0-9_]+)[`"\']?/i',
+ function ($matches) use ($default_collation) {
+ return "COLLATE " . $default_collation;
+ },
+ $sql
+ );
+ // 判断是否是新增字段
+ $pattern = '/^ALTER\s+TABLE\s+(`?)(\w+)\1\s+ADD(?:\s+COLUMN)?\s+(`?)(\w+)\3\s+/i';
+ if (preg_match($pattern, $sql, $matches)) {
+ if (!$this->columnExists($matches[2], $matches[4])) {
+ Db::query($sql);
+ }
+ }else{
+ Db::query($sql);
+ }
}
}
}
return true;
}
+ /**
+ * 判断数据表中某个字段是否存在
+ *
+ * @param string $table 表名(不带前缀)
+ * @param string $column 字段名
+ * @param string|null $database 指定数据库名(可选,默认当前连接的数据库)
+ * @return bool
+ */
+ private function columnExists(string $table, string $column, ?string $database = null): bool
+ {
+ $db = env('database.database', '');
+
+ $count = Db::query(
+ "SELECT COUNT(*) AS cnt FROM information_schema.COLUMNS
+ WHERE table_schema = ? AND table_name = ? AND column_name = ?",
+ [$db, $table, $column]
+ );
+
+ return (int)$count[0]['cnt'] > 0;
+ }
+
/**
* 刷新菜单
* @return array|true
@@ -703,20 +745,10 @@ class UpgradeService extends BaseAdminService
foreach ($log[ 'data' ][ 0 ] as $item) {
if ($item[ 'code' ] == 0) {
$this->upgrade_task[ 'step' ] = 'gteCloudBuildLog';
- $this->upgrade_task[ 'error' ][] = $item[ 'msg' ];
+// $this->upgrade_task[ 'error' ][] = $item[ 'msg' ];
+ $this->upgrade_task[ 'cloud_build_error' ] = $item[ 'msg' ];
Cache::set($this->cache_key, $this->upgrade_task);
-
- $fail_reason = [
- 'Message' => '失败原因 云编译错误:' . $item[ 'msg' ],
- 'File' => '',
- 'Line' => '',
- 'Trace' => ''
- ];
-
( new CoreCloudBuildService() )->clearTask();
-
- $this->upgradeErrorHandle($fail_reason);
-
return true;
}
if (!in_array($item[ 'action' ], $this->upgrade_task[ 'log' ])) {
@@ -745,7 +777,13 @@ class UpgradeService extends BaseAdminService
}
// 执行完成,更新升级记录状态,备份记录状态
( new UpgradeRecordsService() )->complete($this->upgrade_task[ 'key' ]);
- $this->clearUpgradeTask(2);
+ if (!isset($this->upgrade_task['cloud_build_error'])) {
+ $this->upgrade_task['step'] = 'upgradeComplete';
+ $this->clearUpgradeTask(2);
+ } else {
+ $this->upgrade_task['step'] = 'upgradeComplete';
+ Cache::set($this->cache_key, $this->upgrade_task);
+ }
return true;
}
@@ -779,7 +817,7 @@ class UpgradeService extends BaseAdminService
if (!isset($this->upgrade_task['is_need_backup']) || $this->upgrade_task['is_need_backup']) {
$backup_dir = $this->upgrade_dir . $this->upgrade_task[ 'key' ] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR;
} else {
- $backup_dir = $this->upgrade_dir . $this->upgrade_task['upgrade_content']['last_backup'][ 'key' ] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR;
+ $backup_dir = $this->upgrade_dir . $this->upgrade_task['upgrade_content']['last_backup'][ 'backup_key' ] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR;
}
try {
if (is_dir($backup_dir)) {
@@ -802,7 +840,7 @@ class UpgradeService extends BaseAdminService
if (!isset($this->upgrade_task['is_need_backup']) || $this->upgrade_task['is_need_backup']) {
$backup_dir = $this->upgrade_dir . $this->upgrade_task[ 'key' ] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
} else {
- $backup_dir = $this->upgrade_dir . $this->upgrade_task['upgrade_content']['last_backup'][ 'key' ] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
+ $backup_dir = $this->upgrade_dir . $this->upgrade_task['upgrade_content']['last_backup'][ 'backup_key' ] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR;
}
try {
if (is_dir($backup_dir)) {
@@ -826,7 +864,11 @@ class UpgradeService extends BaseAdminService
public function restoreComplete()
{
- ( new UpgradeRecordsService() )->failed($this->upgrade_task[ 'key' ], $this->upgrade_task['error']);
+ $error = $this->upgrade_task['error'] ?? [];
+ if (isset($this->upgrade_task['cloud_build_error'])) $error[] = $this->upgrade_task['cloud_build_error'];
+ ( new UpgradeRecordsService() )->failed($this->upgrade_task[ 'key' ], $error);
+ $this->upgrade_task['step'] = 'restoreComplete';
+ Cache::set($this->cache_key, $this->upgrade_task);
$this->clearUpgradeTask(2);
return true;
}
@@ -951,6 +993,15 @@ class UpgradeService extends BaseAdminService
];
$this->upgradeErrorHandle($fail_reason);
break;
+ case 'cloud_build_error_rollback':
+ $fail_reason = [
+ 'Message' => '失败原因:云编译失败,错误原因:' . $this->upgrade_task['cloud_build_error'],
+ 'File' => '',
+ 'Line' => '',
+ 'Trace' => ''
+ ];
+ $this->upgradeErrorHandle($fail_reason);
+ break;
}
}
}
diff --git a/niucloud/app/service/admin/weapp/WeappVersionService.php b/niucloud/app/service/admin/weapp/WeappVersionService.php
index 6861bd936..47cd832d8 100644
--- a/niucloud/app/service/admin/weapp/WeappVersionService.php
+++ b/niucloud/app/service/admin/weapp/WeappVersionService.php
@@ -12,9 +12,7 @@
namespace app\service\admin\weapp;
use app\dict\sys\CloudDict;
-use app\service\core\site\CoreSiteService;
use app\service\core\weapp\CoreWeappCloudService;
-use app\service\core\weapp\CoreWeappConfigService;
use app\service\core\weapp\CoreWeappService;
use core\base\BaseAdminService;
use app\model\weapp\WeappVersion;
diff --git a/niucloud/app/service/admin/wechat/WechatTemplateService.php b/niucloud/app/service/admin/wechat/WechatTemplateService.php
index dd309d3fb..b19734e01 100644
--- a/niucloud/app/service/admin/wechat/WechatTemplateService.php
+++ b/niucloud/app/service/admin/wechat/WechatTemplateService.php
@@ -65,7 +65,7 @@ class WechatTemplateService extends BaseAdminService
//删除原来的消息模板
// (new CoreWechatTemplateService())->deletePrivateTemplate($wechat_template_id);
$template_loader = new TemplateLoader('wechat');
- $template_loader->delete([ 'templateId' => $wechat_template_id ]);
+ $del_res = $template_loader->delete([ 'templateId' => $wechat_template_id ]);
//新的消息模板
// $res = (new CoreWechatTemplateService())->addTemplate($temp_key, $keyword_name_list);
$res = $template_loader->addTemplate([ 'shortId' => $temp_key, 'keyword_name_list' => $keyword_name_list ]);
@@ -74,6 +74,9 @@ class WechatTemplateService extends BaseAdminService
//修改
$notice_service->modify($key, 'wechat_template_id', $res[ 'template_id' ]);
} else {
+ if (isset($res[ 'errcode' ]) && $res[ 'errcode' ] == 45026) {
+ throw new NoticeException('模板数量超出限制');
+ }
throw new NoticeException($res[ 'errmsg' ]);
}
return true;
diff --git a/niucloud/app/service/api/diy/DiyService.php b/niucloud/app/service/api/diy/DiyService.php
index c5275b3e1..7f85fdae4 100644
--- a/niucloud/app/service/api/diy/DiyService.php
+++ b/niucloud/app/service/api/diy/DiyService.php
@@ -167,9 +167,9 @@ class DiyService extends BaseApiService
];
$data = [];
foreach ($addon_list as $key => $value) {
- if (isset($value[ 'support_app' ]) && empty($value[ 'support_app' ]) && $value[ 'type' ] == 'addon') {
- continue;
- }
+// if (isset($value[ 'support_app' ]) && empty($value[ 'support_app' ]) && $value[ 'type' ] == 'addon') {
+// continue;
+// }
$addon_theme = array_values(array_filter(event('ThemeColor', [ 'key' => $value[ 'key' ] ])))[ 0 ] ?? [];
if (!empty($addon_theme) && !empty($addon_theme[ 'theme_color' ])) {
$data[ $value[ 'key' ] ][ 'title' ] = $theme_data[ $value[ 'key' ] ][ 'title' ] ?? $addon_theme[ 'theme_color' ][ 0 ][ 'title' ];
diff --git a/niucloud/app/service/api/login/AuthService.php b/niucloud/app/service/api/login/AuthService.php
index 4dca45439..1272c7b8b 100644
--- a/niucloud/app/service/api/login/AuthService.php
+++ b/niucloud/app/service/api/login/AuthService.php
@@ -124,10 +124,10 @@ class AuthService extends BaseApiService
$mobile = $phone_info[ 'purePhoneNumber' ];
if (empty($mobile)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST');
- $member_service = new MemberService();
+// $member_service = new MemberService();
- $mobile_member = $member_service->findMemberInfo([ 'mobile' => $mobile ]);
- if (!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST');
+// $mobile_member = $member_service->findMemberInfo([ 'mobile' => $mobile ]);
+// if (!$mobile_member->isEmpty()) throw new AuthException('MOBILE_IS_EXIST');
return [
'mobile' => $mobile
diff --git a/niucloud/app/service/api/sys/ConfigService.php b/niucloud/app/service/api/sys/ConfigService.php
index 98b68dca2..4a43f80c8 100644
--- a/niucloud/app/service/api/sys/ConfigService.php
+++ b/niucloud/app/service/api/sys/ConfigService.php
@@ -39,15 +39,16 @@ class ConfigService extends BaseApiService
*/
public function getCopyright()
{
- return (new CoreSysConfigService())->getCopyright();
+ return ( new CoreSysConfigService() )->getCopyright();
}
/**
* 获取前端域名
* @return array|string[]
*/
- public function getSceneDomain(){
- return (new CoreSysConfigService())->getSceneDomain();
+ public function getSceneDomain()
+ {
+ return ( new CoreSysConfigService() )->getSceneDomain();
}
/**
@@ -80,21 +81,26 @@ class ConfigService extends BaseApiService
'front_end_name' => '',
'front_end_logo' => '',
'icon' => '',
+ 'meta_title' => '',
+ 'meta_desc' => '',
+ 'meta_keyword' => '',
];
}
- $info['site_addons'] = (new CoreAddonService())->getInstallAddonList();
+ $info[ 'site_addons' ] = ( new CoreAddonService() )->getInstallAddonList();
return $info;
}
- public function getMap(){
- return (new CoreSysConfigService())->getMap();
+ public function getMap()
+ {
+ return ( new CoreSysConfigService() )->getMap();
}
- public function getAppConfig() {
- $config = (new CoreAppService())->getConfig();
- if (!empty($config) && isset($config['wechat_app_secret'])) unset($config['wechat_app_secret']);
- $weapp_config = (new CoreWeappConfigService())->getWeappConfig();
- $config['weapp_original'] = $weapp_config['weapp_original'];
+ public function getAppConfig()
+ {
+ $config = ( new CoreAppService() )->getConfig();
+ if (!empty($config) && isset($config[ 'wechat_app_secret' ])) unset($config[ 'wechat_app_secret' ]);
+ $weapp_config = ( new CoreWeappConfigService() )->getWeappConfig();
+ $config[ 'weapp_original' ] = $weapp_config[ 'weapp_original' ];
return $config;
}
diff --git a/niucloud/app/service/api/weapp/WeappAuthService.php b/niucloud/app/service/api/weapp/WeappAuthService.php
index 62e00c272..3a2ba5dd2 100644
--- a/niucloud/app/service/api/weapp/WeappAuthService.php
+++ b/niucloud/app/service/api/weapp/WeappAuthService.php
@@ -148,7 +148,7 @@ class WeappAuthService extends BaseApiService
} else {
return [ 'openid' => $openid, 'unionid' => $unionid ]; // 将重要信息返回给前端保存
}
- } else if($is_mobile) {
+ } else if ($is_mobile) {
if (!empty($data[ 'mobile' ]) || !empty($data[ 'mobile_code' ])) {
return $this->register($openid, $data[ 'mobile' ], $data[ 'mobile_code' ], $unionid);
} else {
@@ -175,6 +175,7 @@ class WeappAuthService extends BaseApiService
// }
}
}
+ if (empty($member_info->wx_unionid) && !empty($unionid)) $member_info->wx_unionid = $unionid;
return $login_service->login($member_info, MemberLoginTypeDict::WEAPP);
}
}
diff --git a/niucloud/app/service/api/wechat/WechatAuthService.php b/niucloud/app/service/api/wechat/WechatAuthService.php
index d111e99a0..0ae905767 100644
--- a/niucloud/app/service/api/wechat/WechatAuthService.php
+++ b/niucloud/app/service/api/wechat/WechatAuthService.php
@@ -136,11 +136,14 @@ class WechatAuthService extends BaseApiService
return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
} else if ($is_force_access_user_info) {
// 开启强制获取会员信息时,必须获取到昵称和头像才能进行注册
- if (!empty($nickname) && !empty($avatar)) {
+// if (!empty($nickname) && !empty($avatar)) {
+ if (empty($nickname)){
+ $nickname = unique_random();
+ }
return $this->register($openid, '', $nickname, $avatar, $unionid); // 获取到昵称和头像,然后进行注册
- } else {
- return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
- }
+// } else {
+// return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
+// }
} else if ($is_bind_mobile) {
// 开启强制绑定手机号,必须获取手机号才能进行注册,由于公众号无法主动获取,所以不能注册
return [ 'openid' => $openid, 'unionid' => $unionid ];
@@ -279,10 +282,10 @@ class WechatAuthService extends BaseApiService
public function updateOpenidByH5($wx_openid)
{
$member_service = new MemberService();
- $member = $member_service->findMemberInfo([ 'wx_openid' => $wx_openid]);
+ $member = $member_service->findMemberInfo([ 'wx_openid' => $wx_openid ]);
if (!$member->isEmpty()) throw new AuthException('MEMBER_OPENID_EXIST');//openid已存在
- $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id]);
+ $member_info = $member_service->findMemberInfo([ 'member_id' => $this->member_id ]);
if ($member_info->isEmpty()) throw new AuthException('MEMBER_NOT_EXIST');//账号不存在
$member_service->editByFind($member_info, [ 'wx_openid' => $wx_openid ]);
return true;
diff --git a/niucloud/app/service/core/addon/CoreAddonInstallService.php b/niucloud/app/service/core/addon/CoreAddonInstallService.php
index 1794e0ded..f71be9390 100644
--- a/niucloud/app/service/core/addon/CoreAddonInstallService.php
+++ b/niucloud/app/service/core/addon/CoreAddonInstallService.php
@@ -173,7 +173,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
}
if (!isset($install_data['support_version']) || empty($install_data['support_version'])) {
$data['addon_check'][] = [
- 'msg' => $install_data['title'] . '插件的info.json文件中未检测到匹配框架当前版本['. $framework_version_arr[0].'.'.$framework_version_arr[1] .'.*]的信息无法安装,点击查看相关手册',
+ 'msg' => $install_data['title'] . '插件的info.json文件中未检测到匹配框架当前版本['. $framework_version_arr[0].'.'.$framework_version_arr[1] .'.*]的信息无法安装,点击查看相关手册',
'status' => false
];
continue;
@@ -182,7 +182,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
if ($framework_version_arr[0].$framework_version_arr[1] != $support_framework_arr[0].$support_framework_arr[1]) {
if ((float) "$support_framework_arr[0].$support_framework_arr[1]" < (float) "$framework_version_arr[0].$framework_version_arr[1]") {
$data['addon_check'][] = [
- 'msg' => $install_data['title'] . '插件的info.json文件中检测到支持的框架版本['. $install_data['support_version'] .']低于当前框架版本['. $framework_version_arr[0].'.'.$framework_version_arr[1] .'.*]无法安装,点击查看相关手册',
+ 'msg' => $install_data['title'] . '插件的info.json文件中检测到支持的框架版本['. $install_data['support_version'] .']低于当前框架版本['. $framework_version_arr[0].'.'.$framework_version_arr[1] .'.*]无法安装,点击查看相关手册',
'status' => false
];
}
diff --git a/niucloud/app/service/core/addon/CoreAddonService.php b/niucloud/app/service/core/addon/CoreAddonService.php
index 2727649a5..0a6c5a685 100644
--- a/niucloud/app/service/core/addon/CoreAddonService.php
+++ b/niucloud/app/service/core/addon/CoreAddonService.php
@@ -46,17 +46,20 @@ class CoreAddonService extends CoreAddonBaseService
public function getLocalAddonList()
{
$list = [];
- $online_app_list = [];
+ $online_app_list = $online_apps = [];
$install_addon_list = $this->model->append(['status_name'])->column('title, icon, key, desc, status, author, version, install_time, update_time, cover', 'key');
try {
$niucloud_module_list = (new CoreModuleService())->getModuleList()['data'] ?? [];
foreach ($niucloud_module_list as $v) {
$data = array(
+ 'app_id' => $v['app']['app_id'],
'title' => $v['app']['app_name'],
'desc' => $v['app']['app_desc'],
'key' => $v['app']['app_key'] ?? '',
'version' => $v['version'] ?? '',
- 'author' => $v['app']['app_name'],
+ 'author' => $v['site_name'],
+ 'author_phone' => $v['site_phone'],
+ 'expire_time' => $v['expire_time'],
'type' => $v['app']['app_type'],
'support_app' => $v['app']['support_channel'] ?? [],
'is_download' => false,
@@ -65,9 +68,15 @@ class CoreAddonService extends CoreAddonBaseService
'cover' => $v['app']['window_logo'][0],
);
$data['install_info'] = $install_addon_list[$v['app']['app_key']] ?? [];
+ //给安装的插件中为授权插件或应用的数据赋值过期时间
+ if (isset($install_addon_list[$v['app']['app_key']])) {
+ $install_addon_list[$v['app']['app_key']]['expire_time'] = $v['expire_time'];
+ }
+
$list[$v['app']['app_key']] = $data;
}
$online_app_list = array_column($list, 'key');
+ $online_apps = array_column($list, 'app_id', 'key');
} catch (Throwable $e) {
$error = $e->getMessage();
}
@@ -81,8 +90,11 @@ class CoreAddonService extends CoreAddonBaseService
$key = $data['key'];
$data['install_info'] = $install_addon_list[$key] ?? [];
$data['is_download'] = true;
- $data['is_local'] = in_array($data['key'], $online_app_list) ? false : true;
+ $data['is_local'] = !in_array($data['key'], $online_app_list);
$data['version'] = isset($list[$data['key']]) ? $list[$data['key']]['version'] : $data['version'];
+ $data['app_id'] = in_array($data['key'], $online_app_list) ? $online_apps[$data['key']] : 0;
+ $data['author_phone'] = '';
+ $data['expire_time'] = !isset($install_addon_list[$data['key']]) ? '长期有效' : ($install_addon_list[$data['key']]['expire_time'] ?? '');
$list[$key] = $data;
}
}
diff --git a/niucloud/app/service/core/addon/WapTrait.php b/niucloud/app/service/core/addon/WapTrait.php
index 60d609bc1..dbc7ac995 100644
--- a/niucloud/app/service/core/addon/WapTrait.php
+++ b/niucloud/app/service/core/addon/WapTrait.php
@@ -126,12 +126,12 @@ trait WapTrait
$content .= " \n";
$content .= " \n";
$content .= " \n";
- $content .= " \n";
+ $content .= " \n";
$content .= " \n";
$content .= " \n\n";
$content .= " \n";
$content .= " \n";
- $content .= " \n";
+ $content .= " \n";
$content .= " \n";
$content .= " \n";
$content .= "\n";
@@ -191,12 +191,20 @@ trait WapTrait
*/
public function installPageCode($compile_path, $addon = '')
{
- if (!file_exists($this->geAddonPackagePath($this->addon) . 'uni-app-pages.php')) return;
+ if (is_array($addon)){
+ foreach ($addon as $item_addon){
+ if (!file_exists($this->geAddonPackagePath($item_addon) . 'uni-app-pages.php')) {
+ continue;
+ }
+ $uniapp_pages = require $this->geAddonPackagePath($item_addon) . 'uni-app-pages.php';
+ }
+ }else{
+ if (!file_exists($this->geAddonPackagePath($this->addon) . 'uni-app-pages.php')) return;
- $uniapp_pages = require $this->geAddonPackagePath($this->addon) . 'uni-app-pages.php';
-
- if (empty($uniapp_pages[ 'pages' ])) {
- return;
+ $uniapp_pages = require $this->geAddonPackagePath($this->addon) . 'uni-app-pages.php';
+ if (empty($uniapp_pages[ 'pages' ])) {
+ return;
+ }
}
$pages = [];
diff --git a/niucloud/app/service/core/channel/CoreAppService.php b/niucloud/app/service/core/channel/CoreAppService.php
index c2f084e44..209e55838 100644
--- a/niucloud/app/service/core/channel/CoreAppService.php
+++ b/niucloud/app/service/core/channel/CoreAppService.php
@@ -55,27 +55,6 @@ class CoreAppService extends BaseCoreService
public function setConfig($data)
{
$info = (new CoreConfigService())->setConfig(ConfigKeyDict::APP, $data);
- $this->appConfigChange($data);
return $info;
}
-
- /**
- * 地图key改变后变更 manifest.json
- * @param string $map_key
- * @return void
- */
- public function appConfigChange($data) {
-// $compile_path = project_path(). 'uni-app' . DIRECTORY_SEPARATOR;
-// $this->mergeManifestJson($compile_path, [
-// "h5" => [
-// "sdkConfigs" => [
-// "maps" => [
-// "qqmap" => [
-// "key" => $map_key
-// ]
-// ]
-// ]
-// ]
-// ]);
- }
}
diff --git a/niucloud/app/service/core/diy/CoreDiyService.php b/niucloud/app/service/core/diy/CoreDiyService.php
index e5954e099..83088621d 100644
--- a/niucloud/app/service/core/diy/CoreDiyService.php
+++ b/niucloud/app/service/core/diy/CoreDiyService.php
@@ -64,7 +64,7 @@ class CoreDiyService extends BaseCoreService
$addon_theme = array_values(array_filter(event('ThemeColor', [ 'key' => $value[ 'key' ] ])))[ 0 ] ?? [];
if (empty($addon_theme)) continue;
- foreach ($addon_theme[ 'theme_color' ] as $k => $v) {
+ foreach ($addon_theme[ 'theme_color' ] ?? [] as $k => $v) {
$data[] = [
'type' => 'app',
'addon' => $value[ 'key' ],
diff --git a/niucloud/app/service/core/map/CoreMapService.php b/niucloud/app/service/core/map/CoreMapService.php
new file mode 100644
index 000000000..fa3c22690
--- /dev/null
+++ b/niucloud/app/service/core/map/CoreMapService.php
@@ -0,0 +1,99 @@
+core_config_service = new CoreConfigService();
+ }
+
+ /**
+ * 获取规划路线
+ * @param $params
+ * @return array
+ */
+ public function getPolyline($params)
+ {
+
+ $url = 'https://apis.map.qq.com/ws/direction/v1/driving/';
+ $map = $this->getMapConfig();
+
+ $get_data = [
+ 'key' => $map[ 'key' ],
+ 'from' => $params[ 'from' ],
+ 'to' => $params[ 'to' ], // 是否返回周边POI列表:1.返回;0不返回(默认)
+ ];
+
+ $url = $url . '?' . http_build_query($get_data);
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_TIMEOUT, 1);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+
+ $res = curl_exec($curl);
+ $res = json_decode($res, true);
+ if ($res) {
+ curl_close($curl);
+
+ if ($res[ 'status' ] == 0) {
+ return $res['result'];
+ } else {
+ throw new CommonException('请检查地图配置:'.$res[ 'message' ]);
+ }
+
+ } else {
+ $error = curl_errno($curl);
+ curl_close($curl);
+ throw new CommonException($error);
+ }
+ }
+
+
+ /**
+ * 获取地图配置
+ * @return array|mixed
+ */
+ public function getMapConfig()
+ {
+ $info = ( new CoreConfigService() )->getConfig('MAPKEY');
+ if (empty($info)) {
+ $info = [];
+ $info[ 'value' ] = [
+ 'key' => 'IZQBZ-3UHEU-WTCVD-2464U-I5N4V-ZFFU3',
+ 'is_open' => 1, // 是否开启定位
+ 'valid_time' => 5 // 定位有效期/分钟,过期后将重新获取定位信息,0为不过期
+ ];
+ }
+
+ $info[ 'value' ][ 'is_open' ] = $info[ 'value' ][ 'is_open' ] ?? 1;
+ $info[ 'value' ][ 'valid_time' ] = $info[ 'value' ][ 'valid_time' ] ?? 5;
+ return $info[ 'value' ];
+ }
+}
diff --git a/niucloud/app/service/core/member/CoreMemberAccountService.php b/niucloud/app/service/core/member/CoreMemberAccountService.php
index 9bc6c0bf4..5520c0cd0 100644
--- a/niucloud/app/service/core/member/CoreMemberAccountService.php
+++ b/niucloud/app/service/core/member/CoreMemberAccountService.php
@@ -37,10 +37,14 @@ class CoreMemberAccountService extends BaseCoreService
$member_info = $member_model->where([
[ 'member_id', '=', $member_id ],
])->field($account_type . ',' . $account_type . "_get" . ', username, mobile, nickname')->lock(true)->find();
- if (empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST');
+ if (empty($member_info)) {
+ Db::rollback();
+ throw new CommonException('MEMBER_NOT_EXIST');
+ }
$account_new_data = round((float) $member_info[ $account_type ] + (float) $account_data, 2);
if ($account_new_data < 0) {
+ Db::rollback();
throw new CommonException('ACCOUNT_INSUFFICIENT');
}
diff --git a/niucloud/app/service/core/niucloud/CoreAuthService.php b/niucloud/app/service/core/niucloud/CoreAuthService.php
index bfc61c9ff..43bb2df6a 100644
--- a/niucloud/app/service/core/niucloud/CoreAuthService.php
+++ b/niucloud/app/service/core/niucloud/CoreAuthService.php
@@ -15,6 +15,7 @@ use core\util\niucloud\BaseNiucloudClient;
use core\util\niucloud\http\Response;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
+use think\facade\Cache;
/**
* 官网授权管理服务层
@@ -28,10 +29,14 @@ class CoreAuthService extends BaseNiucloudClient
*/
public function getAuthInfo()
{
+ $cache = Cache::get("authinfo");
+ if (!empty($cache)) return $cache;
+
$auth_info = $this->httpGet('authinfo', ['code' => $this->code, 'secret' => $this->secret, 'product_key' => self::PRODUCT ]);
if(!empty($auth_info['data'])){
$auth_info['data']['address_type'] = true;
if($auth_info['data']['site_address'] != $_SERVER['HTTP_HOST']) $auth_info['data']['address_type'] = false;
+ Cache::set("authinfo", $auth_info, 7200);
}
return $auth_info;
}
diff --git a/niucloud/app/service/core/niucloud/CoreCloudBuildService.php b/niucloud/app/service/core/niucloud/CoreCloudBuildService.php
index b199f2be4..5e37e3037 100644
--- a/niucloud/app/service/core/niucloud/CoreCloudBuildService.php
+++ b/niucloud/app/service/core/niucloud/CoreCloudBuildService.php
@@ -136,18 +136,18 @@ class CoreCloudBuildService extends BaseCoreService
// 拷贝手机端文件
$wap_is_compile = ( new Addon() )->where([ [ 'compile', 'like', '%wap%' ] ])->field('id')->findOrEmpty();
if ($wap_is_compile->isEmpty()) {
- dir_copy($this->root_path . 'uni-app', $package_dir . 'uni-app', exclude_dirs: [ 'node_modules', 'unpackage', 'dist' ]);
+ dir_copy($this->root_path . 'uni-app', $package_dir . 'uni-app', exclude_dirs: [ 'node_modules', 'unpackage', 'dist', '.git' ]);
$this->handleUniapp($package_dir . 'uni-app');
}
// 拷贝admin端文件
$admin_is_compile = ( new Addon() )->where([ [ 'compile', 'like', '%admin%' ] ])->field('id')->findOrEmpty();
if ($admin_is_compile->isEmpty()) {
- dir_copy($this->root_path . 'admin', $package_dir . 'admin', exclude_dirs: [ 'node_modules', 'dist', '.vscode', '.idea' ]);
+ dir_copy($this->root_path . 'admin', $package_dir . 'admin', exclude_dirs: [ 'node_modules', 'dist', '.vscode', '.idea', '.git' ]);
}
// 拷贝web端文件
$web_is_compile = ( new Addon() )->where([ [ 'compile', 'like', '%web%' ] ])->field('id')->findOrEmpty();
if ($web_is_compile->isEmpty()) {
- dir_copy($this->root_path . 'web', $package_dir . 'web', exclude_dirs: [ 'node_modules', '.output', '.nuxt' ]);
+ dir_copy($this->root_path . 'web', $package_dir . 'web', exclude_dirs: [ 'node_modules', '.output', '.nuxt', '.git' ]);
}
$this->handleCustomPort($package_dir);
diff --git a/niucloud/app/service/core/notice/NoticeService.php b/niucloud/app/service/core/notice/NoticeService.php
index 029b968f1..f82643190 100644
--- a/niucloud/app/service/core/notice/NoticeService.php
+++ b/niucloud/app/service/core/notice/NoticeService.php
@@ -15,6 +15,8 @@ namespace app\service\core\notice;
use app\job\notice\Notice;
use app\model\sys\SysNotice;
use core\base\BaseCoreService;
+use core\exception\NoticeException;
+use think\facade\Log;
/**
@@ -36,16 +38,19 @@ class NoticeService extends BaseCoreService
* @return false|mixed
* @throws \Exception
*/
- public static function send($key, $data){
+ public static function send($key, $data)
+ {
try {
$template = (new CoreNoticeService())->getInfo($key);
- if(empty($template)) return false;
+ Log::write("消息发送");
+ Log::write($template);
+ if (empty($template)) return false;
- return Notice::dispatch(['key' => $key, 'data' => $data, 'template' => $template], is_async:$template['async']);
+ return Notice::dispatch(['key' => $key, 'data' => $data, 'template' => $template], is_async: $template['async']);
- }catch (\Exception $e){
- throw new \Exception($e->getMessage());
+ } catch (\Exception $e) {
+ throw new NoticeException($e->getMessage());
}
}
-}
\ No newline at end of file
+}
diff --git a/niucloud/app/service/core/pay/CorePayService.php b/niucloud/app/service/core/pay/CorePayService.php
index 5298e8350..55a2e9838 100644
--- a/niucloud/app/service/core/pay/CorePayService.php
+++ b/niucloud/app/service/core/pay/CorePayService.php
@@ -150,6 +150,7 @@ class CorePayService extends BaseCoreService
* @param string $trade_type
* @param string $trade_id
* @param string $channel
+ * @param string $scene
* @return array
* @throws DataNotFoundException
* @throws DbException
@@ -203,6 +204,8 @@ class CorePayService extends BaseCoreService
* @param string $return_url
* @param string $quit_url
* @param string $buyer_id
+ * @param string $voucher
+ * @param int $member_id
* @return mixed
* @throws DataNotFoundException
* @throws DbException
@@ -263,7 +266,7 @@ class CorePayService extends BaseCoreService
]
);
if (env('queue.state', true)) {
- PayReturnTo::dispatch([ 'out_trade_no' => $out_trade_no ], secs: 60);
+ PayReturnTo::dispatch([ 'out_trade_no' => $out_trade_no ], secs: 300);
}
}
return $pay_result;
@@ -461,13 +464,10 @@ class CorePayService extends BaseCoreService
switch ($action) {
case 'pay'://支付结果通知
return $this->payNotify($out_trade_no, $type, $params);
- break;
case 'refund':
return ( new CoreRefundService() )->refundNotify($out_trade_no, $type, $params);
- break;
case 'transfer':
return ( new CoreTransferService() )->transferNotify($out_trade_no, $params);
- break;
}
//找不到对应的业务
return true;
@@ -563,7 +563,6 @@ class CorePayService extends BaseCoreService
Db::rollback();
throw new PayException($e->getMessage() . $e->getFile() . $e->getLine());
}
- return true;
}
/**
diff --git a/niucloud/app/service/core/pay/CoreTransferSceneService.php b/niucloud/app/service/core/pay/CoreTransferSceneService.php
index 938c15d56..d7701387f 100644
--- a/niucloud/app/service/core/pay/CoreTransferSceneService.php
+++ b/niucloud/app/service/core/pay/CoreTransferSceneService.php
@@ -13,17 +13,10 @@ namespace app\service\core\pay;
use app\dict\pay\TransferDict;
use app\dict\sys\ConfigKeyDict;
-use app\model\pay\Pay;
-use app\model\pay\Transfer;
use app\model\pay\TransferScene;
use app\service\core\sys\CoreConfigService;
use core\base\BaseCoreService;
-use core\exception\PayException;
-use Exception;
-use think\facade\Db;
-use think\facade\Log;
use think\Model;
-use Throwable;
/**
* 转账场景服务层
@@ -41,7 +34,6 @@ class CoreTransferSceneService extends BaseCoreService
/**
* 获取底部导航配置
- * @param string $key
* @return array
*/
public function getWechatTransferSceneConfig()
@@ -53,7 +45,6 @@ class CoreTransferSceneService extends BaseCoreService
/**
* 设置微信转账场景导航
* @param array $data
- * @param string $key
* @return SysConfig|bool|Model
*/
public function setWechatTransferSceneConfig(array $data)
@@ -96,6 +87,7 @@ class CoreTransferSceneService extends BaseCoreService
/**
* 通过业务设置转账场景的配置信息
+ * @param $type
* @param $data
* @return void
*/
diff --git a/niucloud/app/service/core/pay/CoreTransferService.php b/niucloud/app/service/core/pay/CoreTransferService.php
index 22317e2ff..bcfa4ee45 100644
--- a/niucloud/app/service/core/pay/CoreTransferService.php
+++ b/niucloud/app/service/core/pay/CoreTransferService.php
@@ -14,8 +14,6 @@ namespace app\service\core\pay;
use app\dict\pay\TransferDict;
use app\model\pay\Pay;
use app\model\pay\Transfer;
-use app\model\pay\TransferScene;
-use app\service\core\sys\CoreConfigService;
use core\base\BaseCoreService;
use core\exception\PayException;
use Exception;
diff --git a/niucloud/app/service/core/sys/CoreAttachmentService.php b/niucloud/app/service/core/sys/CoreAttachmentService.php
index 1d1aff50a..f962ed9f4 100644
--- a/niucloud/app/service/core/sys/CoreAttachmentService.php
+++ b/niucloud/app/service/core/sys/CoreAttachmentService.php
@@ -11,6 +11,7 @@
namespace app\service\core\sys;
+use app\dict\sys\StorageDict;
use app\model\sys\SysAttachment;
use app\service\core\upload\CoreFileService;
use core\base\BaseCoreService;
@@ -117,13 +118,29 @@ class CoreAttachmentService extends BaseCoreService
if(empty($list))
throw new UploadFileException('PLEACE_SELECT_IMAGE');
- $ids = array_column($list, 'att_id');
+ $del_success_ids = [];
foreach($list as $v){
- $file_driver = (new CoreFileService())->driver($v['storage_type']);
- //读取上传附件的信息用于后续得校验和数据写入,删除失败直接通过
- $file_driver->delete($v['path']);
+ try {
+ $file_driver = (new CoreFileService())->driver($v['storage_type']);
+ //读取上传附件的信息用于后续得校验和数据写入,删除失败直接通过
+ $file_driver->delete($v['path']);
+ } catch (\Exception $e) {
+ // 如果附件在云存储中删除失败后 尝试该资源是否是在平台云存储中
+ if ($v['storage_type'] != StorageDict::LOCAL) {
+ try {
+ $file_driver = (new CoreFileService())->driver(0, $v['storage_type']);
+ $file_driver->delete($v['path']);
+ } catch (\Exception $e) {
+ if (!empty($del_success_ids)) {
+ $this->model->destroy($del_success_ids);
+ }
+ throw new UploadFileException($e->getMessage());
+ }
+ }
+ }
+ $del_success_ids[] = $v['att_id'];
}
- $this->model->destroy($ids);
+ $this->model->destroy($del_success_ids);
return true;
}
}
diff --git a/niucloud/app/service/core/sys/CoreExportService.php b/niucloud/app/service/core/sys/CoreExportService.php
index d27e8d551..b2d5ce00d 100644
--- a/niucloud/app/service/core/sys/CoreExportService.php
+++ b/niucloud/app/service/core/sys/CoreExportService.php
@@ -14,8 +14,10 @@ namespace app\service\core\sys;
use app\dict\sys\ExportDict;
use app\model\sys\SysExport;
use core\base\BaseCoreService;
+use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use think\facade\Log;
@@ -111,7 +113,7 @@ class CoreExportService extends BaseCoreService
$data_list = [];
foreach ($data_array as $v)
{
- $data_list = empty($data_list) ? $v : array_merge($data_list, $v);
+ $data_list = array_merge($data_list, $v );
}
return $data_list;
}
@@ -195,9 +197,17 @@ class CoreExportService extends BaseCoreService
foreach ($data as $item) {
foreach ($data_column as $k => $v)
{
- $sheet->setCellValue($v['excel_column_name'] . $row, $item[$k]);
- // 将样式应用到单元格
- $sheet->getStyle($v['excel_column_name'] . $row)->applyFromArray($style_array);
+ $cell_value = $item[$k] ?? '';
+ $cell_coordinate = $v['excel_column_name'] . $row;
+ // 步骤1:获取单元格对象
+ $cell = $sheet->getCell($cell_coordinate);
+ // 步骤2:强制单元格格式为纯文本(核心)
+ $cell->getStyle()->getNumberFormat()->setFormatCode(NumberFormat::FORMAT_TEXT);
+ // 步骤3:显式赋值为字符串类型,避免解析为公式(核心)
+ $cell->setValueExplicit($cell_value, DataType::TYPE_STRING);
+
+ // 将样式应用到单元格(原有逻辑保留)
+ $sheet->getStyle($cell_coordinate)->applyFromArray($style_array);
// todo 合并行
if (isset($v['merge_type']) && $v['merge_type'] == 'column') {
diff --git a/niucloud/app/service/core/weapp/CoreWeappCloudService.php b/niucloud/app/service/core/weapp/CoreWeappCloudService.php
index 26146b978..05f5a55d6 100644
--- a/niucloud/app/service/core/weapp/CoreWeappCloudService.php
+++ b/niucloud/app/service/core/weapp/CoreWeappCloudService.php
@@ -65,7 +65,7 @@ class CoreWeappCloudService extends CoreCloudBaseService
// 如果不存在编译版小程序
if ($compile_addon->isEmpty()) {
- dir_copy($this->root_path . 'uni-app', $uni_dir, exclude_dirs: [ 'node_modules', 'unpackage', 'dist' ]);
+ dir_copy($this->root_path . 'uni-app', $uni_dir, exclude_dirs: [ 'node_modules', 'unpackage', 'dist', '.git' ]);
// $this->handleTabbar($uni_dir . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR);
// 替换env文件
$this->weappEnvReplace($uni_dir . DIRECTORY_SEPARATOR . '.env.production');
@@ -90,7 +90,7 @@ class CoreWeappCloudService extends CoreCloudBaseService
'do' => 1,
'timestamp' => time()
];
- $response = ( new CloudService() )->httpPost('cloud/weapp?' . http_build_query($query), [
+ $response = ( new CloudService(true) )->httpPost('cloud/weapp?' . http_build_query($query), [
'multipart' => [
[
'name' => 'file',
@@ -189,7 +189,7 @@ class CoreWeappCloudService extends CoreCloudBaseService
$query = [
'authorize_code' => $this->auth_code,
];
- $preview_url = ( new CloudService() )->getUrl('cloud/get_weapp_preview?' . http_build_query($query));
+ $preview_url = ( new CloudService(true) )->getUrl('cloud/get_weapp_preview?' . http_build_query($query));
try {
$path = runtime_path() . uniqid() . '.jpg';
@@ -211,7 +211,7 @@ class CoreWeappCloudService extends CoreCloudBaseService
'authorize_code' => $this->auth_code,
'timestamp' => $timestamp
];
- $build_log = ( new CloudService() )->httpGet('cloud/get_weapp_logs?' . http_build_query($query));
+ $build_log = ( new CloudService(true) )->httpGet('cloud/get_weapp_logs?' . http_build_query($query));
if (isset($build_log[ 'data' ]) && isset($build_log[ 'data' ][ 0 ]) && is_array($build_log[ 'data' ][ 0 ])) {
$last = end($build_log[ 'data' ][ 0 ]);
diff --git a/niucloud/app/service/core/wechat/CoreWechatServeService.php b/niucloud/app/service/core/wechat/CoreWechatServeService.php
index 60ce350c2..38bef91c3 100644
--- a/niucloud/app/service/core/wechat/CoreWechatServeService.php
+++ b/niucloud/app/service/core/wechat/CoreWechatServeService.php
@@ -138,12 +138,13 @@ class CoreWechatServeService extends BaseCoreService
}
$scene = [ $sceneKey => $key ];
$param = [
- 'expire_seconds' => $expire_seconds, // 二维码的有效时间
+ 'expire_seconds' => $expire_seconds,
'action_name' => $type,
'action_info' => [
'scene' => $scene
],
];
- return $api->postJson('cgi-bin/qrcode/create', $param);
+ $response = $api->postJson('cgi-bin/qrcode/create', $param);
+ return json_decode($response->getContent(), true);
}
}
diff --git a/niucloud/app/upgrade/v158/Upgrade.php b/niucloud/app/upgrade/v158/Upgrade.php
new file mode 100644
index 000000000..328eaf6ca
--- /dev/null
+++ b/niucloud/app/upgrade/v158/Upgrade.php
@@ -0,0 +1,85 @@
+handleDiyData();
+ $this->handleDiyFormData();
+ }
+
+ /**
+ * 处理自定义数据
+ * @return void
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\DbException
+ * @throws \think\db\exception\ModelNotFoundException
+ */
+ private function handleDiyData()
+ {
+ $diy_model = new Diy();
+ $where = [
+ ['value', '<>', ''],
+ ];
+ $field = 'id,value';
+ $list = $diy_model->where($where)->field($field)->select()->toArray();
+ $components_names = ['GoodsList','ManyGoodsList','ShopExchangeGoods','ShopGoodsRecommend','SingleRecommend','ShopNewcomer','ShopGoodsRanking','ShopGoodsHot'];
+
+ if (!empty($list)) {
+ foreach ($list as $k => $v) {
+ $diy_data = json_decode($v['value'], true);
+ $diy_data['global']['copyright']['textColor'] = '#ccc';
+ foreach ($diy_data['value'] as $k1=>$v1) {
+ if (in_array($v1['componentName'],$components_names)){
+ $diy_data['value'][$k1]['mode'] = 'aspectFill';
+ }
+ }
+ $diy_data = json_encode($diy_data);
+ $diy_model->where([['id', '=', $v['id']]])->update(['value' => $diy_data]);
+ }
+ }
+
+ }
+
+ /**
+ * 处理万能表单数据
+ * @return void
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\DbException
+ * @throws \think\db\exception\ModelNotFoundException
+ */
+ private function handleDiyFormData()
+ {
+ $diy_form_model = new DiyForm();
+ $where = [
+ ['value', '<>', '']
+ ];
+ $field = 'form_id,value';
+ $list = $diy_form_model->where($where)->field($field)->select()->toArray();
+ $components_names = ['GoodsList','ManyGoodsList','ShopExchangeGoods','ShopGoodsRecommend','SingleRecommend','ShopNewcomer','ShopGoodsRanking','ShopGoodsHot'];
+
+ if (!empty($list)) {
+ foreach ($list as $k => $v) {
+ $diy_data = $v['value'];
+ if (!isset($diy_data['global']['copyright']['textColor'])) {
+ $diy_data['global']['copyright']['textColor'] = '#ccc';
+ }
+ foreach ($diy_data['value'] as $k1=>$v1) {
+ if (in_array($v1['componentName'],$components_names)){
+ $diy_data['value'][$k1]['mode'] = 'aspectFill';
+ }
+ }
+ $diy_form_model->where([['form_id', '=', $v['form_id']]])->update(['value' => $diy_data]);
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/niucloud/app/upgrade/v158/upgrade.sql b/niucloud/app/upgrade/v158/upgrade.sql
new file mode 100644
index 000000000..803420bd8
--- /dev/null
+++ b/niucloud/app/upgrade/v158/upgrade.sql
@@ -0,0 +1,2 @@
+ALTER TABLE `verify`
+ CHANGE COLUMN `value` `value` TEXT DEFAULT NULL COMMENT '核销内容';
diff --git a/niucloud/config/console.php b/niucloud/config/console.php
index 0389b1a18..57ee7a404 100644
--- a/niucloud/config/console.php
+++ b/niucloud/config/console.php
@@ -6,8 +6,8 @@ use core\dict\DictLoader;
$data = [
// 指令定义
'commands' => [
- 'addon:install' => 'app\command\Addon\Install',
- 'addon:uninstall' => 'app\command\Addon\Uninstall',
+ 'addon:install' => 'app\command\addon\Install',
+ 'addon:uninstall' => 'app\command\addon\Uninstall',
'menu:refresh' => 'app\command\Menu',
//消息队列 自定义命令
'queue:work' => 'app\command\queue\Queue',
@@ -19,7 +19,7 @@ $data = [
'workerman' => 'app\command\workerman\Workerman',
//重置管理员密码
'reset:password' => 'app\command\Resetpassword',
- 'refresh:area' => 'app\command\refreshAreaCommand',
+ 'refresh:area' => 'app\command\RefreshAreaCommand',
],
];
return (new DictLoader("Console"))->load($data);
diff --git a/niucloud/config/version.php b/niucloud/config/version.php
index d53d9d0c3..fc27c0f2b 100644
--- a/niucloud/config/version.php
+++ b/niucloud/config/version.php
@@ -1,5 +1,5 @@
'1.5.7',
- 'code' => '202511120001'
+ 'version' => '1.5.8',
+ 'code' => '202603210001'
];
\ No newline at end of file
diff --git a/niucloud/core/pay/Alipay.php b/niucloud/core/pay/Alipay.php
index b699e508a..b1b4c3c14 100644
--- a/niucloud/core/pay/Alipay.php
+++ b/niucloud/core/pay/Alipay.php
@@ -233,8 +233,12 @@ class Alipay extends BasePay
'out_trade_no' => $out_trade_no
];
} else {
- //todo 这儿可以抛出错误
- return false;
+ return [
+ 'status' => RefundDict::FAIL,
+ 'refund_no' => $refund_no,
+ 'out_trade_no' => $out_trade_no,
+ 'fail_reason' => $result['sub_msg'] ?? ''
+ ];
}
}
diff --git a/niucloud/core/pay/Wechatpay.php b/niucloud/core/pay/Wechatpay.php
index 73c08c18d..05d95d140 100644
--- a/niucloud/core/pay/Wechatpay.php
+++ b/niucloud/core/pay/Wechatpay.php
@@ -130,13 +130,14 @@ class Wechatpay extends BasePay
public function app(array $params)
{
try {
- return $this->returnFormat(Pay::wechat()->app([
+ $result = $this->returnFormat(Pay::wechat()->app([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
]));
+ return ['orderInfo' => $result];
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
diff --git a/niucloud/core/sms/Niuyun.php b/niucloud/core/sms/Niuyun.php
index 0bdb08461..bdbaebfd2 100644
--- a/niucloud/core/sms/Niuyun.php
+++ b/niucloud/core/sms/Niuyun.php
@@ -49,7 +49,7 @@ class Niuyun extends BaseSms
*/
public function send(string $mobile, string $template_id, array $data = [])
{
- Log::write("SEND_NY_SMS pre " . json_encode($data, 256));
+ Log::write("SEND_NY_SMS pre mobile: ".$mobile.' tem_id:'.$template_id . json_encode($data, 256));
if (empty($this->signature)) {
throw new CommonException('签名未配置');
}
diff --git a/niucloud/core/template/Weapp.php b/niucloud/core/template/Weapp.php
index 815fc54fe..28f05d6f5 100644
--- a/niucloud/core/template/Weapp.php
+++ b/niucloud/core/template/Weapp.php
@@ -17,6 +17,7 @@ use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use EasyWeChat\Kernel\Support\Collection;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
+use think\facade\Log;
class Weapp extends BaseTemplate
@@ -42,12 +43,13 @@ class Weapp extends BaseTemplate
public function send(array $data)
{
$api = CoreWeappService::appApiClient();
- $api->postJson('cgi-bin/message/subscribe/send', [
+ $res = $api->postJson('cgi-bin/message/subscribe/send', [
'template_id' => $data['template_id'], // 所需下发的订阅模板id
'touser' => $data['openid'], // 接收者(用户)的 openid
'page' => $data['page'], // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
'data' => $data['data'],
]);
+ Log::write("发送小程序消息Response-" . json_encode($res->toArray(), 256));
}
/**
@@ -60,11 +62,13 @@ class Weapp extends BaseTemplate
public function addTemplate(array $data)
{
$api = CoreWeappService::appApiClient();
- return $api->postJson('wxaapi/newtmpl/addtemplate', [
+ $res = $api->postJson('wxaapi/newtmpl/addtemplate', [
'tid' => $data['tid'],
'kidList' => $data['kid_list'],
'sceneDesc' => $data['scene_desc'],
]);
+ Log::write("添加小程序模版Response-" . json_encode($res->toArray(), 256));
+ return $res;
}
/**
@@ -77,9 +81,11 @@ class Weapp extends BaseTemplate
public function delete(array $data)
{
$api = CoreWeappService::appApiClient();
- return $api->postJson('wxaapi/newtmpl/deltemplate', [
+ $res = $api->postJson('wxaapi/newtmpl/deltemplate', [
'priTmplId' => $data['template_id'],
]);
+ Log::write("删除小程序模版Response-" . json_encode($res->toArray(), 256));
+ return $res;
}
/**
diff --git a/niucloud/core/util/http/HttpClient.php b/niucloud/core/util/http/HttpClient.php
new file mode 100644
index 000000000..220a3cf09
--- /dev/null
+++ b/niucloud/core/util/http/HttpClient.php
@@ -0,0 +1,100 @@
+request($url, 'POST', array_merge([
+ 'json' => $data,
+ 'headers' => [
+ 'Content-Type' => 'application/json;charset=utf-8'
+ ]
+ ], $options));
+ }
+
+ /**
+ * @param string $url
+ * @param array $data
+ * @return array|Response|object|ResponseInterface
+ * @throws GuzzleException
+ */
+ public function httpPut(string $url, array $data = [], array $options = [])
+ {
+ return $this->request($url, 'PUT', array_merge([
+ 'json' => $data,
+ 'headers' => [
+ 'Content-Type' => 'application/json;charset=utf-8'
+ ]
+ ], $options));
+ }
+
+ /**
+ * @param string $url
+ * @param string $method
+ * @param array $options
+ * @param bool $returnRaw
+ *
+ * @return ResponseInterface
+ * @throws GuzzleException
+ */
+ public function request(string $url, string $method = 'GET', array $options = [], bool $returnRaw = false)
+ {
+ $response = $this->toRequest($url, $method, $options);
+ return $response;
+ }
+
+
+ /**
+ * @param string $url
+ * @param array $query
+ * @return array|object|Response|ResponseInterface
+ * @throws GuzzleException
+ */
+ public function httpGet(string $url, array $query = [], array $options = [])
+ {
+ return $this->request($url, 'GET', array_merge([
+ 'query' => $query,
+ ], $options));
+ }
+
+ /**
+ * @param string $url
+ * @param array $data
+ * @param array $query
+ * @return array|Response|object|ResponseInterface
+ * @throws GuzzleException
+ */
+ public function httpPostJson(string $url, array $data = [], array $query = [])
+ {
+ return $this->request($url, 'POST', ['query' => $query, 'json' => $data]);
+ }
+}
diff --git a/niucloud/core/util/http/src/HasHttpRequests.php b/niucloud/core/util/http/src/HasHttpRequests.php
new file mode 100644
index 000000000..5282db4a9
--- /dev/null
+++ b/niucloud/core/util/http/src/HasHttpRequests.php
@@ -0,0 +1,183 @@
+ [
+ CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
+ ],
+ ];
+ /**
+ * @var ClientInterface
+ */
+ protected $httpClient;
+ /**
+ * @var array
+ */
+ protected array $middlewares = [];
+ /**
+ * @var HandlerStack
+ */
+ protected $handlerStack;
+
+ /**
+ * @param array $defaults
+ * @return void
+ */
+ public static function setDefaultOptions(array $defaults = [])
+ {
+ self::$defaults = $defaults;
+ }
+
+ /**
+ * @return array
+ */
+ public static function getDefaultOptions(): array
+ {
+ return self::$defaults;
+ }
+
+ /**
+ * @param callable $middleware
+ * @param string|null $name
+ * @return $this
+ */
+ public function pushMiddleware(callable $middleware, string $name = null)
+ {
+ if (!is_null($name)) {
+ $this->middlewares[$name] = $middleware;
+ } else {
+ $this->middlewares[] = $middleware;
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getMiddlewares(): array
+ {
+ return $this->middlewares;
+ }
+
+ /**
+ * @param $url
+ * @param string $method
+ * @param array $options
+ * @return ResponseInterface
+ * @throws GuzzleException
+ */
+ public function toRequest($url, string $method = 'GET', array $options = [])
+ {
+ $method = strtoupper($method);
+
+ $options = array_merge(self::$defaults, $options, ['handler' => $this->getHandlerStack()]);
+
+ $options = $this->fixJsonIssue($options);
+
+ if (property_exists($this, 'baseUri') && !is_null($this->baseUri)) {
+ $options['base_uri'] = $this->baseUri;
+ }
+ $options['connect_timeout'] = 10;
+ $response = $this->getHttpClient()->request($method, $url, $options);
+ $response->getBody()->rewind();
+ return json_decode($response->getBody()->getContents(), true);
+ }
+
+ /**
+ * @return HandlerStack
+ */
+ public function getHandlerStack(): HandlerStack
+ {
+ if ($this->handlerStack) {
+ return $this->handlerStack;
+ }
+
+ $this->handlerStack = HandlerStack::create($this->getGuzzleHandler());
+
+ foreach ($this->middlewares as $name => $middleware) {
+ $this->handlerStack->push($middleware, $name);
+ }
+
+ return $this->handlerStack;
+ }
+
+ /**
+ * @param HandlerStack $handlerStack
+ *
+ * @return $this
+ */
+ public function setHandlerStack(HandlerStack $handlerStack)
+ {
+ $this->handlerStack = $handlerStack;
+
+ return $this;
+ }
+
+ /**
+ * @return callable
+ */
+ protected function getGuzzleHandler()
+ {
+ return choose_handler();
+ }
+
+ /**
+ * @param array $options
+ * @return array
+ */
+ protected function fixJsonIssue(array $options): array
+ {
+ if (isset($options['json']) && is_array($options['json'])) {
+ $options['headers'] = array_merge($options['headers'] ?? [], ['Content-Type' => 'application/json']);
+
+ if (empty($options['json'])) {
+ $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_FORCE_OBJECT);
+ } else {
+ $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_UNESCAPED_UNICODE);
+ }
+
+ unset($options['json']);
+ }
+
+ return $options;
+ }
+
+ /**
+ * @return ClientInterface
+ */
+ public function getHttpClient(): ClientInterface
+ {
+ if (!($this->httpClient instanceof ClientInterface)) {
+ $this->httpClient = new Client(['handler' => HandlerStack::create($this->getGuzzleHandler())]);
+ }
+
+ return $this->httpClient;
+ }
+
+ /**
+ * @param ClientInterface $httpClient
+ * @return $this
+ */
+ public function setHttpClient(ClientInterface $httpClient)
+ {
+ $this->httpClient = $httpClient;
+
+ return $this;
+ }
+}
diff --git a/niucloud/core/util/niucloud/CloudService.php b/niucloud/core/util/niucloud/CloudService.php
index 6f0f36bca..7f421280b 100644
--- a/niucloud/core/util/niucloud/CloudService.php
+++ b/niucloud/core/util/niucloud/CloudService.php
@@ -30,6 +30,9 @@ class CloudService
$local_cloud_compile_config = (new CoreConfigService())->getConfig(0, 'LOCAL_CLOUD_COMPILE_CONFIG')['value'] ?? [];
if (!empty($local_cloud_compile_config) && isset($local_cloud_compile_config['isOpen']) && $local_cloud_compile_config['isOpen'] == 1){
$baseUri = $local_cloud_compile_config['baseUri'] ?? '';
+ if (empty($baseUri)){
+ throw new CommonException("已开启`第三方云编译`,但未配置云编译服务器地址,详情查看:平台端》云编译》第三方云编译");
+ }
}
if (!empty($local_cloud_compile)){
diff --git a/niucloud/core/util/niucloud/http/AccessToken.php b/niucloud/core/util/niucloud/http/AccessToken.php
index c0315b3ea..5aaffc4d1 100644
--- a/niucloud/core/util/niucloud/http/AccessToken.php
+++ b/niucloud/core/util/niucloud/http/AccessToken.php
@@ -34,6 +34,7 @@ trait AccessToken
{
$this->access_token = '';
Cache::delete($this->access_token_cache);
+ if (file_exists(public_path() . 'access_token.txt')) unlink(file_exists(public_path() . 'access_token.txt'));
return $this;
}
/**
@@ -55,6 +56,9 @@ trait AccessToken
if (empty($this->access_token)) {
$this->access_token = Cache::get($this->access_token_cache, '');
}
+ if (empty($this->access_token) && file_exists(public_path() . 'access_token.txt')) {
+ $this->access_token = file_get_contents(public_path() . 'access_token.txt');
+ }
return $this->access_token;
}
@@ -67,7 +71,9 @@ trait AccessToken
{
$access_token_info = $this->httpGet('auth', ['code' => $this->code, 'secret' => $this->secret, 'token' => $this->createToken(), 'product_key' => self::PRODUCT, 'redirect_uri' => $this->getDomain(false)]);
if (isset($access_token_info['code']) && $access_token_info['code'] != 1) throw new NiucloudException($access_token_info['msg']);
- $this->setAccessToken($access_token_info['data']['token']);
+ if (isset($access_token_info['data']['token']) && !empty($access_token_info['data']['token'])) {
+ $this->setAccessToken($access_token_info['data']['token']);
+ }
}
}
diff --git a/niucloud/core/util/niucloud/http/HasHttpRequests.php b/niucloud/core/util/niucloud/http/HasHttpRequests.php
index e10925e3d..c784b58f1 100644
--- a/niucloud/core/util/niucloud/http/HasHttpRequests.php
+++ b/niucloud/core/util/niucloud/http/HasHttpRequests.php
@@ -164,7 +164,10 @@ trait HasHttpRequests
public function getHttpClient(): ClientInterface
{
if (!($this->httpClient instanceof ClientInterface)) {
- $this->httpClient = new Client(['handler' => HandlerStack::create($this->getGuzzleHandler())]);
+ $this->httpClient = new Client([
+ 'handler' => HandlerStack::create($this->getGuzzleHandler()),
+// 'proxy'=>''//调试放开
+ ]);
}
return $this->httpClient;
|