Преглед изворни кода

租户模式和保修流程初次合并提交

whitefang пре 1 година
родитељ
комит
65e6db9dbb
100 измењених фајлова са 7813 додато и 56 уклоњено
  1. 2 0
      app/adminapi/controller/BaseAdminController.php
  2. 111 0
      app/adminapi/controller/effective/OrderEffectiveLogController.php
  3. 105 0
      app/adminapi/controller/tenant/TenantAdminController.php
  4. 141 0
      app/adminapi/controller/tenant/TenantController.php
  5. 55 0
      app/adminapi/controller/tenant/TenantUserController.php
  6. 90 0
      app/adminapi/lists/effective/OrderEffectiveLogLists.php
  7. 116 0
      app/adminapi/lists/tenant/TenantAdminLists.php
  8. 168 0
      app/adminapi/lists/tenant/TenantLists.php
  9. 287 0
      app/adminapi/logic/effective/OrderEffectiveLogLogic.php
  10. 341 0
      app/adminapi/logic/tenant/TenantAdminLogic.php
  11. 173 0
      app/adminapi/logic/tenant/TenantLogic.php
  12. 61 0
      app/adminapi/logic/tenant/TenantSystemMenuLogic.php
  13. 22 1
      app/adminapi/logic/works/ServiceWorkLogic.php
  14. 278 0
      app/adminapi/service/TenantCreatService.php
  15. 110 0
      app/adminapi/validate/effective/OrderEffectiveLogValidate.php
  16. 172 0
      app/adminapi/validate/tenant/TenantAdminValidate.php
  17. 141 0
      app/adminapi/validate/tenant/TenantValidate.php
  18. 2 0
      app/api/controller/BaseApiController.php
  19. 25 0
      app/api/controller/OrderEffectiveController.php
  20. 2 2
      app/api/lists/OrderEffectiveLogLists.php
  21. 62 0
      app/api/logic/OrderEffectiveLogLogic.php
  22. 58 0
      app/api/logic/PerformanceLogic.php
  23. 36 2
      app/api/logic/ServiceOrderLogic.php
  24. 1 1
      app/api/validate/LoginAccountValidate.php
  25. 116 0
      app/api/validate/OrderEffectiveLogValidate.php
  26. 122 0
      app/common/cache/TenantAdminAuthCache.php
  27. 120 0
      app/common/cache/TenantAdminTokenCache.php
  28. 49 13
      app/common/enum/AdminTerminalEnum.php
  29. 116 6
      app/common/http/middleware/LikeAdminAllowMiddleware.php
  30. 13 0
      app/common/lists/BaseDataLists.php
  31. 3 2
      app/common/logic/RetentionMoneyLogic.php
  32. 19 0
      app/common/model/TenantConfig.php
  33. 179 0
      app/common/model/auth/TenantAdmin.php
  34. 32 0
      app/common/model/auth/TenantAdminDept.php
  35. 32 0
      app/common/model/auth/TenantAdminJobs.php
  36. 34 0
      app/common/model/auth/TenantAdminRole.php
  37. 32 0
      app/common/model/auth/TenantAdminSession.php
  38. 28 0
      app/common/model/auth/TenantSystemMenu.php
  39. 41 0
      app/common/model/auth/TenantSystemRole.php
  40. 30 0
      app/common/model/auth/TenantSystemRoleMenu.php
  41. 73 0
      app/common/model/dept/TenantDept.php
  42. 44 0
      app/common/model/dept/TenantJobs.php
  43. 35 0
      app/common/model/effective/OrderEffectiveLog.php
  44. 24 0
      app/common/model/file/TenantFile.php
  45. 25 0
      app/common/model/file/TenantFileCate.php
  46. 14 1
      app/common/model/orders/OrderEffectiveLog.php
  47. 54 0
      app/common/model/pay/TenantPayConfig.php
  48. 53 0
      app/common/model/pay/TenantPayWay.php
  49. 133 0
      app/common/model/tenant/Tenant.php
  50. 17 12
      app/common/model/works/ServiceWork.php
  51. 42 16
      app/common/service/ConfigService.php
  52. 1 0
      app/common/service/pay/WeChatPayService.php
  53. 28 0
      app/tenantapi/config/route.php
  54. 43 0
      app/tenantapi/controller/BaseAdminController.php
  55. 61 0
      app/tenantapi/controller/ConfigController.php
  56. 50 0
      app/tenantapi/controller/DownloadController.php
  57. 137 0
      app/tenantapi/controller/FileController.php
  58. 59 0
      app/tenantapi/controller/LoginController.php
  59. 80 0
      app/tenantapi/controller/UploadController.php
  60. 38 0
      app/tenantapi/controller/WorkbenchController.php
  61. 134 0
      app/tenantapi/controller/auth/AdminController.php
  62. 142 0
      app/tenantapi/controller/auth/MenuController.php
  63. 124 0
      app/tenantapi/controller/auth/RoleController.php
  64. 53 0
      app/tenantapi/controller/channel/AppSettingController.php
  65. 52 0
      app/tenantapi/controller/channel/MnpSettingsController.php
  66. 74 0
      app/tenantapi/controller/channel/OfficialAccountMenuController.php
  67. 148 0
      app/tenantapi/controller/channel/OfficialAccountReplyController.php
  68. 52 0
      app/tenantapi/controller/channel/OfficialAccountSettingController.php
  69. 54 0
      app/tenantapi/controller/channel/OpenSettingController.php
  70. 54 0
      app/tenantapi/controller/channel/WebPageSettingController.php
  71. 55 0
      app/tenantapi/controller/decorate/DataController.php
  72. 61 0
      app/tenantapi/controller/decorate/PageController.php
  73. 58 0
      app/tenantapi/controller/decorate/TabbarController.php
  74. 134 0
      app/tenantapi/controller/dept/DeptController.php
  75. 118 0
      app/tenantapi/controller/dept/JobsController.php
  76. 51 0
      app/tenantapi/controller/setting/CustomerServiceController.php
  77. 56 0
      app/tenantapi/controller/setting/HotSearchController.php
  78. 53 0
      app/tenantapi/controller/setting/TransactionSettingsController.php
  79. 69 0
      app/tenantapi/controller/setting/pay/PayConfigController.php
  80. 61 0
      app/tenantapi/controller/setting/pay/PayWayController.php
  81. 39 0
      app/tenantapi/controller/setting/system/CacheController.php
  82. 84 0
      app/tenantapi/controller/setting/user/UserController.php
  83. 137 0
      app/tenantapi/controller/setting/web/WebSettingController.php
  84. 86 0
      app/tenantapi/controller/user/UserController.php
  85. 23 0
      app/tenantapi/event.php
  86. 92 0
      app/tenantapi/http/middleware/AuthMiddleware.php
  87. 50 0
      app/tenantapi/http/middleware/CheckDemoMiddleware.php
  88. 114 0
      app/tenantapi/http/middleware/EncryDemoDataMiddleware.php
  89. 57 0
      app/tenantapi/http/middleware/InitMiddleware.php
  90. 87 0
      app/tenantapi/http/middleware/LoginMiddleware.php
  91. 77 0
      app/tenantapi/listener/OperationLog.php
  92. 39 0
      app/tenantapi/lists/BaseAdminDataLists.php
  93. 206 0
      app/tenantapi/lists/auth/AdminLists.php
  94. 60 0
      app/tenantapi/lists/auth/MenuLists.php
  95. 93 0
      app/tenantapi/lists/auth/RoleLists.php
  96. 80 0
      app/tenantapi/lists/channel/OfficialAccountReplyLists.php
  97. 105 0
      app/tenantapi/lists/dept/JobsLists.php
  98. 74 0
      app/tenantapi/lists/file/FileCateLists.php
  99. 109 0
      app/tenantapi/lists/file/FileLists.php
  100. 62 0
      app/tenantapi/lists/setting/pay/PayConfigLists.php

+ 2 - 0
app/adminapi/controller/BaseAdminController.php

@@ -16,6 +16,7 @@ declare (strict_types=1);
 
 namespace app\adminapi\controller;
 
+use app\common\enum\AdminTerminalEnum;
 use think\App;
 use app\common\controller\BaseLikeAdminController;
 
