浏览代码

租户模式

whitefang 1 年之前
父节点
当前提交
0fe36dd8a4
共有 100 个文件被更改,包括 8735 次插入52 次删除
  1. 122 0
      app/common/cache/TenantAdminAuthCache.php
  2. 120 0
      app/common/cache/TenantAdminTokenCache.php
  3. 37 13
      app/common/enum/AdminTerminalEnum.php
  4. 120 11
      app/common/http/middleware/LikeAdminAllowMiddleware.php
  5. 13 0
      app/common/lists/BaseDataLists.php
  6. 19 0
      app/common/model/TenantConfig.php
  7. 179 0
      app/common/model/auth/TenantAdmin.php
  8. 32 0
      app/common/model/auth/TenantAdminDept.php
  9. 32 0
      app/common/model/auth/TenantAdminJobs.php
  10. 34 0
      app/common/model/auth/TenantAdminRole.php
  11. 32 0
      app/common/model/auth/TenantAdminSession.php
  12. 28 0
      app/common/model/auth/TenantSystemMenu.php
  13. 41 0
      app/common/model/auth/TenantSystemRole.php
  14. 30 0
      app/common/model/auth/TenantSystemRoleMenu.php
  15. 73 0
      app/common/model/dept/TenantDept.php
  16. 44 0
      app/common/model/dept/TenantJobs.php
  17. 24 0
      app/common/model/file/TenantFile.php
  18. 25 0
      app/common/model/file/TenantFileCate.php
  19. 54 0
      app/common/model/pay/TenantPayConfig.php
  20. 53 0
      app/common/model/pay/TenantPayWay.php
  21. 133 0
      app/common/model/tenant/Tenant.php
  22. 44 28
      app/common/service/ConfigService.php
  23. 28 0
      app/tenantapi/config/route.php
  24. 43 0
      app/tenantapi/controller/BaseAdminController.php
  25. 61 0
      app/tenantapi/controller/ConfigController.php
  26. 50 0
      app/tenantapi/controller/DownloadController.php
  27. 137 0
      app/tenantapi/controller/FileController.php
  28. 59 0
      app/tenantapi/controller/LoginController.php
  29. 80 0
      app/tenantapi/controller/UploadController.php
  30. 38 0
      app/tenantapi/controller/WorkbenchController.php
  31. 134 0
      app/tenantapi/controller/auth/AdminController.php
  32. 142 0
      app/tenantapi/controller/auth/MenuController.php
  33. 124 0
      app/tenantapi/controller/auth/RoleController.php
  34. 53 0
      app/tenantapi/controller/channel/AppSettingController.php
  35. 52 0
      app/tenantapi/controller/channel/MnpSettingsController.php
  36. 74 0
      app/tenantapi/controller/channel/OfficialAccountMenuController.php
  37. 148 0
      app/tenantapi/controller/channel/OfficialAccountReplyController.php
  38. 52 0
      app/tenantapi/controller/channel/OfficialAccountSettingController.php
  39. 54 0
      app/tenantapi/controller/channel/OpenSettingController.php
  40. 54 0
      app/tenantapi/controller/channel/WebPageSettingController.php
  41. 55 0
      app/tenantapi/controller/decorate/DataController.php
  42. 61 0
      app/tenantapi/controller/decorate/PageController.php
  43. 58 0
      app/tenantapi/controller/decorate/TabbarController.php
  44. 134 0
      app/tenantapi/controller/dept/DeptController.php
  45. 118 0
      app/tenantapi/controller/dept/JobsController.php
  46. 51 0
      app/tenantapi/controller/setting/CustomerServiceController.php
  47. 56 0
      app/tenantapi/controller/setting/HotSearchController.php
  48. 53 0
      app/tenantapi/controller/setting/TransactionSettingsController.php
  49. 69 0
      app/tenantapi/controller/setting/pay/PayConfigController.php
  50. 61 0
      app/tenantapi/controller/setting/pay/PayWayController.php
  51. 39 0
      app/tenantapi/controller/setting/system/CacheController.php
  52. 84 0
      app/tenantapi/controller/setting/user/UserController.php
  53. 137 0
      app/tenantapi/controller/setting/web/WebSettingController.php
  54. 86 0
      app/tenantapi/controller/user/UserController.php
  55. 23 0
      app/tenantapi/event.php
  56. 92 0
      app/tenantapi/http/middleware/AuthMiddleware.php
  57. 50 0
      app/tenantapi/http/middleware/CheckDemoMiddleware.php
  58. 114 0
      app/tenantapi/http/middleware/EncryDemoDataMiddleware.php
  59. 57 0
      app/tenantapi/http/middleware/InitMiddleware.php
  60. 87 0
      app/tenantapi/http/middleware/LoginMiddleware.php
  61. 77 0
      app/tenantapi/listener/OperationLog.php
  62. 39 0
      app/tenantapi/lists/BaseAdminDataLists.php
  63. 206 0
      app/tenantapi/lists/auth/AdminLists.php
  64. 60 0
      app/tenantapi/lists/auth/MenuLists.php
  65. 93 0
      app/tenantapi/lists/auth/RoleLists.php
  66. 80 0
      app/tenantapi/lists/channel/OfficialAccountReplyLists.php
  67. 105 0
      app/tenantapi/lists/dept/JobsLists.php
  68. 74 0
      app/tenantapi/lists/file/FileCateLists.php
  69. 109 0
      app/tenantapi/lists/file/FileLists.php
  70. 62 0
      app/tenantapi/lists/setting/pay/PayConfigLists.php
  71. 111 0
      app/tenantapi/lists/user/UserLists.php
  72. 105 0
      app/tenantapi/logic/ConfigLogic.php
  73. 158 0
      app/tenantapi/logic/FileLogic.php
  74. 83 0
      app/tenantapi/logic/LoginLogic.php
  75. 235 0
      app/tenantapi/logic/WorkbenchLogic.php
  76. 334 0
      app/tenantapi/logic/auth/AdminLogic.php
  77. 104 0
      app/tenantapi/logic/auth/AuthLogic.php
  78. 182 0
      app/tenantapi/logic/auth/MenuLogic.php
  79. 169 0
      app/tenantapi/logic/auth/RoleLogic.php
  80. 56 0
      app/tenantapi/logic/channel/AppSettingLogic.php
  81. 72 0
      app/tenantapi/logic/channel/MnpSettingsLogic.php
  82. 224 0
      app/tenantapi/logic/channel/OfficialAccountMenuLogic.php
  83. 224 0
      app/tenantapi/logic/channel/OfficialAccountReplyLogic.php
  84. 76 0
      app/tenantapi/logic/channel/OfficialAccountSettingLogic.php
  85. 55 0
      app/tenantapi/logic/channel/OpenSettingLogic.php
  86. 59 0
      app/tenantapi/logic/channel/WebPageSettingLogic.php
  87. 96 0
      app/tenantapi/logic/decorate/DecorateDataLogic.php
  88. 67 0
      app/tenantapi/logic/decorate/DecoratePageLogic.php
  89. 81 0
      app/tenantapi/logic/decorate/DecorateTabbarLogic.php
  90. 204 0
      app/tenantapi/logic/dept/DeptLogic.php
  91. 116 0
      app/tenantapi/logic/dept/JobsLogic.php
  92. 65 0
      app/tenantapi/logic/setting/CustomerServiceLogic.php
  93. 75 0
      app/tenantapi/logic/setting/HotSearchLogic.php
  94. 64 0
      app/tenantapi/logic/setting/TransactionSettingsLogic.php
  95. 96 0
      app/tenantapi/logic/setting/pay/PayConfigLogic.php
  96. 111 0
      app/tenantapi/logic/setting/pay/PayWayLogic.php
  97. 37 0
      app/tenantapi/logic/setting/system/CacheLogic.php
  98. 109 0
      app/tenantapi/logic/setting/user/UserLogic.php
  99. 187 0
      app/tenantapi/logic/setting/web/WebSettingLogic.php
  100. 118 0
      app/tenantapi/logic/user/UserLogic.php

+ 122 - 0
app/common/cache/TenantAdminAuthCache.php

@@ -0,0 +1,122 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\cache;
+
+use app\tenantapi\logic\auth\AuthLogic;
+
+
+/**
+ * 管理员权限缓存
+ * Class AdminAuthCache
+ * @package app\common\cache
+ */
+class TenantAdminAuthCache extends BaseCache
+{
+
+    private string $prefix         = 'tenant_auth_';
+    private mixed  $authConfigList = [];
+    private string $cacheMd5Key    = '';          //权限文件MD5的key
+    private string $cacheAllKey    = '';          //全部权限的key
+    private string $cacheUrlKey    = '';          //管理员的url缓存key
+    private string $authMd5        = '';          //权限文件MD5的值
+    private mixed $adminId         = '';
+
+
+    public function __construct($adminId = '')
+    {
+        parent::__construct();
+
+        $this->adminId = $adminId;
+        // 全部权限
+        $this->authConfigList = AuthLogic::getAllAuth();
+        // 当前权限配置文件的md5
+        $this->authMd5 = md5(json_encode($this->authConfigList));
+
+        $this->cacheMd5Key = $this->prefix . 'md5';
+        $this->cacheAllKey = $this->prefix . 'all';
+        $this->cacheUrlKey = $this->prefix . 'url_' . $this->adminId;
+
+        $cacheAuthMd5 = $this->get($this->cacheMd5Key);
+        $cacheAuth = $this->get($this->cacheAllKey);
+        //权限配置和缓存权限对比,不一样说明权限配置文件已修改,清理缓存
+        if ($this->authMd5 !== $cacheAuthMd5 || empty($cacheAuth)) {
+            $this->deleteTag();
+        }
+    }
+
+
+    /**
+     * @notes 获取管理权限uri
+     * @param $adminId
+     * @return array|mixed
+     * @author 令狐冲
+     * @date 2021/8/19 15:27
+     */
+    public function getAdminUri()
+    {
+        //从缓存获取,直接返回
+        $urisAuth = $this->get($this->cacheUrlKey);
+        if ($urisAuth) {
+            return $urisAuth;
+        }
+
+        //获取角色关联的菜单id(菜单或权限)
+        $urisAuth = AuthLogic::getAuthByAdminId($this->adminId);
+        if (empty($urisAuth)) {
+            return [];
+        }
+
+        $this->set($this->cacheUrlKey, $urisAuth, 3600);
+
+        //保存到缓存并读取返回
+        return $urisAuth;
+    }
+
+
+    /**
+     * @notes 获取全部权限uri
+     * @return array|mixed
+     * @author cjhao
+     * @date 2021/9/13 11:41
+     */
+    public function getAllUri()
+    {
+        $cacheAuth = $this->get($this->cacheAllKey);
+        if ($cacheAuth) {
+            return $cacheAuth;
+        }
+        // 获取全部权限
+        $authList = AuthLogic::getAllAuth();
+        //保存到缓存并读取返回
+        $this->set($this->cacheMd5Key, $this->authMd5);
+        $this->set($this->cacheAllKey, $authList);
+        return $authList;
+    }
+
+
+    /**
+     * @notes 清理管理员缓存
+     * @return bool
+     * @author cjhao
+     * @date 2021/10/13 18:47
+     */
+    public function clearAuthCache()
+    {
+        $this->clear($this->cacheUrlKey);
+        return true;
+    }
+
+
+}

+ 120 - 0
app/common/cache/TenantAdminTokenCache.php

@@ -0,0 +1,120 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\cache;
+
+
+use app\common\model\auth\TenantAdmin;
+use app\common\model\auth\TenantAdminSession;
+use app\common\model\auth\TenantSystemRole;
+
+/**
+ * 管理员token缓存
+ * Class AdminTokenCache
+ * @package app\common\cache
+ */
+class TenantAdminTokenCache extends BaseCache
+{
+
+    private $prefix = 'token_tenant_';
+
+    /**
+     * @notes 通过token获取缓存管理员信息
+     * @param $token
+     * @return false|mixed
+     * @author 令狐冲
+     * @date 2021/6/30 16:57
+     */
+    public function getAdminInfo($token)
+    {
+        //直接从缓存获取
+        $adminInfo = $this->get($this->prefix . $token);
+        if ($adminInfo) {
+            return $adminInfo;
+        }
+
+        //从数据获取信息被设置缓存(可能后台清除缓存)
+        $adminInfo = $this->setAdminInfo($token);
+        if ($adminInfo) {
+            return $adminInfo;
+        }
+
+        return false;
+    }
+
+    /**
+     * @notes 通过有效token设置管理信息缓存
+     * @param $token
+     * @return array|false|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 令狐冲
+     * @date 2021/7/5 12:12
+     */
+    public function setAdminInfo($token)
+    {
+        $adminSession = TenantAdminSession::where([['token', '=', $token], ['expire_time', '>', time()]])
+            ->find();
+        if (empty($adminSession)) {
+            return [];
+        }
+        $admin = TenantAdmin::where('id', '=', $adminSession->admin_id)
+            ->append(['role_id'])
+            ->find();
+
+        $roleName = '';
+        $roleLists = TenantSystemRole::column('name', 'id');
+        if ($admin['root'] == 1) {
+            $roleName = '系统管理员';
+        } else {
+            foreach ($admin['role_id'] as $roleId) {
+                $roleName .= $roleLists[$roleId] ?? '';
+                $roleName .= '/';
+            }
+            $roleName = trim($roleName, '/');
+        }
+
+        $adminInfo = [
+            'admin_id' => $admin->id,
+            'tenant_id' => $admin->tenant_id,
+            'root' => $admin->root,
+            'name' => $admin->name,
+            'account' => $admin->account,
+            'role_name' => $roleName,
+            'role_id' => $admin->role_id,
+            'token' => $token,
+            'terminal' => $adminSession->terminal,
+            'expire_time' => $adminSession->expire_time,
+            'login_ip' => request()->ip(),
+        ];
+        $this->set($this->prefix . $token, $adminInfo, new \DateTime(Date('Y-m-d H:i:s', $adminSession->expire_time)));
+        return $this->getAdminInfo($token);
+    }
+
+    /**
+     * @notes 删除缓存
+     * @param $token
+     * @return bool
+     * @author 令狐冲
+     * @date 2021/7/3 16:57
+     */
+    public function deleteAdminInfo($token)
+    {
+        return $this->delete($this->prefix . $token);
+    }
+
+
+}

+ 37 - 13
app/common/enum/AdminTerminalEnum.php

@@ -1,17 +1,4 @@
 <?php
-// +----------------------------------------------------------------------
-// | likeadmin快速开发前后端分离管理后台(PHP版)
-// +----------------------------------------------------------------------
-// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
-// | 开源版本可自由商用,可去除界面版权logo
-// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
-// | github下载:https://github.com/likeshop-github/likeadmin
-// | 访问官网:https://www.likeadmin.cn
-// | likeadmin团队 版权所有 拥有最终解释权
-// +----------------------------------------------------------------------
-// | author: likeadminTeam
-// +----------------------------------------------------------------------
-
 
 namespace app\common\enum;
 
@@ -25,4 +12,41 @@ class AdminTerminalEnum
 {
     const PC = 1;
     const MOBILE = 2;
+
+    const PLATFORM = '__saas__platform__';
+    const TENANT = '__saas__tenant__';
+    const USER = '__saas__user__';
+
+    /**
+     * @notes 是否为租户端
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/04 16:44
+     */
+    public static function isTenant()
+    {
+        return request()->source === self::TENANT;
+    }
+
+    /**
+     * @notes 是否为平台端
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/04 16:44
+     */
+    public static function isPlatform()
+    {
+        return request()->source === self::PLATFORM;
+    }
+
+    /**
+     * @notes 是否为用户端
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/04 16:44
+     */
+    public static function isUser()
+    {
+        return request()->source === self::USER;
+    }
 }

+ 120 - 11
app/common/http/middleware/LikeAdminAllowMiddleware.php

@@ -16,7 +16,10 @@ declare (strict_types=1);
 
 namespace app\common\http\middleware;
 
+use app\common\model\tenant\Tenant;
+use app\common\service\JsonService;
 use Closure;
+use think\facade\Config;
 
 /**
  * 自定义跨域中间件
@@ -25,26 +28,132 @@ use Closure;
  */
 class LikeAdminAllowMiddleware
 {
+    /**
+     * 允许的请求头常量
+     */
+    private const ALLOWED_HEADERS = [
+        'Authorization', 'Sec-Fetch-Mode', 'DNT', 'X-Mx-ReqToken', 'Keep-Alive', 'User-Agent',
+        'If-Match', 'If-None-Match', 'If-Unmodified-Since', 'X-Requested-With', 'If-Modified-Since',
+        'Cache-Control', 'Content-Type', 'Accept-Language', 'Origin', 'Accept-Encoding', 'Access-Token',
+        'token', 'version'
+    ];
+
     /**
      * @notes 跨域处理
      * @param $request
-     * @param \Closure $next
+     * @param Closure $next
      * @param array|null $header
-     * @return mixed|\think\Response
-     * @author 令狐冲
-     * @date 2021/7/26 11:51
+     * @return mixed|\think\Response|\think\response\Json|\think\response\View
+     * @author JXDN
+     * @date 2024/09/11 14:11
      */
     public function handle($request, Closure $next, ?array $header = [])
     {
-        header('Access-Control-Allow-Origin: *');
-        header("Access-Control-Allow-Headers: Authorization, Sec-Fetch-Mode, DNT, X-Mx-ReqToken, Keep-Alive, User-Agent, If-Match, If-None-Match, If-Unmodified-Since, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Accept-Language, Origin, Accept-Encoding,Access-Token,token,version");
-        header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, post');
-        header('Access-Control-Max-Age: 1728000');
-        header('Access-Control-Allow-Credentials:true');
-        if (strtoupper($request->method()) == "OPTIONS") {
+        // 设置跨域头
+        $this->setCorsHeaders();
+
+        // 如果是OPTIONS请求,直接返回响应
+        if (strtoupper($request->method()) === 'OPTIONS') {
             return response();
         }
+
+        // 安装检测
+        $install = file_exists(root_path() . '/config/install.lock');
+        if (!$install) {
+            return JsonService::fail('程序未安装', [], -2);
+        }
+
+        // 获取租户信息
+        $tenantModel = new Tenant();
+        $domain = preg_replace('/^https?:\/\/|\/$/', '', $request->domain());
+        $pathSegments = explode('/', $request->pathinfo());
+        $firstSegment = $pathSegments[0];
+
+        // 处理API请求
+        if (str_contains($firstSegment, 'api')) {
+            if ($firstSegment !== 'adminapi') {
+                return $this->handleTenantAccess($tenantModel, $domain, $request, $next);
+            }
+        } else {
+            // 处理页面请求
+            if ($firstSegment !== 'admin') {
+                return $this->handleTenantAccess($tenantModel, $domain, $request, $next, true);
+            } else {
+                if ($domain !== Config::get('project.http_host')) {
+                    return view(app()->getRootPath() . 'public/error/platform/404.html');
+                }
+            }
+        }
+
         return $next($request);
     }
 
-}
+    /**
+     * 设置跨域头信息
+     */
+    private function setCorsHeaders()
+    {
+        $headers = [
+            'Access-Control-Allow-Origin'      => '*',
+            'Access-Control-Allow-Headers'     => implode(', ', self::ALLOWED_HEADERS),
+            'Access-Control-Allow-Methods'     => 'GET, POST, PATCH, PUT, DELETE, post',
+            'Access-Control-Max-Age'           => '1728000',
+            'Access-Control-Allow-Credentials' => 'true'
+        ];
+
+        foreach ($headers as $key => $value) {
+            header("$key: $value");
+        }
+    }
+
+    /**
+     * @notes 处理租户访问逻辑
+     * @param Tenant $tenantModel
+     * @param string $domain
+     * @param $request
+     * @param Closure $next
+     * @param bool $isPage
+     * @return mixed|\think\Response|\think\response\Json|\think\response\View
+     * @author JXDN
+     * @date 2024/09/11 14:06
+     */
+    private function handleTenantAccess(Tenant $tenantModel, string $domain, $request, Closure $next, bool $isPage = false)
+    {
+        // 通过别名访问租户
+        $tenant = $tenantModel->where(['domain_alias' => $domain])->findOrEmpty();
+        if (!$tenant->isEmpty() && $tenant->disable === 0 && $tenant->domain_alias_enable === 0) {
+            $request->tenantId = $tenant->id;
+            $request->tenantSn = $tenant->sn;
+            return $next($request);
+        } elseif (!$tenant->isEmpty()) {
+            return $this->tenantDisabledResponse($isPage);
+        }
+
+        // 通过子域名访问租户
+        $request->tenantSn = $request->subDomain();
+        $tenant = $tenantModel->where(['sn' => $request->tenantSn])->findOrEmpty();
+        if (!$tenant->isEmpty()) {
+            if ($tenant->disable === 0) {
+                $request->tenantId = $tenant->id;
+                return $next($request);
+            } else {
+                return $this->tenantDisabledResponse($isPage);
+            }
+        }
+
+        // 租户不存在或域名错误
+        return $isPage ? view(app()->getRootPath() . 'public/error/tenant/404.html') : JsonService::fail('接口域名错误或租户不存在', [], 4, 0);
+    }
+
+    /**
+     * @notes 返回租户停用的响应
+     * @param bool $isPage
+     * @return \think\response\Json|\think\response\View
+     * @author JXDN
+     * @date 2024/09/11 14:06
+     */
+    private function tenantDisabledResponse(bool $isPage)
+    {
+        return $isPage ? view(app()->getRootPath() . 'public/error/tenant/403.html') : JsonService::fail('该租户已停用', [], 3, 0);
+    }
+}

+ 13 - 0
app/common/lists/BaseDataLists.php

@@ -66,8 +66,13 @@ abstract class BaseDataLists implements ListsInterface
 
         //请求参数设置
         $this->request = request();
+
+
         $this->params = $this->request->param();
 
+        //初始化租户
+        $this->initTenant();
+
         //分页初始化
         $this->initPage();
 
@@ -82,6 +87,14 @@ abstract class BaseDataLists implements ListsInterface
     }
 
 