@@ -31,6 +32,7 @@ class BaseAdminController extends BaseLikeAdminController
 
     public function initialize()
     {
+        $this->request->source = AdminTerminalEnum::PLATFORM;
         if (isset($this->request->adminInfo) && $this->request->adminInfo) {
             $this->adminInfo = $this->request->adminInfo;
             $this->adminId = $this->request->adminInfo['admin_id'];

+ 111 - 0
app/adminapi/controller/effective/OrderEffectiveLogController.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\adminapi\controller\effective;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\effective\OrderEffectiveLogLists;
+use app\adminapi\logic\effective\OrderEffectiveLogLogic;
+use app\adminapi\validate\effective\OrderEffectiveLogValidate;
+
+
+/**
+ * OrderEffectiveLog控制器
+ * Class OrderEffectiveLogController
+ * @package app\adminapi\controller
+ */
+class OrderEffectiveLogController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function lists()
+    {
+        return $this->dataLists(new OrderEffectiveLogLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function add()
+    {
+        $params = (new OrderEffectiveLogValidate())->post()->goCheck('add');
+        $result = OrderEffectiveLogLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(OrderEffectiveLogLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function edit()
+    {
+        $params = (new OrderEffectiveLogValidate())->post()->goCheck('detail',[
+            'adminId' => $this->adminId,
+            'adminInfo' => $this->adminInfo
+        ]);
+        $result = OrderEffectiveLogLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(OrderEffectiveLogLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function delete()
+    {
+        $params = (new OrderEffectiveLogValidate())->post()->goCheck('delete');
+        OrderEffectiveLogLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function detail()
+    {
+        $params = (new OrderEffectiveLogValidate())->goCheck('detail');
+        $result = OrderEffectiveLogLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 105 - 0
app/adminapi/controller/tenant/TenantAdminController.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\adminapi\controller\tenant;
+
+use app\api\validate\PasswordValidate;
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\tenant\TenantAdminLists;
+use app\adminapi\logic\tenant\TenantAdminLogic;
+use app\adminapi\validate\tenant\TenantAdminValidate;
+
+/**
+ * 租户账号用户控制器
+ * Class TenantController
+ * @package app\adminapi\controller\user
+ */
+class TenantAdminController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取租户管理员账号 租户查询参数必传防止越权查看
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 22:11
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TenantAdminLists());
+    }
+
+
+    /**
+     * @notes 获取租户管理员账号 租户id以及主键id查询参数必传 防止越权查看
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 22:14
+     */
+    public function detail()
+    {
+        $params = (new TenantAdminValidate())->goCheck('detail');
+        $result = TenantAdminLogic::detail($params['id']);
+        if (false === $result) {
+            return $this->fail(TenantAdminLogic::getError());
+        }
+        return $this->success('获取成功', $result);
+    }
+
+    /**
+     * @notes 创建租户管理员账号
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 22:58
+     */
+    public function add()
+    {
+        $params = (new TenantAdminValidate())->post()->goCheck('add');
+        $result = TenantAdminLogic::add($params);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(TenantAdminLogic::getError());
+    }
+
+    /**
+     * @notes 编辑租户管理员账号
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 22:58
+     */
+    public function edit()
+    {
+        $params = (new TenantAdminValidate())->post()->goCheck('edit');
+        $result = TenantAdminLogic::edit($params);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(TenantAdminLogic::getError());
+    }
+
+    /**
+     * @notes 删除租户管理员账号
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 22:59
+     */
+    public function delete()
+    {
+        $params = (new TenantAdminValidate())->post()->goCheck('delete');
+        $result = TenantAdminLogic::delete($params);
+        if (true === $result) {
+            return $this->success('删除成功', [], 1, 1);
+        }
+        return $this->fail(TenantAdminLogic::getError());
+    }
+}

+ 141 - 0
app/adminapi/controller/tenant/TenantController.php

@@ -0,0 +1,141 @@
+<?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\adminapi\controller\tenant;
+
+use app\common\model\dept\TenantDept;
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\tenant\TenantLists;
+use app\adminapi\logic\setting\pay\PayConfigLogic;
+use app\adminapi\logic\setting\pay\PayWayLogic;
+use app\adminapi\logic\tenant\TenantAdminLogic;
+use app\adminapi\logic\tenant\TenantLogic;
+use app\adminapi\logic\tenant\TenantSystemMenuLogic;
+use app\adminapi\service\TenantCreatService;
+use app\adminapi\validate\tenant\TenantValidate;
+use app\tenantapi\logic\article\ArticleLogic;
+use app\tenantapi\logic\decorate\DecorateDataLogic;
+use app\tenantapi\logic\notice\NoticeLogic;
+use think\facade\Db;
+
+/**
+ * 用户控制器
+ * Class TenantController
+ * @package app\adminapi\controller\user
+ */
+class TenantController extends BaseAdminController
+{
+
+    /**
+     * @notes 用户列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/22 16:16
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TenantLists());
+    }
+
+
+    /**
+     * @notes 获取用户详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/22 16:34
+     */
+    public function detail()
+    {
+        $params = (new TenantValidate())->goCheck('detail');
+        $result = TenantLogic::detail($params['id']);
+        if (false === $result) {
+            return $this->fail(TenantLogic::getError());
+        }
+        return $this->success('获取成功', $result);
+    }
+
+    /**
+     * @notes 新增租户信息 同步初始化对应租户信息
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/07 12:23
+     */
+    public function add()
+    {
+        $params = (new TenantValidate())->post()->goCheck('add');
+        try {
+            // 开始事务
+            DB::startTrans();
+            // 验证参数
+            // 创建租户基本信息
+            $tenant = TenantLogic::add($params);
+            // 判断用户是否采用分表模式
+            // todo 测试模式,全部采用分表模式
+            // $params['suitable'] = '1';
+            if (isset($params['tactics']) && $params['tactics'] == '1') {
+                (new TenantCreatService)->createTenantTable($tenant['sn']);
+                (new TenantCreatService)->initializationTenantData($tenant['id'],$tenant['sn'],$params);
+            }else{
+                // 初始化租户管理员账号
+                $managerInfo = TenantAdminLogic::initialization($tenant['id'], $tenant['sn'], $params);
+                // 初始化管理员部门信息
+                TenantDept::initialization($tenant['id'], $managerInfo['id']);
+                // 创建租户菜单权限
+                TenantSystemMenuLogic::initialization($tenant['id']);
+                // 创建默认装修数据
+                DecorateDataLogic::initialization($tenant['id']);
+            }
+            // 提交事务
+            DB::commit();
+            // 返回成功
+            return $this->success('新增成功', [], 1, 1);
+        } catch (\Exception $e) {
+            // 回滚事务
+            DB::rollBack();
+            // 处理异常并返回错误信息
+            return $this->fail('新增失败:' . $e->getMessage());
+        }
+    }
+
+    /**
+     * @notes 编辑用户信息
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/9/22 16:34
+     */
+    public function edit()
+    {
+        $params = (new TenantValidate())->post()->goCheck('edit');
+        $result = TenantLogic::edit($params);
+        if (true === $result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(TenantLogic::getError());
+    }
+
+    /**
+     * @notes 删除租户
+     * @return \think\response\Json
+     * @author JXDN
+     * @date 2024/09/03 17:02
+     */
+    public function delete()
+    {
+        $params = (new TenantValidate())->post()->goCheck('delete');
+        $result = TenantLogic::delete($params);
+        if (true === $result) {
+            return $this->success('删除成功', [], 1, 1);
+        }
+        return $this->fail(TenantLogic::getError());
+    }
+}

+ 55 - 0
app/adminapi/controller/tenant/TenantUserController.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\adminapi\controller\tenant;
+
+use app\adminapi\controller\BaseAdminController;
+use app\tenantapi\lists\user\UserLists;
+use app\tenantapi\logic\user\UserLogic;
+use app\tenantapi\validate\user\UserValidate;
+
+/**
+ * 租户用户控制器
+ * Class TenantUserController
+ * @package app\adminapi\controller\user
+ */
+class TenantUserController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取租户用户列表
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 23:36
+     */
+    public function lists()
+    {
+        //进行租户信息校验
+        (new UserValidate())->goCheck('manager');
+        return $this->dataLists(new UserLists());
+    }
+
+
+    /**
+     * @notes 获取租户用户详情
+     * @return \think\response\Json
+     * @author yfdong
+     * @date 2024/09/04 23:36
+     */
+    public function detail()
+    {
+        $params = (new UserValidate())->goCheck('detail');
+        $detail = UserLogic::detail($params['id']);
+        return $this->success('获取租户用户详情成功', $detail);
+    }
+}

+ 90 - 0
app/adminapi/lists/effective/OrderEffectiveLogLists.php

@@ -0,0 +1,90 @@
+<?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\adminapi\lists\effective;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\adminapi\logic\effective\OrderEffectiveLogLogic;
+use app\common\model\orders\OrderEffectiveLog;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\works\ServiceWork;
+
+
+/**
+ * OrderEffectiveLog列表
+ * Class OrderEffectiveLogLists
+ * @package app\adminapi\lists
+ */
+class OrderEffectiveLogLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['effective_id', 'sn', 'user_id', 'work_id', 'goods_id', 'effective_unit', 'effective_num', 'remark', 'end_effective_time'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function lists(): array
+    {
+        $list = OrderEffectiveLog::with(['goods'=>function ($query) {
+                $query->with(['goodsCategory'=>function ($query1) {
+                    $query1->field(['name','picture']);
+                }]);
+            },'serviceWork','originalServiceWork'])->where('effective_status','>',0)->where($this->searchWhere)
+            ->field(['*'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        foreach ($list as &$value) {
+            $value['income_fee'] = 0;
+            if($value['originalServiceWork']) $value['income_fee'] = OrderEffectiveLogLogic::commissionAndAssuranceDeposit($value['originalServiceWork']);
+        }
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function count(): int
+    {
+        return OrderEffectiveLog::where($this->searchWhere)->count();
+    }
+
+}

+ 116 - 0
app/adminapi/lists/tenant/TenantAdminLists.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\adminapi\lists\tenant;
+
+use app\common\model\auth\TenantAdmin;
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\user\UserTerminalEnum;
+use app\common\lists\ListsExcelInterface;
+use app\common\model\tenant\Tenant;
+
+
+/**
+ * 用户列表
+ * Class TenantLists
+ * @package app\tenantapi\lists\user
+ */
+class TenantAdminLists extends BaseAdminDataLists implements ListsExcelInterface
+{
+
+    /**
+     * @notes 搜索条件
+     * @return array
+     * @author 段誉
+     * @date 2022/9/22 15:50
+     */
+    public function setSearch(): array
+    {
+        $allowSearch = ['keyword', '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
+    {
+        //进行参数校验 租户标识必填
+        if(!isset($this->params['tenant_id'])){
+            return [];
+        }
+
+        $field = "id,root,name,avatar,account,multipoint_login,disable,create_time";
+
+        $lists = TenantAdmin::withSearch($this->setSearch(), $this->params)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->field($field)
+            ->order('create_time desc')
+            ->select()->toArray();
+
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2022/9/22 15:51
+     */
+    public function count(): int
+    {
+        return TenantAdmin::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 [
+            'root' => '是否超级管理员',
+            'name' => '租户账户昵称',
+            'avatar' => '头像',
+            'account' => '账号',
+            'multipoint_login' => '是否允许多处登录',
+            'disable' => '是否禁用',
+            'create_time' => '注册时间',
+        ];
+    }
+
+}

+ 168 - 0
app/adminapi/lists/tenant/TenantLists.php

@@ -0,0 +1,168 @@
+<?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\adminapi\lists\tenant;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\user\UserTerminalEnum;
+use app\common\lists\ListsExcelInterface;
+use app\common\model\tenant\Tenant;
+
+
+/**
+ * 用户列表
+ * Class TenantLists
+ * @package app\tenantapi\lists\user
+ */
+class TenantLists extends BaseAdminDataLists implements ListsExcelInterface
+{
+
+    /**
+     * @notes 搜索条件
+     * @return array
+     * @author 段誉
+     * @date 2022/9/22 15:50
+     */
+    public function setSearch(): array
+    {
+        $allowSearch = ['keyword', 'create_time_start', 'create_time_end'];
+        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,name,avatar,disable,create_time,domain_alias,domain_alias_enable,notes,tel";
+
+        $lists = Tenant::withCount(['users'])
+            ->withSearch($this->setSearch(), $this->params)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->field($field)
+            ->order('id desc')
+            ->select()->toArray();
+
+        $domain = self::getRootDmain(request()->domain());
+
+        // 遍历结果,添加 link 字段
+        return array_map(function ($item) use ($domain) {
+            // 拼接租户的链接 http://[sn].likeadmin-saas.localhost/admin/
+            $http_prefix = self::checkHttp() ? 'https://' : 'http://';
+            $item['default_domain'] = $http_prefix . $item['sn'] . '.' . $domain . '/tenant/';
+
+            if ($item['domain_alias_enable'] === 0) {
+                $item['domain'] = $http_prefix . $item['domain_alias'] . '/tenant/';
+            } else {
+                $item['domain'] = $item['default_domain'];
+            }
+            return $item;
+        }, $lists);
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2022/9/22 15:51
+     */
+    public function count(): int
+    {
+        return Tenant::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' => '租户编号',
+            'name' => '租户昵称',
+            'disable' => '租户状态',
+            'create_time' => '注册时间',
+        ];
+    }
+
+    /**
+     * @notes 检查是否为https
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/11 14:39
+     */
+    public static function checkHttp()
+    {
+        if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * @notes 获取根域名
+     * @param $url
+     * @return array|int|string|null
+     * @author JXDN
+     * @date 2024/09/11 14:49
+     */
+    public static function getRootDmain($url)
+    {
+        // 解析 URL 获取主机名
+        $host = parse_url($url, PHP_URL_HOST);
+
+        // 如果主机名为空,返回 null
+        if (!$host) {
+            return null;
+        }
+
+        // 拆分域名
+        $parts = explode('.', $host);
+
+        // 检查域名的级数
+        $numParts = count($parts);
+
+        // 针对常见的两级或三级域名进行处理
+        if ($numParts >= 2) {
+            // 获取最后两部分,例如 qq.com 或 co.uk
+            $rootDomain = $parts[$numParts - 2] . '.' . $parts[$numParts - 1];
+            return $rootDomain;
+        }
+
+        return $host; // 当域名本身就是根域名时,直接返回
+    }
+}

+ 287 - 0
app/adminapi/logic/effective/OrderEffectiveLogLogic.php

@@ -0,0 +1,287 @@
+<?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\adminapi\logic\effective;
+
+
+use app\adminapi\logic\works\ServiceWorkLogic;
+use app\common\enum\GoodsEnum;
+use app\common\enum\PayEnum;
+use app\common\enum\WorkEnum;
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\model\orders\OrderEffectiveLog;
+use app\common\logic\BaseLogic;
+use app\common\model\goods\Goods;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
+use app\common\model\orders\RechargeOrder;
+use app\common\model\recharge\OrderGoods;
+use app\common\model\works\ServiceWork;
+use think\facade\Db;
+
+
+/**
+ * OrderEffectiveLog逻辑
+ * Class OrderEffectiveLogLogic
+ * @package app\adminapi\logic
+ */
+class OrderEffectiveLogLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            OrderEffectiveLog::create([
+                'effective_id' => $params['effective_id'],
+                'sn' => $params['sn'],
+                'user_id' => $params['user_id'],
+                'work_id' => $params['work_id'],
+                'goods_id' => $params['goods_id'],
+                'effective_unit' => $params['effective_unit'],
+                'effective_num' => $params['effective_num'],
+                'remark' => $params['remark'],
+                'end_effective_time' => $params['end_effective_time'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public static function edit(array $params): bool
+    {
+        if($params['operation_type'] == 1){
+            //无需保修 - 恢复状态
+            OrderEffectiveLog::where('id', $params['id'])->update([
+                'effective_status' => 0,
+                'effective_time' => 0,
+            ]);
+            return true;
+        }
+
+        // 用户已提交 - 客服处理下单
+        if($params['edit_status'] == 1){
+            self::effectiveServiceWork($params);
+        }
+        // 保修中 - 客服处理新增定金 ,尾款可由工程师完成 =0 || >0 均可
+        if($params['edit_status'] == 2){
+            // 惩罚金额
+            OrderEffectiveLog::where('id', $params['id'])->update([
+                'penalty_amount' => $params['penalty_amount']
+            ]);
+        }
+        return true;
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public static function delete(array $params): bool
+    {
+        return OrderEffectiveLog::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public static function detail($params): array
+    {
+        return OrderEffectiveLog::findOrEmpty($params['id'])->toArray();
+    }
+    /**
+     * @notes 计算工单所得的 提成+质保金
+     */
+    public static function commissionAndAssuranceDeposit($serviceWork)
+    {
+        $change_amount = MasterWorkerAccountLog::where([
+            'change_object'=>WorkerAccountLogEnum::UM,'change_type'=>WorkerAccountLogEnum::UM_INC_ADMIN,
+            'action'=>WorkerAccountLogEnum::INC,'worker_id'=>$serviceWork['master_worker_id'],
+            'work_sn'=>$serviceWork['work_sn']])->value('change_amount');
+        $retentionAmount = MasterWorkerRetentionMoneyLog::where(['action'=>WorkerAccountLogEnum::INC,'source'=>2,'worker_id'=>$serviceWork['master_worker_id'],'work_id'=>$serviceWork['id']])->value('amount');
+        return bcadd((string)$change_amount,(string)$retentionAmount,2);
+    }
+
+
+    /**
+     * @notes 用户已提交 - 客服处理下单
+     */
+    public static function effectiveServiceWork($params)
+    {
+        Db::startTrans();
+        try {
+            /*{ name: '无需保修', value: 1 },
+            { name: '原工程师修复', value: 2 },
+            { name: '新工程师修复', value: 3 }*/
+            $effectiveLog = OrderEffectiveLog::where('id', $params['id'])->find();
+
+            /*$effectiveLog['user_id']
+            $effectiveLog['work_id']
+            $effectiveLog['goods_id']*/
+            // 原工单信息 $effectiveLog['work_id']
+            $serviceWork = ServiceWork::find($effectiveLog['work_id'])->toArray();
+
+            if($params['operation_type'] == 2){
+                //原工程师修复
+                OrderEffectiveLog::where('id', $params['id'])->update([
+                    'effective_status' => 2
+                ]);
+                // 原工程师为0
+                $service_fee = 0;
+                $master_worker_id = $serviceWork['master_worker_id'];
+
+            }else if($params['operation_type'] == 3){
+                //新工程师修复
+                OrderEffectiveLog::where('id', $params['id'])->update([
+                    'effective_status' => 2
+                ]);
+                // 计算原工程师的原工单的提成+质保金
+                //$service_fee = self::commissionAndAssuranceDeposit($serviceWork);
+                $service_fee = 0;
+                if($serviceWork['master_worker_id'] == $params['master_worker_id']){
+                    throw new \Exception('请选择新的工程师');
+                }
+                $master_worker_id = $params['master_worker_id'];
+            }else{
+                throw new \Exception('操作类型错误');
+            }
+
+            //生成服务工单
+            $work_data = [
+                'work_sn' => generate_sn(ServiceWork::class, 'work_sn'),
+                'real_name' => $serviceWork['real_name'],
+                'mobile' => $serviceWork['mobile'],
+                'address' => $serviceWork['address'],
+
+                'province' => $serviceWork['province']??0,
+                'city' => $serviceWork['city']??0,
+                'area_name' => $serviceWork['area_name']??'',
+
+                'title' => $serviceWork['title']??'',
+                'category_type' => $serviceWork['category_type'],
+                'goods_category_ids' => $serviceWork['goods_category_ids'],
+                'goods_category_id' => $serviceWork['goods_category_id'],
+
+                'user_id'=>$serviceWork['user_id'],
+                'lon'=>$serviceWork['lon'],
+                'lat'=>$serviceWork['lat'],
+                'property_activity_id'=>0,
+                'user_equity_id'=>0,
+
+                'work_pay_status'=>WorkEnum::IS_PAY_STATUS,
+                'appointment_time' => $params['appointment_time']?strtotime($params['appointment_time']):0,
+                'order_effective_id'=>$params['id'],
+                'base_service_fee' => 0,
+                'service_fee' => 0,
+                'work_total'=>0,
+                'work_amount'=>0,
+            ];
+
+            $service_work = ServiceWork::create($work_data);
+
+            //生成支付订单
+            $data = [
+                'work_id'=> $service_work['id'],
+                'sn' => generate_sn(RechargeOrder::class, 'sn'),
+                'order_type'=>0,//服务订单
+                'order_terminal' => 1,
+                'payment_type'=>1,
+                'user_id' => $serviceWork['user_id'],
+                'pay_way' => 2,
+                'pay_status' => PayEnum::ISPAID,
+                'pay_time' => time(),
+                'paid_amount' => 0,
+                'coupon_id'=>0,
+                'coupon_price'=>0,
+                'order_total' => 0,
+                'order_amount' => 0,
+            ];
+            $order = RechargeOrder::create($data);
+
+            //生成订单服务详情
+            $goods = Goods::findOrEmpty($effectiveLog['goods_id']);
+            OrderGoods::create([
+                'sn' => $order['sn'],
+                'goods_id' => $effectiveLog['goods_id'],
+                'category_type' => $goods['category_type'],
+                'goods_category_ids' => $goods['goods_category_ids'],
+                'goods_category_id' => $goods['goods_category_id'],
+                'goods_name' => $goods['goods_name'],
+                'goods_image' => $goods['goods_image'],
+                'goods_video' => $goods['goods_video'],
+                'goods_number' => $goods['goods_number'],
+                'good_unit' => $goods['good_unit'],
+                'goods_size' => $goods['goods_size'],
+                'goods_type' => $goods['goods_type'],
+                'goods_brand' => $goods['goods_brand'],
+                'install_guide' => $goods['install_guide'],
+                'goods_payment_type'=>1,
+                'base_service_fee' => $goods['base_service_fee'],
+                'service_total' => $goods['service_total'],
+                'service_fee' => $goods['service_fee'],
+                'service_image' => $goods['service_image'],
+                'warranty_period'=>$goods['warranty_period'],
+                'fee_schedule' => $goods['fee_schedule'],
+                'goods_status' => $goods['goods_status'],
+                'is_show' => 0,
+            ]);
+
+            Db::commit();
+
+            //派单
+            if(isset($service_work['id']) && !empty($service_work['id'])) ServiceWorkLogic::allocateWorker(['id'=>$service_work['id'],'master_worker_id'=>$master_worker_id],$params['adminInfo']);
+
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+
+
+
+}

+ 341 - 0
app/adminapi/logic/tenant/TenantAdminLogic.php

@@ -0,0 +1,341 @@
+<?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\adminapi\logic\tenant;
+
+use app\common\cache\TenantAdminAuthCache;
+use app\common\cache\TenantAdminTokenCache;
+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\service\FileService;
+use think\facade\Db;
+use think\facade\Config;
+
+/**
+ * 用户逻辑层
+ * Class TenantLogic
+ * @package app\adminapi\logic\user
+ */
+class TenantAdminLogic extends BaseLogic
+{
+    /**
+     * @notes 新增租户管理员
+     * @param array $params
+     * @return bool
+     * @author yfdong
+     * @date 2024/09/04 22:43
+     */
+    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'],
+                'tenant_id'        => $params['tenant_id'],
+                '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 int $userId
+     * @return array | bool
+     * @author yfdong
+     * @date 2024/09/04 22:44
+     */
+    public static function detail(int $userId): array|bool
+    {
+        $field = "id,root,name,avatar,account,multipoint_login,disable,create_time";
+
+        try {
+            return TenantAdmin::where(['id' => $userId])->field($field)->findOrEmpty()->toArray();
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 修改租户管理员
+     * @param array $params
+     * @return bool
+     * @author yfdong
+     * @date 2024/09/04 22:44
+     */
+    public static function edit(array $params)
+    {
+        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 yfdong
+     * @date 2024/09/04 22:58
+     */
+    public static function delete(array $params)
+    {
+        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 JXDN
+     * @date 2024/09/06 18:03
+     */
+    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 $adminId
+     * @param $roleIds
+     * @return void
+     * @throws \Exception
+     * @author JXDN
+     * @date 2024/09/06 18:05
+     */
+    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
+     * @return void
+     * @throws \Exception
+     * @author JXDN
+     * @date 2024/09/06 18:05
+     */
+    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
+     * @return void
+     * @throws \Exception
+     * @author JXDN
+     * @date 2024/09/06 18:05
+     */
+    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);
+        }
+    }
+
+    /**
+     * @notes 根据加密规则创建密码
+     * @param $password
+     * @return string
+     * @author yfdong
+     * @date 2024/09/04 22:53
+     */
+    public static function createPassword($password)
+    {
+        // 密码盐
+        $passwordSalt = Config::get('project.unique_identification');
+        return create_password($password, $passwordSalt);
+    }
+
+    /**
+     * @notes 初始化管理员账号
+     * @param mixed $id
+     * @param $name
+     * @return TenantAdmin|\think\Model
+     * @author yfdong
+     * @date 2024/09/05 22:52
+     */
+    public static function initialization(mixed $id, $sn, $params)
+    {
+        // 获取配置中的默认密码
+        $defaultPassword = Config::get('project.default_password');
+        // 初始化管理员账号
+        return TenantAdmin::create([
+            'tenant_id' => $id,
+            'account'   => $params['account'] ?: $sn,
+            'name'      => '超级管理员',
+            'password'  => self::createPassword($params['password'] ?: $defaultPassword),
+            'avatar'    => '',
+            'disable'   => 0,
+            'root'      => 1
+        ]);
+    }
+}

+ 173 - 0
app/adminapi/logic/tenant/TenantLogic.php

@@ -0,0 +1,173 @@
+<?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\adminapi\logic\tenant;
+
+use app\common\enum\user\UserTerminalEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\tenant\Tenant;
+use app\common\model\user\User;
+
+/**
+ * 用户逻辑层
+ * Class TenantLogic
+ * @package app\adminapi\logic\user
+ */
+class TenantLogic extends BaseLogic
+{
+    /**
+     * @notes 新增租户
+     * @param array $params
+     * @return Tenant|\think\Model
+     * @author JXDN
+     * @date 2024/09/03 14:42
+     */
+    public static function add(array $params)
+    {
+        $domain_alias = preg_replace('/^https?:\/\/|\/$/', '', $params['domain_alias']);
+        return Tenant::create([
+            'sn'                  => Tenant::createUserSn(),
+            'name'                => $params['name'],
+            'avatar'              => $params['avatar'],
+            'tel'                 => $params['tel'],
+            'domain_alias'        => $domain_alias,
+            'domain_alias_enable' => $params['domain_alias_enable'],
+            'disable'             => $params['disable'] ?? 0,
+            'notes'               => $params['notes'] ?? '',
+            'tactics'             => $params['tactics'] ?? 0,
+        ]);
+    }
+
+    /**
+     * @notes 用户详情
+     * @param int $userId
+     * @return array|false
+     * @author JXDN
+     * @date 2024/09/11 15:48
+     */
+    public static function detail(int $userId)
+    {
+        try {
+            $field = "id,sn,name,avatar,tel,domain_alias,domain_alias_enable,disable,create_time,notes";
+
+            $user = Tenant::where(['id' => $userId])->field($field)->findOrEmpty();
+            $user['user_total'] = User::where(['tenant_id' => $userId])->count();
+
+            $domain = self::getRootDmain(request()->domain());
+            $user['default_domain'] = (self::checkHttp() ? 'https://' : 'http://') . $user['sn'] . '.' . $domain . '/tenant/';
+            if ($user['domain_alias_enable'] === 0) {
+                $user['domain'] = (self::checkHttp() ? 'https://' : 'http://') . $user['domain_alias'] . '/tenant/';
+            } else {
+                $user['domain'] = $user['default_domain'];
+            }
+
+            return $user->toArray();
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+
+    }
+
+    /**
+     * @notes 更新租户信息
+     * @param array $params
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/03 14:28
+     */
+    public static function edit(array $params)
+    {
+        try {
+            $domain_alias = preg_replace('/^https?:\/\/|\/$/', '', $params['domain_alias']);
+            Tenant::update([
+                'name'                => $params['name'],
+                'avatar'              => $params['avatar'],
+                'disable'             => $params['disable'] ?? 0,
+                'tel'                 => $params['tel'],
+                'domain_alias'        => $domain_alias,
+                'domain_alias_enable' => $params['domain_alias_enable'],
+                'notes'               => $params['notes'] ?? '',
+            ], ['id' => $params['id']]);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * @notes 删除租户
+     * @param array $params
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/03 17:04
+     */
+    public static function delete(array $params)
+    {
+        try {
+            Tenant::destroy($params['id']);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * @notes 检查是否为https
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/11 14:39
+     */
+    public static function checkHttp()
+    {
+        if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * @notes 获取根域名
+     * @param $url
+     * @return array|int|string|null
+     * @author JXDN
+     * @date 2024/09/11 14:49
+     */
+    public static function getRootDmain($url)
+    {
+        // 解析 URL 获取主机名
+        $host = parse_url($url, PHP_URL_HOST);
+
+        // 如果主机名为空,返回 null
+        if (!$host) {
+            return null;
+        }
+
+        // 拆分域名
+        $parts = explode('.', $host);
+
+        // 检查域名的级数
+        $numParts = count($parts);
+
+        // 针对常见的两级或三级域名进行处理
+        if ($numParts >= 2) {
+            // 获取最后两部分,例如 qq.com 或 co.uk
+            return $parts[$numParts - 2] . '.' . $parts[$numParts - 1];
+        }
+
+        return $host; // 当域名本身就是根域名时,直接返回
+    }
+}

+ 61 - 0
app/adminapi/logic/tenant/TenantSystemMenuLogic.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\adminapi\logic\tenant;
+
+use app\common\model\auth\TenantSystemMenu;
+
+/**
+ * 租户菜单逻辑
+ *  Class TenantSystemMenuLogic
+ * @package app\adminapi\logic\tenant
+ */
+class TenantSystemMenuLogic
+{
+
+    /**
+     * @notes 初始化租户菜单信息
+     * @param $tenant_id
+     * @author yfdong
+     * @date 2024/09/05 22:15
+     */
+    public static function initialization($tenant_id)
+    {
+        //初始化租户菜单字段
+        $field = "id,pid,type,name,icon,sort,perms,paths,component,selected,params,is_cache,is_show,is_disable,tenant_id";
+        //查询模板菜单配置文件 此处默认为租户号为0的模板数据
+        $tenantSystemMenuList = TenantSystemMenu::where(['tenant_id' => 0])->field($field)->order('pid')->select()->toArray();
+        //记录对应的关系
+        foreach ($tenantSystemMenuList as $item) {
+            $tenantSystemMenu[$item['id']] = $item;
+        }
+        //创建菜单数据
+        foreach ($tenantSystemMenuList as $item) {
+            $item['tenant_id'] = $tenant_id;
+            //创建新的菜单并保存原本id对应现在的哪个信息
+            $oldId = $item['id'];
+            unset($item['id']);
+            $newMenu = TenantSystemMenu::create($item);
+            $tenantSystemMenu[$oldId] = $newMenu;
+        }
+        //获取当前租户的初始化菜单关系
+        $tenantSystemMenuNewList = TenantSystemMenu::where(['tenant_id' => $tenant_id])->field($field)->order('pid')->select()->toArray();
+        //更新对应的主菜单关系
+        foreach ($tenantSystemMenuNewList as $item) {
+            if ($item['pid'] != 0)
+                $item['pid'] = $tenantSystemMenu[$item['pid']]['id'];
+            $where = array('id' => intval($item['id']));
+            TenantSystemMenu::update($item, $where);
+        }
+    }
+}

+ 22 - 1
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -364,6 +364,19 @@ class ServiceWorkLogic extends BaseLogic
             ];
             ServiceWorkerAllocateWorkerLogic::add($work_log);
             Db::commit();
+            // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
+            $workDetail = ServiceWorkLogic::detail($params);
+            $res = event('Notice',  [
+                'scene_id' => 113,
+                'params' => [
+                    'user_id' => $params['master_worker_id'],
+                    'order_id' => $params['id'],
+                    'thing9' => $workDetail['title'],
+                    'time7' => $workDetail['appointment_time'],
+                    'thing8' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],
+                    'phone_number6' => asteriskString($workDetail['mobile']),
+                ]
+            ]);
             return true;
         }catch(\Exception $e){
             Db::rollback();
@@ -522,7 +535,15 @@ class ServiceWorkLogic extends BaseLogic
             ->each(function ($item){
                 $item['amount'] = $item['action'] == 1 ? '+'.$item['amount'] : '-'.$item['amount'];
             })->toArray();
-
+        //保修工单时的信息
+        $result['effective_income_amount'] = 0;
+        if(!empty($result['order_effective_id'])){
+            $order_effective = OrderEffectiveLog:: findOrEmpty($result['order_effective_id']);
+            $serviceWork = ServiceWork::findOrEmpty($order_effective->work_id);
+            if($serviceWork->master_worker_id != $result['master_worker_id']){
+                $result['effective_income_amount'] = \app\adminapi\logic\effective\OrderEffectiveLogLogic::commissionAndAssuranceDeposit($serviceWork);
+            }
+        }
         return  $result;
     }
 

+ 278 - 0
app/adminapi/service/TenantCreatService.php

@@ -0,0 +1,278 @@
+<?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\adminapi\service;
+
+
+use Exception;
+use PDO;
+use PDOException;
+use think\facade\Config;
+
+/**
+ * 创建租户service
+ * Class TenantCreatService
+ * @package app\adminapi\service
+ */
+class TenantCreatService
+{
+
+    /**
+     * 数据库连接
+     */
+    private $dbh = null;
+
+    /**
+     * @notes 创建租户模式分表
+     * @param $tenantSn
+     * @return bool
+     * @throws \Random\RandomException
+     * @author yfdong
+     * @date 2024/09/28 10:55
+     */
+    public function createTenantTable($tenantSn)
+    {
+        // 创建数据库链接
+        $this->dbh = self::connectDB();
+
+        // 获取数据库版本
+        $version = self::getMysqlVersion($this->dbh);
+
+        // 获取数据库SQL文件路径
+        $dbFile = dirname(__DIR__) . '/db/tenant.sql';
+
+        // 检查文件是否存在,若不存在,直接返回错误
+        if (!file_exists($dbFile)) {
+            throw new Exception("SQL file not found: $dbFile");
+        }
+
+        // 读取并规范化SQL文件内容
+        $content = str_replace(";\r\n", ";\n", file_get_contents($dbFile));
+
+        // 对数据库中的脚本进行租户唯一标识替换
+        $content = str_replace("{tenantSn}", $tenantSn, $content);
+
+        // 分割SQL语句
+        $tables = explode(";\n", $content);
+
+        // 初始化安装时间戳
+        $installTime = microtime(true) * 10000;
+
+        // 循环处理每个SQL语句
+        foreach ($tables as $table) {
+            // 去除前后空白字符
+            $table = trim($table);
+
+            // 跳过空的SQL语句
+            if (empty($table)) continue;
+
+            // 处理数据库版本兼容性问题(版本<=4.1时移除CHARSET)
+            if (strpos($table, 'CREATE') !== false && $version <= 4.1) {
+                $table = str_replace('DEFAULT CHARSET=utf8', '', $table);
+            }
+
+            // 跳过注释的SQL语句
+            if (strpos($table, '--') === 0) continue;
+
+            // 替换表前缀
+            $table = str_replace('`la_', env('database.database', 'likeadmin_saas') . '.`la_', $table);
+            $table = str_replace('`la_', '`' . env('database.prefix', 'la_'), $table);
+
+            // 如果是创建表的SQL,记录表名和时间戳
+//            if (strpos($table, 'CREATE') !== false) {
+//                $tableName = explode('`', $table)[1];
+//                $installTime += random_int(3000, 7000); // 随机递增安装时间
+//                $successTable[] = [$tableName, date('Y-m-d H:i:s', $installTime / 10000)];
+//            }
+
+            // 执行SQL语句
+            try {
+                if (!$this->dbh->query($table)) {
+                    throw new Exception("SQL execution failed: $table");
+                }
+            } catch (Exception $e) {
+                // 捕获异常并输出详细错误信息
+                echo 'Error executing SQL: ' . htmlspecialchars($table) . "<br>";
+                echo 'Error message: ' . $e->getMessage() . "<br>";
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * @notes 初始化租户数据
+     * @param $tenantSn
+     * @return bool
+     * @throws \Random\RandomException
+     * @author yfdong
+     * @date 2024/10/01 15:43
+     */
+    public function initializationTenantData($tenantId, $tenantSn, $param)
+    {
+        // 创建数据库链接
+        $this->dbh = self::connectDB();
+
+        // 获取数据库版本
+        $version = self::getMysqlVersion($this->dbh);
+
+        // 获取数据库SQL文件路径
+        $dbFile = dirname(__DIR__) . '/db/tenantData.sql';
+
+        // 检查文件是否存在,若不存在,直接返回错误
+        if (!file_exists($dbFile)) {
+            throw new Exception("SQL file not found: $dbFile");
+        }
+
+        // 读取并规范化SQL文件内容
+        $content = str_replace(";\r\n", ";\n", file_get_contents($dbFile));
+
+        // 对数据库中的脚本进行租户唯一标识替换
+        $content = str_replace("{tenantSn}", $tenantSn, $content);
+
+        // 对数据库中的脚本进行租户唯一标识替换
+        $content = str_replace("{tenantId}", $tenantId, $content);
+
+        // 分割SQL语句
+        $tables = explode(";\n", $content);
+
+        // 初始化安装时间戳
+        $installTime = microtime(true) * 10000;
+
+        // 创建管理员账号
+        $tables[] = $this->initAccount($tenantId, $tenantSn, $param);
+
+        // 循环处理每个SQL语句
+        foreach ($tables as $table) {
+            // 去除前后空白字符
+            $table = trim($table);
+
+            // 跳过空的SQL语句
+            if (empty($table)) continue;
+
+            // 处理数据库版本兼容性问题(版本<=4.1时移除CHARSET)
+            if (strpos($table, 'CREATE') !== false && $version <= 4.1) {
+                $table = str_replace('DEFAULT CHARSET=utf8', '', $table);
+            }
+
+            // 跳过注释的SQL语句
+            if (strpos($table, '--') === 0) continue;
+
+            // 替换表前缀
+            $table = str_replace('`la_', env('database.database', 'likeadmin_saas') . '.`la_', $table);
+            $table = str_replace('`la_', '`' . env('database.prefix', 'la_'), $table);
+
+            // 执行SQL语句
+            try {
+                if (!$this->dbh->query($table)) {
+                    throw new Exception("SQL execution failed: $table");
+                }
+            } catch (Exception $e) {
+                // 捕获异常并输出详细错误信息
+                echo "初始化租户初始数据失败";
+                echo 'Error executing SQL: ' . htmlspecialchars($table) . "<br>";
+                echo 'Error message: ' . $e->getMessage() . "<br>";
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * @notes 检查数据库版本
+     * @return string
+     * @author yfdong
+     * @date 2024/10/01 13:39
+     */
+    public function getMysqlVersion($dbh)
+    {
+        $sql = "SELECT VERSION() AS version";
+        $result = $dbh->query($sql)->fetch();
+        return substr($result->version, 0, 3);
+    }
+
+
+    /**
+     * @notes 创建数据库链接
+     * @return PDO|string
+     * @author yfdong
+     * @date 2024/10/01 13:39
+     */
+    public function connectDB()
+    {
+        // 获取数据库链接
+        $host = env('database.hostname', '');
+        $port = env('database.hostport', '');
+        $user = env('database.username', '');
+        $password = env('database.password', '');
+        $dsn = "mysql:host={$host}; port={$port}";
+        try {
+            $this->dbh = new PDO($dsn, $user, $password);
+            $this->dbh->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
+            $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+            $this->dbh->exec("SET NAMES 'utf8mb4'");
+            $this->dbh->exec("SET NAMES 'utf8mb4'");
+            try {
+                $this->dbh->exec("SET GLOBAL sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';");
+            } catch (Exception $e) {
+
+            }
+            return $this->dbh;
+        } catch (PDOException $exception) {
+            return $exception->getMessage();
+        }
+    }
+
+
+    /**
+     * @notes 创建管理员账号
+     * @param $post
+     * @return string
+     * @author yfdong
+     * @date 2024/10/01 16:02
+     */
+    public function initAccount($tenantId, $tenantSn, $param)
+    {
+        $time = time();
+        $salt = Config::get('project.unique_identification');
+        $defaultPassword = Config::get('project.default_password');
+
+        global $uniqueSalt;
+        $uniqueSalt = $salt;
+
+        // 账号
+        if (isset($param['account'])) {
+            $account = $param['account'];
+        } else {
+            $account = 'admin';
+        }
+
+        //设置密码
+        if (isset($param['password'])) {
+            $password = md5($salt . md5($param['password'] . $salt));
+        } else {
+            $password = $defaultPassword;
+        }
+
+        // 超级管理员
+        $sql = "INSERT INTO `la_tenant_admin_{$tenantSn}`(`id`, `tenant_id`,`root`, `name`, `avatar`, `account`, `password`, `login_time`, `login_ip`, `multipoint_login`, `disable`, `create_time`, `update_time`, `delete_time`) VALUES (1, {$tenantId},1, '超级管理员', '', '{$account}', '{$password}','{$time}', '', 1, 0, '{$time}', '{$time}', NULL);";
+        // 超级管理员关联部门
+        $sql .= "INSERT INTO `la_tenant_admin_dept_{$tenantSn}` (`admin_id`, `dept_id`) VALUES (1, 1);";
+
+        return $sql;
+    }
+}

+ 110 - 0
app/adminapi/validate/effective/OrderEffectiveLogValidate.php

@@ -0,0 +1,110 @@
+<?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\adminapi\validate\effective;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * OrderEffectiveLog验证器
+ * Class OrderEffectiveLogValidate
+ * @package app\adminapi\validate
+ */
+class OrderEffectiveLogValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'effective_id' => 'require',
+        'sn' => 'require',
+        'user_id' => 'require',
+        'work_id' => 'require',
+        'goods_id' => 'require',
+        'effective_num' => 'require',
+        'end_effective_time' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'effective_id' => '保修卡ID',
+        'sn' => '订单编号',
+        'user_id' => '用户ID',
+        'work_id' => '工单ID',
+        'goods_id' => '商品ID',
+        'effective_num' => '值',
+        'end_effective_time' => '保修截至时间',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['effective_id','sn','user_id','work_id','goods_id','effective_num','end_effective_time']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','effective_id','sn','user_id','work_id','goods_id','effective_num','end_effective_time']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 172 - 0
app/adminapi/validate/tenant/TenantAdminValidate.php

@@ -0,0 +1,172 @@
+<?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\adminapi\validate\tenant;
+
+
+use app\common\model\auth\TenantAdmin;
+use app\common\model\tenant\Tenant;
+use app\common\validate\BaseValidate;
+
+/**
+ * 用户验证
+ * Class TenantValidate
+ * @package app\adminapi\validate\user
+ */
+class TenantAdminValidate extends BaseValidate
+{
+
+    protected $rule = [
+        'id'               => 'require|checkUser',
+        'tenant_id'        => 'require|checkTenant',
+        'account'          => 'require|length:1,32|checkAccount',
+        'name'             => 'require',
+        'password'         => 'require|length:6,32|edit',
+        'password_confirm' => 'requireWith:password|confirm',
+    ];
+
+    protected $message = [
+        'id.require'                   => '请选择用户',
+        'name.require'                 => '请输入用户名',
+        'account.require'              => '请输入账户',
+        'account.checkAccount'         => '账号已存在',
+        'account.length'               => '账号长度须在1-32位字符',
+        'tenant_id.require'            => '请选择对应的租户',
+        'password.require'             => '密码不能为空',
+        'password.length'              => '密码长度须在6-32位字符',
+        'password_confirm.requireWith' => '确认密码不能为空',
+        'password_confirm.confirm'     => '两次输入的密码不一致',
+    ];
+
+
+    /**
+     * @notes 详情场景
+     * @return TenantAdminValidate
+     * @author yfdong
+     * @date 2024/09/04 22:58
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id', 'tenant_id']);
+    }
+
+
+    /**
+     * @notes 租户信息校验
+     * @param $value
+     * @param $rule
+     * @param $data
+     * @return string|true
+     * @author yfdong
+     * @date 2024/09/04 22:57
+     */
+    public function checkUser($value, $rule, $data)
+    {
+        $userIds = TenantAdmin::findOrEmpty($value);
+        if ($userIds->isEmpty()) {
+            return '租户管理员不存在';
+        }
+        return true;
+    }
+
+    public function checkAccount($value, $rule, $data)
+    {
+        $adminAccount = TenantAdmin::where(['account' => $value, 'tenant_id' => $data['tenant_id']])->findOrEmpty();
+        if (!$adminAccount->isEmpty()) {
+            return '账号已存在';
+        }
+        return true;
+    }
+
+    /**
+     * @notes 检查对应租户号是否存在
+     * @param $value
+     * @return string|true
+     * @author yfdong
+     * @date 2024/09/04 22:16
+     */
+    public function checkTenant($value)
+    {
+        $adminTenant = Tenant::where(['id' => $value])->findOrEmpty();
+        if ($adminTenant->isEmpty()) {
+            return '对应租户账号不存在';
+        }
+        return true;
+    }
+
+    /**
+     * @notes 添加场景
+     * @return TenantAdminValidate
+     * @author yfdong
+     * @date 2024/09/04 22:57
+     */
+    public function sceneAdd()
+    {
+        return $this->remove('id', true);
+    }
+
+    /**
+     * @notes 修改场景
+     * @return TenantAdminValidate
+     * @author yfdong
+     * @date 2024/09/04 22:57
+     */
+    public function sceneEdit()
+    {
+        return $this->remove('password', true)->remove('account', true);
+    }
+
+    /**
+     * @notes 删除场景
+     * @return TenantAdminValidate
+     * @author yfdong
+     * @date 2024/09/04 22:57
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 重置密码情形
+     * @return TenantAdminValidate
+     * @author yfdong
+     * @date 2024/09/04 23:29
+     */
+    public function sceneResetPassword()
+    {
+        return $this->only(['id']);
+    }
+
+    /**
+     * @notes 编辑情况下,检查是否填密码
+     * @param $value
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @author 段誉
+     * @date 2021/12/29 10:19
+     */
+    public function edit($value, $rule, $data)
+    {
+        if (empty($data['password']) && empty($data['password_confirm'])) {
+            return true;
+        }
+        $len = strlen($value);
+        if ($len < 6 || $len > 32) {
+            return '密码长度须在6-32位字符';
+        }
+        return true;
+    }
+}

+ 141 - 0
app/adminapi/validate/tenant/TenantValidate.php

@@ -0,0 +1,141 @@
+<?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\adminapi\validate\tenant;
+
+
+use app\common\model\tenant\Tenant;
+use app\common\validate\BaseValidate;
+
+/**
+ * 用户验证
+ * Class TenantValidate
+ * @package app\adminapi\validate\user
+ */
+class TenantValidate extends BaseValidate
+{
+
+    protected $rule = [
+        'id'   => 'require|checkUser',
+        'name' => 'require',
+        'domain_alias' => 'checkDomainAlias'
+    ];
+
+    protected $message = [
+        'id.require'   => '请选择用户',
+        'name.require' => '请输入用户名',
+    ];
+
+
+    /**
+     * @notes 详情场景
+     * @return TenantValidate
+     * @author 段誉
+     * @date 2022/9/22 16:35
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 租户信息校验
+     * @param $value
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @author 段誉
+     * @date 2022/9/22 17:03
+     */
+    public function checkUser($value, $rule, $data)
+    {
+        $userIds = Tenant::findOrEmpty($value);
+        if ($userIds->isEmpty()) {
+            return '租户不存在';
+        }
+        return true;
+    }
+
+    /**
+     * @notes 域名校验
+     * @param $value
+     * @param $rule
+     * @param $data
+     * @return string|true
+     * @author JXDN
+     * @date 2024/09/11 15:30
+     */
+    public function checkDomainAlias($value, $rule, $data)
+    {
+        $tenant = Tenant::where(['domain_alias' => $value])->findOrEmpty();
+        if (!$tenant->isEmpty()) {
+            return '租户别名已存在';
+        }
+        return true;
+    }
+
+    /**
+     * @notes 域名校验
+     * @param $value
+     * @param $rule
+     * @param $data
+     * @return string|true
+     * @author JXDN
+     * @date 2024/09/11 15:30
+     */
+    public function checkDomainAliasEdit($value, $rule, $data)
+    {
+        $tenant = Tenant::where('domain_alias', $value)
+            ->where('id', '<>', $data['id']) // 排除当前租户
+            ->findOrEmpty();
+        if (!$tenant->isEmpty()) {
+            return '租户别名已存在';
+        }
+        return true;
+    }
+
+
+    /**
+     * @notes 添加场景
+     * @return TenantValidate
+     * @author 段誉
+     * @date 2022/5/25 18:16
+     */
+    public function sceneAdd()
+    {
+        return $this->remove('id', true);
+    }
+
+    /**
+     * @notes 编辑场景
+     * @return TenantValidate
+     * @author JXDN
+     * @date 2024/09/11 15:31
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id', 'name'])->append('domain_alias', 'checkDomainAliasEdit');
+    }
+
+    /**
+     * @notes 删除场景
+     * @return TenantValidate
+     * @author 段誉
+     * @date 2022/5/25 18:16
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+}

+ 2 - 0
app/api/controller/BaseApiController.php

@@ -15,6 +15,7 @@
 namespace app\api\controller;
 
 use app\common\controller\BaseLikeAdminController;
+use app\common\enum\AdminTerminalEnum;
 
 class BaseApiController extends BaseLikeAdminController
 {
@@ -23,6 +24,7 @@ class BaseApiController extends BaseLikeAdminController
 
     public function initialize()
     {
+        $this->request->source = AdminTerminalEnum::USER;
         if (isset($this->request->userInfo) && $this->request->userInfo) {
             $this->userInfo = $this->request->userInfo;
             $this->userId = $this->request->userInfo['user_id'];

+ 25 - 0
app/api/controller/OrderEffectiveController.php

@@ -3,11 +3,36 @@
 namespace app\api\controller;
 
 use app\api\lists\OrderEffectiveLogLists;
+use app\api\logic\OrderEffectiveLogLogic;
+use app\api\validate\OrderEffectiveLogValidate;
 
 class OrderEffectiveController extends BaseApiController
 {
+    public array $notNeedLogin = ['submitEffective'];
     public function lists()
     {
         return $this->dataLists(new OrderEffectiveLogLists());
     }
+
+
+    /**
+     * 提交保修申请
+     * @return \think\response\Json
+     */
+    public function submitEffective()
+    {
+        $params = (new OrderEffectiveLogValidate())->post()->goCheck('applyFor', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = OrderEffectiveLogLogic::submitEffective($params);
+        if (false === $result) {
+            return $this->fail(OrderEffectiveLogLogic::getError());
+        }
+        return $this->success('提交成功', [], 1, 1);
+    }
+
+
+
+
 }

+ 2 - 2
app/api/lists/OrderEffectiveLogLists.php

@@ -22,9 +22,9 @@ class OrderEffectiveLogLists  extends BaseApiDataLists
            $query->with(['goodsCategory'=>function ($query1) {
                $query1->field(['name','picture']);
            }]);
-       }])->where($this->queryWhere())
+       },'serviceWork'])->where($this->queryWhere())
            ->limit($this->limitOffset, $this->limitLength)
-           ->field(['id','goods_id','sn','effective_unit','effective_num','remark','end_effective_time'])
+           ->field(['*'])
            ->append(['effective_unit_text'])
            ->order('create_time desc')
            ->select()

+ 62 - 0
app/api/logic/OrderEffectiveLogLogic.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\api\logic;
+
+
+use app\common\model\orders\OrderEffectiveLog;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * OrderEffectiveLog逻辑
+ * Class OrderEffectiveLogLogic
+ * @package app\api\logic
+ */
+class OrderEffectiveLogLogic extends BaseLogic
+{
+
+    /**
+     * @notes 提交保修工单申请
+     */
+    public static function submitEffective(array $params): bool
+    {
+        //Db::startTrans();
+        try {
+            $info = OrderEffectiveLog::find($params['id']);
+            if($info['end_effective_time'] < time()){
+                throw new \Exception('该保修卡已过期');
+            }
+            if($info['effective_status'] > 0){
+                throw new \Exception('该保修卡已提交过');
+            }
+
+            OrderEffectiveLog::where('id', $params['id'])->update([
+                'effective_images' => json_encode($params['effective_images']),
+                'remark' => $params['remark'] ?? '',
+                'effective_status' => 1,
+                'effective_time' => time()
+            ]);
+
+            //Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            //Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+}

+ 58 - 0
app/api/logic/PerformanceLogic.php

@@ -7,6 +7,7 @@ use app\common\logic\BaseLogic;
 use app\common\logic\EffectiveLogic;
 use app\common\logic\WorkAddMoneyLogic;
 use app\common\logic\WorkerAccountLogLogic;
+use app\common\model\orders\OrderEffectiveLog;
 use app\common\model\master_commission\MasterWorkerCommissionConfig;
 use app\common\model\master_commission\MasterWorkerCommissionRatio;
 use app\common\model\master_worker\MasterWorker;
@@ -14,6 +15,8 @@ use app\common\model\orders\RechargeOrder;
 use app\common\model\performance\PerformanceRules;
 use app\common\model\recharge\OrderGoods;
 use app\common\logic\RetentionMoneyLogic;
+use app\common\model\works\ServiceWork;
+use app\common\model\works\ServiceWorkLog;
 use think\facade\Db;
 use think\facade\Log;
 
@@ -187,4 +190,59 @@ class PerformanceLogic extends BaseLogic
         EffectiveLogic::receiveEffective($work);
     }
 
+    /**
+     * @notes 保修单结算
+     * @param $work
+     * @return bool|mixed
+     */
+    public static function effectivePerformance($work)
+    {
+        if(empty($work->order_effective_id)){
+            return false;
+        }
+        Log::info('effectivePerformance:'.json_encode($work->toArray()));
+        // 判断该工单是否为新工程师 - 保修前工单的工程师是谁
+        $orderEffectiveLog = OrderEffectiveLog::where('id',$work->order_effective_id)->findOrEmpty();
+        if($orderEffectiveLog->effective_status == 3){
+            return false;
+        }
+        // 前工单
+        $serviceWork = ServiceWork::where('id',$orderEffectiveLog->work_id)->findOrEmpty();
+        if($serviceWork->master_worker_id != $work->master_worker_id){
+            // 扣掉 原工单工程师的提成+质保金 to 新工程师余额  + 惩罚金额
+            $income_fee = \app\adminapi\logic\effective\OrderEffectiveLogLogic::commissionAndAssuranceDeposit($serviceWork);
+            $new_amount = bcadd((string)$income_fee,(string)$orderEffectiveLog->penalty_amount,2);
+
+            $remark = '工单号:'.$work->work_sn.',扣除金额:'.$new_amount.',扣除原因:保修工单新工程师收益';
+            RetentionMoneyLogic::refundRetention([
+                'remark'=>$remark,
+                'work_id'=>$work->id,
+                'worker_id'=>$serviceWork->master_worker_id,
+                'amount'=>$new_amount
+            ],false);
+
+            // 新工程师收益: 原工单工程师的提成+质保金
+            $remark = '保修单结算-工单号:'.$work->work_sn.',收益金额:'.$income_fee.',原因:保修工单新工程师收益';
+            WorkerAccountLogLogic::addAccountLog($work,$income_fee,WorkerAccountLogEnum::UM_INC_ADMIN,WorkerAccountLogEnum::INC,$remark);
+
+            Log::info('effectivePerformance:'.$remark);
+        }else{
+            $new_amount = $orderEffectiveLog->penalty_amount;
+
+            $remark = '工单号:'.$work->work_sn.',扣除金额:'.$new_amount.',扣除原因:保修工单原工程师差额|罚金';
+            RetentionMoneyLogic::refundRetention([
+                'remark'=>$remark,
+                'work_id'=>$work->id,
+                'worker_id'=>$serviceWork->master_worker_id,
+                'amount'=>$new_amount
+            ],false);
+        }
+        $orderEffectiveLog->effective_status = 3;
+        $orderEffectiveLog->save();
+
+        $work->work_pay_status = 2;
+        $work->save();
+
+        return true;
+    }
 }

+ 36 - 2
app/api/logic/ServiceOrderLogic.php

@@ -20,6 +20,7 @@ use app\common\model\master_commission\MasterWorkerCommissionConfig;
 use app\common\model\master_commission\MasterWorkerCommissionNotice;
 use app\common\model\master_worker\MasterWorker;
 use app\common\model\master_worker\MasterWorkerRule;
+use app\common\model\orders\OrderEffectiveLog;
 use app\common\model\orders\RechargeOrder;
 use app\common\model\property\PropertyActivity;
 use app\common\model\recharge\OrderGoods;
@@ -541,7 +542,15 @@ class ServiceOrderLogic extends BaseLogic
                 $propertyActivity = PropertyActivity::findOrEmpty($order_info['service_work']['property_activity_id']);
                 $order_info['service_work']['url_page'] = rawurlencode($params['domain'].'/static/wxapp/H5/'.$propertyActivity['url_page'].'/index.html?property_activity_id='.$propertyActivity['id'].'&token='.$params['user_info']['token']);
             }
-
+            //保修工单时的信息
+            $order_info['effective_income_amount'] = 0;
+            if(!empty($order_info['service_work']['order_effective_id'])){
+                $order_effective = OrderEffectiveLog:: findOrEmpty($order_info['service_work']['order_effective_id']);
+                $serviceWork = ServiceWork::findOrEmpty($order_effective->work_id);
+                if($serviceWork->master_worker_id != $order_info['service_work']['master_worker_id']){
+                    $order_info['effective_income_amount'] = \app\adminapi\logic\effective\OrderEffectiveLogLogic::commissionAndAssuranceDeposit($serviceWork);
+                }
+            }
             return $order_info;
         }
         catch (\Exception $e) {
@@ -845,8 +854,33 @@ class ServiceOrderLogic extends BaseLogic
                 $service_work->user_confirm_status = 4;
             }
             $service_work->finished_time = time();
-
             $service_work->save();
+
+
+            //保修工单时,且尾款=0,直接支付无需用户操作支付
+            if($service_work->order_effective_id >0){
+                $paid_amount = 0;
+                $order_id = 0;
+                foreach ($orders as $order) {
+                    if($order['payment_type'] == 2) $order_id = $order['id'];
+                    $paid_amount += $order['order_amount'];
+                }
+                if($paid_amount == 0){
+                    // 直接支付
+                    $order = PaymentLogic::getPayOrderInfo(['order_id'=>$order_id]);
+                    if ($order) {
+                        //支付流程
+                        $result = PaymentLogic::workerPay(1, 'goods', $order, ['terminal'=>0], '');
+                        /*if ($result && ($result['need_pay'] == 0)) {
+                            $service_work->work_status = 7;
+                            $service_work->user_confirm_status = 5;
+                            $service_work->service_status = 3;
+                            $service_work->work_pay_status = 1;
+                        }*/
+                    }
+                }
+            }
+
             //更新工程师的进行工单数量
             MasterWorker::setWorktotal('dec',$service_work->master_worker_id);
             $work_log = [

+ 1 - 1
app/api/validate/LoginAccountValidate.php

@@ -78,7 +78,7 @@ class LoginAccountValidate extends BaseValidate
         // 手机验证码登录
         if (LoginEnum::MOBILE_CAPTCHA == $scene) {
             //微信小程序提交版本测试
-            if($data['account'] == '13545228441'){
+            if($data['account'] == '13545228441' || $data['account'] == '17362953140'){
                 return true;
             }
             if (!isset($data['code'])) {

+ 116 - 0
app/api/validate/OrderEffectiveLogValidate.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\api\validate;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * OrderEffectiveLog验证器
+ * Class OrderEffectiveLogValidate
+ * @package app\api\validate
+ */
+class OrderEffectiveLogValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'effective_id' => 'require',
+        'sn' => 'require',
+        'user_id' => 'require',
+        'work_id' => 'require',
+        'goods_id' => 'require',
+        'effective_num' => 'require',
+        'end_effective_time' => 'require',
+        'effective_images' => 'require'
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'effective_id' => '保修卡ID',
+        'sn' => '订单编号',
+        'user_id' => '用户ID',
+        'work_id' => '工单ID',
+        'goods_id' => '商品ID',
+        'effective_num' => '值',
+        'end_effective_time' => '保修截至时间',
+        'effective_images' => '保修图片/视频',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['effective_id','sn','user_id','work_id','goods_id','effective_num','end_effective_time']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','effective_id','sn','user_id','work_id','goods_id','effective_num','end_effective_time']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return OrderEffectiveLogValidate
+     * @author likeadmin
+     * @date 2025/01/17 11:10
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+    public function sceneApplyFor()
+    {
+        return $this->only(['id','effective_images']);
+    }
+
+}

+ 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);
+    }
+
+
+}

+ 49 - 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,53 @@ class AdminTerminalEnum
 {
     const PC = 1;
     const MOBILE = 2;
+
+    const PLATFORM = '__saas__platform__';
+    const TENANT = '__saas__tenant__';
+    const USER = '__saas__user__';
+    const Worker = '__saas__worker__';
+
+    /**
+     * @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;
+    }
+
+    /**
+     * @notes 是否为工程师端
+     * @return bool
+     * @author JXDN
+     * @date 2024/09/04 16:44
+     */
+    public static function isWorker()
+    {
+        return request()->source === self::Worker;
+    }
 }

+ 116 - 6
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,16 +28,124 @@ 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 = [])
+    {
+        // 设置跨域头
+        $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];
+
+        if($firstSegment === 'tenantapi'){
+            return $this->handleTenantAccess($tenantModel, $domain, $request, $next, true);
+        }else{
+            return $this->apiHandle($request, $next);
+        }
+    }
+
+    /**
+     * 设置跨域头信息
+     */
+    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);
+    }
+
+    public function apiHandle($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");
@@ -46,5 +157,4 @@ class LikeAdminAllowMiddleware
         }
         return $next($request);
     }
-
-}
+}

+ 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 令狐冲

+ 3 - 2
app/common/logic/RetentionMoneyLogic.php

@@ -190,8 +190,9 @@ class RetentionMoneyLogic extends BaseLogic
             $earnest_money_usable = $masterWorkerInfo->earnest_money_usable - $params['amount'];
             if($earnest_money_usable < 0){
                 Log::info('RetentionMoneyLogic-refundRetention-error:退可用质保金不足:'.$earnest_money_usable.',可用质保金:'.$masterWorkerInfo->earnest_money_usable);
-                $earnest_money_usable = 0;
-                $params['amount'] = $masterWorkerInfo->earnest_money_usable;
+                //允许负数
+                //$earnest_money_usable = 0;
+                //$params['amount'] = $masterWorkerInfo->earnest_money_usable;
             }
             $masterWorkerInfo->earnest_money_usable = $earnest_money_usable;
             // 是否要扣到 冻结 里面?

+ 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'] ? '正常' : '停用';
+    }
+}

+ 35 - 0
app/common/model/effective/OrderEffectiveLog.php

@@ -0,0 +1,35 @@
+<?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\effective;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * OrderEffectiveLog模型
+ * Class OrderEffectiveLog
+ * @package app\common\model
+ */
+class OrderEffectiveLog extends BaseModel
+{
+    
+    protected $name = 'order_effective_log';
+    protected $type = [
+        'effective_images' => 'array',
+    ];
+    
+}

+ 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';
+}

+ 14 - 1
app/common/model/orders/OrderEffectiveLog.php

@@ -2,6 +2,7 @@
 namespace app\common\model\orders;
 use app\common\model\BaseModel;
 use app\common\model\goods\Goods;
+use app\common\model\works\ServiceWork;
 
 /**
  * @author 林海涛
@@ -10,12 +11,24 @@ use app\common\model\goods\Goods;
 class OrderEffectiveLog extends BaseModel
 {
     protected $name = 'order_effective_log';
-
+    protected $type = [
+        'effective_images' => 'array',
+    ];
     public function goods()
     {
         return $this->hasOne(Goods::class, 'id', 'goods_id');
     }
 
+    public function originalServiceWork()
+    {
+        return $this->hasOne(ServiceWork::class, 'id', 'work_id');
+    }
+
+
+    public function serviceWork()
+    {
+        return $this->hasOne(ServiceWork::class, 'order_effective_id', 'id');
+    }
 
     public function getEndEffectiveTimeAttr($value,$data)
     {

+ 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;
+    }
+
+}

+ 17 - 12
app/common/model/works/ServiceWork.php

@@ -41,20 +41,25 @@ class ServiceWork extends BaseModel
     public static function onAfterUpdate($model)
     {
         if($model->user_confirm_status == 5 and $model->work_status == 7 and $model->work_pay_status==1){
-            //工单已完结,进行结算,结算完成后设置work_pay_status为2,已结算
-            $ratio = 0;
-            $commissionConfig = MasterWorkerCommissionConfig::where('master_worker_id',$model->master_worker_id)->where('voucher_status',2)->findOrEmpty();
-            !$commissionConfig->isEmpty() && $ratio = MasterWorkerCommissionRatio::where('commission_config_id',$commissionConfig['id'])->where('goods_category_id',$model->goods_category_id)->value('ratio')?:0;
-            if($commissionConfig->isEmpty() || empty($ratio)){
-                PerformanceLogic::calculatePerformance($model);
+            // 保修工单完结,若新工程师则进行结算,用户支付的尾款不再提成
+            if($model->order_effective_id >0){
+                PerformanceLogic::effectivePerformance($model);
             }else{
-                // 存在服务分类比例进行结算
-                PerformanceLogic::calculatePerformanceCommission($model);
+                //工单已完结,进行结算,结算完成后设置work_pay_status为2,已结算
+                $ratio = 0;
+                $commissionConfig = MasterWorkerCommissionConfig::where('master_worker_id',$model->master_worker_id)->where('voucher_status',2)->findOrEmpty();
+                !$commissionConfig->isEmpty() && $ratio = MasterWorkerCommissionRatio::where('commission_config_id',$commissionConfig['id'])->where('goods_category_id',$model->goods_category_id)->value('ratio')?:0;
+                if($commissionConfig->isEmpty() || empty($ratio)){
+                    PerformanceLogic::calculatePerformance($model);
+                }else{
+                    // 存在服务分类比例进行结算
+                    PerformanceLogic::calculatePerformanceCommission($model);
+                }
+                // 优惠券逆向为活动工单+代理订单
+                event('ReverseCouponToActivity',['id'=>$model->id]);
+                //工单已完结, - 物业后续分成事件 $params['user_id']) || empty($params['sn']
+                event('PropertyCommission',['id'=>$model->id]);
             }
-            // 优惠券逆向为活动工单+代理订单
-            event('ReverseCouponToActivity',['id'=>$model->id]);
-            //工单已完结, - 物业后续分成事件 $params['user_id']) || empty($params['sn']
-            event('PropertyCommission',['id'=>$model->id]);
         }
     }
     //分配记录

+ 42 - 16
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::isTenant()) {
+            $options['tenant_id'] = request()->tenantId;
+            $query['tenant_id'] = request()->tenantId;
+        }
+        $data = (AdminTerminalEnum::isTenant() ? new TenantConfig() : new Config())->where($query)->findOrEmpty();
 
         if ($data->isEmpty()) {
-            Config::create([
-                'type' => $type,
-                'name' => $name,
-                'value' => $value,
-            ]);
+
+            (AdminTerminalEnum::isTenant() ? 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::isTenant() ? new Config() : new TenantConfig();
+            // 判断是否为租户端
+            if (AdminTerminalEnum::isTenant()) {
+                $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 ($value) {
-                return $value;
+                if (json_last_error() === JSON_ERROR_NONE) {
+                    $value = $json;
+                }
             }
-            // 返回特殊值 0 '0'
-            if ($value === 0 || $value === '0') {
+            // 返回配置值
+            if ($value !== null) {
+                // 处理特殊值
+                if ($value === 0 || $value === '0') {
+                    return $value;
+                }
                 return $value;
             }
             // 返回默认值

+ 1 - 0
app/common/service/pay/WeChatPayService.php

@@ -89,6 +89,7 @@ class WeChatPayService extends BasePayService
      */
     public function pay($from, $order)
     {
+
         try {
             switch ($this->terminal) {
                 case UserTerminalEnum::WECHAT_MMP:

+ 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();
+    }
+
+
+
+}

Неке датотеке нису приказане због велике количине промена