+    public function initTenant()
+    {
+        if(!empty($this->request->adminInfo['tenant_id'])){
+            $this->params['tenant_id'] = $this->request->adminInfo['tenant_id'];
+        }
+    }
+
+
     /**
      * @notes 分页参数初始化
      * @author 令狐冲

+ 19 - 0
app/common/model/TenantConfig.php

@@ -0,0 +1,19 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model;
+
+class TenantConfig extends BaseModel
+{
+}

+ 179 - 0
app/common/model/auth/TenantAdmin.php

@@ -0,0 +1,179 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\auth;
+
+use app\common\enum\YesNoEnum;
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+use app\common\service\FileService;
+
+class TenantAdmin extends BaseModel
+{
+    use SoftDelete;
+
+    protected $deleteTime = 'delete_time';
+
+    protected $append = [
+        'role_id',
+        'dept_id',
+        'jobs_id',
+    ];
+
+    /**
+     * @notes 搜索器-租户账号信息
+     * @param $query
+     * @param $value
+     * @param $data
+     * @return void
+     * @author JXDN
+     * @date 2024/09/06 11:17
+     */
+    public function searchKeywordAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('account|name', 'like', '%' . $value . '%');
+        }
+    }
+
+    /**
+     * @notes 搜索器-租户id
+     * @param $query
+     * @param $value
+     * @param $data
+     * @return void
+     * @author JXDN
+     * @date 2024/09/06 11:25
+     */
+    public function searchTenantIdAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('tenant_id', '=', $value);
+        }
+    }
+
+    /**
+     * @notes 搜索器-注册时间
+     * @param $query
+     * @param $value
+     * @param $data
+     * @return void
+     * @author JXDN
+     * @date 2024/09/06 11:24
+     */
+    public function searchCreateTimeStartAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('create_time', '>=', strtotime($value));
+        }
+    }
+
+
+    /**
+     * @notes 搜索器-注册时间
+     * @param $query
+     * @param $value
+     * @param $data
+     * @return void
+     * @author JXDN
+     * @date 2024/09/06 11:24
+     */
+    public function searchCreateTimeEndAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('create_time', '<=', strtotime($value));
+        }
+    }
+
+    /**
+     * @notes 关联角色id
+     * @param $value
+     * @param $data
+     * @return array
+     * @author 段誉
+     * @date 2022/11/25 15:00
+     */
+    public function getRoleIdAttr($value, $data)
+    {
+        return TenantAdminRole::where('admin_id', $data['id'])->column('role_id');
+    }
+
+
+    /**
+     * @notes 关联部门id
+     * @param $value
+     * @param $data
+     * @return array
+     * @author 段誉
+     * @date 2022/11/25 15:00
+     */
+    public function getDeptIdAttr($value, $data)
+    {
+        return TenantAdminDept::where('admin_id', $data['id'])->column('dept_id');
+    }
+
+
+    /**
+     * @notes 关联岗位id
+     * @param $value
+     * @param $data
+     * @return array
+     * @author 段誉
+     * @date 2022/11/25 15:01
+     */
+    public function getJobsIdAttr($value, $data)
+    {
+        return TenantAdminJobs::where('admin_id', $data['id'])->column('jobs_id');
+    }
+
+
+
+    /**
+     * @notes 获取禁用状态
+     * @param $value
+     * @param $data
+     * @return string|string[]
+     * @author 令狐冲
+     * @date 2021/7/7 01:25
+     */
+    public function getDisableDescAttr($value, $data)
+    {
+        return YesNoEnum::getDisableDesc($data['disable']);
+    }
+
+    /**
+     * @notes 最后登录时间获取器 - 格式化:年-月-日 时:分:秒
+     * @param $value
+     * @return string
+     * @author Tab
+     * @date 2021/7/13 11:35
+     */
+    public function getLoginTimeAttr($value)
+    {
+        return empty($value) ? '' : date('Y-m-d H:i:s', $value);
+    }
+
+    /**
+     * @notes 头像获取器 - 头像路径添加域名
+     * @param $value
+     * @return string
+     * @author Tab
+     * @date 2021/7/13 11:35
+     */
+    public function getAvatarAttr($value)
+    {
+        return empty($value) ? FileService::getFileUrl(config('project.tenant.admin_avatar')) : FileService::getFileUrl(trim($value, '/'));
+    }
+
+}

+ 32 - 0
app/common/model/auth/TenantAdminDept.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+
+class TenantAdminDept extends BaseModel
+{
+    /**
+     * @notes 删除用户关联部门
+     * @param $adminId
+     * @return bool
+     * @author 段誉
+     * @date 2022/11/25 14:14
+     */
+    public static function delByUserId($adminId)
+    {
+        return self::where(['admin_id' => $adminId])->delete();
+    }
+}

+ 32 - 0
app/common/model/auth/TenantAdminJobs.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+
+class TenantAdminJobs extends BaseModel
+{
+    /**
+     * @notes 删除用户关联岗位
+     * @param $adminId
+     * @return bool
+     * @author 段誉
+     * @date 2022/11/25 14:14
+     */
+    public static function delByUserId($adminId)
+    {
+        return self::where(['admin_id' => $adminId])->delete();
+    }
+}

+ 34 - 0
app/common/model/auth/TenantAdminRole.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+
+class TenantAdminRole extends BaseModel
+{
+
+    /**
+     * @notes 删除用户关联角色
+     * @param $adminId
+     * @return bool
+     * @author 段誉
+     * @date 2022/11/25 14:14
+     */
+    public static function delByUserId($adminId)
+    {
+        return self::where(['admin_id' => $adminId])->delete();
+    }
+
+}

+ 32 - 0
app/common/model/auth/TenantAdminSession.php

@@ -0,0 +1,32 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+
+class TenantAdminSession extends BaseModel
+{
+    /**
+     * @notes 关联管理员表
+     * @return \think\model\relation\HasOne
+     * @author 令狐冲
+     * @date 2021/7/5 14:39
+     */
+    public function admin()
+    {
+        return $this->hasOne(TenantAdmin::class, 'id', 'admin_id')
+            ->field('id,multipoint_login');
+    }
+}

+ 28 - 0
app/common/model/auth/TenantSystemMenu.php

@@ -0,0 +1,28 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+
+
+/**
+ * 租户菜单
+ * Class SystemMenu
+ * @package app\common\model\auth
+ */
+class TenantSystemMenu extends BaseModel
+{
+}

+ 41 - 0
app/common/model/auth/TenantSystemRole.php

@@ -0,0 +1,41 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+/**
+ * 角色模型
+ * Class Role
+ * @package app\common\model
+ */
+class TenantSystemRole extends BaseModel
+{
+    use SoftDelete;
+
+    protected $deleteTime = 'delete_time';
+
+    /**
+     * @notes 角色与菜单关联关系
+     * @return \think\model\relation\HasMany
+     * @author 段誉
+     * @date 2022/7/6 11:16
+     */
+    public function roleMenuIndex()
+    {
+        return $this->hasMany(TenantSystemRoleMenu::class, 'role_id');
+    }
+}

+ 30 - 0
app/common/model/auth/TenantSystemRoleMenu.php

@@ -0,0 +1,30 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\model\auth;
+
+use app\common\model\BaseModel;
+
+
+/**
+ * 角色与菜单权限关系
+ * Class SystemRoleMenu
+ * @package app\common\model\auth
+ */
+class TenantSystemRoleMenu extends BaseModel
+{
+
+
+}

+ 73 - 0
app/common/model/dept/TenantDept.php

@@ -0,0 +1,73 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\dept;
+
+use app\common\model\auth\TenantAdminDept;
+use app\common\model\BaseModel;
+use think\Exception;
+use think\model\concern\SoftDelete;
+
+
+/**
+ * 部门模型
+ * Class Dept
+ * @package app\common\model\article
+ */
+class TenantDept extends BaseModel
+{
+
+    use SoftDelete;
+
+    protected $deleteTime = 'delete_time';
+
+    /**
+     * @notes 初始化管理员部门信息
+     * @param mixed $tenantId
+     * @param mixed $managerId
+     * @return void
+     * @throws Exception
+     * @author yfdong
+     * @date 2024/09/12 21:43
+     */
+    public static function initialization(mixed $tenantId, mixed $managerId)
+    {
+        $field = "tenant_id,name,pid,sort,leader,mobile,status";
+        $tenantDept = TenantDept::where(['tenant_id' => 0])->field($field)->findOrEmpty()->toArray();
+        if($tenantDept){
+            $tenantDept['tenant_id'] = $tenantId;
+            $dept = TenantDept::create($tenantDept);
+            //添加对应的部门关联关系
+            $tenantAdminDept ['admin_id'] = $managerId;
+            $tenantAdminDept ['dept_id'] = $dept['id'];
+            TenantAdminDept::create($tenantAdminDept);
+        }else{
+            throw new Exception("部门模板缺失");
+        }
+    }
+
+    /**
+     * @notes 状态描述
+     * @param $value
+     * @param $data
+     * @return string
+     * @author 段誉
+     * @date 2022/5/25 18:03
+     */
+    public function getStatusDescAttr($value, $data)
+    {
+        return $data['status'] ? '正常' : '停用';
+    }
+
+}

+ 44 - 0
app/common/model/dept/TenantJobs.php

@@ -0,0 +1,44 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\dept;
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+
+/**
+ * 岗位模型
+ * Class Jobs
+ * @package app\common\model\dept
+ */
+class TenantJobs extends BaseModel
+{
+    use SoftDelete;
+
+    protected $deleteTime = 'delete_time';
+
+    /**
+     * @notes 状态描述
+     * @param $value
+     * @param $data
+     * @return string
+     * @author 段誉
+     * @date 2022/5/25 18:03
+     */
+    public function getStatusDescAttr($value, $data)
+    {
+        return $data['status'] ? '正常' : '停用';
+    }
+}

+ 24 - 0
app/common/model/file/TenantFile.php

@@ -0,0 +1,24 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\file;
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+class TenantFile extends BaseModel
+{
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
+}

+ 25 - 0
app/common/model/file/TenantFileCate.php

@@ -0,0 +1,25 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\file;
+
+
+use app\common\model\BaseModel;
+use think\model\concern\SoftDelete;
+
+class TenantFileCate extends BaseModel
+{
+    use SoftDelete;
+    protected $deleteTime = 'delete_time';
+}

+ 54 - 0
app/common/model/pay/TenantPayConfig.php

@@ -0,0 +1,54 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\pay;
+
+use app\common\enum\PayEnum;
+use app\common\model\BaseModel;
+use app\common\service\FileService;
+
+
+class TenantPayConfig extends BaseModel
+{
+    // 设置json类型字段
+    protected $json = ['config'];
+
+    // 设置JSON数据返回数组
+    protected $jsonAssoc = true;
+
+    /**
+     * @notes 支付图标获取器 - 路径添加域名
+     * @param $value
+     * @return string
+     * @author ljj
+     * @date 2021/7/28 2:12 下午
+     */
+    public function getIconAttr($value)
+    {
+        return empty($value) ? '' : FileService::getFileUrl($value);
+    }
+
+    /**
+     * @notes 支付方式名称获取器
+     * @param $value
+     * @param $data
+     * @return string|string[]
+     * @author ljj
+     * @date 2021/7/31 2:24 下午
+     */
+    public function getPayWayNameAttr($value,$data)
+    {
+        return PayEnum::getPayDesc($data['pay_way']);
+    }
+}

+ 53 - 0
app/common/model/pay/TenantPayWay.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\pay;
+
+
+use app\common\model\BaseModel;
+use app\common\model\pay\PayConfig;
+use app\common\service\FileService;
+
+
+class TenantPayWay extends BaseModel
+{
+    public function getIconAttr($value,$data)
+    {
+        return FileService::getFileUrl($value);
+    }
+
+    /**
+     * @notes 支付方式名称获取器
+     * @param $value
+     * @param $data
+     * @return mixed
+     * @author ljj
+     * @date 2021/7/28 4:02 下午
+     */
+    public static function getPayWayNameAttr($value,$data)
+    {
+        return PayConfig::where('id',$data['pay_config_id'])->value('name');
+    }
+
+    /**
+     * @notes 关联支配配置模型
+     * @return \think\model\relation\HasOne
+     * @author ljj
+     * @date 2021/10/11 3:04 下午
+     */
+    public function payConfig()
+    {
+        return $this->hasOne(PayConfig::class,'id','pay_config_id');
+    }
+}

+ 133 - 0
app/common/model/tenant/Tenant.php

@@ -0,0 +1,133 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\common\model\tenant;
+
+
+use app\common\enum\YesNoEnum;
+use app\common\model\BaseModel;
+use app\common\model\user\User;
+use app\common\service\FileService;
+use think\model\concern\SoftDelete;
+use think\facade\Request;
+
+/**
+ * 用户模型
+ * Class User
+ * @package app\common\model\user
+ */
+class Tenant extends BaseModel
+{
+    use SoftDelete;
+
+    protected $deleteTime = 'delete_time';
+
+    /**
+     * @notes 关联用户模型
+     * @author 段誉
+     * @date 2022/9/22 16:03
+     */
+    public function users()
+    {
+        return $this->hasMany(User::class, 'tenant_id', 'id');
+    }
+
+    /**
+     * @notes 搜索器-用户信息
+     * @param $query
+     * @param $value
+     * @param $data
+     * @author 段誉
+     * @date 2022/9/22 16:12
+     */
+    public function searchKeywordAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('sn|name|tel|domain_alias', 'like', '%' . $value . '%');
+        }
+    }
+
+    /**
+     * @notes 搜索器-注册时间
+     * @param $query
+     * @param $value
+     * @param $data
+     * @author 段誉
+     * @date 2022/9/22 16:13
+     */
+    public function searchCreateTimeStartAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('create_time', '>=', strtotime($value));
+        }
+    }
+
+
+    /**
+     * @notes 搜索器-注册时间
+     * @param $query
+     * @param $value
+     * @param $data
+     * @author 段誉
+     * @date 2022/9/22 16:13
+     */
+    public function searchCreateTimeEndAttr($query, $value, $data)
+    {
+        if ($value) {
+            $query->where('create_time', '<=', strtotime($value));
+        }
+    }
+
+    /**
+     * @notes 头像获取器 - 用于头像地址拼接域名
+     * @param $value
+     * @return string
+     * @author Tab
+     * @date 2021/7/17 14:28
+     */
+    public function getAvatarAttr($value)
+    {
+        return empty($value) ? FileService::getFileUrl(config('project.tenant.admin_avatar')) : FileService::getFileUrl(trim($value, '/'));
+    }
+
+    /**
+     * @notes 生成用户编码
+     * @param $prefix
+     * @param $length
+     * @return string
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author JXDN
+     * @date 2024/09/03 14:32
+     */
+    public static function createUserSn($prefix = '', $length = 8)
+    {
+        $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; // 字母和数字的字符集
+        $rand_str = '';
+        for ($i = 0; $i < $length; $i++) {
+            $rand_str .= $characters[mt_rand(0, strlen($characters) - 1)];
+        }
+        $sn = $prefix . $rand_str;
+
+        // 检查是否存在相同的sn
+        if (Tenant::where(['sn' => $sn])->find()) {
+            return self::createUserSn($prefix, $length); // 递归重新生成
+        }
+
+        return $sn;
+    }
+
+}

+ 44 - 28
app/common/service/ConfigService.php

@@ -16,7 +16,9 @@ declare(strict_types=1);
 
 namespace app\common\service;
 
+use app\common\enum\AdminTerminalEnum;
 use app\common\model\Config;
+use app\common\model\TenantConfig;
 
 class ConfigService
 {
@@ -35,15 +37,21 @@ class ConfigService
         if (is_array($value)) {
             $value = json_encode($value, JSON_UNESCAPED_UNICODE);
         }
-
-        $data = Config::where(['type' => $type, 'name' => $name])->findOrEmpty();
+        $options = [
+            'type' => $type,
+            'name' => $name,
+            'value' => $value,
+        ];
+        $query = ['type' => $type, 'name' => $name];
+        if(!AdminTerminalEnum::isPlatform()) {
+            $options['tenant_id'] = request()->tenantId;
+            $query['tenant_id'] = request()->tenantId;
+        }
+        $data = (!AdminTerminalEnum::isPlatform() ? new TenantConfig() : new Config())->where($query)->findOrEmpty();
 
         if ($data->isEmpty()) {
-            Config::create([
-                'type' => $type,
-                'name' => $name,
-                'value' => $value,
-            ]);
+
+            (!AdminTerminalEnum::isPlatform() ? new TenantConfig() : new Config())->create($options);
         } else {
             $data->value = $value;
             $data->save();
@@ -55,7 +63,7 @@ class ConfigService
 
     /**
      * @notes 获取配置值
-     * @param $type
+     * @param string $type
      * @param string $name
      * @param null $default_value
      * @return array|int|mixed|string
@@ -64,17 +72,35 @@ class ConfigService
      */
     public static function get(string $type, string $name = '', $default_value = null)
     {
+        // 初始化查询条件
+        $query = ['type' => $type, 'name' => $name];
+        // 当查询的为文件存储配置时获取平台端配置
+        if($type === 'storage') {
+            $configClass = new Config();
+        }else{
+            // 根据是否为平台决定查询类
+            $configClass = AdminTerminalEnum::isPlatform() ? new Config() : new TenantConfig();
+            // 判断是否为租户端
+            if (!AdminTerminalEnum::isPlatform()) {
+                $query['tenant_id'] = request()->tenantId;
+            }
+        }
         if (!empty($name)) {
-            $value = Config::where(['type' => $type, 'name' => $name])->value('value');
-            if (!is_null($value)) {
+            // 查询配置值
+            $value = $configClass->where($query)->value('value');
+            // 处理 JSON 数据
+            if ($value !== null) {
                 $json = json_decode($value, true);
-                $value = json_last_error() === JSON_ERROR_NONE ? $json : $value;
+                if (json_last_error() === JSON_ERROR_NONE) {
+                    $value = $json;
+                }
             }
-            if ($value) {
-                return $value;
-            }
-            // 返回特殊值 0 '0'
-            if ($value === 0 || $value === '0') {
+            // 返回配置值
+            if ($value !== null) {
+                // 处理特殊值
+                if ($value === 0 || $value === '0') {
+                    return $value;
+                }
                 return $value;
             }
             // 返回默认值
@@ -84,17 +110,7 @@ class ConfigService
             // 返回本地配置文件中的值
             return config('project.' . $type . '.' . $name);
         }
-
-        // 取某个类型下的所有name的值
-        $data = Config::where(['type' => $type])->column('value', 'name');
-        foreach ($data as $k => $v) {
-            $json = json_decode($v, true);
-            if (json_last_error() === JSON_ERROR_NONE) {
-                $data[$k] = $json;
-            }
-        }
-        if ($data) {
-            return $data;
-        }
+        // 返回默认值或本地配置文件中的值
+        return $default_value !== null ? $default_value : config('project.' . $type . '.' . $name);
     }
 }

+ 28 - 0
app/tenantapi/config/route.php

@@ -0,0 +1,28 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+return [
+    'middleware' => [
+        // 初始化
+        app\tenantapi\http\middleware\InitMiddleware::class,
+        // 登录验证
+        app\tenantapi\http\middleware\LoginMiddleware::class,
+        // 权限认证
+        app\tenantapi\http\middleware\AuthMiddleware::class,
+        // 演示模式 - 禁止提交数据
+        app\tenantapi\http\middleware\CheckDemoMiddleware::class,
+        // 演示模式 - 不返回敏感数据
+        app\tenantapi\http\middleware\EncryDemoDataMiddleware::class,
+    ],
+];

+ 43 - 0
app/tenantapi/controller/BaseAdminController.php

@@ -0,0 +1,43 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+declare (strict_types=1);
+
+namespace app\tenantapi\controller;
+
+use app\common\controller\BaseLikeAdminController;
+use app\common\enum\AdminTerminalEnum;
+
+/**
+ * 管理元控制器基类
+ * Class BaseAdminController
+ * @package app\tenantapi\controller
+ */
+class BaseAdminController extends BaseLikeAdminController
+{
+    protected int $adminId = 0;
+    protected int $tenantId = 0;
+    protected array $adminInfo = [];
+
+    public function initialize()
+    {
+        $this->request->source = AdminTerminalEnum::TENANT;
+        if (isset($this->request->adminInfo) && $this->request->adminInfo) {
+            $this->adminInfo = $this->request->adminInfo;
+            $this->tenantId = $this->request->adminInfo['tenant_id'];
+            $this->adminId = $this->request->adminInfo['admin_id'];
+        }
+    }
+
+}

+ 61 - 0
app/tenantapi/controller/ConfigController.php

@@ -0,0 +1,61 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller;
+
+use app\tenantapi\logic\auth\AuthLogic;
+use app\tenantapi\logic\ConfigLogic;
+
+/**
+ * 配置控制器
+ * Class ConfigController
+ * @package app\tenantapi\controller
+ */
+class ConfigController extends BaseAdminController
+{
+    public array $notNeedLogin = ['getConfig', 'dict'];
+
+
+    /**
+     * @notes 基础配置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/31 11:01
+     */
+    public function getConfig()
+    {
+        $data = ConfigLogic::getConfig();
+        return $this->data($data);
+    }
+
+
+    /**
+     * @notes 根据类型获取字典数据
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/27 19:10
+     */
+    public function dict()
+    {
+        $type = $this->request->get('type', '');
+        $data = ConfigLogic::getDictByType($type);
+        return $this->data($data);
+    }
+
+
+
+}

+ 50 - 0
app/tenantapi/controller/DownloadController.php

@@ -0,0 +1,50 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller;
+
+
+use app\common\cache\ExportCache;
+use app\common\service\JsonService;
+
+class DownloadController extends BaseAdminController
+{
+
+    public array $notNeedLogin = ['export'];
+
+    /**
+     * @notes 导出文件
+     * @return \think\response\File|\think\response\Json
+     * @author 段誉
+     * @date 2022/11/24 16:10
+     */
+    public function export()
+    {
+        //获取文件缓存的key
+        $fileKey = request()->get('file');
+
+        //通过文件缓存的key获取文件储存的路径
+        $exportCache = new ExportCache();
+        $fileInfo = $exportCache->getFile($fileKey);
+
+        if (empty($fileInfo)) {
+            return JsonService::fail('下载文件不存在');
+        }
+
+        //下载前删除缓存
+        $exportCache->delete($fileKey);
+
+        return download($fileInfo['src'] . $fileInfo['name'], $fileInfo['name']);
+    }
+}

+ 137 - 0
app/tenantapi/controller/FileController.php

@@ -0,0 +1,137 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller;
+
+
+use app\tenantapi\lists\file\FileCateLists;
+use app\tenantapi\lists\file\FileLists;
+use app\tenantapi\logic\FileLogic;
+use app\tenantapi\validate\FileValidate;
+use think\response\Json;
+
+/**文件管理
+ * Class FileController
+ * @package app\tenantapi\controller
+ */
+class FileController extends BaseAdminController
+{
+
+    /**
+     * @notes 文件列表
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:30
+     */
+    public function lists()
+    {
+        return $this->dataLists(new FileLists());
+    }
+
+
+    /**
+     * @notes 文件移动成功
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:30
+     */
+    public function move()
+    {
+        $params = (new FileValidate())->post()->goCheck('move');
+        FileLogic::move($params);
+        return $this->success('移动成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 重命名文件
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:31
+     */
+    public function rename()
+    {
+        $params = (new FileValidate())->post()->goCheck('rename');
+        FileLogic::rename($params);
+        return $this->success('重命名成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 删除文件
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:31
+     */
+    public function delete()
+    {
+        $params = (new FileValidate())->post()->goCheck('delete');
+        FileLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 分类列表
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:31
+     */
+    public function listCate()
+    {
+        return $this->dataLists(new FileCateLists());
+    }
+
+
+    /**
+     * @notes 添加文件分类
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:31
+     */
+    public function addCate()
+    {
+        $params = (new FileValidate())->post()->goCheck('addCate');
+        FileLogic::addCate($params);
+        return $this->success('添加成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 编辑文件分类
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:31
+     */
+    public function editCate()
+    {
+        $params = (new FileValidate())->post()->goCheck('editCate');
+        FileLogic::editCate($params);
+        return $this->success('编辑成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 删除文件分类
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 14:32
+     */
+    public function delCate()
+    {
+        $params = (new FileValidate())->post()->goCheck('id');
+        FileLogic::delCate($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+}

+ 59 - 0
app/tenantapi/controller/LoginController.php

@@ -0,0 +1,59 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller;
+
+use app\tenantapi\logic\LoginLogic;
+use app\tenantapi\validate\LoginValidate;
+
+/**
+ * 管理员登录控制器
+ * Class LoginController
+ * @package app\tenantapi\controller
+ */
+class LoginController extends BaseAdminController
+{
+    public array $notNeedLogin = ['account'];
+
+    /**
+     * @notes 账号登录
+     * @date 2021/6/30 17:01
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 令狐冲
+     */
+    public function account()
+    {
+        $params = (new LoginValidate())->post()->goCheck();
+        return $this->data((new LoginLogic())->login($params));
+    }
+
+    /**
+     * @notes 退出登录
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 令狐冲
+     * @date 2021/7/8 00:36
+     */
+    public function logout()
+    {
+        //退出登录情况特殊,只有成功的情况,也不需要token验证
+        (new LoginLogic())->logout($this->adminInfo);
+        return $this->success();
+    }
+}

+ 80 - 0
app/tenantapi/controller/UploadController.php

@@ -0,0 +1,80 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller;
+
+
+use app\common\service\UploadService;
+use Exception;
+use think\response\Json;
+
+/**
+ * 上传文件
+ * Class UploadController
+ * @package app\tenantapi\controller
+ */
+class UploadController extends BaseAdminController
+{
+    /**
+     * @notes 上传图片
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 16:27
+     */
+    public function image()
+    {
+        try {
+            $cid = $this->request->post('cid', 0);
+            $result = UploadService::image($cid);
+            return $this->success('上传成功', $result);
+        } catch (Exception $e) {
+            return $this->fail($e->getMessage());
+        }
+    }
+
+    /**
+     * @notes 上传视频
+     * @return Json
+     * @author 段誉
+     * @date 2021/12/29 16:27
+     */
+    public function video()
+    {
+        try {
+            $cid = $this->request->post('cid', 0);
+            $result = UploadService::video($cid);
+            return $this->success('上传成功', $result);
+        } catch (Exception $e) {
+            return $this->fail($e->getMessage());
+        }
+    }
+
+    /**
+     * @notes 上传文件
+     * @return Json
+     * @author dw
+     * @date 2023/06/26
+     */
+    public function file()
+    {
+        try {
+            $cid = $this->request->post('cid', 0);
+            $result = UploadService::file($cid);
+            return $this->success('上传成功', $result);
+        } catch (Exception $e) {
+            return $this->fail($e->getMessage());
+        }
+    }
+
+}

+ 38 - 0
app/tenantapi/controller/WorkbenchController.php

@@ -0,0 +1,38 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller;
+
+use app\tenantapi\logic\WorkbenchLogic;
+
+/**
+ * 工作台
+ * Class WorkbenchCotroller
+ * @package app\tenantapi\controller
+ */
+class WorkbenchController extends BaseAdminController
+{
+
+    /**
+     * @notes 工作台
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 17:01
+     */
+    public function index()
+    {
+        $result = WorkbenchLogic::index();
+        return $this->data($result);
+    }
+}

+ 134 - 0
app/tenantapi/controller/auth/AdminController.php

@@ -0,0 +1,134 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\auth;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\auth\AdminLists;
+use app\tenantapi\validate\auth\AdminValidate;
+use app\tenantapi\logic\auth\AdminLogic;
+use app\tenantapi\validate\auth\editSelfValidate;
+
+/**
+ * 管理员控制器
+ * Class AdminController
+ * @package app\tenantapi\controller\auth
+ */
+class AdminController extends BaseAdminController
+{
+
+    /**
+     * @notes 查看管理员列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 9:55
+     */
+    public function lists()
+    {
+        return $this->dataLists(new AdminLists());
+    }
+
+
+    /**
+     * @notes 添加管理员
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 10:21
+     */
+    public function add()
+    {
+        $params = (new AdminValidate())->post()->goCheck('add');
+        $result = AdminLogic::add($params);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(AdminLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑管理员
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 11:03
+     */
+    public function edit()
+    {
+        $params = (new AdminValidate())->post()->goCheck('edit');
+        $result = AdminLogic::edit($params);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(AdminLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除管理员
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 11:03
+     */
+    public function delete()
+    {
+        $params = (new AdminValidate())->post()->goCheck('delete');
+        $result = AdminLogic::delete($params);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(AdminLogic::getError());
+    }
+
+
+    /**
+     * @notes 查看管理员详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 11:07
+     */
+    public function detail()
+    {
+        $params = (new AdminValidate())->goCheck('detail');
+        $result = AdminLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 获取当前管理员信息
+     * @return \think\response\Json
+     * @author JXDN
+     * @date 2024/09/02 14:21
+     */
+    public function mySelf()
+    {
+        $result = AdminLogic::detail(['id' => $this->adminId], 'auth');
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 编辑超级管理员信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/4/8 17:54
+     */
+    public function editSelf()
+    {
+        $params = (new editSelfValidate())->post()->goCheck('', ['admin_id' => $this->adminId]);
+        $result = AdminLogic::editSelf($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+}

+ 142 - 0
app/tenantapi/controller/auth/MenuController.php

@@ -0,0 +1,142 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\auth;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\auth\MenuLists;
+use app\tenantapi\logic\auth\MenuLogic;
+use app\tenantapi\validate\auth\MenuValidate;
+
+
+/**
+ * 系统菜单权限
+ * Class MenuController
+ * @package app\tenantapi\controller\setting\system
+ */
+class MenuController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取菜单路由
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/6/29 17:41
+     */
+    public function route()
+    {
+        $result = MenuLogic::getMenuByAdminId($this->adminId);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 获取菜单列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/6/29 17:23
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MenuLists());
+    }
+
+
+    /**
+     * @notes 菜单详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/6/30 10:07
+     */
+    public function detail()
+    {
+        $params = (new MenuValidate())->goCheck('detail');
+        return $this->data(MenuLogic::detail($params));
+    }
+
+
+    /**
+     * @notes 添加菜单
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/6/30 10:07
+     */
+    public function add()
+    {
+        $params = (new MenuValidate())->post()->goCheck('add');
+        MenuLogic::add($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 编辑菜单
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/6/30 10:07
+     */
+    public function edit()
+    {
+        $params = (new MenuValidate())->post()->goCheck('edit');
+        MenuLogic::edit($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 删除菜单
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/6/30 10:07
+     */
+    public function delete()
+    {
+        $params = (new MenuValidate())->post()->goCheck('delete');
+        MenuLogic::delete($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 更新状态
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/7/6 17:04
+     */
+    public function updateStatus()
+    {
+        $params = (new MenuValidate())->post()->goCheck('status');
+        MenuLogic::updateStatus($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取菜单数据
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 11:03
+     */
+    public function all()
+    {
+        $result = MenuLogic::getAllData();
+        return $this->data($result);
+    }
+
+
+}

+ 124 - 0
app/tenantapi/controller/auth/RoleController.php

@@ -0,0 +1,124 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\auth;
+
+use app\tenantapi\{
+    logic\auth\RoleLogic,
+    lists\auth\RoleLists,
+    validate\auth\RoleValidate,
+    controller\BaseAdminController
+};
+
+/**
+ * 角色控制器
+ * Class RoleController
+ * @package app\tenantapi\controller\auth
+ */
+class RoleController extends BaseAdminController
+{
+
+    /**
+     * @notes 查看角色列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 11:49
+     */
+    public function lists()
+    {
+        return $this->dataLists(new RoleLists());
+    }
+
+
+    /**
+     * @notes 添加权限
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 11:49
+     */
+    public function add()
+    {
+        $params = (new RoleValidate())->post()->goCheck('add');
+        $res = RoleLogic::add($params);
+        if (true === $res) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(RoleLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑角色
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 14:18
+     */
+    public function edit()
+    {
+        $params = (new RoleValidate())->post()->goCheck('edit');
+        $res = RoleLogic::edit($params);
+        if (true === $res) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(RoleLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除角色
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/29 14:18
+     */
+    public function delete()
+    {
+        $params = (new RoleValidate())->post()->goCheck('del');
+        RoleLogic::delete($params['id']);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 查看角色详情
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2021/12/29 14:18
+     */
+    public function detail()
+    {
+        $params = (new RoleValidate())->goCheck('detail');
+        $detail = RoleLogic::detail($params['id']);
+        return $this->data($detail);
+    }
+
+
+    /**
+     * @notes 获取角色数据
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:39
+     */
+    public function all()
+    {
+        $result = RoleLogic::getAllData();
+        return $this->data($result);
+    }
+
+}

+ 53 - 0
app/tenantapi/controller/channel/AppSettingController.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\channel\AppSettingLogic;
+
+/**
+ * APP设置控制器
+ * Class AppSettingController
+ * @package app\tenantapi\controller\setting\app
+ */
+class AppSettingController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取App设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:24
+     */
+    public function getConfig()
+    {
+        $result = AppSettingLogic::getConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes App设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:25
+     */
+    public function setConfig()
+    {
+        $params = $this->request->post();
+        AppSettingLogic::setConfig($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+}

+ 52 - 0
app/tenantapi/controller/channel/MnpSettingsController.php

@@ -0,0 +1,52 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\channel\MnpSettingsLogic;
+use app\tenantapi\validate\channel\MnpSettingsValidate;
+
+/**
+ * 小程序设置
+ * Class MnpSettingsController
+ * @package app\tenantapi\controller\channel
+ */
+class MnpSettingsController extends BaseAdminController
+{
+    /**
+     * @notes 获取小程序配置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/16 9:38 上午
+     */
+    public function getConfig()
+    {
+        $result = (new MnpSettingsLogic())->getConfig();
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 设置小程序配置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/16 9:51 上午
+     */
+    public function setConfig()
+    {
+        $params = (new MnpSettingsValidate())->post()->goCheck();
+        (new MnpSettingsLogic())->setConfig($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+}

+ 74 - 0
app/tenantapi/controller/channel/OfficialAccountMenuController.php

@@ -0,0 +1,74 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\channel\OfficialAccountMenuLogic;
+
+/**
+ * 微信公众号菜单控制器
+ * Class OfficialAccountMenuController
+ * @package app\tenantapi\controller\channel
+ */
+class OfficialAccountMenuController extends BaseAdminController
+{
+
+    /**
+     * @notes 保存菜单
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:41
+     */
+    public function save()
+    {
+        $params = $this->request->post();
+        $result = OfficialAccountMenuLogic::save($params);
+        if(false === $result) {
+            return $this->fail(OfficialAccountMenuLogic::getError());
+        }
+        return $this->success('保存成功',[],1,1);
+    }
+
+
+    /**
+     * @notes 保存发布菜单
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:42
+     */
+    public function saveAndPublish()
+    {
+        $params = $this->request->post();
+        $result = OfficialAccountMenuLogic::saveAndPublish($params);
+        if($result) {
+            return $this->success('保存并发布成功',[],1,1);
+        }
+        return $this->fail(OfficialAccountMenuLogic::getError());
+    }
+
+
+
+    /**
+     * @notes 查看菜单详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:42
+     */
+    public function detail()
+    {
+        $result = OfficialAccountMenuLogic::detail();
+        return $this->data($result);
+    }
+}

+ 148 - 0
app/tenantapi/controller/channel/OfficialAccountReplyController.php

@@ -0,0 +1,148 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\channel\OfficialAccountReplyLists;
+use app\tenantapi\logic\channel\OfficialAccountReplyLogic;
+use app\tenantapi\validate\channel\OfficialAccountReplyValidate;
+
+/**
+ * 微信公众号回复控制器
+ * Class OfficialAccountReplyController
+ * @package app\tenantapi\controller\channel
+ */
+class OfficialAccountReplyController extends BaseAdminController
+{
+
+    public array $notNeedLogin = ['index'];
+
+
+    /**
+     * @notes 查看回复列表(关注/关键词/默认)
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:58
+     */
+    public function lists()
+    {
+        return $this->dataLists(new OfficialAccountReplyLists());
+    }
+
+
+    /**
+     * @notes 添加回复(关注/关键词/默认)
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:58
+     */
+    public function add()
+    {
+        $params = (new OfficialAccountReplyValidate())->post()->goCheck('add');
+        $result = OfficialAccountReplyLogic::add($params);
+        if ($result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(OfficialAccountReplyLogic::getError());
+    }
+
+
+    /**
+     * @notes 查看回复详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:58
+     */
+    public function detail()
+    {
+        $params = (new OfficialAccountReplyValidate())->goCheck('detail');
+        $result = OfficialAccountReplyLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 编辑回复(关注/关键词/默认)
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:58
+     */
+    public function edit()
+    {
+        $params = (new OfficialAccountReplyValidate())->post()->goCheck('edit');
+        $result = OfficialAccountReplyLogic::edit($params);
+        if ($result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(OfficialAccountReplyLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除回复(关注/关键词/默认)
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:59
+     */
+    public function delete()
+    {
+        $params = (new OfficialAccountReplyValidate())->post()->goCheck('delete');
+        OfficialAccountReplyLogic::delete($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 更新排序
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:59
+     */
+    public function sort()
+    {
+        $params = (new OfficialAccountReplyValidate())->post()->goCheck('sort');
+        OfficialAccountReplyLogic::sort($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 更新状态
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:59
+     */
+    public function status()
+    {
+        $params = (new OfficialAccountReplyValidate())->post()->goCheck('status');
+        OfficialAccountReplyLogic::status($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 微信公众号回调
+     * @throws \ReflectionException
+     * @author 段誉
+     * @date 2022/3/29 10:59
+     */
+    public function index()
+    {
+        $result = OfficialAccountReplyLogic::index();
+        return response($result->getBody())->header([
+            'Content-Type' => 'text/plain;charset=utf-8'
+        ]);
+    }
+}

+ 52 - 0
app/tenantapi/controller/channel/OfficialAccountSettingController.php

@@ -0,0 +1,52 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\channel\OfficialAccountSettingLogic;
+use app\tenantapi\validate\channel\OfficialAccountSettingValidate;
+
+/**
+ * 公众号设置
+ * Class OfficialAccountSettingController
+ * @package app\tenantapi\controller\channel
+ */
+class OfficialAccountSettingController extends BaseAdminController
+{
+    /**
+     * @notes 获取公众号配置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/16 10:09 上午
+     */
+    public function getConfig()
+    {
+        $result = (new OfficialAccountSettingLogic())->getConfig();
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 设置公众号配置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/16 10:09 上午
+     */
+    public function setConfig()
+    {
+        $params = (new OfficialAccountSettingValidate())->post()->goCheck();
+        (new OfficialAccountSettingLogic())->setConfig($params);
+        return $this->success('操作成功',[],1,1);
+    }
+}

+ 54 - 0
app/tenantapi/controller/channel/OpenSettingController.php

@@ -0,0 +1,54 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\channel\OpenSettingLogic;
+use app\tenantapi\validate\channel\OpenSettingValidate;
+
+/**
+ * 微信开放平台
+ * Class AppSettingController
+ * @package app\tenantapi\controller\setting\app
+ */
+class OpenSettingController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取微信开放平台设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 11:03
+     */
+    public function getConfig()
+    {
+        $result = OpenSettingLogic::getConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 微信开放平台设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 11:03
+     */
+    public function setConfig()
+    {
+        $params = (new OpenSettingValidate())->post()->goCheck();
+        OpenSettingLogic::setConfig($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+}

+ 54 - 0
app/tenantapi/controller/channel/WebPageSettingController.php

@@ -0,0 +1,54 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\channel;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\channel\WebPageSettingLogic;
+use app\tenantapi\validate\channel\WebPageSettingValidate;
+
+/**
+ * H5设置控制器
+ * Class HFiveSettingController
+ * @package app\tenantapi\controller\setting\h5
+ */
+class WebPageSettingController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取H5设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:36
+     */
+    public function getConfig()
+    {
+        $result = WebPageSettingLogic::getConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes H5设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:36
+     */
+    public function setConfig()
+    {
+        $params = (new WebPageSettingValidate())->post()->goCheck();
+        WebPageSettingLogic::setConfig($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+}

+ 55 - 0
app/tenantapi/controller/decorate/DataController.php

@@ -0,0 +1,55 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\controller\decorate;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\decorate\DecorateDataLogic;
+use think\response\Json;
+
+/**
+ * 装修-数据
+ * Class DataController
+ * @package app\tenantapi\controller\decorate
+ */
+class DataController extends BaseAdminController
+{
+    /**
+     * @notes 文章列表
+     * @return Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author mjf
+     * @date 2024/3/14 18:13
+     */
+    public function article(): Json
+    {
+        $limit = $this->request->get('limit/d', 10);
+        $result = DecorateDataLogic::getArticleLists($limit);
+        return $this->success('获取成功', $result);
+    }
+
+    /**
+     * @notes pc设置
+     * @return Json
+     * @author mjf
+     * @date 2024/3/14 18:13
+     */
+    public function pc(): Json
+    {
+        $result = DecorateDataLogic::pc();
+        return $this->data($result);
+    }
+
+}

+ 61 - 0
app/tenantapi/controller/decorate/PageController.php

@@ -0,0 +1,61 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\controller\decorate;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\decorate\DecoratePageLogic;
+use app\tenantapi\validate\decorate\DecoratePageValidate;
+
+
+/**
+ * 装修页面
+ * Class DecoratePageController
+ * @package app\tenantapi\controller\decorate
+ */
+class PageController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取装修修页面详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/14 18:43
+     */
+    public function detail()
+    {
+        $type = $this->request->get('type/d');
+        $result = DecoratePageLogic::getDetail($type);
+        return $this->success('获取成功', $result);
+    }
+
+
+    /**
+     * @notes 保存装修配置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/15 9:57
+     */
+    public function save()
+    {
+        $params = (new DecoratePageValidate())->post()->goCheck();
+        $result = DecoratePageLogic::save($params);
+        if (false === $result) {
+            return $this->fail(DecoratePageLogic::getError());
+        }
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+}

+ 58 - 0
app/tenantapi/controller/decorate/TabbarController.php

@@ -0,0 +1,58 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\controller\decorate;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\decorate\DecorateTabbarLogic;
+
+/**
+ * 装修-底部导航
+ * Class DecorateTabbarController
+ * @package app\tenantapi\controller\decorate
+ */
+class TabbarController extends BaseAdminController
+{
+
+    /**
+     * @notes 底部导航详情
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/7 16:39
+     */
+    public function detail()
+    {
+        $data = DecorateTabbarLogic::detail();
+        return $this->success('', $data);
+    }
+
+
+    /**
+     * @notes 底部导航保存
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/6 9:58
+     */
+    public function save()
+    {
+        $params = $this->request->post();
+        DecorateTabbarLogic::save($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+}

+ 134 - 0
app/tenantapi/controller/dept/DeptController.php

@@ -0,0 +1,134 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\dept;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\dept\DeptLogic;
+use app\tenantapi\validate\dept\DeptValidate;
+
+/**
+ * 部门管理控制器
+ * Class DeptController
+ * @package app\tenantapi\controller\dept
+ */
+class DeptController extends BaseAdminController
+{
+
+    /**
+     * @notes 部门列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:07
+     */
+    public function lists()
+    {
+        $params = $this->request->get();
+        $result = DeptLogic::lists($params);
+        return $this->success('',$result);
+    }
+
+
+    /**
+     * @notes 上级部门
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/5/26 18:36
+     */
+    public function leaderDept()
+    {
+        $result = DeptLogic::leaderDept();
+        return $this->success('',$result);
+    }
+
+
+    /**
+     * @notes 添加部门
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:40
+     */
+    public function add()
+    {
+        $params = (new DeptValidate())->post()->goCheck('add');
+        DeptLogic::add($params);
+        return $this->success('添加成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 编辑部门
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:41
+     */
+    public function edit()
+    {
+        $params = (new DeptValidate())->post()->goCheck('edit');
+        $result = DeptLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(DeptLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除部门
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:41
+     */
+    public function delete()
+    {
+        $params = (new DeptValidate())->post()->goCheck('delete');
+        DeptLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取部门详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:41
+     */
+    public function detail()
+    {
+        $params = (new DeptValidate())->goCheck('detail');
+        $result = DeptLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 获取部门数据
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:28
+     */
+    public function all()
+    {
+        $result = DeptLogic::getAllData();
+        return $this->data($result);
+    }
+
+
+}

+ 118 - 0
app/tenantapi/controller/dept/JobsController.php

@@ -0,0 +1,118 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\dept;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\dept\JobsLists;
+use app\tenantapi\logic\dept\JobsLogic;
+use app\tenantapi\validate\dept\JobsValidate;
+
+
+/**
+ * 岗位管理控制器
+ * Class JobsController
+ * @package app\tenantapi\controller\dept
+ */
+class JobsController extends BaseAdminController
+{
+
+    /**
+     * @notes 岗位列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/26 10:00
+     */
+    public function lists()
+    {
+        return $this->dataLists(new JobsLists());
+    }
+
+
+    /**
+     * @notes 添加岗位
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:40
+     */
+    public function add()
+    {
+        $params = (new JobsValidate())->post()->goCheck('add');
+        JobsLogic::add($params);
+        return $this->success('添加成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 编辑岗位
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:41
+     */
+    public function edit()
+    {
+        $params = (new JobsValidate())->post()->goCheck('edit');
+        $result = JobsLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(JobsLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除岗位
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:41
+     */
+    public function delete()
+    {
+        $params = (new JobsValidate())->post()->goCheck('delete');
+        JobsLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取岗位详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/5/25 18:41
+     */
+    public function detail()
+    {
+        $params = (new JobsValidate())->goCheck('detail');
+        $result = JobsLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 获取岗位数据
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:31
+     */
+    public function all()
+    {
+        $result = JobsLogic::getAllData();
+        return $this->data($result);
+    }
+
+
+}

+ 51 - 0
app/tenantapi/controller/setting/CustomerServiceController.php

@@ -0,0 +1,51 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\setting;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\setting\CustomerServiceLogic;
+
+/**
+ * 客服设置
+ * Class CustomerServiceController
+ * @package app\tenantapi\controller\setting
+ */
+class CustomerServiceController extends BaseAdminController
+{
+    /**
+     * @notes 获取客服设置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/15 12:05 下午
+     */
+    public function getConfig()
+    {
+        $result = CustomerServiceLogic::getConfig();
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 设置客服设置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/15 12:11 下午
+     */
+    public function setConfig()
+    {
+        $params = $this->request->post();
+        CustomerServiceLogic::setConfig($params);
+        return $this->success('设置成功', [], 1, 1);
+    }
+}

+ 56 - 0
app/tenantapi/controller/setting/HotSearchController.php

@@ -0,0 +1,56 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\setting;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\setting\HotSearchLogic;
+
+/**
+ * 热门搜索设置
+ * Class HotSearchController
+ * @package app\tenantapi\controller\setting
+ */
+class HotSearchController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取热门搜索
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/5 19:00
+     */
+    public function getConfig()
+    {
+        $result = HotSearchLogic::getConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 设置热门搜索
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/5 19:00
+     */
+    public function setConfig()
+    {
+        $params = $this->request->post();
+        $result = HotSearchLogic::setConfig($params);
+        if (false === $result) {
+            return $this->fail(HotSearchLogic::getError() ?: '系统错误');
+        }
+        return $this->success('设置成功', [], 1, 1);
+    }
+}

+ 53 - 0
app/tenantapi/controller/setting/TransactionSettingsController.php

@@ -0,0 +1,53 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\setting;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\setting\TransactionSettingsLogic;
+use app\tenantapi\validate\setting\TransactionSettingsValidate;
+
+/**
+ * 交易设置
+ * Class TransactionSettingsController
+ * @package app\tenantapi\controller\setting
+ */
+class TransactionSettingsController extends BaseAdminController
+{
+    /**
+     * @notes 获取交易设置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/15 11:40 上午
+     */
+    public function getConfig()
+    {
+        $result = TransactionSettingsLogic::getConfig();
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 设置交易设置
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/15 11:50 上午
+     */
+    public function setConfig()
+    {
+        $params = (new TransactionSettingsValidate())->post()->goCheck('setConfig');
+        TransactionSettingsLogic::setConfig($params);
+        return $this->success('操作成功',[],1,1);
+    }
+}

+ 69 - 0
app/tenantapi/controller/setting/pay/PayConfigController.php

@@ -0,0 +1,69 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\controller\setting\pay;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\setting\pay\PayConfigLists;
+use app\tenantapi\logic\setting\pay\PayConfigLogic;
+use app\tenantapi\validate\setting\PayConfigValidate;
+use think\response\Json;
+
+/**
+ * 支付配置
+ * Class PayConfigController
+ * @package app\tenantapi\controller\setting\pay
+ */
+class PayConfigController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 设置支付配置
+     * @return Json
+     * @author 段誉
+     * @date 2023/2/23 16:14
+     */
+    public function setConfig(): Json
+    {
+        $params = (new PayConfigValidate())->post()->goCheck();
+        PayConfigLogic::setConfig($params);
+        return $this->success('设置成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取支付配置
+     * @return Json
+     * @author 段誉
+     * @date 2023/2/23 16:14
+     */
+    public function getConfig(): Json
+    {
+        $id = (new PayConfigValidate())->goCheck('get');
+        $result = PayConfigLogic::getConfig($id);
+        return $this->success('获取成功', $result);
+    }
+
+
+    /**
+     * @notes
+     * @return Json
+     * @author 段誉
+     * @date 2023/2/23 16:15
+     */
+    public function lists(): Json
+    {
+        return $this->dataLists(new PayConfigLists());
+    }
+}

+ 61 - 0
app/tenantapi/controller/setting/pay/PayWayController.php

@@ -0,0 +1,61 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\setting\pay;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\setting\pay\PayWayLogic;
+
+
+/**
+ * 支付方式
+ * Class PayWayController
+ * @package app\tenantapi\controller\setting\pay
+ */
+class PayWayController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取支付方式
+     * @return \think\response\Json
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/2/23 16:27
+     */
+    public function getPayWay()
+    {
+        $result = PayWayLogic::getPayWay();
+        return $this->success('获取成功',$result);
+    }
+
+
+    /**
+     * @notes 设置支付方式
+     * @return \think\response\Json
+     * @throws \Exception
+     * @author 段誉
+     * @date 2023/2/23 16:27
+     */
+    public function setPayWay()
+    {
+        $params = $this->request->post();
+        $result = (new PayWayLogic())->setPayWay($params);
+        if (true !== $result) {
+            return $this->fail($result);
+        }
+        return $this->success('操作成功',[],1, 1);
+    }
+}

+ 39 - 0
app/tenantapi/controller/setting/system/CacheController.php

@@ -0,0 +1,39 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\setting\system;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\setting\system\CacheLogic;
+
+/**
+ * 系统缓存
+ * Class CacheController
+ * @package app\tenantapi\controller\setting\system
+ */
+class CacheController extends BaseAdminController
+{
+
+    /**
+     * @notes 清除系统缓存
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/4/8 16:34
+     */
+    public function clear()
+    {
+         CacheLogic::clear();
+         return $this->success('清除成功', [], 1, 1);
+    }
+}

+ 84 - 0
app/tenantapi/controller/setting/user/UserController.php

@@ -0,0 +1,84 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\controller\setting\user;
+
+use app\tenantapi\{
+    controller\BaseAdminController,
+    logic\setting\user\UserLogic,
+    validate\setting\UserConfigValidate
+};
+
+
+/**
+ * 设置-用户设置控制器
+ * Class TenantController
+ * @package app\tenantapi\controller\config
+ */
+class UserController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取用户设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:08
+     */
+    public function getConfig()
+    {
+        $result = (new UserLogic())->getConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 设置用户设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:08
+     */
+    public function setConfig()
+    {
+        $params = (new UserConfigValidate())->post()->goCheck('user');
+        (new UserLogic())->setConfig($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取注册配置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:08
+     */
+    public function getRegisterConfig()
+    {
+        $result = (new UserLogic())->getRegisterConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 设置注册配置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 10:08
+     */
+    public function setRegisterConfig()
+    {
+        $params = (new UserConfigValidate())->post()->goCheck('register');
+        (new UserLogic())->setRegisterConfig($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+}

+ 137 - 0
app/tenantapi/controller/setting/web/WebSettingController.php

@@ -0,0 +1,137 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\setting\web;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\logic\setting\web\WebSettingLogic;
+use app\tenantapi\validate\setting\WebSettingValidate;
+
+/**
+ * 网站设置
+ * Class WebSettingController
+ * @package app\tenantapi\controller\setting
+ */
+class WebSettingController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取网站信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/28 15:44
+     */
+    public function getWebsite()
+    {
+        $result = WebSettingLogic::getWebsiteInfo();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 设置网站信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/28 15:45
+     */
+    public function setWebsite()
+    {
+        $params = (new WebSettingValidate())->post()->goCheck('website');
+        WebSettingLogic::setWebsiteInfo($params);
+        return $this->success('设置成功', [], 1, 1);
+    }
+
+
+
+    /**
+     * @notes 获取备案信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/28 16:10
+     */
+    public function getCopyright()
+    {
+        $result = WebSettingLogic::getCopyright();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 设置备案信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2021/12/28 16:10
+     */
+    public function setCopyright()
+    {
+        $params = $this->request->post();
+        $result = WebSettingLogic::setCopyright($params);
+        if (false === $result) {
+            return $this->fail(WebSettingLogic::getError() ?: '操作失败');
+        }
+        return $this->success('设置成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 设置政策协议
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/15 11:00 上午
+     */
+    public function setAgreement()
+    {
+        $params = $this->request->post();
+        WebSettingLogic::setAgreement($params);
+        return $this->success('设置成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取政策协议
+     * @return \think\response\Json
+     * @author ljj
+     * @date 2022/2/15 11:16 上午
+     */
+    public function getAgreement()
+    {
+        $result = WebSettingLogic::getAgreement();
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 获取站点统计配置
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/20 22:24
+     */
+    public function getSiteStatistics()
+    {
+        $result = WebSettingLogic::getSiteStatistics();
+        return $this->data($result);
+    }
+
+    /**
+     * @notes 获取站点统计配置
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/20 22:51
+     */
+    public function setSiteStatistics()
+    {
+        $params = (new WebSettingValidate())->post()->goCheck('siteStatistics');
+        WebSettingLogic::setSiteStatistics($params);
+        return $this->success('设置成功', [], 1, 1);
+    }
+}

+ 86 - 0
app/tenantapi/controller/user/UserController.php

@@ -0,0 +1,86 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\controller\user;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\user\UserLists;
+use app\tenantapi\logic\user\UserLogic;
+use app\tenantapi\validate\user\AdjustUserMoney;
+use app\tenantapi\validate\user\UserValidate;
+
+/**
+ * 用户控制器
+ * Class TenantController
+ * @package app\tenantapi\controller\user
+ */
+class UserController extends BaseAdminController
+{
+
+    /**
+     * @notes 用户列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/22 16:16
+     */
+    public function lists()
+    {
+        return $this->dataLists(new UserLists());
+    }
+
+
+    /**
+     * @notes 获取用户详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/22 16:34
+     */
+    public function detail()
+    {
+        $params = (new UserValidate())->goCheck('detail');
+        $detail = UserLogic::detail($params['id']);
+        return $this->success('', $detail);
+    }
+
+
+    /**
+     * @notes 编辑用户信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/22 16:34
+     */
+    public function edit()
+    {
+        $params = (new UserValidate())->post()->goCheck('setInfo');
+        UserLogic::setUserInfo($params);
+        return $this->success('操作成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 调整用户余额
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/23 14:33
+     */
+    public function adjustMoney()
+    {
+        $params = (new AdjustUserMoney())->post()->goCheck();
+        $res = UserLogic::adjustUserMoney($params);
+        if (true === $res) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail($res);
+    }
+
+}

+ 23 - 0
app/tenantapi/event.php

@@ -0,0 +1,23 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+return [
+    'listen' => [
+        'AppInit' => [],
+        'HttpRun' => [],
+        'HttpEnd' => ['app\tenantapi\listener\OperationLog'],
+        'LogLevel' => [],
+        'LogWrite' => [],
+    ]
+];

+ 92 - 0
app/tenantapi/http/middleware/AuthMiddleware.php

@@ -0,0 +1,92 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+declare (strict_types=1);
+
+namespace app\tenantapi\http\middleware;
+
+use app\common\service\JsonService;
+use app\common\{
+    cache\TenantAdminAuthCache
+};
+use think\helper\Str;
+
+/**
+ * 权限验证中间件
+ * Class AuthMiddleware
+ * @package app\tenantapi\http\middleware
+ */
+class AuthMiddleware
+{
+    /**
+     * @notes 权限验证
+     * @param $request
+     * @param \Closure $next
+     * @return mixed
+     * @author 令狐冲
+     * @date 2021/7/2 19:29
+     */
+    public function handle($request, \Closure $next)
+    {
+        //不登录访问,无需权限验证
+        if ($request->controllerObject->isNotNeedLogin()) {
+            return $next($request);
+        }
+
+        if ($request->adminInfo['login_ip'] != request()->ip()) {
+            return JsonService::fail('ip地址发生变化,请重新登录', [], -1);
+        }
+
+        //系统默认超级管理员,无需权限验证
+        if (1 === $request->adminInfo['root']) {
+            return $next($request);
+        }
+        $adminAuthCache = new TenantAdminAuthCache($request->adminInfo['admin_id']);
+
+        // 当前访问路径
+        $accessUri = strtolower($request->controller() . '/' . $request->action());
+        // 全部路由
+        $allUri = $this->formatUrl($adminAuthCache->getAllUri());
+
+        // 判断该当前访问的uri是否存在,不存在无需验证
+        if (!in_array($accessUri, $allUri)) {
+            return $next($request);
+        }
+
+        // 当前管理员拥有的路由权限
+        $AdminUris = $adminAuthCache->getAdminUri() ?? [];
+        $AdminUris = $this->formatUrl($AdminUris);
+
+        if (in_array($accessUri, $AdminUris)) {
+            return $next($request);
+        }
+        return JsonService::fail('权限不足,无法访问或操作');
+    }
+
+
+    /**
+     * @notes 格式化URL
+     * @param array $data
+     * @return array|string[]
+     * @author 段誉
+     * @date 2022/7/7 15:39
+     */
+    public function formatUrl(array $data)
+    {
+        return array_map(function ($item) {
+            return strtolower(Str::camel($item));
+        }, $data);
+    }
+
+}

+ 50 - 0
app/tenantapi/http/middleware/CheckDemoMiddleware.php

@@ -0,0 +1,50 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+declare (strict_types=1);
+
+namespace app\tenantapi\http\middleware;
+
+
+use app\common\service\JsonService;
+
+/**
+ * 校验演示环境
+ * Class CheckDemoMiddleware
+ * @package app\tenantapi\http\middleware
+ */
+class CheckDemoMiddleware
+{
+
+    // 允许post的接口
+    protected $ablePost = [
+        'login/account',
+        'login/logout',
+    ];
+
+    public function handle($request, \Closure $next)
+    {
+        if ($request->method() != 'POST') {
+            return $next($request);
+        }
+
+        $accessUri = strtolower($request->controller() . '/' . $request->action());
+        if (!in_array($accessUri, $this->ablePost) && env('project.demo_env')) {
+            return JsonService::fail('演示环境不支持修改数据,请下载源码本地部署体验');
+        }
+
+        return $next($request);
+    }
+
+}

+ 114 - 0
app/tenantapi/http/middleware/EncryDemoDataMiddleware.php

@@ -0,0 +1,114 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+declare (strict_types=1);
+
+namespace app\tenantapi\http\middleware;
+
+/**
+ * 演示环境数据加密
+ * Class DemoDataMiddleware
+ * @package app\tenantapi\http\middleware
+ */
+class EncryDemoDataMiddleware
+{
+
+    // 需要过滤的接口
+    protected $needCheck = [
+        // 存储配置
+        'setting.storage/detail',
+        // 短信配置
+        'notice.smsConfig/detail',
+        // 公众号配置
+        'channel.official_account_setting/getConfig',
+        // 小程序配置
+        'channel.mnp_settings/getConfig',
+        // 开放平台配置
+        'channel.open_setting/getConfig',
+        // 支付配置
+        'setting.pay.pay_config/getConfig',
+    ];
+
+    // 可以排除字段
+    protected $excludeParams = [
+        'name',
+        'icon',
+        'image',
+        'qr_code',
+        'interface_version',
+        'merchant_type',
+    ];
+
+
+    public function handle($request, \Closure $next)
+    {
+        $response = $next($request);
+
+        // 非需校验的接口 或者 未开启演示模式
+        $accessUri = strtolower($request->controller() . '/' . $request->action());
+        if (!in_array($accessUri, lower_uri($this->needCheck)) || !env('project.demo_env')) {
+            return $response;
+        }
+
+        // 非json数据
+        if (!method_exists($response, 'header') || !in_array('application/json; charset=utf-8', $response->getHeader())) {
+            return $response;
+        }
+
+        $data = $response->getData();
+        if (!is_array($data) || empty($data)) {
+            return $response;
+        }
+
+        foreach ($data['data'] as $key => $item) {
+            // 字符串
+            if (is_string($item)) {
+                $data['data'][$key] = $this->getEncryData($key, $item);
+                continue;
+            }
+            // 数组
+            if (is_array($item)) {
+                foreach ($item as $itemKey => $itemValue) {
+                    $data['data'][$key][$itemKey] = $this->getEncryData($itemKey, $itemValue);
+                }
+            }
+        }
+
+        return $response->data($data);
+    }
+
+
+    /**
+     * @notes 加密配置
+     * @param $key
+     * @param $value
+     * @return mixed|string
+     * @author 段誉
+     * @date 2023/3/6 11:49
+     */
+    protected function getEncryData($key, $value)
+    {
+        // 非隐藏字段
+        if (in_array($key, $this->excludeParams)) {
+            return $value;
+        }
+
+        // 隐藏字段
+        if (is_string($value)) {
+            return '******';
+        }
+        return $value;
+    }
+
+}

+ 57 - 0
app/tenantapi/http/middleware/InitMiddleware.php

@@ -0,0 +1,57 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\tenantapi\http\middleware;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\common\exception\ControllerExtendException;
+use think\exception\ClassNotFoundException;
+use think\exception\HttpException;
+
+/**
+ * 初始化验证中间件
+ * Class InitMiddleware
+ * @package app\tenantapi\http\middleware
+ */
+class InitMiddleware
+{
+    /**
+     * @notes 初始化
+     * @param $request
+     * @param \Closure $next
+     * @return mixed
+     * @author 令狐冲
+     * @date 2021/7/2 19:29
+     */
+    public function handle($request, \Closure $next)
+    {
+        //获取控制器
+        try {
+            $controller = str_replace('.', '\\', $request->controller());
+            $controller = '\\app\\tenantapi\\controller\\' . $controller . 'Controller';
+            $controllerClass = invoke($controller);
+            if (($controllerClass instanceof BaseAdminController) === false) {
+                throw new ControllerExtendException($controller, '404');
+            }
+        } catch (ClassNotFoundException $e) {
+            throw new HttpException(404, 'controller not exists:' . $e->getClass());
+        }
+
+        //创建控制器对象
+        $request->controllerObject = invoke($controller);
+
+        return $next($request);
+    }
+}

+ 87 - 0
app/tenantapi/http/middleware/LoginMiddleware.php

@@ -0,0 +1,87 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+declare (strict_types=1);
+
+namespace app\tenantapi\http\middleware;
+
+use app\common\cache\TenantAdminTokenCache;
+use app\tenantapi\service\TenantTokenService;
+use app\common\service\JsonService;
+use think\facade\Config;
+
+/**
+ * 登录中间件
+ * Class LoginMiddleware
+ * @package app\tenantapi\http\middleware
+ */
+class LoginMiddleware
+{
+    /**
+     * @notes 登录验证
+     * @param $request
+     * @param \Closure $next
+     * @return mixed|\think\response\Json
+     * @author 令狐冲
+     * @date 2021/7/1 17:33
+     */
+    public function handle($request, \Closure $next)
+    {
+        $token = $request->header('token');
+        //判断接口是否免登录
+        $isNotNeedLogin = $request->controllerObject->isNotNeedLogin();
+
+        //不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问
+        if (empty($token) && !$isNotNeedLogin) {
+            //没有token并且该地址需要登录才能访问
+            return JsonService::fail('请求参数缺token', [], 0, 0);
+        }
+
+        $adminInfo = (new TenantAdminTokenCache())->getAdminInfo($token);
+
+
+        if (empty($adminInfo) && !$isNotNeedLogin) {
+            //token过期无效并且该地址需要登录才能访问
+            return JsonService::fail('登录超时,请重新登录', [], -1);
+        }
+
+        //token临近过期,自动续期
+        if ($adminInfo) {
+            //获取临近过期自动续期时长
+            $beExpireDuration = Config::get('project.admin_token.be_expire_duration');
+            //token续期
+            if (time() > ($adminInfo['expire_time'] - $beExpireDuration)) {
+                $result = TenantTokenService::overtimeToken($token);
+                //续期失败(数据表被删除导致)
+                if (empty($result)) {
+                    return JsonService::fail('登录过期', [], -1);
+                }
+            }
+
+            if ($adminInfo['tenant_id'] !== $request->tenantId) {
+                if (!$isNotNeedLogin) {
+                    TenantTokenService::expireToken($token);
+                    return JsonService::fail('非该站点成员禁止访问', [], -1);
+                }
+            }
+        }
+
+        //给request赋值,用于控制器
+        $request->adminInfo = $adminInfo;
+        $request->adminId = $adminInfo['admin_id'] ?? 0;
+
+        return $next($request);
+    }
+
+}

+ 77 - 0
app/tenantapi/listener/OperationLog.php

@@ -0,0 +1,77 @@
+<?php
+
+
+namespace app\tenantapi\listener;
+
+
+use ReflectionClass;
+use think\Exception;
+
+class OperationLog
+{
+    /**
+     * @notes 管理员操作日志
+     * @param $response
+     * @return bool|void
+     * @throws \ReflectionException
+     * @author 段誉
+     * @date 2022/4/8 17:09
+     */
+    public function handle($response)
+    {
+        $request = request();
+
+        //需要登录的接口,无效访问时不记录
+        if (!$request->controllerObject->isNotNeedLogin() && empty($request->adminInfo)) {
+            return;
+        }
+
+        //不记录日志操作
+        if (strtolower(str_replace('.', '\\', $request->controller())) === 'setting\system\log') {
+            return;
+        }
+
+        //获取操作注解
+        $notes = '';
+        try {
+            $re = new ReflectionClass($request->controllerObject);
+            $doc = $re->getMethod($request->action())->getDocComment();
+            if (empty($doc)) {
+                throw new Exception('请给控制器方法注释');
+            }
+            preg_match('/\s(\w+)/u', $re->getMethod($request->action())->getDocComment(), $values);
+            $notes = $values[0];
+        } catch (Exception $e) {
+            $notes = $notes ?: '无法获取操作名称,请给控制器方法注释';
+        }
+
+        $params = $request->param();
+
+        //过滤密码参数
+        if (isset($params['password'])) {
+            $params['password'] = "******";
+        }
+        //过滤密钥参数
+        if(isset($params['app_secret'])){
+            $params['app_secret'] = "******";
+        }
+
+        //导出数据操作进行记录
+        if (isset($params['export']) && $params['export'] == 2) {
+            $notes .= '-数据导出';
+        }
+
+        //记录日志
+        $systemLog = new \app\common\model\OperationLog();
+        $systemLog->admin_id = $request->adminInfo['admin_id'] ?? 0;
+        $systemLog->admin_name = $request->adminInfo['name'] ?? '';
+        $systemLog->action = $notes;
+        $systemLog->account = $request->adminInfo['account'] ?? '';
+        $systemLog->url = $request->url(true);
+        $systemLog->type = $request->isGet() ? 'GET' : 'POST';
+        $systemLog->params = json_encode($params, true);
+        $systemLog->ip = $request->ip();
+        $systemLog->result = $response->getContent();
+        return $systemLog->save();
+    }
+}

+ 39 - 0
app/tenantapi/lists/BaseAdminDataLists.php

@@ -0,0 +1,39 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\tenantapi\lists;
+
+
+use app\common\lists\BaseDataLists;
+
+/**
+ * 管理员模块数据列表基类
+ * Class BaseAdminDataLists
+ * @package app\tenantapi\lists
+ */
+abstract class BaseAdminDataLists extends BaseDataLists
+{
+    protected array $adminInfo;
+    protected int $adminId;
+
+    public function __construct()
+    {
+        parent::__construct();
+        $this->adminInfo = $this->request->adminInfo;
+        $this->adminId = $this->request->adminId;
+    }
+
+
+}

+ 206 - 0
app/tenantapi/lists/auth/AdminLists.php

@@ -0,0 +1,206 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\auth;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsExcelInterface;
+use app\common\lists\ListsExtendInterface;
+use app\common\lists\ListsSearchInterface;
+use app\common\lists\ListsSortInterface;
+use app\common\model\auth\TenantAdmin;
+use app\common\model\auth\TenantAdminRole;
+use app\common\model\auth\TenantSystemRole;
+use app\common\model\dept\TenantDept;
+use app\common\model\dept\TenantJobs;
+
+/**
+ * 管理员列表
+ * Class AdminLists
+ * @package app\tenantapi\lists\auth
+ */
+class AdminLists extends BaseAdminDataLists implements ListsExtendInterface, ListsSearchInterface, ListsSortInterface,ListsExcelInterface
+{
+    /**
+     * @notes 设置导出字段
+     * @return string[]
+     * @author 段誉
+     * @date 2021/12/29 10:08
+     */
+    public function setExcelFields(): array
+    {
+        return [
+            'account' => '账号',
+            'name' => '名称',
+            'role_name' => '角色',
+            'dept_name' => '部门',
+            'create_time' => '创建时间',
+            'login_time' => '最近登录时间',
+            'login_ip' => '最近登录IP',
+            'disable_desc' => '状态',
+        ];
+    }
+
+
+    /**
+     * @notes 设置导出文件名
+     * @return string
+     * @author 段誉
+     * @date 2021/12/29 10:08
+     */
+    public function setFileName(): string
+    {
+        return '管理员列表';
+    }
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author 段誉
+     * @date 2021/12/29 10:07
+     */
+    public function setSearch(): array
+    {
+        return [
+            '%like%' => ['name', 'account'],
+        ];
+    }
+
+
+    /**
+     * @notes 设置支持排序字段
+     * @return string[]
+     * @author 段誉
+     * @date 2021/12/29 10:07
+     * @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
+     */
+    public function setSortFields(): array
+    {
+        return ['create_time' => 'create_time', 'id' => 'id'];
+    }
+
+
+    /**
+     * @notes 设置默认排序
+     * @return string[]
+     * @author 段誉
+     * @date 2021/12/29 10:06
+     */
+    public function setDefaultOrder(): array
+    {
+        return ['id' => 'desc'];
+    }
+
+    /**
+     * @notes 查询条件
+     * @return array
+     * @author 段誉
+     * @date 2022/11/29 11:33
+     */
+    public function queryWhere()
+    {
+        $where = [];
+        if (isset($this->params['role_id']) && $this->params['role_id'] != '') {
+            $adminIds = TenantAdminRole::where('role_id', $this->params['role_id'])->column('admin_id');
+            if (!empty($adminIds)) {
+                $where[] = ['id', 'in', $adminIds];
+            }
+        }
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取管理列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2021/12/29 10:05
+     */
+    public function lists(): array
+    {
+        $field = [
+            'id', 'name', 'account', 'create_time', 'disable', 'root',
+            'login_time', 'login_ip', 'multipoint_login', 'avatar'
+        ];
+
+        $adminLists = TenantAdmin::field($field)
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order($this->sortOrder)
+            ->append(['role_id', 'dept_id', 'jobs_id', 'disable_desc'])
+            ->select()
+            ->toArray();
+
+        // 角色数组('角色id'=>'角色名称')
+        $roleLists = TenantSystemRole::column('name', 'id');
+        // 部门列表
+        $deptLists = TenantDept::column('name', 'id');
+        // 岗位列表
+        $jobsLists = TenantJobs::column('name', 'id');
+
+        //管理员列表增加角色名称
+        foreach ($adminLists as $k => $v) {
+            $roleName = '';
+            if ($v['root'] == 1) {
+                $roleName = '系统管理员';
+            } else {
+                foreach ($v['role_id'] as $roleId) {
+                    $roleName .= $roleLists[$roleId] ?? '';
+                    $roleName .= '/';
+                }
+            }
+
+            $deptName = '';
+            foreach ($v['dept_id'] as $deptId) {
+                $deptName .= $deptLists[$deptId] ?? '';
+                $deptName .= '/';
+            }
+
+            $jobsName = '';
+            foreach ($v['jobs_id'] as $jobsId) {
+                $jobsName .= $jobsLists[$jobsId] ?? '';
+                $jobsName .= '/';
+            }
+
+            $adminLists[$k]['role_name'] = trim($roleName, '/');
+            $adminLists[$k]['dept_name'] = trim($deptName, '/');
+            $adminLists[$k]['jobs_name'] = trim($jobsName, '/');
+        }
+
+        return $adminLists;
+    }
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 令狐冲
+     * @date 2021/7/13 00:52
+     */
+    public function count(): int
+    {
+        return TenantAdmin::where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->count();
+    }
+
+    public function extend()
+    {
+        return [];
+    }
+}

+ 60 - 0
app/tenantapi/lists/auth/MenuLists.php

@@ -0,0 +1,60 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\auth;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\auth\TenantSystemMenu;
+use think\db\exception\DbException;
+
+
+/**
+ *  菜单列表
+ * Class MenuLists
+ * @package app\tenantapi\lists\auth
+ */
+class MenuLists extends BaseAdminDataLists
+{
+
+    /**
+     * @notes 获取菜单列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/6/29 16:41
+     */
+    public function lists(): array
+    {
+        $lists = TenantSystemMenu::order(['sort' => 'desc', 'id' => 'asc'])
+            ->select()
+            ->toArray();
+        return linear_to_tree($lists, 'children');
+    }
+
+
+    /**
+     * @notes 获取菜单数量
+     * @return int
+     * @throws DbException
+     * @author 段誉
+     * @date 2022/6/29 16:41
+     */
+    public function count(): int
+    {
+        return TenantSystemMenu::count();
+    }
+
+}

+ 93 - 0
app/tenantapi/lists/auth/RoleLists.php

@@ -0,0 +1,93 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\auth;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\auth\TenantAdminRole;
+use app\common\model\auth\TenantSystemRole;
+
+/**
+ * 角色列表
+ * Class RoleLists
+ * @package app\tenantapi\lists\auth
+ */
+class RoleLists extends BaseAdminDataLists
+{
+    /**
+     * @notes 导出字段
+     * @return string[]
+     * @author Tab
+     * @date 2021/9/22 18:52
+     */
+    public function setExcelFields(): array
+    {
+        return [
+            'name' => '角色名称',
+            'desc' => '备注',
+            'create_time' => '创建时间'
+        ];
+    }
+
+    /**
+     * @notes 导出表名
+     * @return string
+     * @author Tab
+     * @date 2021/9/22 18:52
+     */
+    public function setFileName(): string
+    {
+        return '角色表';
+    }
+
+    /**
+     * @notes 角色列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author cjhao
+     * @date 2021/8/25 18:00
+     */
+    public function lists(): array
+    {
+        $lists = TenantSystemRole::with(['role_menu_index'])
+            ->field('id,name,desc,sort,create_time')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        foreach ($lists as $key => $role) {
+            //使用角色的人数
+            $lists[$key]['num'] = TenantAdminRole::where('role_id', $role['id'])->count();
+            $menuId = array_column($role['role_menu_index'], 'menu_id');
+            $lists[$key]['menu_id'] = $menuId;
+            unset($lists[$key]['role_menu_index']);
+        }
+
+        return $lists;
+    }
+
+    /**
+     * @notes 总记录数
+     * @return int
+     * @author Tab
+     * @date 2021/7/13 11:26
+     */
+    public function count(): int
+    {
+        return TenantSystemRole::count();
+    }
+}

+ 80 - 0
app/tenantapi/lists/channel/OfficialAccountReplyLists.php

@@ -0,0 +1,80 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\channel;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\channel\OfficialAccountReply;
+
+/**
+ * 微信公众号回复列表
+ * Class OfficialAccountLists
+ * @package app\tenantapi\lists
+ */
+class OfficialAccountReplyLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * @notes 设置搜索
+     * @return \string[][]
+     * @author 段誉
+     * @date 2022/3/30 15:02
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['reply_type']
+        ];
+    }
+
+
+    /**
+     * @notes 回复列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/3/30 15:02
+     */
+    public function lists(): array
+    {
+        $field = 'id,name,keyword,matching_type,content,content_type,status,sort';
+        $field .= ',matching_type as matching_type_desc,content_type as content_type_desc,status as status_desc';
+
+        $lists = OfficialAccountReply::field($field)
+            ->where($this->searchWhere)
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 回复记录数
+     * @return int
+     * @author 段誉
+     * @date 2022/3/30 15:02
+     */
+    public function count(): int
+    {
+        $count = OfficialAccountReply::where($this->searchWhere)->count();
+
+        return $count;
+    }
+}

+ 105 - 0
app/tenantapi/lists/dept/JobsLists.php

@@ -0,0 +1,105 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\dept;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsExcelInterface;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\dept\TenantJobs;
+
+/**
+ * 岗位列表
+ * Class JobsLists
+ * @package app\tenantapi\lists\dept
+ */
+class JobsLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
+{
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author 段誉
+     * @date 2022/5/26 9:46
+     */
+    public function setSearch(): array
+    {
+        return [
+            '%like%' => ['name'],
+            '=' => ['code', 'status']
+        ];
+    }
+
+
+    /**
+     * @notes  获取管理列表
+     * @return array
+     * @author heshihu
+     * @date 2022/2/21 17:11
+     */
+    public function lists(): array
+    {
+        $lists = TenantJobs::where($this->searchWhere)
+            ->append(['status_desc'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2022/5/26 9:48
+     */
+    public function count(): int
+    {
+        return TenantJobs::where($this->searchWhere)->count();
+    }
+
+
+    /**
+     * @notes 导出文件名
+     * @return string
+     * @author 段誉
+     * @date 2022/11/24 16:17
+     */
+    public function setFileName(): string
+    {
+        return '岗位列表';
+    }
+
+
+    /**
+     * @notes 导出字段
+     * @return string[]
+     * @author 段誉
+     * @date 2022/11/24 16:17
+     */
+    public function setExcelFields(): array
+    {
+        return [
+            'code' => '岗位编码',
+            'name' => '岗位名称',
+            'remark' => '备注',
+            'status_desc' => '状态',
+            'create_time' => '添加时间',
+        ];
+    }
+
+}

+ 74 - 0
app/tenantapi/lists/file/FileCateLists.php

@@ -0,0 +1,74 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\file;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\file\TenantFileCate;
+
+/**
+ * 文件分类列表
+ * Class FileCateLists
+ * @package app\tenantapi\lists\file
+ */
+class FileCateLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * @notes 文件分类搜素条件
+     * @return \string[][]
+     * @author 段誉
+     * @date 2021/12/29 14:24
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['type']
+        ];
+    }
+
+
+    /**
+     * @notes 获取文件分类列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2021/12/29 14:24
+     */
+    public function lists(): array
+    {
+        $lists = (new TenantFileCate())->field(['id,pid,type,name'])
+            ->where($this->searchWhere)
+            ->order('id desc')
+            ->select()->toArray();
+
+        return linear_to_tree($lists, 'children');
+    }
+
+
+    /**
+     * @notes 获取文件分类数量
+     * @return int
+     * @author 段誉
+     * @date 2021/12/29 14:24
+     */
+    public function count(): int
+    {
+        return (new TenantFileCate())->where($this->searchWhere)->count();
+    }
+}

+ 109 - 0
app/tenantapi/lists/file/FileLists.php

@@ -0,0 +1,109 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\file;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\tenantapi\logic\FileLogic;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\file\TenantFile;
+use app\common\service\FileService;
+
+/**
+ * 文件列表
+ * Class FileLists
+ * @package app\tenantapi\lists\file
+ */
+class FileLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * @notes 文件搜索条件
+     * @return \string[][]
+     * @author 段誉
+     * @date 2021/12/29 14:27
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['type', 'source'],
+            '%like%' => ['name']
+        ];
+    }
+
+    /**
+     * @notes 额外查询处理
+     * @return array
+     * @author 段誉
+     * @date 2024/2/7 10:26
+     */
+    public function queryWhere(): array
+    {
+        $where = [];
+        // 如果cid为0则为未分组
+        if("0" === $this->params['cid']){
+            $where[] = ['cid', '=', '0'];
+        }
+        if (!empty($this->params['cid'])) {
+            $cateChild = FileLogic::getCateIds($this->params['cid']);
+            $cateChild[] = (int)$this->params['cid'];
+            $where[] = ['cid', 'in', $cateChild];
+        }
+
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取文件列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2021/12/29 14:27
+     */
+    public function lists(): array
+    {
+        $lists = (new TenantFile())->field(['id,cid,type,name,uri,create_time'])
+            ->order('id', 'desc')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+//            ->where('source', FileEnum::SOURCE_ADMIN)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+
+        foreach ($lists as &$item) {
+            $item['url'] = FileService::getFileUrl($item['uri']);
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取文件数量
+     * @return int
+     * @author 段誉
+     * @date 2021/12/29 14:29
+     */
+    public function count(): int
+    {
+        return (new TenantFile())->where($this->searchWhere)
+            ->where($this->queryWhere())
+//            ->where('source', FileEnum::SOURCE_ADMIN)
+            ->count();
+    }
+}

+ 62 - 0
app/tenantapi/lists/setting/pay/PayConfigLists.php

@@ -0,0 +1,62 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\setting\pay;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\pay\TenantPayConfig;
+
+/**
+ * 支付配置列表
+ * Class PayConfigLists
+ * @package app\tenantapi\lists\setting\pay
+ */
+class PayConfigLists extends BaseAdminDataLists
+{
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/2/23 16:15
+     */
+    public function lists(): array
+    {
+        $lists = TenantPayConfig::field('id,name,pay_way,icon,sort')
+            ->append(['pay_way_name'])
+            ->order('sort','desc')
+            ->select()
+            ->toArray();
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2023/2/23 16:15
+     */
+    public function count(): int
+    {
+        return TenantPayConfig::count();
+    }
+
+
+
+}

+ 111 - 0
app/tenantapi/lists/user/UserLists.php

@@ -0,0 +1,111 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\lists\user;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\user\UserTerminalEnum;
+use app\common\lists\ListsExcelInterface;
+use app\common\model\user\User;
+
+
+/**
+ * 用户列表
+ * Class TenantLists
+ * @package app\tenantapi\lists\user
+ */
+class UserLists extends BaseAdminDataLists implements ListsExcelInterface
+{
+
+    /**
+     * @notes 搜索条件
+     * @return array
+     * @author 段誉
+     * @date 2022/9/22 15:50
+     */
+    public function setSearch(): array
+    {
+        $allowSearch = ['keyword', 'channel', 'create_time_start', 'create_time_end','tenant_id'];
+        return array_intersect(array_keys($this->params), $allowSearch);
+    }
+
+
+    /**
+     * @notes 获取用户列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/22 15:50
+     */
+    public function lists(): array
+    {
+        $field = "id,sn,nickname,sex,avatar,account,mobile,channel,create_time,is_disable";
+        $lists = User::withSearch($this->setSearch(), $this->params)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->field($field)
+            ->order('id desc')
+            ->select()->toArray();
+
+        foreach ($lists as &$item) {
+            $item['channel'] = UserTerminalEnum::getTermInalDesc($item['channel']);
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2022/9/22 15:51
+     */
+    public function count(): int
+    {
+        return User::withSearch($this->setSearch(), $this->params)->count();
+    }
+
+
+    /**
+     * @notes 导出文件名
+     * @return string
+     * @author 段誉
+     * @date 2022/11/24 16:17
+     */
+    public function setFileName(): string
+    {
+        return '用户列表';
+    }
+
+
+    /**
+     * @notes 导出字段
+     * @return string[]
+     * @author 段誉
+     * @date 2022/11/24 16:17
+     */
+    public function setExcelFields(): array
+    {
+        return [
+            'sn' => '用户编号',
+            'nickname' => '用户昵称',
+            'account' => '账号',
+            'mobile' => '手机号码',
+            'channel' => '注册来源',
+            'create_time' => '注册时间',
+        ];
+    }
+
+}

+ 105 - 0
app/tenantapi/logic/ConfigLogic.php

@@ -0,0 +1,105 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic;
+
+use app\tenantapi\logic\article\ArticleCateLogic;
+use app\tenantapi\logic\auth\MenuLogic;
+use app\tenantapi\logic\auth\RoleLogic;
+use app\tenantapi\logic\dept\DeptLogic;
+use app\tenantapi\logic\dept\JobsLogic;
+use app\tenantapi\logic\setting\dict\DictTypeLogic;
+use app\common\enum\YesNoEnum;
+use app\common\model\article\ArticleCate;
+use app\common\model\auth\SystemMenu;
+use app\common\model\auth\SystemRole;
+use app\common\model\dept\Dept;
+use app\common\model\dept\Jobs;
+use app\common\model\dict\DictData;
+use app\common\model\dict\DictType;
+use app\common\service\ConfigService;
+use app\common\service\{FileService};
+
+/**
+ * 配置类逻辑层
+ * Class ConfigLogic
+ * @package app\tenantapi\logic
+ */
+class ConfigLogic
+{
+    /**
+     * @notes 获取配置
+     * @return array
+     * @author 段誉
+     * @date 2021/12/31 11:03
+     */
+    public static function getConfig(): array
+    {
+        $config = [
+            // 文件域名
+            'oss_domain' => FileService::getFileUrl(),
+
+            // 网站名称
+            'web_name' => ConfigService::get('tenant', 'name'),
+            // 网站图标
+            'web_favicon' => FileService::getFileUrl(ConfigService::get('tenant', 'web_favicon')),
+            // 网站logo
+            'web_logo' => FileService::getFileUrl(ConfigService::get('tenant', 'web_logo')),
+            // 登录页
+            'login_image' => FileService::getFileUrl(ConfigService::get('tenant', 'login_image')),
+
+            // 版权信息
+            'copyright_config' => ConfigService::get('copyright', 'config', []),
+        ];
+        return $config;
+    }
+
+
+    /**
+     * @notes 根据类型获取字典类型
+     * @param $type
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/27 19:09
+     */
+    public static function getDictByType($type)
+    {
+        if (!is_string($type)) {
+            return [];
+        }
+        
+        $type = explode(',', $type);
+        $lists = DictData::whereIn('type_value', $type)->select()->toArray();
+
+        if (empty($lists)) {
+            return [];
+        }
+
+        $result = [];
+        foreach ($type as $item) {
+            foreach ($lists as $dict) {
+                if ($dict['type_value'] == $item) {
+                    $result[$item][] = $dict;
+                }
+            }
+        }
+        return $result;
+    }
+
+
+
+}

+ 158 - 0
app/tenantapi/logic/FileLogic.php

@@ -0,0 +1,158 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic;
+
+
+use app\common\logic\BaseLogic;
+use app\common\model\file\TenantFile;
+use app\common\model\file\TenantFileCate;
+use app\common\service\ConfigService;
+use app\common\service\storage\Driver as StorageDriver;
+
+/**
+ * 文件逻辑层
+ * Class FileLogic
+ * @package app\tenantapi\logic
+ */
+class FileLogic extends BaseLogic
+{
+    /**
+     * @notes 移动文件
+     * @param $params
+     * @author 张无忌
+     * @date 2021/7/28 15:29
+     */
+    public static function move($params)
+    {
+        (new TenantFile())->whereIn('id', $params['ids'])
+            ->update([
+                'cid' => $params['cid'],
+                'update_time' => time()
+            ]);
+    }
+
+    /**
+     * @notes 重命名文件
+     * @param $params
+     * @author 张无忌
+     * @date 2021/7/29 17:16
+     */
+    public static function rename($params)
+    {
+        (new TenantFile())->where('id', $params['id'])
+            ->update([
+                'name' => $params['name'],
+                'update_time' => time()
+            ]);
+    }
+
+    /**
+     * @notes 批量删除文件
+     * @param $params
+     * @author 张无忌
+     * @date 2021/7/28 15:41
+     */
+    public static function delete($params)
+    {
+        $result = TenantFile::whereIn('id', $params['ids'])->select();
+        $StorageDriver = new StorageDriver([
+            'default' => ConfigService::get('storage', 'default', 'local'),
+            'engine'  => ConfigService::get('storage') ?? ['local'=>[]],
+        ]);
+        foreach ($result as $item) {
+            $StorageDriver->delete($item['uri']);
+        }
+        TenantFile::destroy($params['ids']);
+    }
+
+    /**
+     * @notes 添加文件分类
+     * @param $params
+     * @author 张无忌
+     * @date 2021/7/28 11:32
+     */
+    public static function addCate($params)
+    {
+        TenantFileCate::create([
+            'type' => $params['type'],
+            'pid' => $params['pid'],
+            'name' => $params['name']
+        ]);
+    }
+
+    /**
+     * @notes 编辑文件分类
+     * @param $params
+     * @author 张无忌
+     * @date 2021/7/28 14:03
+     */
+    public static function editCate($params)
+    {
+        TenantFileCate::update([
+            'name' => $params['name'],
+            'update_time' => time()
+        ], ['id' => $params['id']]);
+    }
+
+    /**
+     * @notes 删除文件分类
+     * @param $params
+     * @author 张无忌
+     * @date 2021/7/28 14:21
+     */
+    public static function delCate($params)
+    {
+        $fileModel = new TenantFile();
+        $cateModel = new TenantFileCate();
+
+        $cateIds = self::getCateIds($params['id']);
+        array_push($cateIds, $params['id']);
+
+        // 删除分类及子分类
+        $cateModel->whereIn('id', $cateIds)->update(['delete_time' => time()]);
+
+        // 删除文件
+        $fileIds = $fileModel->whereIn('cid', $cateIds)->column('id');
+
+        if (!empty($fileIds)) {
+            self::delete(['ids' => $fileIds]);
+        }
+    }
+
+
+    /**
+     * @notes 获取所有分类id
+     * @param $parentId
+     * @param array $cateArr
+     * @return array
+     * @author 段誉
+     * @date 2024/2/7 15:03
+     */
+    public static function getCateIds($parentId, array $cateArr = []): array
+    {
+        $childIds = TenantFileCate::where(['pid' => $parentId])->column('id');
+
+        if (empty($childIds)) {
+            return $childIds;
+        } else {
+            $allChildIds = $childIds;
+            foreach ($childIds as $childId) {
+                $allChildIds = array_merge($allChildIds, static::getCateIds($childId, $cateArr));
+            }
+            return $allChildIds;
+        }
+    }
+
+}

+ 83 - 0
app/tenantapi/logic/LoginLogic.php

@@ -0,0 +1,83 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic;
+
+use app\common\logic\BaseLogic;
+use app\common\model\auth\TenantAdmin;
+use app\tenantapi\service\TenantTokenService;
+use app\common\service\FileService;
+use think\facade\Config;
+
+/**
+ * 登录逻辑
+ * Class LoginLogic
+ * @package app\tenantapi\logic
+ */
+class LoginLogic extends BaseLogic
+{
+    /**
+     * @notes 管理员账号登录
+     * @param $params
+     * @return false|mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 令狐冲
+     * @date 2021/6/30 17:00
+     */
+    public function login($params)
+    {
+        $time = time();
+        $admin = TenantAdmin::where('account', '=', $params['account'])->find();
+        //用户表登录信息更新
+        $admin->login_time = $time;
+        $admin->login_ip = request()->ip();
+        $admin->save();
+
+        //设置token
+        $adminInfo = TenantTokenService::setToken($admin->id, $params['terminal'], $admin->multipoint_login);
+        //返回登录信息
+        $avatar = $admin->avatar ?: Config::get('project.default_image.admin_avatar');
+        $avatar = FileService::getFileUrl($avatar);
+
+        return [
+            'name' => $adminInfo['name'],
+            'avatar' => $avatar,
+            'role_name' => $adminInfo['role_name'],
+            'token' => $adminInfo['token'],
+        ];
+    }
+
+
+    /**
+     * @notes 退出登录
+     * @param $adminInfo
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 令狐冲
+     * @date 2021/7/5 14:34
+     */
+    public function logout($adminInfo)
+    {
+        //token不存在,不注销
+        if (!isset($adminInfo['token'])) {
+            return false;
+        }
+        //设置token过期
+        return TenantTokenService::expireToken($adminInfo['token']);
+    }
+}

+ 235 - 0
app/tenantapi/logic/WorkbenchLogic.php

@@ -0,0 +1,235 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic;
+
+
+use app\common\logic\BaseLogic;
+use app\common\model\user\User;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+
+/**
+ * 工作台
+ * Class WorkbenchLogic
+ * @package app\tenantapi\logic
+ */
+class WorkbenchLogic extends BaseLogic
+{
+    /**
+     * @notes 工作套
+     * @param $adminInfo
+     * @return array
+     * @author 段誉
+     * @date 2021/12/29 15:58
+     */
+    public static function index()
+    {
+        return [
+            // 版本信息
+            'version' => self::versionInfo(),
+            // 今日数据
+            'today' => self::today(),
+            // 常用功能
+            'menu' => self::menu(),
+            // 近15日访客数
+            'visitor' => self::visitor(),
+            // 服务支持
+            'support' => self::support(),
+            // 销售数据
+            'sale' => self::sale()
+        ];
+    }
+
+
+    /**
+     * @notes 常用功能
+     * @return array[]
+     * @author 段誉
+     * @date 2021/12/29 16:40
+     */
+    public static function menu(): array
+    {
+        return [
+            [
+                'name' => '管理员',
+                'image' => FileService::getFileUrl(config('project.default_image.menu_admin')),
+                'url' => '/permission/admin'
+            ],
+            [
+                'name' => '角色管理',
+                'image' => FileService::getFileUrl(config('project.default_image.menu_role')),
+                'url' => '/permission/role'
+            ],
+            [
+                'name' => '部门管理',
+                'image' => FileService::getFileUrl(config('project.default_image.menu_dept')),
+                'url' => '/organization/department'
+            ],
+            // [
+            //     'name' => '字典管理',
+            //     'image' => FileService::getFileUrl(config('project.default_image.menu_dict')),
+            //     'url' => '/setting/dev_tools/dict'
+            // ],
+            // [
+            //     'name' => '代码生成器',
+            //     'image' => FileService::getFileUrl(config('project.default_image.menu_generator')),
+            //     'url' => '/setting/dev_tools/code'
+            // ],
+            [
+                'name' => '素材中心',
+                'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
+                'url' => '/app/material/index'
+            ],
+            [
+                'name' => '菜单权限',
+                'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
+                'url' => '/permission/menu'
+            ],
+            [
+                'name' => '网站信息',
+                'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
+                'url' => '/setting/website/information'
+            ],
+        ];
+    }
+
+
+    /**
+     * @notes 版本信息
+     * @return array
+     * @author 段誉
+     * @date 2021/12/29 16:08
+     */
+    public static function versionInfo(): array
+    {
+        return [
+            'version' => config('project.version'),
+            'website' => config('project.website.url'),
+            'name' => ConfigService::get('tenant', 'name'),
+            'based' => 'vue3.x、ElementUI、MySQL',
+            'channel' => [
+                'website' => 'https://www.likeadmin.cn',
+                'gitee' => 'https://gitee.com/likeadmin/likeadmin_php_saas',
+            ]
+        ];
+    }
+
+
+    /**
+     * @notes 今日数据
+     * @return int[]
+     * @author 段誉
+     * @date 2021/12/29 16:15
+     */
+    public static function today(): array
+    {
+        return [
+            'time' => date('Y-m-d H:i:s'),
+            // 今日销售额
+            'today_sales' => 100,
+            // 总销售额
+            'total_sales' => 1000,
+
+            // 今日访问量
+            'today_visitor' => 10,
+            // 总访问量
+            'total_visitor' => 100,
+
+            // 今日新增用户量
+            'today_new_user' => User::where('create_time', '>=', strtotime('today'))->count(),
+            // 总用户量
+            'total_new_user' => User::count(),
+
+            // 订单量 (笔)
+            'order_num' => 12,
+            // 总订单量
+            'order_sum' => 255
+        ];
+    }
+
+
+    /**
+     * @notes 访问数
+     * @return array
+     * @author 段誉
+     * @date 2021/12/29 16:57
+     */
+    public static function visitor(): array
+    {
+        $num = [];
+        $date = [];
+        for ($i = 0; $i < 15; $i++) {
+            $where_start = strtotime("- " . $i . "day");
+            $date[] = date('m/d', $where_start);
+            $num[$i] = rand(0, 100);
+        }
+
+        return [
+            'date' => $date,
+            'list' => [
+                ['name' => '访客数', 'data' => $num]
+            ]
+        ];
+    }
+
+    /**
+     * @notes 访问数
+     * @return array
+     * @author 段誉
+     * @date 2021/12/29 16:57
+     */
+    public static function sale(): array
+    {
+        $num = [];
+        $date = [];
+        for ($i = 0; $i < 7; $i++) {
+            $where_start = strtotime("- " . $i . "day");
+            $date[] = date('m/d', $where_start);
+            $num[$i] = rand(30, 200);
+        }
+
+        return [
+            'date' => $date,
+            'list' => [
+                ['name' => '销售量', 'data' => $num]
+            ]
+        ];
+    }
+
+
+    /**
+     * @notes 服务支持
+     * @return array[]
+     * @author 段誉
+     * @date 2022/7/18 11:18
+     */
+    public static function support()
+    {
+        return [
+            [
+                'image' => FileService::getFileUrl(config('project.default_image.qq_group')),
+                'title' => '官方公众号',
+                'desc' => '关注官方公众号',
+            ],
+            [
+                'image' => FileService::getFileUrl(config('project.default_image.customer_service')),
+                'title' => '添加企业客服微信',
+                'desc' => '想了解更多请添加客服',
+            ]
+        ];
+    }
+
+}

+ 334 - 0
app/tenantapi/logic/auth/AdminLogic.php

@@ -0,0 +1,334 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\auth;
+
+use app\common\cache\TenantAdminAuthCache;
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\auth\TenantAdmin;
+use app\common\model\auth\TenantAdminDept;
+use app\common\model\auth\TenantAdminJobs;
+use app\common\model\auth\TenantAdminRole;
+use app\common\model\auth\TenantAdminSession;
+use app\common\cache\TenantAdminTokenCache;
+use app\common\service\FileService;
+use think\facade\Config;
+use think\facade\Db;
+
+/**
+ * 管理员逻辑
+ * Class AdminLogic
+ * @package app\tenantapi\logic\auth
+ */
+class AdminLogic extends BaseLogic
+{
+
+    /**
+     * @notes 添加管理员
+     * @param array $params
+     * @author 段誉
+     * @date 2021/12/29 10:23
+     */
+    public static function add(array $params)
+    {
+        Db::startTrans();
+        try {
+            $passwordSalt = Config::get('project.unique_identification');
+            $password = create_password($params['password'], $passwordSalt);
+            $defaultAvatar = config('project.default_image.admin_avatar');
+            $avatar = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
+
+            $admin = TenantAdmin::create([
+                'name' => $params['name'],
+                'account' => $params['account'],
+                'avatar' => $avatar,
+                'password' => $password,
+                'create_time' => time(),
+                'disable' => $params['disable'],
+                'multipoint_login' => $params['multipoint_login'],
+            ]);
+
+            // 角色
+            self::insertRole($admin['id'], $params['role_id'] ?? []);
+            // 部门
+            self::insertDept($admin['id'], $params['dept_id'] ?? []);
+            // 岗位
+            self::insertJobs($admin['id'], $params['jobs_id'] ?? []);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑管理员
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2021/12/29 10:43
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            // 基础信息
+            $data = [
+                'name' => $params['name'],
+                'account' => $params['account'],
+                'disable' => $params['disable'],
+                'multipoint_login' => $params['multipoint_login']
+            ];
+
+            // 头像
+            $data['avatar'] = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : '';
+
+            // 密码
+            if (!empty($params['password'])) {
+                $passwordSalt = Config::get('project.unique_identification');
+                $data['password'] = create_password($params['password'], $passwordSalt);
+            }
+
+            // 禁用或更换角色后.设置token过期
+            $roleId = TenantAdminRole::where('admin_id', $params['id'])->column('role_id');
+            $editRole = false;
+            if (!empty(array_diff_assoc($roleId, $params['role_id']))) {
+                $editRole = true;
+            }
+
+            if ($params['disable'] == 1 || $editRole) {
+                $tokenArr = TenantAdminSession::where('admin_id', $params['id'])->select()->toArray();
+                foreach ($tokenArr as $token) {
+                    self::expireToken($token['token']);
+                }
+            }
+
+            TenantAdmin::update($data, ['id' => $params['id']]);
+            (new TenantAdminAuthCache($params['id']))->clearAuthCache();
+
+            // 删除旧的关联信息
+            TenantAdminRole::delByUserId($params['id']);
+            TenantAdminDept::delByUserId($params['id']);
+            TenantAdminJobs::delByUserId($params['id']);
+            // 角色
+            self::insertRole($params['id'], $params['role_id']);
+            // 部门
+            self::insertDept($params['id'], $params['dept_id'] ?? []);
+            // 岗位
+            self::insertJobs($params['id'], $params['jobs_id'] ?? []);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除管理员
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2021/12/29 10:45
+     */
+    public static function delete(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $admin = TenantAdmin::findOrEmpty($params['id']);
+            if ($admin->root == YesNoEnum::YES) {
+                throw new \Exception("超级管理员不允许被删除");
+            }
+            TenantAdmin::destroy($params['id']);
+
+            //设置token过期
+            $tokenArr = TenantAdminSession::where('admin_id', $params['id'])->select()->toArray();
+            foreach ($tokenArr as $token) {
+                self::expireToken($token['token']);
+            }
+            (new TenantAdminAuthCache($params['id']))->clearAuthCache();
+
+            // 删除旧的关联信息
+            TenantAdminRole::delByUserId($params['id']);
+            TenantAdminDept::delByUserId($params['id']);
+            TenantAdminJobs::delByUserId($params['id']);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 过期token
+     * @param $token
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2021/12/29 10:46
+     */
+    public static function expireToken($token): bool
+    {
+        $adminSession = TenantAdminSession::where('token', '=', $token)
+            ->with('admin')
+            ->find();
+
+        if (empty($adminSession)) {
+            return false;
+        }
+
+        $time = time();
+        $adminSession->expire_time = $time;
+        $adminSession->update_time = $time;
+        $adminSession->save();
+
+        return (new TenantAdminTokenCache())->deleteAdminInfo($token);
+    }
+
+
+    /**
+     * @notes 查看管理员详情
+     * @param $params
+     * @return array
+     * @author 段誉
+     * @date 2021/12/29 11:07
+     */
+    public static function detail($params, $action = 'detail'): array
+    {
+        $admin = TenantAdmin::field([
+            'id', 'account', 'name', 'disable', 'root',
+            'multipoint_login', 'avatar',
+        ])->findOrEmpty($params['id'])->toArray();
+
+        if ($action == 'detail') {
+            return $admin;
+        }
+
+        $result['user'] = $admin;
+        // 当前管理员角色拥有的菜单
+        $result['menu'] = MenuLogic::getMenuByAdminId($params['id']);
+        // 当前管理员橘色拥有的按钮权限
+        $result['permissions'] = AuthLogic::getBtnAuthByRoleId($admin);
+        return $result;
+    }
+
+
+    /**
+     * @notes 编辑超级管理员
+     * @param $params
+     * @author 段誉
+     * @date 2022/4/8 17:54
+     */
+    public static function editSelf($params)
+    {
+        $data = [
+            'name' => $params['name'],
+            'avatar' => FileService::setFileUrl($params['avatar']),
+        ];
+
+        if (!empty($params['password'])) {
+            $passwordSalt = Config::get('project.unique_identification');
+            $data['password'] = create_password($params['password'], $passwordSalt);
+        }
+
+        return TenantAdmin::update($data, ['id' => $params['admin_id']]);
+    }
+
+
+    /**
+     * @notes 新增角色
+     * @param $adminId
+     * @param $roleIds
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/11/25 14:23
+     */
+    public static function insertRole($adminId, $roleIds)
+    {
+        if (!empty($roleIds)) {
+            // 角色
+            $roleData = [];
+            foreach ($roleIds as $roleId) {
+                $roleData[] = [
+                    'admin_id' => $adminId,
+                    'role_id' => $roleId,
+                ];
+            }
+            (new TenantAdminRole())->saveAll($roleData);
+        }
+    }
+
+
+    /**
+     * @notes 新增部门
+     * @param $adminId
+     * @param $deptIds
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/11/25 14:22
+     */
+    public static function insertDept($adminId, $deptIds)
+    {
+        // 部门
+        if (!empty($deptIds)) {
+            $deptData = [];
+            foreach ($deptIds as $deptId) {
+                $deptData[] = [
+                    'admin_id' => $adminId,
+                    'dept_id' => $deptId
+                ];
+            }
+            (new TenantAdminDept())->saveAll($deptData);
+        }
+    }
+
+
+    /**
+     * @notes 新增岗位
+     * @param $adminId
+     * @param $jobsIds
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/11/25 14:22
+     */
+    public static function insertJobs($adminId, $jobsIds)
+    {
+        // 岗位
+        if (!empty($jobsIds)) {
+            $jobsData = [];
+            foreach ($jobsIds as $jobsId) {
+                $jobsData[] = [
+                    'admin_id' => $adminId,
+                    'jobs_id' => $jobsId
+                ];
+            }
+            (new TenantAdminJobs())->saveAll($jobsData);
+        }
+    }
+
+}

+ 104 - 0
app/tenantapi/logic/auth/AuthLogic.php

@@ -0,0 +1,104 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\auth;
+
+use app\common\model\auth\TenantAdminRole;
+use app\common\model\auth\TenantSystemMenu;
+use app\common\model\auth\TenantSystemRoleMenu;
+
+
+/**
+ * 权限功能类
+ * Class AuthLogic
+ * @package app\tenantapi\logic\auth
+ */
+class AuthLogic
+{
+
+    /**
+     * @notes 获取全部权限
+     * @return mixed
+     * @author 段誉
+     * @date 2022/7/1 11:55
+     */
+    public static function getAllAuth()
+    {
+        return TenantSystemMenu::distinct(true)
+            ->where([
+                ['is_disable', '=', 0],
+                ['perms', '<>', '']
+            ])
+            ->column('perms');
+    }
+
+
+    /**
+     * @notes 获取当前管理员角色按钮权限
+     * @param $roleId
+     * @return mixed
+     * @author 段誉
+     * @date 2022/7/1 16:10
+     */
+    public static function getBtnAuthByRoleId($admin)
+    {
+        if ($admin['root']) {
+            return ['*'];
+        }
+
+        $menuId = TenantSystemRoleMenu::whereIn('role_id', $admin['role_id'])
+            ->column('menu_id');
+
+        $where[] = ['is_disable', '=', 0];
+        $where[] = ['perms', '<>', ''];
+
+        $roleAuth = TenantSystemMenu::distinct(true)
+            ->where('id', 'in', $menuId)
+            ->where($where)
+            ->column('perms');
+
+        $allAuth = TenantSystemMenu::distinct(true)
+            ->where($where)
+            ->column('perms');
+
+        $hasAllAuth = array_diff($allAuth, $roleAuth);
+        if (empty($hasAllAuth)) {
+            return ['*'];
+        }
+
+        return $roleAuth;
+    }
+
+
+    /**
+     * @notes 获取管理员角色关联的菜单id(菜单,权限)
+     * @param int $adminId
+     * @return array
+     * @author 段誉
+     * @date 2022/7/1 15:56
+     */
+    public static function getAuthByAdminId(int $adminId): array
+    {
+        $roleIds = TenantAdminRole::where('admin_id', $adminId)->column('role_id');
+        $menuId = TenantSystemRoleMenu::whereIn('role_id', $roleIds)->column('menu_id');
+
+        return TenantSystemMenu::distinct(true)
+            ->where([
+                ['is_disable', '=', 0],
+                ['perms', '<>', ''],
+                ['id', 'in', array_unique($menuId)],
+            ])
+            ->column('perms');
+    }
+}

+ 182 - 0
app/tenantapi/logic/auth/MenuLogic.php

@@ -0,0 +1,182 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\auth;
+
+
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\auth\TenantAdmin;
+use app\common\model\auth\TenantSystemMenu;
+use app\common\model\auth\TenantSystemRoleMenu;
+
+
+/**
+ * 系统菜单
+ * Class MenuLogic
+ * @package app\tenantapi\logic\auth
+ */
+class MenuLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 获取管理员对应的角色菜单
+     * @param $adminId
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/7/1 10:50
+     */
+    public static function getMenuByAdminId($adminId)
+    {
+        $admin = TenantAdmin::findOrEmpty($adminId);
+
+        $where = [];
+        $where[] = ['type', 'in', ['M', 'C']];
+        $where[] = ['is_disable', '=', 0];
+
+        if ($admin['root'] != 1) {
+            $roleMenu = TenantSystemRoleMenu::whereIn('role_id', $admin['role_id'])->column('menu_id');
+            $where[] = ['id', 'in', $roleMenu];
+        }
+
+        $menu = TenantSystemMenu::where($where)
+            ->order(['sort' => 'desc', 'id' => 'asc'])
+            ->select();
+
+        return linear_to_tree($menu, 'children');
+    }
+
+
+    /**
+     * @notes 添加菜单
+     * @param array $params
+     * @return TenantSystemMenu|\think\Model
+     * @author 段誉
+     * @date 2022/6/30 10:06
+     */
+    public static function add(array $params)
+    {
+        return TenantSystemMenu::create([
+            'pid' => $params['pid'],
+            'type' => $params['type'],
+            'name' => $params['name'],
+            'icon' => $params['icon'] ?? '',
+            'sort' => $params['sort'],
+            'perms' => $params['perms'] ?? '',
+            'paths' => $params['paths'] ?? '',
+            'component' => $params['component'] ?? '',
+            'selected' => $params['selected'] ?? '',
+            'params' => $params['params'] ?? '',
+            'is_cache' => $params['is_cache'],
+            'is_show' => $params['is_show'],
+            'is_disable' => $params['is_disable'],
+        ]);
+    }
+
+
+    /**
+     * @notes 编辑菜单
+     * @param array $params
+     * @return TenantSystemMenu
+     * @author 段誉
+     * @date 2022/6/30 10:07
+     */
+    public static function edit(array $params)
+    {
+        return TenantSystemMenu::update([
+            'pid' => $params['pid'],
+            'type' => $params['type'],
+            'name' => $params['name'],
+            'icon' => $params['icon'] ?? '',
+            'sort' => $params['sort'],
+            'perms' => $params['perms'] ?? '',
+            'paths' => $params['paths'] ?? '',
+            'component' => $params['component'] ?? '',
+            'selected' => $params['selected'] ?? '',
+            'params' => $params['params'] ?? '',
+            'is_cache' => $params['is_cache'],
+            'is_show' => $params['is_show'],
+            'is_disable' => $params['is_disable'],
+        ], ['id' => $params['id']]);
+    }
+
+
+    /**
+     * @notes 详情
+     * @param $params
+     * @return array
+     * @author 段誉
+     * @date 2022/6/30 9:54
+     */
+    public static function detail($params)
+    {
+        return TenantSystemMenu::findOrEmpty($params['id'])->toArray();
+    }
+
+
+    /**
+     * @notes 删除菜单
+     * @param $params
+     * @author 段誉
+     * @date 2022/6/30 9:47
+     */
+    public static function delete($params)
+    {
+        // 删除菜单
+        TenantSystemMenu::destroy($params['id']);
+        // 删除角色-菜单表中 与该菜单关联的记录
+        TenantSystemRoleMenu::where(['menu_id' => $params['id']])->delete();
+    }
+
+
+    /**
+     * @notes 更新状态
+     * @param array $params
+     * @return TenantSystemMenu
+     * @author 段誉
+     * @date 2022/7/6 17:02
+     */
+    public static function updateStatus(array $params)
+    {
+        return TenantSystemMenu::update([
+            'is_disable' => $params['is_disable']
+        ], ['id' => $params['id']]);
+    }
+
+
+    /**
+     * @notes 全部数据
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 11:03
+     */
+    public static function getAllData()
+    {
+        $data = TenantSystemMenu::where(['is_disable' => YesNoEnum::NO])
+            ->field('id,pid,name')
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        return linear_to_tree($data, 'children');
+    }
+
+}

+ 169 - 0
app/tenantapi/logic/auth/RoleLogic.php

@@ -0,0 +1,169 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\auth;
+
+use app\common\logic\BaseLogic;
+use app\common\model\auth\TenantSystemRole;
+use app\common\model\auth\TenantSystemRoleMenu;
+use app\common\{
+    cache\TenantAdminAuthCache
+};
+use think\facade\Db;
+
+
+/**
+ * 角色逻辑层
+ * Class RoleLogic
+ * @package app\tenantapi\logic\auth
+ */
+class RoleLogic extends BaseLogic
+{
+
+    /**
+     * @notes 添加角色
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2021/12/29 11:50
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $menuId = !empty($params['menu_id']) ? $params['menu_id'] : [];
+
+            $role = TenantSystemRole::create([
+                'name' => $params['name'],
+                'desc' => $params['desc'] ?? '',
+                'sort' => $params['sort'] ?? 0,
+            ]);
+
+            $data = [];
+            foreach ($menuId as $item) {
+                if (empty($item)) {
+                    continue;
+                }
+                $data[] = [
+                    'role_id' => $role['id'],
+                    'menu_id' => $item,
+                ];
+            }
+            (new TenantSystemRoleMenu)->insertAll($data);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::$error = $e->getMessage();
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑角色
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2021/12/29 14:16
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $menuId = !empty($params['menu_id']) ? $params['menu_id'] : [];
+
+            TenantSystemRole::update([
+                'name' => $params['name'],
+                'desc' => $params['desc'] ?? '',
+                'sort' => $params['sort'] ?? 0,
+            ], ['id' => $params['id']]);
+
+            if (!empty($menuId)) {
+                TenantSystemRoleMenu::where(['role_id' => $params['id']])->delete();
+                $data = [];
+                foreach ($menuId as $item) {
+                    $data[] = [
+                        'role_id' => $params['id'],
+                        'menu_id' => $item,
+                    ];
+                }
+                (new TenantSystemRoleMenu)->insertAll($data);
+            }
+
+            (new TenantAdminAuthCache())->deleteTag();
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::$error = $e->getMessage();
+            return false;
+        }
+    }
+
+    /**
+     * @notes 删除角色
+     * @param int $id
+     * @return bool
+     * @author 段誉
+     * @date 2021/12/29 14:16
+     */
+    public static function delete(int $id)
+    {
+        TenantSystemRole::destroy(['id' => $id]);
+        (new TenantAdminAuthCache())->deleteTag();
+        return true;
+    }
+
+
+    /**
+     * @notes 角色详情
+     * @param int $id
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2021/12/29 14:17
+     */
+    public static function detail(int $id): array
+    {
+        $detail = TenantSystemRole::field('id,name,desc,sort')->find($id);
+        $authList = $detail->roleMenuIndex()->select()->toArray();
+        $menuId = array_column($authList, 'menu_id');
+        $detail['menu_id'] = $menuId;
+        return $detail->toArray();
+    }
+
+
+    /**
+     * @notes 角色数据
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:39
+     */
+    public static function getAllData()
+    {
+        return TenantSystemRole::order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+}

+ 56 - 0
app/tenantapi/logic/channel/AppSettingLogic.php

@@ -0,0 +1,56 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\channel;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+
+/**
+ * App设置逻辑层
+ * Class AppSettingLogic
+ * @package app\tenantapi\logic\setting\app
+ */
+class AppSettingLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取App设置
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 10:25
+     */
+    public static function getConfig()
+    {
+        $config = [
+            'ios_download_url' => ConfigService::get('app', 'ios_download_url', ''),
+            'android_download_url' => ConfigService::get('app', 'android_download_url', ''),
+            'download_title' => ConfigService::get('app', 'download_title', ''),
+        ];
+        return $config;
+    }
+
+
+    /**
+     * @notes App设置
+     * @param $params
+     * @author 段誉
+     * @date 2022/3/29 10:26
+     */
+    public static function setConfig($params)
+    {
+        ConfigService::set('app', 'ios_download_url', $params['ios_download_url'] ?? '');
+        ConfigService::set('app', 'android_download_url', $params['android_download_url'] ?? '');
+        ConfigService::set('app', 'download_title', $params['download_title'] ?? '');
+    }
+}

+ 72 - 0
app/tenantapi/logic/channel/MnpSettingsLogic.php

@@ -0,0 +1,72 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\channel;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+/**
+ * 小程序设置逻辑
+ * Class MnpSettingsLogic
+ * @package app\tenantapi\logic\channel
+ */
+class MnpSettingsLogic extends BaseLogic
+{
+    /**
+     * @notes 获取小程序配置
+     * @return array
+     * @author ljj
+     * @date 2022/2/16 9:38 上午
+     */
+    public function getConfig()
+    {
+        $domainName = $_SERVER['SERVER_NAME'];
+        $qrCode = ConfigService::get('mnp_setting', 'qr_code', '');
+        $qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
+        $config = [
+            'name'                  => ConfigService::get('mnp_setting', 'name', ''),
+            'original_id'           => ConfigService::get('mnp_setting', 'original_id', ''),
+            'qr_code'               => $qrCode,
+            'app_id'                => ConfigService::get('mnp_setting', 'app_id', ''),
+            'app_secret'            => ConfigService::get('mnp_setting', 'app_secret', ''),
+            'request_domain'        => 'https://'.$domainName,
+            'socket_domain'         => 'wss://'.$domainName,
+            'upload_file_domain'     => 'https://'.$domainName,
+            'download_file_domain'   => 'https://'.$domainName,
+            'udp_domain'            => 'udp://'.$domainName,
+            'business_domain'       => $domainName,
+        ];
+
+        return $config;
+    }
+
+    /**
+     * @notes 设置小程序配置
+     * @param $params
+     * @author ljj
+     * @date 2022/2/16 9:51 上午
+     */
+    public function setConfig($params)
+    {
+        $qrCode = isset($params['qr_code']) ? FileService::setFileUrl($params['qr_code']) : '';
+
+        ConfigService::set('mnp_setting','name', $params['name'] ?? '');
+        ConfigService::set('mnp_setting','original_id',$params['original_id'] ?? '');
+        ConfigService::set('mnp_setting','qr_code',$qrCode);
+        ConfigService::set('mnp_setting','app_id',$params['app_id']);
+        ConfigService::set('mnp_setting','app_secret',$params['app_secret']);
+    }
+}

+ 224 - 0
app/tenantapi/logic/channel/OfficialAccountMenuLogic.php

@@ -0,0 +1,224 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\channel;
+
+use app\common\enum\OfficialAccountEnum;
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+use app\common\service\wechat\WeChatOaService;
+
+/**
+ * 微信公众号菜单逻辑层
+ * Class OfficialAccountMenuLogic
+ * @package app\tenantapi\logic\wechat
+ */
+class OfficialAccountMenuLogic extends BaseLogic
+{
+    /**
+     * @notes 保存
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/3/29 10:43
+     */
+    public static function save($params)
+    {
+        try {
+            self::checkMenu($params);
+            ConfigService::set('oa_setting', 'menu', $params);
+            return true;
+        } catch (\Exception $e) {
+            OfficialAccountMenuLogic::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 一级菜单校验
+     * @param $menu
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 10:55
+     */
+    public static function checkMenu($menu)
+    {
+        if (empty($menu) || !is_array($menu)) {
+            throw new \Exception('请设置正确格式菜单');
+        }
+
+        if (count($menu) > 3) {
+            throw new \Exception('一级菜单超出限制(最多3个)');
+        }
+
+        foreach ($menu as $item) {
+            if (!is_array($item)) {
+                throw new \Exception('一级菜单项须为数组格式');
+            }
+
+            if (empty($item['name'])) {
+                throw new \Exception('请输入一级菜单名称');
+            }
+
+            if (mb_strlen($item['name']) > 4) {
+                throw new \Exception("一级菜单名称字数不能超过4个字符");
+            }
+
+            if (false == $item['has_menu']) {
+                if (empty($item['type'])) {
+                    throw new \Exception('一级菜单未选择菜单类型');
+                }
+                if (!in_array($item['type'], OfficialAccountEnum::MENU_TYPE)) {
+                    throw new \Exception('一级菜单类型错误');
+                }
+                self::checkType($item);
+            }
+
+            if (true == $item['has_menu'] && empty($item['sub_button'])) {
+                throw new \Exception('请配置子菜单');
+            }
+
+            if (!empty($item['sub_button'])) {
+                self::checkSubButton($item['sub_button']);
+            }
+        }
+    }
+
+
+    /**
+     * @notes 二级菜单校验
+     * @param $subButtion
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 10:55
+     */
+    public static function checkSubButton($subButtion)
+    {
+        if (!is_array($subButtion)) {
+            throw new \Exception('二级菜单须为数组格式');
+        }
+
+        if (count($subButtion) > 5) {
+            throw new \Exception('二级菜单超出限制(最多5个)');
+        }
+
+        foreach ($subButtion as $subItem) {
+            if (!is_array($subItem)) {
+                throw new \Exception('二级菜单项须为数组');
+            }
+
+            if (empty($subItem['name'])) {
+                throw new \Exception('请输入二级菜单名称');
+            }
+
+            if (mb_strlen($subItem['name']) > 8) {
+                throw new \Exception("二级菜单名称字数不能超过8个字符");
+            }
+
+            if (empty($subItem['type']) || !in_array($subItem['type'], OfficialAccountEnum::MENU_TYPE)) {
+                throw new \Exception('二级未选择菜单类型或菜单类型错误');
+            }
+
+            self::checkType($subItem);
+        }
+    }
+
+
+    /**
+     * @notes 菜单类型校验
+     * @param $item
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 10:55
+     */
+    public static function checkType($item)
+    {
+        switch ($item['type']) {
+            // 关键字
+            case 'click':
+                if (empty($item['key'])) {
+                    throw new \Exception('请输入关键字');
+                }
+                break;
+            // 跳转网页链接
+            case 'view':
+                if (empty($item['url'])) {
+                    throw new \Exception('请输入网页链接');
+                }
+                break;
+            // 小程序
+            case 'miniprogram':
+                if (empty($item['url'])) {
+                    throw new \Exception('请输入网页链接');
+                }
+                if (empty($item['appid'])) {
+                    throw new \Exception('请输入appid');
+                }
+                if (empty($item['pagepath'])) {
+                    throw new \Exception('请输入小程序路径');
+                }
+                break;
+        }
+    }
+
+    /**
+     * @notes 保存发布菜单
+     * @param $params
+     * @return bool
+     * @throws \GuzzleHttp\Exception\GuzzleException
+     * @author 段誉
+     * @date 2022/3/29 10:55
+     */
+    public static function saveAndPublish($params)
+    {
+        try {
+            self::checkMenu($params);
+
+            $result = (new WeChatOaService())->createMenu($params);
+            if ($result['errcode'] == 0) {
+                ConfigService::set('oa_setting', 'menu', $params);
+                return true;
+            }
+
+            self::setError('保存发布菜单失败' . json_encode($result->getContent()));
+
+            return false;
+
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 查看菜单详情
+     * @return array|int|mixed|string|null
+     * @author 段誉
+     * @date 2022/3/29 10:56
+     */
+    public static function detail()
+    {
+        $data = ConfigService::get('oa_setting', 'menu', []);
+
+        if (!empty($data)) {
+            foreach ($data as &$item) {
+                $item['has_menu'] = !empty($item['has_menu']);
+            }
+        }
+
+        return $data;
+    }
+}

+ 224 - 0
app/tenantapi/logic/channel/OfficialAccountReplyLogic.php

@@ -0,0 +1,224 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\channel;
+
+use app\common\enum\OfficialAccountEnum;
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\channel\OfficialAccountReply;
+use app\common\service\wechat\WeChatConfigService;
+use app\common\service\wechat\WeChatOaService;
+
+
+
+/**
+ * 微信公众号回复逻辑层
+ * Class OfficialAccountReplyLogic
+ * @package app\tenantapi\logic\channel
+ */
+class OfficialAccountReplyLogic extends BaseLogic
+{
+    /**
+     * @notes 添加回复(关注/关键词/默认)
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/3/29 10:57
+     */
+    public static function add($params)
+    {
+        try {
+            // 关键字回复排序值须大于0
+            if ($params['reply_type'] == OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['sort'] < 0) {
+                throw new \Exception('排序值须大于或等于0');
+            }
+            if ($params['reply_type'] != OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['status']) {
+                // 非关键词回复只能有一条记录处于启用状态,所以将该回复类型下的已有记录置为禁用状态
+                OfficialAccountReply::where(['reply_type' => $params['reply_type']])->update(['status' => YesNoEnum::NO]);
+            }
+            OfficialAccountReply::create($params);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 查看回复详情
+     * @param $params
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 11:00
+     */
+    public static function detail($params)
+    {
+        $field = 'id,name,keyword,reply_type,matching_type,content_type,content,status,sort';
+        $field .= ',reply_type as reply_type_desc, matching_type as matching_type_desc, content_type as content_type_desc, status as status_desc';
+        return OfficialAccountReply::field($field)->findOrEmpty($params['id'])->toArray();
+    }
+
+
+    /**
+     * @notes 编辑回复(关注/关键词/默认)
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/3/29 11:01
+     */
+    public static function edit($params)
+    {
+        try {
+            // 关键字回复排序值须大于0
+            if ($params['reply_type'] == OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['sort'] < 0) {
+                throw new \Exception('排序值须大于或等于0');
+            }
+            if ($params['reply_type'] != OfficialAccountEnum::REPLY_TYPE_KEYWORD && $params['status']) {
+                // 非关键词回复只能有一条记录处于启用状态,所以将该回复类型下的已有记录置为禁用状态
+                OfficialAccountReply::where(['reply_type' => $params['reply_type']])->update(['status' => YesNoEnum::NO]);
+            }
+            OfficialAccountReply::update($params, ['id' => $params['id']]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除回复(关注/关键词/默认)
+     * @param $params
+     * @author 段誉
+     * @date 2022/3/29 11:01
+     */
+    public static function delete($params)
+    {
+        OfficialAccountReply::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 更新排序
+     * @param $params
+     * @author 段誉
+     * @date 2022/3/29 11:01
+     */
+    public static function sort($params)
+    {
+        $params['sort'] = $params['new_sort'];
+        OfficialAccountReply::update($params, ['id' => $params['id']]);
+    }
+
+
+    /**
+     * @notes 更新状态
+     * @param $params
+     * @author 段誉
+     * @date 2022/3/29 11:01
+     */
+    public static function status($params)
+    {
+        $reply = OfficialAccountReply::findOrEmpty($params['id']);
+        $reply->status = !$reply->status;
+        $reply->save();
+    }
+
+
+    /**
+     * @notes 微信公众号回调
+     * @return \Psr\Http\Message\ResponseInterface|void
+     * @throws \EasyWeChat\Kernel\Exceptions\BadRequestException
+     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
+     * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
+     * @throws \ReflectionException
+     * @throws \Throwable
+     * @author 段誉
+     * @date 2023/2/27 14:38\
+     */
+    public static function index()
+    {
+        $server = (new WeChatOaService())->getServer();
+        // 事件
+        $server->addMessageListener(OfficialAccountEnum::MSG_TYPE_EVENT, function ($message, \Closure $next) {
+            switch ($message['Event']) {
+                case OfficialAccountEnum::EVENT_SUBSCRIBE: // 关注事件
+                    $replyContent = OfficialAccountReply::where([
+                        'reply_type' => OfficialAccountEnum::REPLY_TYPE_FOLLOW,
+                        'status' => YesNoEnum::YES
+                    ])
+                        ->value('content');
+
+                    if ($replyContent) {
+                        return $replyContent;
+                    }
+                    break;
+            }
+            return $next($message);
+        });
+
+        // 文本
+        $server->addMessageListener(OfficialAccountEnum::MSG_TYPE_TEXT, function ($message, \Closure $next) {
+            $replyList = OfficialAccountReply::where([
+                'reply_type' => OfficialAccountEnum::REPLY_TYPE_KEYWORD,
+                'status' => YesNoEnum::YES
+            ])
+                ->order('sort asc')
+                ->select();
+
+            $replyContent = '';
+            foreach ($replyList as $reply) {
+                switch ($reply['matching_type']) {
+                    case OfficialAccountEnum::MATCHING_TYPE_FULL:
+                        $reply['keyword'] === $message['Content'] && $replyContent = $reply['content'];
+                        break;
+                    case OfficialAccountEnum::MATCHING_TYPE_FUZZY:
+                        stripos($message['Content'], $reply['keyword']) !== false && $replyContent = $reply['content'];
+                        break;
+                }
+                if ($replyContent) {
+                    break; // 得到回复文本,中止循环
+                }
+            }
+            //消息回复为空的话,找默认回复
+            if (empty($replyContent)) {
+                $replyContent = static::getDefaultReply();
+            }
+            if ($replyContent) {
+                return $replyContent;
+            }
+            return $next($message);
+        });
+
+        return $server->serve();
+    }
+
+
+    /**
+     * @notes 默认回复信息
+     * @return mixed
+     * @author 段誉
+     * @date 2023/2/27 14:36
+     */
+    public static function getDefaultReply()
+    {
+        return OfficialAccountReply::where([
+            'reply_type' => OfficialAccountEnum::REPLY_TYPE_DEFAULT,
+            'status' => YesNoEnum::YES
+        ])
+            ->value('content');
+    }
+}

+ 76 - 0
app/tenantapi/logic/channel/OfficialAccountSettingLogic.php

@@ -0,0 +1,76 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\channel;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+/**
+ * 公众号设置逻辑
+ * Class OfficialAccountSettingLogic
+ * @package app\tenantapi\logic\channel
+ */
+class OfficialAccountSettingLogic extends BaseLogic
+{
+    /**
+     * @notes 获取公众号配置
+     * @return array
+     * @author ljj
+     * @date 2022/2/16 10:08 上午
+     */
+    public function getConfig()
+    {
+        $domainName = $_SERVER['SERVER_NAME'];
+        $qrCode = ConfigService::get('oa_setting', 'qr_code', '');
+        $qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
+        $config = [
+            'name'              => ConfigService::get('oa_setting', 'name', ''),
+            'original_id'       => ConfigService::get('oa_setting', 'original_id', ''),
+            'qr_code'           => $qrCode,
+            'app_id'            => ConfigService::get('oa_setting', 'app_id', ''),
+            'app_secret'        => ConfigService::get('oa_setting', 'app_secret', ''),
+            // url()方法返回Url实例,通过与空字符串连接触发该实例的__toString()方法以得到路由地址
+            'url'               => url('tenantapi/channel.official_account_reply/index', [],'',true).'',
+            'token'             => ConfigService::get('oa_setting', 'token'),
+            'encoding_aes_key'  => ConfigService::get('oa_setting', 'encoding_aes_key', ''),
+            'encryption_type'   => ConfigService::get('oa_setting', 'encryption_type', 1),
+            'business_domain'   => $domainName,
+            'js_secure_domain'  => $domainName,
+            'web_auth_domain'   => $domainName,
+        ];
+        return $config;
+    }
+
+    /**
+     * @notes 设置公众号配置
+     * @param $params
+     * @author ljj
+     * @date 2022/2/16 10:08 上午
+     */
+    public function setConfig($params)
+    {
+        $qrCode = isset($params['qr_code']) ? FileService::setFileUrl($params['qr_code']) : '';
+
+        ConfigService::set('oa_setting','name', $params['name'] ?? '');
+        ConfigService::set('oa_setting','original_id', $params['original_id'] ?? '');
+        ConfigService::set('oa_setting','qr_code', $qrCode);
+        ConfigService::set('oa_setting','app_id',$params['app_id']);
+        ConfigService::set('oa_setting','app_secret',$params['app_secret']);
+        ConfigService::set('oa_setting','token',$params['token'] ?? '');
+        ConfigService::set('oa_setting','encoding_aes_key',$params['encoding_aes_key'] ?? '');
+        ConfigService::set('oa_setting','encryption_type',$params['encryption_type']);
+    }
+}

+ 55 - 0
app/tenantapi/logic/channel/OpenSettingLogic.php

@@ -0,0 +1,55 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\channel;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+
+/**
+ * 微信开放平台
+ * Class AppSettingLogic
+ * @package app\tenantapi\logic\setting\app
+ */
+class OpenSettingLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取微信开放平台设置
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 11:03
+     */
+    public static function getConfig()
+    {
+        $config = [
+            'app_id' => ConfigService::get('open_platform', 'app_id', ''),
+            'app_secret' => ConfigService::get('open_platform', 'app_secret', ''),
+        ];
+
+        return $config;
+    }
+
+
+    /**
+     * @notes 微信开放平台设置
+     * @param $params
+     * @author 段誉
+     * @date 2022/3/29 11:03
+     */
+    public static function setConfig($params)
+    {
+        ConfigService::set('open_platform', 'app_id', $params['app_id'] ?? '');
+        ConfigService::set('open_platform', 'app_secret', $params['app_secret'] ?? '');
+    }
+}

+ 59 - 0
app/tenantapi/logic/channel/WebPageSettingLogic.php

@@ -0,0 +1,59 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\channel;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+
+/**
+ * H5设置逻辑层
+ * Class HFiveSettingLogic
+ * @package app\tenantapi\logic\setting\h5
+ */
+class WebPageSettingLogic extends BaseLogic
+{
+    /**
+     * @notes 获取H5设置
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 10:34
+     */
+    public static function getConfig()
+    {
+        $config = [
+            // 渠道状态 0-关闭 1-开启
+            'status' => ConfigService::get('web_page', 'status', 1),
+            // 关闭后渠道后访问页面 0-空页面 1-自定义链接
+            'page_status' => ConfigService::get('web_page', 'page_status', 0),
+            // 自定义链接
+            'page_url' => ConfigService::get('web_page', 'page_url', ''),
+            'url' => request()->domain() . '/mobile'
+        ];
+        return $config;
+    }
+
+
+    /**
+     * @notes H5设置
+     * @param $params
+     * @author 段誉
+     * @date 2022/3/29 10:34
+     */
+    public static function setConfig($params)
+    {
+        ConfigService::set('web_page', 'status', $params['status']);
+        ConfigService::set('web_page', 'page_status', $params['page_status']);
+        ConfigService::set('web_page', 'page_url', $params['page_url']);
+    }
+}

+ 96 - 0
app/tenantapi/logic/decorate/DecorateDataLogic.php

@@ -0,0 +1,96 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\decorate;
+
+use app\common\logic\BaseLogic;
+use app\common\model\article\Article;
+use app\common\model\decorate\DecoratePage;
+use app\common\model\decorate\DecorateTabbar;
+
+/**
+ * 装修页-数据
+ * Class DecorateDataLogic
+ * @package app\tenantapi\logic\decorate
+ */
+class DecorateDataLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取文章列表
+     * @param $limit
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/22 16:49
+     */
+    public static function getArticleLists($limit): array
+    {
+        $field = 'id,title,desc,abstract,image,author,content,
+        click_virtual,click_actual,create_time';
+
+        return Article::withoutGlobalScope()->where(['is_show' => 1, 'tenant_id' => 0])
+            ->field($field)
+            ->order(['id' => 'desc'])
+            ->limit($limit)
+            ->append(['click'])
+            ->hidden(['click_virtual', 'click_actual'])
+            ->select()->toArray();
+    }
+
+    /**
+     * @notes pc设置
+     * @return array
+     * @author mjf
+     * @date 2024/3/14 18:13
+     */
+    public static function pc(): array
+    {
+        $pcPage = DecoratePage::findOrEmpty(4)->toArray();
+        $updateTime = !empty($pcPage['update_time']) ? $pcPage['update_time'] : date('Y-m-d H:i:s');
+        return [
+            'update_time' => $updateTime,
+            'pc_url' => request()->domain() . '/pc'
+        ];
+    }
+
+    /**
+     * @notes 初始化装修配置
+     * @param mixed $tenant_id
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author JXDN
+     * @date 2024/09/10 15:46
+     */
+    public static function initialization(mixed $tenant_id)
+    {
+        // 支付方式配置
+        $page_field = "name,type,data,meta,tenant_id";
+        $tabbar_field = "name,selected,unselected,link,is_show,tenant_id";
+        // 查询装修配置模版数据,此处默认为租户号为0的模板数据
+        $pageList = DecoratePage::where(['tenant_id' => 0])->field($page_field)->select()->toArray();
+        $tabbarList = DecorateTabbar::where(['tenant_id' => 0])->field($tabbar_field)->select()->toArray();
+        foreach ($pageList as $item) {
+            $item['tenant_id'] = $tenant_id;
+            DecoratePage::create($item);
+        }
+        foreach ($tabbarList as $item) {
+            $item['tenant_id'] = $tenant_id;
+            DecorateTabbar::create($item);
+        }
+    }
+}

+ 67 - 0
app/tenantapi/logic/decorate/DecoratePageLogic.php

@@ -0,0 +1,67 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\decorate;
+
+
+use app\common\logic\BaseLogic;
+use app\common\model\decorate\DecoratePage;
+
+
+/**
+ * 装修页面
+ * Class DecoratePageLogic
+ * @package app\tenantapi\logic\theme
+ */
+class DecoratePageLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 获取详情
+     * @param $id
+     * @return array
+     * @author 段誉
+     * @date 2022/9/14 18:41
+     */
+    public static function getDetail($type)
+    {
+        return DecoratePage::where(['type' => $type])->findOrEmpty()->toArray();
+    }
+
+
+    /**
+     * @notes 保存装修配置
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/9/15 9:37
+     */
+    public static function save($params)
+    {
+        $pageData = DecoratePage::where(['id' => $params['id']])->findOrEmpty();
+        if ($pageData->isEmpty()) {
+            self::$error = '信息不存在';
+            return false;
+        }
+        DecoratePage::update([
+            'type' => $params['type'],
+            'data' => $params['data'],
+            'meta' => $params['meta'] ?? '',
+        ], ['id' => $params['id']]);
+        return true;
+    }
+
+
+
+}

+ 81 - 0
app/tenantapi/logic/decorate/DecorateTabbarLogic.php

@@ -0,0 +1,81 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\decorate;
+
+use app\common\logic\BaseLogic;
+use app\common\model\decorate\DecorateTabbar;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+
+/**
+ * 装修配置-底部导航
+ * Class DecorateTabbarLogic
+ * @package app\tenantapi\logic\decorate
+ */
+class DecorateTabbarLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取底部导航详情
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/9/7 16:58
+     */
+    public static function detail(): array
+    {
+        $list = DecorateTabbar::getTabbarLists();
+        $style = ConfigService::get('tabbar', 'style', config('project.decorate.tabbar_style'));
+        return ['style' => $style, 'list' => $list];
+    }
+
+
+    /**
+     * @notes 底部导航保存
+     * @param $params
+     * @return bool
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/9/7 17:19
+     */
+    public static function save($params): bool
+    {
+        $model = new DecorateTabbar();
+        // 删除旧配置数据
+        $model->where('id', '>', 0)->delete();
+
+        // 保存数据
+        $tabbars = $params['list'] ?? [];
+        $data = [];
+        foreach ($tabbars as $item) {
+            $data[] = [
+                'name' => $item['name'],
+                'selected' => FileService::setFileUrl($item['selected']),
+                'unselected' => FileService::setFileUrl($item['unselected']),
+                'link' => $item['link'],
+                'is_show' => $item['is_show'] ?? 0,
+            ];
+        }
+        $model->saveAll($data);
+
+        if (!empty($params['style'])) {
+            ConfigService::set('tabbar', 'style', $params['style']);
+        }
+        return true;
+    }
+
+}

+ 204 - 0
app/tenantapi/logic/dept/DeptLogic.php

@@ -0,0 +1,204 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\dept;
+
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\dept\TenantDept;
+
+
+/**
+ * 部门管理逻辑
+ * Class DeptLogic
+ * @package app\tenantapi\logic\dept
+ */
+class DeptLogic extends BaseLogic
+{
+
+    /**
+     * @notes 部门列表
+     * @param $params
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/5/30 15:44
+     */
+    public static function lists($params)
+    {
+        $where = [];
+        if (!empty($params['name'])) {
+            $where[] = ['name', 'like', '%' . $params['name'] . '%'];
+        }
+        if (isset($params['status']) && $params['status'] != '') {
+            $where[] = ['status', '=', $params['status']];
+        }
+        $lists = TenantDept::where($where)
+            ->append(['status_desc'])
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        $pid = 0;
+        if (!empty($lists)) {
+            $pid = min(array_column($lists, 'pid'));
+        }
+        return self::getTree($lists, $pid);
+    }
+
+
+    /**
+     * @notes 列表树状结构
+     * @param $array
+     * @param int $pid
+     * @param int $level
+     * @return array
+     * @author 段誉
+     * @date 2022/5/30 15:44
+     */
+    public static function getTree($array, $pid = 0, $level = 0)
+    {
+        $list = [];
+        foreach ($array as $key => $item) {
+            if ($item['pid'] == $pid) {
+                $item['level'] = $level;
+                $item['children'] = self::getTree($array, $item['id'], $level + 1);
+                $list[] = $item;
+            }
+        }
+        return $list;
+    }
+
+
+    /**
+     * @notes 上级部门
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/5/26 18:36
+     */
+    public static function leaderDept()
+    {
+        $lists = TenantDept::field(['id', 'name'])->where(['status' => 1])
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+        return $lists;
+    }
+
+
+    /**
+     * @notes 添加部门
+     * @param array $params
+     * @author 段誉
+     * @date 2022/5/25 18:20
+     */
+    public static function add(array $params)
+    {
+        TenantDept::create([
+            'pid' => $params['pid'],
+            'name' => $params['name'],
+            'leader' => $params['leader'] ?? '',
+            'mobile' => $params['mobile'] ?? '',
+            'status' => $params['status'],
+            'sort' => $params['sort'] ?? 0
+        ]);
+    }
+
+
+    /**
+     * @notes 编辑部门
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/5/25 18:39
+     */
+    public static function edit(array $params): bool
+    {
+        try {
+            $pid = $params['pid'];
+            $oldDeptData = TenantDept::findOrEmpty($params['id']);
+            if ($oldDeptData['pid'] == 0) {
+                $pid = 0;
+            }
+
+            TenantDept::update([
+                'pid' => $pid,
+                'name' => $params['name'],
+                'leader' => $params['leader'] ?? '',
+                'mobile' => $params['mobile'] ?? '',
+                'status' => $params['status'],
+                'sort' => $params['sort'] ?? 0
+            ], ['id' => $params['id']]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除部门
+     * @param array $params
+     * @author 段誉
+     * @date 2022/5/25 18:40
+     */
+    public static function delete(array $params)
+    {
+        TenantDept::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取部门详情
+     * @param $params
+     * @return array
+     * @author 段誉
+     * @date 2022/5/25 18:40
+     */
+    public static function detail($params): array
+    {
+        return TenantDept::findOrEmpty($params['id'])->toArray();
+    }
+
+
+    /**
+     * @notes 部门数据
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:19
+     */
+    public static function getAllData()
+    {
+        $data = TenantDept::where(['status' => YesNoEnum::YES])
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        if(empty($data)) {
+            return [];
+        }
+        $pid = min(array_column($data, 'pid'));
+        return self::getTree($data, $pid);
+    }
+
+}

+ 116 - 0
app/tenantapi/logic/dept/JobsLogic.php

@@ -0,0 +1,116 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\dept;
+
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\dept\TenantJobs;
+
+
+/**
+ * 岗位管理逻辑
+ * Class JobsLogic
+ * @package app\tenantapi\logic\dept
+ */
+class JobsLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 新增岗位
+     * @param array $params
+     * @author 段誉
+     * @date 2022/5/26 9:58
+     */
+    public static function add(array $params)
+    {
+        TenantJobs::create([
+            'name' => $params['name'],
+            'code' => $params['code'],
+            'sort' => $params['sort'] ?? 0,
+            'status' => $params['status'],
+            'remark' => $params['remark'] ?? '',
+        ]);
+    }
+
+
+    /**
+     * @notes 编辑岗位
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/5/26 9:58
+     */
+    public static function edit(array $params) : bool
+    {
+        try {
+            TenantJobs::update([
+                'name' => $params['name'],
+                'code' => $params['code'],
+                'sort' => $params['sort'] ?? 0,
+                'status' => $params['status'],
+                'remark' => $params['remark'] ?? '',
+            ], ['id' => $params['id']]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除岗位
+     * @param array $params
+     * @author 段誉
+     * @date 2022/5/26 9:59
+     */
+    public static function delete(array $params)
+    {
+        TenantJobs::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取岗位详情
+     * @param $params
+     * @return array
+     * @author 段誉
+     * @date 2022/5/26 9:59
+     */
+    public static function detail($params) : array
+    {
+        return TenantJobs::findOrEmpty($params['id'])->toArray();
+    }
+
+
+    /**
+     * @notes 岗位数据
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2022/10/13 10:30
+     */
+    public static function getAllData()
+    {
+        return TenantJobs::where(['status' => YesNoEnum::YES])
+            ->order(['sort' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+}

+ 65 - 0
app/tenantapi/logic/setting/CustomerServiceLogic.php

@@ -0,0 +1,65 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+/**
+ * 客服设置逻辑
+ * Class CustomerServiceLogic
+ * @package app\tenantapi\logic\setting
+ */
+class CustomerServiceLogic extends BaseLogic
+{
+    /**
+     * @notes 获取客服设置
+     * @return array
+     * @author ljj
+     * @date 2022/2/15 12:05 下午
+     */
+    public static function getConfig()
+    {
+        $qrCode = ConfigService::get('customer_service', 'qr_code');
+        $qrCode = empty($qrCode) ? '' : FileService::getFileUrl($qrCode);
+        $config = [
+            'qr_code' => $qrCode,
+            'wechat' => ConfigService::get('customer_service', 'wechat', ''),
+            'phone' => ConfigService::get('customer_service', 'phone', ''),
+            'service_time' => ConfigService::get('customer_service', 'service_time', ''),
+        ];
+        return $config;
+    }
+
+    /**
+     * @notes 设置客服设置
+     * @param $params
+     * @author ljj
+     * @date 2022/2/15 12:11 下午
+     */
+    public static function setConfig($params)
+    {
+        $allowField = ['qr_code','wechat','phone','service_time'];
+        foreach($params as $key => $value) {
+            if(in_array($key, $allowField)) {
+                if ($key == 'qr_code') {
+                    $value = FileService::setFileUrl($value);
+                }
+                ConfigService::set('customer_service', $key, $value);
+            }
+        }
+    }
+}

+ 75 - 0
app/tenantapi/logic/setting/HotSearchLogic.php

@@ -0,0 +1,75 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting;
+
+use app\common\logic\BaseLogic;
+use app\common\model\HotSearch;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+
+/**
+ * 热门搜素逻辑
+ * Class HotSearchLogic
+ * @package app\tenantapi\logic\setting
+ */
+class HotSearchLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取配置
+     * @return array
+     * @author 段誉
+     * @date 2022/9/5 18:48
+     */
+    public static function getConfig()
+    {
+        return [
+            // 功能状态 0-关闭 1-开启
+            'status' => ConfigService::get('hot_search', 'status', 0),
+            // 热门搜索数据
+            'data' => HotSearch::field(['name', 'sort'])->order(['sort' => 'desc', 'id' =>'desc'])->select()->toArray(),
+        ];
+    }
+
+
+    /**
+     * @notes 设置热门搜搜
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/9/5 18:58
+     */
+    public static function setConfig($params)
+    {
+        try {
+            if (!empty($params['data'])) {
+                $model = (new HotSearch());
+                $model->where('id', '>', 0)->delete();
+                $model->saveAll($params['data']);
+            }
+
+            $status = empty($params['status']) ? 0 : $params['status'];
+            ConfigService::set('hot_search', 'status', $status);
+
+            return true;
+        } catch (\Exception $e) {
+            self::$error = $e->getMessage();
+            return false;
+        }
+    }
+
+
+}

+ 64 - 0
app/tenantapi/logic/setting/TransactionSettingsLogic.php

@@ -0,0 +1,64 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting;
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+
+/**
+ * 交易设置逻辑
+ * Class TransactionSettingsLogic
+ * @package app\tenantapi\logic\setting
+ */
+class TransactionSettingsLogic extends BaseLogic
+{
+    /**
+     * @notes 获取交易设置
+     * @return array
+     * @author ljj
+     * @date 2022/2/15 11:40 上午
+     */
+    public static function getConfig()
+    {
+        $config = [
+            'cancel_unpaid_orders' => ConfigService::get('transaction', 'cancel_unpaid_orders', 1),
+            'cancel_unpaid_orders_times' => ConfigService::get('transaction', 'cancel_unpaid_orders_times', 30),
+            'verification_orders' => ConfigService::get('transaction', 'verification_orders', 1),
+            'verification_orders_times' => ConfigService::get('transaction', 'verification_orders_times', 24),
+        ];
+
+        return $config;
+    }
+
+    /**
+     * @notes 设置交易设置
+     * @param $params
+     * @author ljj
+     * @date 2022/2/15 11:49 上午
+     */
+    public static function setConfig($params)
+    {
+        ConfigService::set('transaction', 'cancel_unpaid_orders', $params['cancel_unpaid_orders']);
+        ConfigService::set('transaction', 'verification_orders', $params['verification_orders']);
+
+        if (isset($params['cancel_unpaid_orders_times'])) {
+            ConfigService::set('transaction', 'cancel_unpaid_orders_times', $params['cancel_unpaid_orders_times']);
+        }
+
+        if (isset($params['verification_orders_times'])) {
+            ConfigService::set('transaction', 'verification_orders_times', $params['verification_orders_times']);
+        }
+    }
+}

+ 96 - 0
app/tenantapi/logic/setting/pay/PayConfigLogic.php

@@ -0,0 +1,96 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting\pay;
+
+
+use app\common\enum\PayEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\pay\TenantPayConfig;
+use app\common\service\FileService;
+
+/**
+ * 支付配置
+ * Class PayConfigLogic
+ * @package app\tenantapi\logic\setting\pay
+ */
+class PayConfigLogic extends BaseLogic
+{
+
+    /**
+     * @notes 设置配置
+     * @param $params
+     * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/2/23 16:16
+     */
+    public static function setConfig($params)
+    {
+        $payConfig = TenantPayConfig::find($params['id']);
+
+        $config = '';
+        if ($payConfig['pay_way'] == PayEnum::WECHAT_PAY) {
+            $config = [
+                'interface_version' => $params['config']['interface_version'],
+                'merchant_type' => $params['config']['merchant_type'],
+                'mch_id' => $params['config']['mch_id'],
+                'pay_sign_key' => $params['config']['pay_sign_key'],
+                'apiclient_cert' => $params['config']['apiclient_cert'],
+                'apiclient_key' => $params['config']['apiclient_key'],
+            ];
+        }
+        if ($payConfig['pay_way'] == PayEnum::ALI_PAY) {
+            $config = [
+                'mode' => $params['config']['mode'],
+                'merchant_type' => $params['config']['merchant_type'],
+                'app_id' => $params['config']['app_id'],
+                'private_key' => $params['config']['private_key'],
+                'ali_public_key' => $params['config']['mode'] == 'normal_mode' ? $params['config']['ali_public_key'] : '',
+                'public_cert' => $params['config']['mode'] == 'certificate' ? $params['config']['public_cert'] : '',
+                'ali_public_cert' => $params['config']['mode'] == 'certificate' ? $params['config']['ali_public_cert'] : '',
+                'ali_root_cert' => $params['config']['mode'] == 'certificate' ? $params['config']['ali_root_cert'] : '',
+            ];
+        }
+
+        $payConfig->name = $params['name'];
+        $payConfig->icon = FileService::setFileUrl($params['icon']);
+        $payConfig->sort = $params['sort'];
+        $payConfig->config = $config;
+        $payConfig->remark = $params['remark'] ?? '';
+        return $payConfig->save();
+    }
+
+
+    /**
+     * @notes 获取配置
+     * @param $params
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/2/23 16:16
+     */
+    public static function getConfig($params)
+    {
+        $payConfig = TenantPayConfig::find($params['id'])->toArray();
+        $payConfig['icon'] = FileService::getFileUrl($payConfig['icon']);
+        $payConfig['domain'] = request()->domain();
+        return $payConfig;
+    }
+
+}

+ 111 - 0
app/tenantapi/logic/setting/pay/PayWayLogic.php

@@ -0,0 +1,111 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting\pay;
+
+
+use app\common\enum\PayEnum;
+use app\common\enum\YesNoEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\pay\TenantPayConfig;
+use app\common\model\pay\TenantPayWay;
+use app\common\service\FileService;
+
+/**
+ * 支付方式
+ * Class PayWayLogic
+ * @package app\tenantapi\logic\setting\pay
+ */
+class PayWayLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取支付方式
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/2/23 16:25
+     */
+    public static function getPayWay()
+    {
+        $payWay = TenantPayWay::select()->append(['pay_way_name'])
+            ->toArray();
+
+        if (empty($payWay)) {
+            return [];
+        }
+
+        $lists = [];
+        for ($i = 1; $i <= max(array_column($payWay, 'scene')); $i++) {
+            foreach ($payWay as $val) {
+                if ($val['scene'] == $i) {
+                    $val['icon'] = FileService::getFileUrl(TenantPayConfig::where('id', $val['pay_config_id'])->value('icon'));
+                    $lists[$i][] = $val;
+                }
+            }
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 设置支付方式
+     * @param $params
+     * @return bool|string
+     * @throws \Exception
+     * @author 段誉
+     * @date 2023/2/23 16:26
+     */
+    public static function setPayWay($params)
+    {
+        $payWay = new PayWay;
+        $data = [];
+        foreach ($params as $key => $value) {
+            $isDefault = array_column($value, 'is_default');
+            $isDefaultNum = array_count_values($isDefault);
+            $status = array_column($value, 'status');
+            $sceneName = PayEnum::getPaySceneDesc($key);
+            if (!in_array(YesNoEnum::YES, $isDefault)) {
+                return $sceneName . '支付场景缺少默认支付';
+            }
+            if ($isDefaultNum[YesNoEnum::YES] > 1) {
+                return $sceneName . '支付场景的默认值只能存在一个';
+            }
+            if (!in_array(YesNoEnum::YES, $status)) {
+                return $sceneName . '支付场景至少开启一个支付状态';
+            }
+
+            foreach ($value as $val) {
+                $result = TenantPayWay::where('id', $val['id'])->findOrEmpty();
+                if ($result->isEmpty()) {
+                    continue;
+                }
+                if ($val['is_default'] == YesNoEnum::YES && $val['status'] == YesNoEnum::NO) {
+                    return $sceneName . '支付场景的默认支付未开启支付状态';
+                }
+                $data[] = [
+                    'id' => $val['id'],
+                    'is_default' => $val['is_default'],
+                    'status' => $val['status'],
+                ];
+            }
+        }
+        $payWay->saveAll($data);
+        return true;
+    }
+}
+

+ 37 - 0
app/tenantapi/logic/setting/system/CacheLogic.php

@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting\system;
+
+use app\common\logic\BaseLogic;
+use think\facade\Cache;
+
+/**
+ * 系统缓存逻辑
+ * Class CacheLogic
+ * @package app\tenantapi\logic\setting\system
+ */
+class CacheLogic extends BaseLogic
+{
+    /**
+     * @notes 清楚系统缓存
+     * @author 段誉
+     * @date 2022/4/8 16:29
+     */
+    public static function clear()
+    {
+       Cache::clear();
+       del_target_dir(app()->getRootPath().'runtime/file',true);
+    }
+}

+ 109 - 0
app/tenantapi/logic/setting/user/UserLogic.php

@@ -0,0 +1,109 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\setting\user;
+
+use app\common\service\ConfigService;
+use app\common\service\{FileService};
+
+/**
+ * 设置-用户设置逻辑层
+ * Class TenantLogic
+ * @package app\tenantapi\logic\config
+ */
+class UserLogic
+{
+
+    /**
+     * @notes 获取用户设置
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 10:09
+     */
+    public static function getConfig(): array
+    {
+        $defaultAvatar = config('project.default_image.user_avatar');
+        $config = [
+            //默认头像
+            'default_avatar' => FileService::getFileUrl(ConfigService::get('default_image', 'user_avatar', $defaultAvatar)),
+        ];
+        return $config;
+    }
+
+
+    /**
+     * @notes 设置用户设置
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/3/29 10:09
+     */
+    public function setConfig(array $params): bool
+    {
+        $avatar = FileService::setFileUrl($params['default_avatar']);
+        ConfigService::set('default_image', 'user_avatar', $avatar);
+        return true;
+    }
+
+
+    /**
+     * @notes 获取注册配置
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 10:10
+     */
+    public function getRegisterConfig(): array
+    {
+        $config = [
+            // 登录方式
+            'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')),
+            // 注册强制绑定手机
+            'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')),
+            // 政策协议
+            'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')),
+            // 第三方登录 开关
+            'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
+            // 微信授权登录
+            'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')),
+            // qq授权登录
+            'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
+        ];
+        return $config;
+    }
+
+
+    /**
+     * @notes 设置登录注册
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/3/29 10:10
+     */
+    public static function setRegisterConfig(array $params): bool
+    {
+        // 登录方式:1-账号密码登录;2-手机短信验证码登录
+        ConfigService::set('login', 'login_way', $params['login_way']);
+        // 注册强制绑定手机
+        ConfigService::set('login', 'coerce_mobile', $params['coerce_mobile']);
+        // 政策协议
+        ConfigService::set('login', 'login_agreement', $params['login_agreement']);
+        // 第三方授权登录
+        ConfigService::set('login', 'third_auth', $params['third_auth']);
+        // 微信授权登录
+        ConfigService::set('login', 'wechat_auth', $params['wechat_auth']);
+        // qq登录
+        ConfigService::set('login', 'qq_auth', $params['qq_auth']);
+        return true;
+    }
+
+}

+ 187 - 0
app/tenantapi/logic/setting/web/WebSettingLogic.php

@@ -0,0 +1,187 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\setting\web;
+
+
+use app\common\logic\BaseLogic;
+use app\common\service\ConfigService;
+use app\common\service\FileService;
+
+
+/**
+ * 网站设置
+ * Class WebSettingLogic
+ * @package app\tenantapi\logic\setting
+ */
+class WebSettingLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取网站信息
+     * @return array
+     * @author 段誉
+     * @date 2021/12/28 15:43
+     */
+    public static function getWebsiteInfo(): array
+    {
+        return [
+            'name' => ConfigService::get('tenant', 'name'),
+            'web_favicon' => FileService::getFileUrl(ConfigService::get('tenant', 'web_favicon')),
+            'web_logo' => FileService::getFileUrl(ConfigService::get('tenant', 'web_logo')),
+            'login_image' => FileService::getFileUrl(ConfigService::get('tenant', 'login_image')),
+            
+            'shop_name' => ConfigService::get('website', 'shop_name'),
+            'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
+
+            'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')),
+            'pc_title' => ConfigService::get('website', 'pc_title', ''),
+            'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')),
+            'pc_desc' => ConfigService::get('website', 'pc_desc', ''),
+            'pc_keywords' => ConfigService::get('website', 'pc_keywords', ''),
+            'h5_favicon' => FileService::getFileUrl(ConfigService::get('website', 'h5_favicon')),
+        ];
+    }
+
+
+    /**
+     * @notes 设置网站信息
+     * @param array $params
+     * @author 段誉
+     * @date 2021/12/28 15:43
+     */
+    public static function setWebsiteInfo(array $params)
+    {
+        $h5favicon = FileService::setFileUrl($params['h5_favicon']);
+        $favicon = FileService::setFileUrl($params['web_favicon']);
+        $logo = FileService::setFileUrl($params['web_logo']);
+        $login = FileService::setFileUrl($params['login_image']);
+        $shopLogo = FileService::setFileUrl($params['shop_logo']);
+        $pcLogo = FileService::setFileUrl($params['pc_logo']);
+        $pcIco = FileService::setFileUrl($params['pc_ico'] ?? '');
+
+        ConfigService::set('tenant', 'name', $params['name']);
+        ConfigService::set('tenant', 'web_favicon', $favicon);
+        ConfigService::set('tenant', 'web_logo', $logo);
+        ConfigService::set('tenant', 'login_image', $login);
+
+        ConfigService::set('website', 'pc_logo', $pcLogo);
+        ConfigService::set('website', 'pc_title', $params['pc_title']);
+        ConfigService::set('website', 'pc_ico', $pcIco);
+        ConfigService::set('website', 'pc_desc', $params['pc_desc'] ?? '');
+        ConfigService::set('website', 'pc_keywords', $params['pc_keywords'] ?? '');
+
+        ConfigService::set('website', 'shop_name', $params['shop_name']);
+        ConfigService::set('website', 'shop_logo', $shopLogo);
+        ConfigService::set('website', 'h5_favicon', $h5favicon);
+    }
+
+
+    /**
+     * @notes 获取版权备案
+     * @return array
+     * @author 段誉
+     * @date 2021/12/28 16:09
+     */
+    public static function getCopyright() : array
+    {
+        return ConfigService::get('copyright', 'config', []);
+    }
+
+
+    /**
+     * @notes 设置版权备案
+     * @param array $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/8/8 16:33
+     */
+    public static function setCopyright(array $params)
+    {
+        try {
+            if (!is_array($params['config'])) {
+                throw new \Exception('参数异常');
+            }
+            ConfigService::set('copyright', 'config', $params['config'] ?? []);
+            return true;
+        } catch (\Exception $e) {
+            self::$error = $e->getMessage();
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 设置政策协议
+     * @param array $params
+     * @author ljj
+     * @date 2022/2/15 10:59 上午
+     */
+    public static function setAgreement(array $params)
+    {
+        $serviceContent = clear_file_domain($params['service_content'] ?? '');
+        $privacyContent = clear_file_domain($params['privacy_content'] ?? '');
+        ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
+        ConfigService::set('agreement', 'service_content', $serviceContent);
+        ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
+        ConfigService::set('agreement', 'privacy_content', $privacyContent);
+    }
+
+
+    /**
+     * @notes 获取政策协议
+     * @return array
+     * @author ljj
+     * @date 2022/2/15 11:15 上午
+     */
+    public static function getAgreement() : array
+    {
+        $config = [
+            'service_title' => ConfigService::get('agreement', 'service_title'),
+            'service_content' => ConfigService::get('agreement', 'service_content'),
+            'privacy_title' => ConfigService::get('agreement', 'privacy_title'),
+            'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
+        ];
+
+        $config['service_content'] = get_file_domain($config['service_content']);
+        $config['privacy_content'] = get_file_domain($config['privacy_content']);
+
+        return $config;
+    }
+
+    /**
+     * @notes 获取站点统计配置
+     * @return array
+     * @author yfdong
+     * @date 2024/09/20 22:25
+     */
+    public static function getSiteStatistics()
+    {
+        return [
+            'clarity_code' => ConfigService::get('siteStatistics', 'clarity_code')
+        ];
+    }
+
+    /**
+     * @notes 设置站点统计配置
+     * @param array $params
+     * @return void
+     * @author yfdong
+     * @date 2024/09/20 22:31
+     */
+    public static function setSiteStatistics(array $params)
+    {
+        ConfigService::set('siteStatistics', 'clarity_code', $params['clarity_code']);
+    }
+}

+ 118 - 0
app/tenantapi/logic/user/UserLogic.php

@@ -0,0 +1,118 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+namespace app\tenantapi\logic\user;
+
+use app\common\enum\user\AccountLogEnum;
+use app\common\enum\user\UserTerminalEnum;
+use app\common\logic\AccountLogLogic;
+use app\common\logic\BaseLogic;
+use app\common\model\user\User;
+use think\facade\Db;
+
+/**
+ * 用户逻辑层
+ * Class TenantLogic
+ * @package app\tenantapi\logic\user
+ */
+class UserLogic extends BaseLogic
+{
+
+    /**
+     * @notes 用户详情
+     * @param int $userId
+     * @return array
+     * @author 段誉
+     * @date 2022/9/22 16:32
+     */
+    public static function detail(int $userId): array
+    {
+        $field = [
+            'id', 'sn', 'account', 'nickname', 'avatar', 'real_name',
+            'sex', 'mobile', 'create_time', 'login_time', 'channel',
+            'user_money','is_disable'
+        ];
+
+        $user = User::where(['id' => $userId])->field($field)
+            ->findOrEmpty();
+
+        $user['channel'] = UserTerminalEnum::getTermInalDesc($user['channel']);
+        $user->sexCode = $user->getData('sex');
+        return $user->toArray();
+    }
+
+
+    /**
+     * @notes 更新用户信息
+     * @param array $params
+     * @return User
+     * @author 段誉
+     * @date 2022/9/22 16:38
+     */
+    public static function setUserInfo(array $params)
+    {
+        return User::update([
+            $params['field'] => $params['value']
+        ], ['id' => $params['id']]);
+    }
+
+
+    /**
+     * @notes 调整用户余额
+     * @param array $params
+     * @return bool|string
+     * @author 段誉
+     * @date 2023/2/23 14:25
+     */
+    public static function adjustUserMoney(array $params)
+    {
+        Db::startTrans();
+        try {
+            $user = User::find($params['user_id']);
+            if (AccountLogEnum::INC == $params['action']) {
+                //调整可用余额
+                $user->user_money += $params['num'];
+                $user->save();
+                //记录日志
+                AccountLogLogic::add(
+                    $user->id,
+                    AccountLogEnum::UM_INC_ADMIN,
+                    AccountLogEnum::INC,
+                    $params['num'],
+                    '',
+                    $params['remark'] ?? ''
+                );
+            } else {
+                $user->user_money -= $params['num'];
+                $user->save();
+                //记录日志
+                AccountLogLogic::add(
+                    $user->id,
+                    AccountLogEnum::UM_DEC_ADMIN,
+                    AccountLogEnum::DEC,
+                    $params['num'],
+                    '',
+                    $params['remark'] ?? ''
+                );
+            }
+
+            Db::commit();
+            return true;
+
+        } catch (\Exception $e) {
+            Db::rollback();
+            return $e->getMessage();
+        }
+    }
+
+}

部分文件因为文件数量过多而无法显示