浏览代码

提交自动派单功能

dongxiaoqin 1 年之前
父节点
当前提交
b68646afaa
共有 100 个文件被更改,包括 9209 次插入89 次删除
  1. 1 5
      app/adminapi/controller/master_worker/MasterWorkerController.php
  2. 108 0
      app/adminapi/controller/training/TrainingCourseController.php
  3. 108 0
      app/adminapi/controller/training/TrainingQuestionsController.php
  4. 108 0
      app/adminapi/controller/training/TrainingTaskController.php
  5. 108 0
      app/adminapi/controller/training/TrainingWorkerCourseController.php
  6. 108 0
      app/adminapi/controller/training/TrainingWorkerTaskController.php
  7. 1 1
      app/adminapi/controller/works/ReturnWorkController.php
  8. 13 0
      app/adminapi/controller/works/ServiceWorkController.php
  9. 14 14
      app/adminapi/lists/master_worker/MasterWorkerLists.php
  10. 2 2
      app/adminapi/lists/tenant/TenantLists.php
  11. 78 0
      app/adminapi/lists/training/TrainingCourseLists.php
  12. 78 0
      app/adminapi/lists/training/TrainingQuestionsLists.php
  13. 78 0
      app/adminapi/lists/training/TrainingTaskLists.php
  14. 78 0
      app/adminapi/lists/training/TrainingWorkerCourseLists.php
  15. 84 0
      app/adminapi/lists/training/TrainingWorkerTaskLists.php
  16. 1 1
      app/adminapi/lists/works/ServiceWorkLists.php
  17. 14 7
      app/adminapi/logic/master_worker/MasterWorkerLogic.php
  18. 11 4
      app/adminapi/logic/master_worker/MasterWorkerTeamLogic.php
  19. 32 3
      app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php
  20. 127 0
      app/adminapi/logic/training/TrainingCourseLogic.php
  21. 136 0
      app/adminapi/logic/training/TrainingQuestionsLogic.php
  22. 108 0
      app/adminapi/logic/training/TrainingTaskLogic.php
  23. 124 0
      app/adminapi/logic/training/TrainingWorkerCourseLogic.php
  24. 156 0
      app/adminapi/logic/training/TrainingWorkerTaskLogic.php
  25. 41 8
      app/adminapi/logic/works/ServiceWorkLogic.php
  26. 110 0
      app/adminapi/validate/training/TrainingCourseValidate.php
  27. 108 0
      app/adminapi/validate/training/TrainingQuestionsValidate.php
  28. 99 0
      app/adminapi/validate/training/TrainingTaskValidate.php
  29. 116 0
      app/adminapi/validate/training/TrainingWorkerCourseValidate.php
  30. 110 0
      app/adminapi/validate/training/TrainingWorkerTaskValidate.php
  31. 2 1
      app/api/logic/IssueWorkLogic.php
  32. 38 1
      app/common.php
  33. 1 0
      app/common/cache/MasterWokerTokenCache.php
  34. 3 1
      app/common/cache/TenantAdminTokenCache.php
  35. 5 1
      app/common/http/middleware/LikeAdminAllowMiddleware.php
  36. 37 3
      app/common/logic/TableDataLogic.php
  37. 36 0
      app/common/model/training/TrainingCourse.php
  38. 36 0
      app/common/model/training/TrainingQuestions.php
  39. 36 0
      app/common/model/training/TrainingTask.php
  40. 47 0
      app/common/model/training/TrainingWorkerCourse.php
  41. 37 0
      app/common/model/training/TrainingWorkerQuestion.php
  42. 49 0
      app/common/model/training/TrainingWorkerTask.php
  43. 92 35
      app/common/service/UploadService.php
  44. 1 1
      app/tenantapi/controller/FileController.php
  45. 39 0
      app/tenantapi/controller/finance/AccountLogController.php
  46. 108 0
      app/tenantapi/controller/finance/MasterWorkerCaseOutLogController.php
  47. 72 0
      app/tenantapi/controller/finance/RefundController.php
  48. 39 0
      app/tenantapi/controller/finance/WorkerAccountLogController.php
  49. 112 0
      app/tenantapi/controller/goods_category/GoodsCategoryController.php
  50. 119 0
      app/tenantapi/controller/master_worker/BankAccountController.php
  51. 129 0
      app/tenantapi/controller/master_worker/EngineerBillController.php
  52. 124 0
      app/tenantapi/controller/master_worker/EngineerSettlementController.php
  53. 120 0
      app/tenantapi/controller/master_worker/MasterWorkerAgreeController.php
  54. 129 0
      app/tenantapi/controller/master_worker/MasterWorkerController.php
  55. 109 0
      app/tenantapi/controller/master_worker/MasterWorkerExamineController.php
  56. 116 0
      app/tenantapi/controller/master_worker/MasterWorkerInfoController.php
  57. 108 0
      app/tenantapi/controller/master_worker/MasterWorkerRuleController.php
  58. 66 0
      app/tenantapi/controller/master_worker/MasterWorkerServiceOrderController.php
  59. 108 0
      app/tenantapi/controller/master_worker/MasterWorkerTeamController.php
  60. 37 0
      app/tenantapi/controller/master_worker/RetentionMoneyLogController.php
  61. 135 0
      app/tenantapi/controller/notice/NoticeController.php
  62. 107 0
      app/tenantapi/controller/recharge/RechargeController.php
  63. 108 0
      app/tenantapi/controller/works/IssueWorkController.php
  64. 147 0
      app/tenantapi/controller/works/ReturnWorkController.php
  65. 210 0
      app/tenantapi/controller/works/ServiceWorkController.php
  66. 2 0
      app/tenantapi/lists/file/FileLists.php
  67. 119 0
      app/tenantapi/lists/finance/AccountLogLists.php
  68. 97 0
      app/tenantapi/lists/finance/MasterWorkerCaseOutLogLists.php
  69. 79 0
      app/tenantapi/lists/finance/RefundLogLists.php
  70. 151 0
      app/tenantapi/lists/finance/RefundRecordLists.php
  71. 101 0
      app/tenantapi/lists/finance/WorkerAccountLogLists.php
  72. 79 0
      app/tenantapi/lists/goods_category/GoodsCategoryLists.php
  73. 107 0
      app/tenantapi/lists/master_worker/BankAccountLists.php
  74. 147 0
      app/tenantapi/lists/master_worker/EngineerBillLists.php
  75. 90 0
      app/tenantapi/lists/master_worker/EngineerSettlementLists.php
  76. 106 0
      app/tenantapi/lists/master_worker/MasterWorkerAgreeLists.php
  77. 118 0
      app/tenantapi/lists/master_worker/MasterWorkerExamineLists.php
  78. 106 0
      app/tenantapi/lists/master_worker/MasterWorkerInfoLists.php
  79. 225 0
      app/tenantapi/lists/master_worker/MasterWorkerLists.php
  80. 78 0
      app/tenantapi/lists/master_worker/MasterWorkerRuleLists.php
  81. 202 0
      app/tenantapi/lists/master_worker/MasterWorkerServiceOrderLists.php
  82. 79 0
      app/tenantapi/lists/master_worker/MasterWorkerTeamLists.php
  83. 104 0
      app/tenantapi/lists/master_worker/MoneyAnalysis.php
  84. 88 0
      app/tenantapi/lists/master_worker/RetentionMoneyLogLists.php
  85. 71 0
      app/tenantapi/lists/notice/NoticeSettingLists.php
  86. 146 0
      app/tenantapi/lists/recharge/RechargeLists.php
  87. 162 0
      app/tenantapi/lists/works/IssueWorkLists.php
  88. 127 0
      app/tenantapi/lists/works/ReturnWorkLists.php
  89. 200 0
      app/tenantapi/lists/works/ServiceWorkLists.php
  90. 10 1
      app/tenantapi/logic/ConfigLogic.php
  91. 1 0
      app/tenantapi/logic/FileLogic.php
  92. 144 0
      app/tenantapi/logic/effective/EffectiveRulesLogic.php
  93. 287 0
      app/tenantapi/logic/effective/OrderEffectiveLogLogic.php
  94. 113 0
      app/tenantapi/logic/finance/MasterWorkerCaseOutLogLogic.php
  95. 97 0
      app/tenantapi/logic/finance/RefundLogic.php
  96. 133 0
      app/tenantapi/logic/goods_category/GoodsCategoryLogic.php
  97. 129 0
      app/tenantapi/logic/master_worker/BankAccountLogic.php
  98. 121 0
      app/tenantapi/logic/master_worker/EngineerBillLogic.php
  99. 346 0
      app/tenantapi/logic/master_worker/EngineerSettlementLogic.php
  100. 122 0
      app/tenantapi/logic/master_worker/MasterWorkerAgreeLogic.php

+ 1 - 5
app/adminapi/controller/master_worker/MasterWorkerController.php

@@ -128,10 +128,6 @@ class MasterWorkerController extends BaseAdminController
     public function getAllWorkers()
     {
         $params = (new MasterWorkerValidate())->get();
-        $result = MasterWorkerLogic::getAllWorkers($params);
-        if (false === $result) {
-            return $this->fail(MasterWorkerLogic::getError());
-        }
-        return $this->data($result);
+        return $this->data(MasterWorkerLogic::getAllWorkers($params));
     }
 }

+ 108 - 0
app/adminapi/controller/training/TrainingCourseController.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\training\TrainingCourseLists;
+use app\adminapi\logic\training\TrainingCourseLogic;
+use app\adminapi\validate\training\TrainingCourseValidate;
+
+
+/**
+ * TrainingCourse控制器
+ * Class TrainingCourseController
+ * @package app\adminapi\controller
+ */
+class TrainingCourseController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TrainingCourseLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function add()
+    {
+        $params = (new TrainingCourseValidate())->post()->goCheck('add');
+        $result = TrainingCourseLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(TrainingCourseLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function edit()
+    {
+        $params = (new TrainingCourseValidate())->post()->goCheck('edit');
+        $result = TrainingCourseLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(TrainingCourseLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function delete()
+    {
+        $params = (new TrainingCourseValidate())->post()->goCheck('delete');
+        TrainingCourseLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function detail()
+    {
+        $params = (new TrainingCourseValidate())->goCheck('detail');
+        $result = TrainingCourseLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 108 - 0
app/adminapi/controller/training/TrainingQuestionsController.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\training\TrainingQuestionsLists;
+use app\adminapi\logic\training\TrainingQuestionsLogic;
+use app\adminapi\validate\training\TrainingQuestionsValidate;
+
+
+/**
+ * TrainingQuestions控制器
+ * Class TrainingQuestionsController
+ * @package app\adminapi\controller
+ */
+class TrainingQuestionsController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TrainingQuestionsLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function add()
+    {
+        $params = (new TrainingQuestionsValidate())->post()->goCheck('add');
+        $result = TrainingQuestionsLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(TrainingQuestionsLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function edit()
+    {
+        $params = (new TrainingQuestionsValidate())->post()->goCheck('edit');
+        $result = TrainingQuestionsLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(TrainingQuestionsLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function delete()
+    {
+        $params = (new TrainingQuestionsValidate())->post()->goCheck('delete');
+        TrainingQuestionsLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function detail()
+    {
+        $params = (new TrainingQuestionsValidate())->goCheck('detail');
+        $result = TrainingQuestionsLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 108 - 0
app/adminapi/controller/training/TrainingTaskController.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\training\TrainingTaskLists;
+use app\adminapi\logic\training\TrainingTaskLogic;
+use app\adminapi\validate\training\TrainingTaskValidate;
+
+
+/**
+ * TrainingTask控制器
+ * Class TrainingTaskController
+ * @package app\adminapi\controller
+ */
+class TrainingTaskController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TrainingTaskLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function add()
+    {
+        $params = (new TrainingTaskValidate())->post()->goCheck('add');
+        $result = TrainingTaskLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(TrainingTaskLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function edit()
+    {
+        $params = (new TrainingTaskValidate())->post()->goCheck('edit');
+        $result = TrainingTaskLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(TrainingTaskLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function delete()
+    {
+        $params = (new TrainingTaskValidate())->post()->goCheck('delete');
+        TrainingTaskLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function detail()
+    {
+        $params = (new TrainingTaskValidate())->goCheck('detail');
+        $result = TrainingTaskLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 108 - 0
app/adminapi/controller/training/TrainingWorkerCourseController.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\training\TrainingWorkerCourseLists;
+use app\adminapi\logic\training\TrainingWorkerCourseLogic;
+use app\adminapi\validate\training\TrainingWorkerCourseValidate;
+
+
+/**
+ * TrainingWorkerCourse控制器
+ * Class TrainingWorkerCourseController
+ * @package app\adminapi\controller
+ */
+class TrainingWorkerCourseController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TrainingWorkerCourseLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function add()
+    {
+        $params = (new TrainingWorkerCourseValidate())->post()->goCheck('add');
+        $result = TrainingWorkerCourseLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(TrainingWorkerCourseLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function edit()
+    {
+        $params = (new TrainingWorkerCourseValidate())->post()->goCheck('edit');
+        $result = TrainingWorkerCourseLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(TrainingWorkerCourseLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function delete()
+    {
+        $params = (new TrainingWorkerCourseValidate())->post()->goCheck('delete');
+        TrainingWorkerCourseLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function detail()
+    {
+        $params = (new TrainingWorkerCourseValidate())->goCheck('detail');
+        $result = TrainingWorkerCourseLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 108 - 0
app/adminapi/controller/training/TrainingWorkerTaskController.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\training\TrainingWorkerTaskLists;
+use app\adminapi\logic\training\TrainingWorkerTaskLogic;
+use app\adminapi\validate\training\TrainingWorkerTaskValidate;
+
+
+/**
+ * TrainingWorkerTask控制器
+ * Class TrainingWorkerTaskController
+ * @package app\adminapi\controller
+ */
+class TrainingWorkerTaskController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TrainingWorkerTaskLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function add()
+    {
+        $params = (new TrainingWorkerTaskValidate())->post()->goCheck('add');
+        $result = TrainingWorkerTaskLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(TrainingWorkerTaskLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function edit()
+    {
+        $params = (new TrainingWorkerTaskValidate())->post()->goCheck('edit');
+        $result = TrainingWorkerTaskLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(TrainingWorkerTaskLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function delete()
+    {
+        $params = (new TrainingWorkerTaskValidate())->post()->goCheck('delete');
+        TrainingWorkerTaskLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function detail()
+    {
+        $params = (new TrainingWorkerTaskValidate())->goCheck('detail');
+        $result = TrainingWorkerTaskLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 1 - 1
app/adminapi/controller/works/ReturnWorkController.php

@@ -132,7 +132,7 @@ class ReturnWorkController extends BaseAdminController
                 'scene_id' => 124,
                 'params' => [
                     'user_id' => $returnWork['master_worker_id'],
-                    'order_id' => $params['issue_work_id'],
+                    'order_id' => $returnWork['id'],
                     'thing2' => $issueWork['complaint_type_text'],
                     'thing3' => $issueWork['complaint_details'],
                     'thing4' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],

+ 13 - 0
app/adminapi/controller/works/ServiceWorkController.php

@@ -194,4 +194,17 @@ class ServiceWorkController extends BaseAdminController
         ServiceOrderLogic::orderQuantityRule($params);
         return $this->success('操作成功!', [], 1, 1);
     }
+
+
+    public function distributeTenants()
+    {
+        $params = request()->post();
+        $params['admin_id'] = $this->adminId;
+        $result = ServiceWorkLogic::distributeTenants($params);
+        if (true === $result) {
+            return $this->success('分配成功', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+
 }

+ 14 - 14
app/adminapi/lists/master_worker/MasterWorkerLists.php

@@ -153,16 +153,17 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
     {
         $fields = ['mw.*','mwr.maintain_exp_type','mwr.other_exp_type'];
         $orders = ['mw.id' => 'desc'];
-        $having = 'mw.id > 0';
         $queryWhere = $this->queryWhere();
         //dd($queryWhere,$this->searchWhere);
         // 派单搜索条件 - 订单坐标距离排序
+        $distanceWhereSql = 'mw.id > 0';
         if($this->lat && $this->lon){
-            $fields[] = Db::raw('ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2) AS user_distance');
+            $user_distance = 'ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2)';
+            $fields[] = Db::raw($user_distance.' AS user_distance');
             $orders = 'user_distance';
-            $having = '(user_distance - mw.distance) <= 0';
+            $distanceWhereSql = '('.$user_distance.' - mw.distance) <= 0';
             if($this->range){
-                $having = 'user_distance <= '.$this->range;
+                $distanceWhereSql = '('.$user_distance.' <= '.$this->range;
             }
         }
         $list = MasterWorker::alias('mw')
@@ -170,9 +171,9 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
             ->where($this->searchWhere)
             ->where($queryWhere)
             ->where($this->queryDataWhere())
+            ->whereRaw($distanceWhereSql)
             ->field($fields)
             ->limit($this->limitOffset, $this->limitLength)
-            ->having($having)
             ->order($orders)
             ->select()->toArray();
         $workCount = array_column(ServiceWork::where('master_worker_id','>',0)
@@ -199,25 +200,24 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function count(): int
     {
         $fields = ['mw.*','mwr.maintain_exp_type','mwr.other_exp_type'];
-        $orders = ['mw.id' => 'desc'];
-        $having = 'mw.id > 0';
         $queryWhere = $this->queryWhere();
         // 派单搜索条件 - 订单坐标距离排序
+        $distanceWhereSql = 'mw.id > 0';
         if($this->lat && $this->lon){
-            $fields[] = Db::raw('ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2) AS user_distance');
-            $orders = 'user_distance';
-            $having = '(user_distance - mw.distance) <= 0';
+            $user_distance = 'ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2)';
+            $fields[] = Db::raw($user_distance.' AS user_distance');
+            $distanceWhereSql = '('.$user_distance.' - mw.distance) <= 0';
             if($this->range){
-                $having = 'user_distance <= '.$this->range;
+                $distanceWhereSql = '('.$user_distance.' <= '.$this->range;
             }
         }
-        return count(MasterWorker::alias('mw')
+        return MasterWorker::alias('mw')
             ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
             ->where($this->searchWhere)
             ->where($queryWhere)
             ->where($this->queryDataWhere())
+            ->whereRaw($distanceWhereSql)
             ->field($fields)
-            ->having($having)
-            ->select()->toArray());
+            ->count();
     }
 }

+ 2 - 2
app/adminapi/lists/tenant/TenantLists.php

@@ -66,10 +66,10 @@ class TenantLists extends BaseAdminDataLists implements ListsExcelInterface
         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/';
+            $item['default_domain'] = $http_prefix . $item['sn'] . '.' . $domain . '/';
 
             if ($item['domain_alias_enable'] === 0) {
-                $item['domain'] = $http_prefix . $item['domain_alias'] . '/tenant/';
+                $item['domain'] = $http_prefix . $item['domain_alias'] . '/';
             } else {
                 $item['domain'] = $item['default_domain'];
             }

+ 78 - 0
app/adminapi/lists/training/TrainingCourseLists.php

@@ -0,0 +1,78 @@
+<?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\training;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\training\TrainingCourse;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * TrainingCourse列表
+ * Class TrainingCourseLists
+ * @package app\adminapi\lists
+ */
+class TrainingCourseLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['course_picture', 'course_url', 'course_lock', 'course_length', 'course_question_setting', 'course_question_score'],
+            '%like%' => ['course_name'],
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function lists(): array
+    {
+        return TrainingCourse::where($this->searchWhere)
+            ->field(['id', 'course_name', 'course_picture', 'course_url', 'course_lock', 'course_length', 'course_question_setting', 'course_question_score'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function count(): int
+    {
+        return TrainingCourse::where($this->searchWhere)->count();
+    }
+
+}

+ 78 - 0
app/adminapi/lists/training/TrainingQuestionsLists.php

@@ -0,0 +1,78 @@
+<?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\training;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\training\TrainingQuestions;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * TrainingQuestions列表
+ * Class TrainingQuestionsLists
+ * @package app\adminapi\lists
+ */
+class TrainingQuestionsLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['training_course_id', 'question_type', 'question_selects', 'question_answer', 'question_analysis'],
+            '%like%' => ['title'],
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function lists(): array
+    {
+        return TrainingQuestions::where($this->searchWhere)
+            ->field(['id', 'training_course_id', 'title', 'question_type', 'question_selects', 'question_answer', 'question_analysis'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function count(): int
+    {
+        return TrainingQuestions::where($this->searchWhere)->count();
+    }
+
+}

+ 78 - 0
app/adminapi/lists/training/TrainingTaskLists.php

@@ -0,0 +1,78 @@
+<?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\training;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\training\TrainingTask;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * TrainingTask列表
+ * Class TrainingTaskLists
+ * @package app\adminapi\lists
+ */
+class TrainingTaskLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['training_course_id'],
+            '%like%' => ['task_name'],
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function lists(): array
+    {
+        return TrainingTask::where($this->searchWhere)
+            ->field(['id', 'task_name', 'training_course_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function count(): int
+    {
+        return TrainingTask::where($this->searchWhere)->count();
+    }
+
+}

+ 78 - 0
app/adminapi/lists/training/TrainingWorkerCourseLists.php

@@ -0,0 +1,78 @@
+<?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\training;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\training\TrainingWorkerCourse;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * TrainingWorkerCourse列表
+ * Class TrainingWorkerCourseLists
+ * @package app\adminapi\lists
+ */
+class TrainingWorkerCourseLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['master_worker_id', 'training_task_id', 'training_course_id', 'play_time', 'exam_start_time', 'exam_end_time', 'study_status', 'exam_score'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function lists(): array
+    {
+        return TrainingWorkerCourse::with(['trainingCourse','masterWorker','trainingTask'])->where($this->searchWhere)
+            ->field(['id', 'master_worker_id', 'training_task_id', 'training_course_id', 'play_time', 'exam_start_time', 'exam_end_time', 'study_status', 'exam_score'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function count(): int
+    {
+        return TrainingWorkerCourse::where($this->searchWhere)->count();
+    }
+
+}

+ 84 - 0
app/adminapi/lists/training/TrainingWorkerTaskLists.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\adminapi\lists\training;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\training\TrainingWorkerTask;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * TrainingWorkerTask列表
+ * Class TrainingWorkerTaskLists
+ * @package app\adminapi\lists
+ */
+class TrainingWorkerTaskLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['master_worker_id', 'shop_goods_id', 'shop_orders_id', 'training_task_id', 'training_status', 'lead_master_worker_id', 'operate_status'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function lists(): array
+    {
+        return TrainingWorkerTask::with([
+                'TrainingTask',
+                'MasterWorker',
+                'LeadMasterWorker',
+                'ShopGoods',
+                'ShopOrders',
+            ])->where($this->searchWhere)
+            ->field(['id', 'master_worker_id', 'shop_goods_id', 'shop_orders_id', 'training_task_id', 'training_status', 'lead_master_worker_id', 'operate_status'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function count(): int
+    {
+        return TrainingWorkerTask::where($this->searchWhere)->count();
+    }
+
+}

+ 1 - 1
app/adminapi/lists/works/ServiceWorkLists.php

@@ -70,7 +70,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
     public function setSearch(): array
     {
         return [
-            '=' => ['id','category_type', 'base_service_fee', 'service_fee', 'work_status', 'service_status',  'data_type',  'finished_images', 'master_worker_id', 'work_amount','work_type','appoint_approval','refund_approval', 'city'],
+            '=' => ['id','category_type', 'base_service_fee', 'service_fee', 'work_status', 'service_status',  'data_type',  'finished_images', 'master_worker_id', 'work_amount','work_type','appoint_approval','refund_approval', 'city','tenant_id'],
             '%like%'=>[ 'work_sn','mobile','real_name', 'title', 'address']
         ];
     }

+ 14 - 7
app/adminapi/logic/master_worker/MasterWorkerLogic.php

@@ -109,10 +109,13 @@ class MasterWorkerLogic extends BaseLogic
             //$params['category_ids'] = ["goods_category_ids"=>$params['category_ids'],"ids"=>$ids];
             $params['category_ids'] = implode(',',$ids);
         }
+        /*if($params['tenant_id']){
+            // 绑定租户 绑定团队-组员
+            $team_id = MasterWorkerTeam::where('tenant_id',$params['tenant_id'])->value('id');
+        }*/
         Db::startTrans();
         try {
-
-            MasterWorker::where('id', $params['id'])->update([
+            $update = [
                 'sn' => $params['sn'],
                 'avatar' => $params['avatar'],
                 'real_avatar' => $params['real_avatar'],
@@ -150,7 +153,10 @@ class MasterWorkerLogic extends BaseLogic
                 'settlement_type' => $params['settlement_type']??2,
                 'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
                 'remark' => $params['remark']??'',
-            ]);
+            ];
+            //'tenant_id' => $params['tenant_id']??0,
+            MasterWorker::where('id', $params['id'])->update($update);
+            
             if (is_numeric($params['weight_score'])) {
                 $exists = MasterWorkerScore::where('worker_id', $params['id'])->value('id');
                 if ($exists) {
@@ -158,10 +164,11 @@ class MasterWorkerLogic extends BaseLogic
                 } else {
                     MasterWorkerScore::create([
                         'worker_id' => $params['id'],
-                       'weight_score' => $params['weight_score'],
+                    'weight_score' => $params['weight_score'],
                     ]);
                 }
             }
+
             Db::commit();
             return true;
         } catch (\Exception $e) {
@@ -232,14 +239,14 @@ class MasterWorkerLogic extends BaseLogic
     /**
      * 获取所有工程师选项列表
      * @param $params
-     * @return false|string
+     * @return array
      */
     public static function getAllWorkers($params){
         try{
-            return MasterWorker::where(['is_disable'=>0])->column('id,id as value,worker_number as name,account,mobile');
+            return MasterWorker::where(['is_disable'=>0])->column('id,id as value,worker_number as name,real_name,account,mobile');
         } catch (\Exception $e){
             self::setError($e->getMessage());
-            return false;
+            return [];
         }
 
     }

+ 11 - 4
app/adminapi/logic/master_worker/MasterWorkerTeamLogic.php

@@ -42,18 +42,21 @@ class MasterWorkerTeamLogic extends BaseLogic
         try {
             $masterWorker = MasterWorker::where('id', $params['master_worker_id'])->find();
             if($masterWorker['team_id']){
-                throw new \Exception('该师傅已加入团队,请先退出团队');
+                throw new \Exception('该师傅已加入团队');
             }
+
             if($params['goods_category_ids']){
                 foreach ($params['goods_category_ids'] as $val){
                     is_array($val)?($ids[] = end($val)):($ids[] = $val);
                 }
                 $params['goods_category_ids'] = implode(',',$ids);
             }
+
+            MasterWorkerTeam::where('tenant_id', $params['tenant_id'])->value('id') && throw new \Exception('该租户已有团队');
             $masterWorkerTeam = MasterWorkerTeam::create([
                 'team_name' => $params['team_name'],
                 'master_worker_id' => $params['master_worker_id'],
-                'tenant_id' => MasterWorker::where('id', $params['master_worker_id'])->value('tenant_id'),
+                'tenant_id' => $params['tenant_id']??0,
                 'city' => $params['city'],
                 'area_name' => $params['area_name'],
                 'lon' => $params['lon'],
@@ -69,6 +72,7 @@ class MasterWorkerTeamLogic extends BaseLogic
                 [
                     'team_id' => $masterWorkerTeam->id,
                     'team_role' => 1,
+                    'tenant_id' => $params['tenant_id'],
                 ]
             );
 
@@ -107,14 +111,15 @@ class MasterWorkerTeamLogic extends BaseLogic
 
             MasterWorker::where('id', $masterWorkerTeam['master_worker_id'])->update(
                 [
-                    'team_id' => 0,
+                    //'team_id' => $params['id'],
                     'team_role' => 0,
+                    //'tenant_id' => $params['tenant_id'],
                 ]
             );
             MasterWorkerTeam::where('id', $params['id'])->update([
                 'team_name' => $params['team_name'],
                 'master_worker_id' => $params['master_worker_id'],
-                'tenant_id' => MasterWorker::where('id', $params['master_worker_id'])->value('tenant_id'),
+                'tenant_id' => $params['tenant_id']??0,
                 'city' => $params['city'],
                 'area_name' => $params['area_name'],
                 'lon' => $params['lon'],
@@ -125,11 +130,13 @@ class MasterWorkerTeamLogic extends BaseLogic
                 'min_order' => $params['min_order'],
                 'goods_category_ids' => $params['goods_category_ids'],
                 'accept_order_status' => $params['accept_order_status'],
+
             ]);
             MasterWorker::where('id', $params['master_worker_id'])->update(
                 [
                     'team_id' => $params['id'],
                     'team_role' => 1,
+                    'tenant_id' => $params['tenant_id'],
                 ]
             );
             Db::commit();

+ 32 - 3
app/adminapi/logic/master_worker_register/MasterWorkerRegisterLogic.php

@@ -146,18 +146,47 @@ class MasterWorkerRegisterLogic extends BaseLogic
                 'nickname' => '用户' . $userSn,
                 'account' => $params['mobile'],
                 'mobile' => $params['mobile'],
+                'real_name' => $params['real_name']??'',
                 'password' => $password,
                 'channel' => 1,
                 'lon' => $params['lon']??0,
                 'lat' => $params['lat']??0,
-                'province' => $params['province'],
-                'city' => $params['city'],
-                'area_name' => $params['area_name'],
+                'province' => $params['province']??0,
+                'city' => $params['city']??0,
+                'area_name' => $params['area_name']??'',
+                'tenant_id' => $params['tenant_id']??0,
+                'category_ids' => $params['category_ids']??'',
             ]);
             //添加工程师汇总评分数据
             MasterWorkerScore::create([
                 'worker_id' => $masterWorker->id
             ]);
+
+            $masterWorkerRegister = MasterWorkerRegister::where($where)->findOrEmpty();
+            if ($masterWorkerRegister->isEmpty()) {
+                MasterWorkerRegister::create([
+                    'maintain_exp_type' => isset($params['maintain_exp_type'])?$params['maintain_exp_type']:0,
+                    'other_exp_type' => isset($params['other_exp_type'])?$params['other_exp_type']:'',
+                    'other_exp_name' => (isset($params['other_exp_name']) && isset($params['other_exp_type']) && $params['other_exp_type'] == 4)?$params['other_exp_name']:'',
+                    'province' => $params['province']??0,
+                    'city' => $params['city']??0,
+                    'area_name' => $params['area_name']??'',
+                    'vehicle_type' => $params['vehicle_type']??0,
+                    'name' => $params['real_name']??'',
+                    'age' => $params['age']??0,
+                    'sex' => $params['sex']??0,
+                    'status' => 1,
+                    'worker_id' => $masterWorker->id,
+                    'mobile' => $params['mobile'],
+                    'is_credential' => !empty($params['is_credential'])?$params['is_credential']:0,
+                    'credential_name' => !empty($params['credential_name'])?$params['credential_name']:'',
+                    'credential_images'=>!empty($params['credential_images'])?json_encode($params['credential_images'],JSON_UNESCAPED_UNICODE):'',
+                    'lon' => !empty($params['lon'])?$params['lon']:0,
+                    'lat' => !empty($params['lat'])?$params['lat']:0,
+                    'address' => !empty($params['address'])?$params['address']:'',
+                ]);
+            }
+
         }
         return $masterWorker->id;
     }

+ 127 - 0
app/adminapi/logic/training/TrainingCourseLogic.php

@@ -0,0 +1,127 @@
+<?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\training;
+
+
+use app\common\model\training\TrainingCourse;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * TrainingCourse逻辑
+ * Class TrainingCourseLogic
+ * @package app\adminapi\logic
+ */
+class TrainingCourseLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingCourse::create([
+                'course_name' => $params['course_name'],
+                'course_picture' => $params['course_picture'],
+                'course_url' => $params['course_url'],
+                'course_lock' => $params['course_lock'],
+                'course_length' => $params['course_length'],
+                'course_question_setting' => self::configureReservedField($params['course_question_setting']??[]),
+                'course_question_score' => $params['course_question_score'],
+            ]);
+
+            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/02/14 17:37
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingCourse::where('id', $params['id'])->update([
+                'course_name' => $params['course_name'],
+                'course_picture' => $params['course_picture'],
+                'course_url' => $params['course_url'],
+                'course_lock' => $params['course_lock'],
+                'course_length' => $params['course_length'],
+                'course_question_setting' => json_encode(self::configureReservedField($params['course_question_setting']??[])),
+                'course_question_score' => $params['course_question_score'],
+            ]);
+
+            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/02/14 17:37
+     */
+    public static function delete(array $params): bool
+    {
+        return TrainingCourse::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public static function detail($params): array
+    {
+        return TrainingCourse::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function configureReservedField($data): array
+    {
+        foreach ($data as $key => &$item) {
+            $data[$key]['block_key'] = $key+1;
+            $item['select_value'] = (int)$item['select_value'];
+        }
+        return $data??[];
+    }
+}

+ 136 - 0
app/adminapi/logic/training/TrainingQuestionsLogic.php

@@ -0,0 +1,136 @@
+<?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\training;
+
+
+use app\common\model\training\TrainingQuestions;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * TrainingQuestions逻辑
+ * Class TrainingQuestionsLogic
+ * @package app\adminapi\logic
+ */
+class TrainingQuestionsLogic extends BaseLogic
+{
+
+    public static $select_value = [];
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingQuestions::create([
+                'training_course_id' => $params['training_course_id'],
+                'title' => $params['title'],
+                'question_type' => $params['question_type'],
+                //'question_selects' => $params['question_selects'],
+                'question_selects' => self::configureReservedField($params['question_selects']??[]),
+                'question_answer' => self::$select_value?implode(',',self::$select_value):'',
+                'question_analysis' => $params['question_analysis'],
+            ]);
+
+            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/02/14 13:49
+     */
+    public static function edit(array $params): bool
+    {
+
+        Db::startTrans();
+        try {
+            TrainingQuestions::where('id', $params['id'])->update([
+                'training_course_id' => $params['training_course_id'],
+                'title' => $params['title'],
+                'question_type' => $params['question_type'],
+                'question_selects' => json_encode(self::configureReservedField($params['question_selects']??[])),
+                'question_answer' => self::$select_value?implode(',',self::$select_value):'',
+                'question_analysis' => $params['question_analysis'],
+            ]);
+
+            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/02/14 13:49
+     */
+    public static function delete(array $params): bool
+    {
+        return TrainingQuestions::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public static function detail($params): array
+    {
+        return TrainingQuestions::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function configureReservedField($data): array
+    {
+        $select_value = [];
+        foreach ($data as $key => &$item) {
+            $data[$key]['block_key'] = $key+1;
+            if($item['select_value']){
+                $select_value[] = $data[$key]['block_key'];
+                $item['select_value'] = \true;
+            }else{
+                $item['select_value'] = \false;
+            }
+        }
+        self::$select_value = $select_value;
+        return $data??[];
+    }
+
+
+}

+ 108 - 0
app/adminapi/logic/training/TrainingTaskLogic.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\common\model\training\TrainingTask;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * TrainingTask逻辑
+ * Class TrainingTaskLogic
+ * @package app\adminapi\logic
+ */
+class TrainingTaskLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingTask::create([
+                'task_name' => $params['task_name'],
+                'training_course_id' => array_map('intval', $params['training_course_id'])
+            ]);
+
+            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/02/14 17:45
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingTask::where('id', $params['id'])->update([
+                'task_name' => $params['task_name'],
+                'training_course_id' => json_encode(array_map('intval', $params['training_course_id']))
+            ]);
+
+            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/02/14 17:45
+     */
+    public static function delete(array $params): bool
+    {
+        return TrainingTask::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public static function detail($params): array
+    {
+        return TrainingTask::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 124 - 0
app/adminapi/logic/training/TrainingWorkerCourseLogic.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\adminapi\logic\training;
+
+
+use app\common\model\training\TrainingWorkerCourse;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * TrainingWorkerCourse逻辑
+ * Class TrainingWorkerCourseLogic
+ * @package app\adminapi\logic
+ */
+class TrainingWorkerCourseLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingWorkerCourse::create([
+                'master_worker_id' => $params['master_worker_id'],
+                'training_task_id' => $params['training_task_id'],
+                'training_course_id' => $params['training_course_id'],
+                'play_time' => $params['play_time'],
+                'exam_start_time' => $params['exam_start_time'],
+                'exam_end_time' => $params['exam_end_time'],
+                'study_status' => $params['study_status'],
+                'question_all_score' => $params['question_all_score'],
+                'question_qualified_score' => $params['question_qualified_score'],
+                'exam_score' => $params['exam_score'],
+            ]);
+
+            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/02/16 16:44
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingWorkerCourse::where('id', $params['id'])->update([
+                'master_worker_id' => $params['master_worker_id'],
+                'training_task_id' => $params['training_task_id'],
+                'training_course_id' => $params['training_course_id'],
+                'play_time' => $params['play_time'],
+                'exam_start_time' => $params['exam_start_time'],
+                'exam_end_time' => $params['exam_end_time'],
+                'study_status' => $params['study_status'],
+                'question_all_score' => $params['question_all_score'],
+                'question_qualified_score' => $params['question_qualified_score'],
+                'exam_score' => $params['exam_score'],
+            ]);
+
+            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/02/16 16:44
+     */
+    public static function delete(array $params): bool
+    {
+        return TrainingWorkerCourse::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public static function detail($params): array
+    {
+        return TrainingWorkerCourse::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 156 - 0
app/adminapi/logic/training/TrainingWorkerTaskLogic.php

@@ -0,0 +1,156 @@
+<?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\training;
+
+
+use app\common\model\training\TrainingCourse;
+use app\common\model\training\TrainingTask;
+use app\common\model\training\TrainingWorkerCourse;
+use app\common\model\training\TrainingWorkerQuestion;
+use app\common\model\training\TrainingWorkerTask;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * TrainingWorkerTask逻辑
+ * Class TrainingWorkerTaskLogic
+ * @package app\adminapi\logic
+ */
+class TrainingWorkerTaskLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingWorkerTask::create([
+                'master_worker_id' => $params['master_worker_id'],
+                'shop_goods_id' => $params['shop_goods_id'],
+                'training_task_id' => $params['training_task_id'],
+                'lead_master_worker_id' => $params['lead_master_worker_id'],
+                'operate_status' => $params['operate_status']??0,
+            ]);
+
+            // 添加该工程师初始化记录
+            self::trainingCourseRecord($params['master_worker_id'],$params['training_task_id']);
+
+            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/02/16 13:49
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TrainingWorkerTask::where('id', $params['id'])->update([
+                'master_worker_id' => $params['master_worker_id'],
+                'shop_goods_id' => $params['shop_goods_id'],
+                'training_task_id' => $params['training_task_id'],
+                'lead_master_worker_id' => $params['lead_master_worker_id'],
+                'operate_status' => $params['operate_status']??0,
+            ]);
+
+            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/02/16 13:49
+     */
+    public static function delete(array $params): bool
+    {
+        return TrainingWorkerTask::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public static function detail($params): array
+    {
+        return TrainingWorkerTask::findOrEmpty($params['id'])->toArray();
+    }
+
+    /** 培训课程初始化记录
+     */
+    public static function trainingCourseRecord($masterWorkerId,$training_task_id): array
+    {
+        $training_course_ids  = json_decode(TrainingTask::where('id',$training_task_id)->value('training_course_id'),true);
+        // 添加该工程师的所有培训课程初始化记录
+        foreach ($training_course_ids as $course_id) {
+            $workerCourse = TrainingWorkerCourse::create([
+                'master_worker_id' => $masterWorkerId,
+                'training_task_id' => $training_task_id,
+                'training_course_id' => $course_id,
+                'play_time' => 0,
+                'exam_start_time' => 0,
+                'exam_end_time' => 0,
+                'study_status' => 0,
+                'exam_score' => 0,
+            ]);
+
+            // 添加该工程师该课程的所有试题初始化记录
+            //[{"block_key":1,"select_value":1,"score":"20"},{"block_key":2,"select_value":2,"score":"10"},{"block_key":3,"select_value":3,"score":"70"}]
+            $course_question = json_decode(TrainingCourse::where('id',$course_id)->value('course_question_setting'),true);
+            $course_question_ids = array_column($course_question,'select_value');
+            foreach ($course_question_ids as $question_id) {
+                $workerQuestion = TrainingWorkerQuestion::create([
+                    'worker_course_id' => $workerCourse->id,
+                    'questions_id' => $question_id,
+                    'worker_answer' => '',
+                    'exam_score' => 0
+                ]);
+            }
+        }
+        return $training_course_ids??[];
+    }
+
+}

+ 41 - 8
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -14,9 +14,8 @@
 
 namespace app\adminapi\logic\works;
 
-
-use think\db\Query;
 use think\Exception;
+use think\db\Query;
 use think\facade\Db;
 use think\facade\Log;
 use app\common\logic\BaseLogic;
@@ -33,6 +32,7 @@ use app\common\model\works\ServiceWorkSpare;
 use app\workerapi\logic\ServiceWorkLogLogic;
 use app\common\model\orders\OrderEffectiveLog;
 use app\common\model\master_worker\MasterWorker;
+use app\common\model\training\TrainingWorkerTask;
 use app\common\model\performance\PerformanceRules;
 use app\common\model\works\ServiceWorkCustomerLog;
 use app\workerapi\logic\ServiceWorkReceiveLogLogic;
@@ -44,7 +44,6 @@ use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
 use app\common\model\master_commission\MasterWorkerCommissionRatio;
 use app\common\model\master_commission\MasterWorkerCommissionConfig;
 
-
 /**
  * ServiceWork逻辑
  * Class ServiceWorkLogic
@@ -407,8 +406,20 @@ class ServiceWorkLogic extends BaseLogic
         ])->append(['id','work_status_text','service_status_text'])
             ->where($work_where)
             ->findOrEmpty()->toArray();
-        if(isset($params['user_id']) && $params['user_id'] && ($params['user_id'] != $result['master_worker_id'])){
-            throw new \Exception('您没有权限操作该工单');
+        $result['is_operate_prohibit'] = 0;
+        if(isset($params['user_id']) && $params['user_id'] && ($params['user_id'] != $result['master_worker_id']) ){
+            // 带徒师傅的工单
+            $lead_master_worker_id = TrainingWorkerTask::where('master_worker_id',$params['user_id'])->where('training_status',2)
+                ->where('operate_status',0)->value('lead_master_worker_id');
+            // 团队负责人编辑 工单池(包括已派队员) 工单
+            if($params['user_info']['team_role'] == 1 && $params['user_info']['tenant_id'] == $result['tenant_id'] ){
+                $result['is_operate_prohibit'] = 0;
+            }elseif(!empty($lead_master_worker_id) && !empty($result['master_worker_id']) && $lead_master_worker_id == $result['master_worker_id']){
+                // 徒查看师父的工单 不能编辑可查看
+                $result['is_operate_prohibit'] = 1;
+            }else{
+                throw new \Exception('您没有权限操作该工单');
+            }
         }
         //工程师工单按钮状态
         $work_service_status = 0;
@@ -909,6 +920,28 @@ class ServiceWorkLogic extends BaseLogic
         }
     }
 
+    public static function distributeTenants($params)
+    {
+        Db::startTrans();
+        try {
+            if(empty($params['id']) || empty($params['tenant_id'])){
+                throw new \Exception('参数错误');
+            }
+            if (is_array($params['id'])) {
+                $ids = $params['id'];
+            } else{
+                $ids = [$params['id']];
+            }
+            ServiceWork::whereIn('id',$ids)->update(['tenant_id'=>$params['tenant_id']]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
     /**
      *
      * @return false|void
@@ -918,7 +951,7 @@ class ServiceWorkLogic extends BaseLogic
         try {
             $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
             if($work->isEmpty()){
-                throw new Exception('工单不存在');
+                throw new \Exception('工单不存在');
             }
             if (empty($work->first_contact_time)) {
                 $work->first_contact_time = time();
@@ -926,11 +959,11 @@ class ServiceWorkLogic extends BaseLogic
             }
             return true;
         }
-        catch (\Exception $e) {
+        catch  (\Exception $e) {
+            Db::rollback();
             self::setError($e->getMessage());
             return false;
         }
     }
 
-
 }

+ 110 - 0
app/adminapi/validate/training/TrainingCourseValidate.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\training;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * TrainingCourse验证器
+ * Class TrainingCourseValidate
+ * @package app\adminapi\validate
+ */
+class TrainingCourseValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'course_name' => 'require',
+        'course_picture' => 'require',
+        'course_url' => 'require',
+        'course_lock' => 'require',
+        'course_length' => 'require',
+        'course_question_setting' => 'require',
+        'course_question_score' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'course_name' => '课程名称',
+        'course_picture' => '课程图片',
+        'course_url' => '课程链接(mp4)',
+        'course_lock' => '是否免费',
+        'course_length' => '课程时长',
+        'course_question_setting' => '试题配置 JSON',
+        'course_question_score' => '合格分',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return TrainingCourseValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['course_name','course_picture','course_url','course_lock','course_question_setting','course_question_score']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return TrainingCourseValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','course_name','course_picture','course_url','course_lock','course_question_setting','course_question_score']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return TrainingCourseValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return TrainingCourseValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:37
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 108 - 0
app/adminapi/validate/training/TrainingQuestionsValidate.php

@@ -0,0 +1,108 @@
+<?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\training;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * TrainingQuestions验证器
+ * Class TrainingQuestionsValidate
+ * @package app\adminapi\validate
+ */
+class TrainingQuestionsValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'training_course_id' => 'require',
+        'title' => 'require',
+        'question_type' => 'require',
+        'question_selects' => 'require',
+        'question_answer' => 'require',
+        'question_analysis' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'training_course_id' => '课程 ID',
+        'title' => '试题名称',
+        'question_type' => '试题类型',
+        'question_selects' => '试题选项(含各选项内容)',
+        'question_answer' => '试题答案',
+        'question_analysis' => '试题解析',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return TrainingQuestionsValidate
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['title','question_type','question_selects','question_analysis']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return TrainingQuestionsValidate
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','title','question_type','question_selects','question_analysis']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return TrainingQuestionsValidate
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return TrainingQuestionsValidate
+     * @author likeadmin
+     * @date 2025/02/14 13:49
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 99 - 0
app/adminapi/validate/training/TrainingTaskValidate.php

@@ -0,0 +1,99 @@
+<?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\training;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * TrainingTask验证器
+ * Class TrainingTaskValidate
+ * @package app\adminapi\validate
+ */
+class TrainingTaskValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'task_name' => 'require',
+        'training_course_id' => 'require'
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'task_name' => '名称',
+        'training_course_id' => '课程id(逗号拼接)'
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return TrainingTaskValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['task_name','training_course_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return TrainingTaskValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','task_name','training_course_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return TrainingTaskValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return TrainingTaskValidate
+     * @author likeadmin
+     * @date 2025/02/14 17:45
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 116 - 0
app/adminapi/validate/training/TrainingWorkerCourseValidate.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\validate\training;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * TrainingWorkerCourse验证器
+ * Class TrainingWorkerCourseValidate
+ * @package app\adminapi\validate
+ */
+class TrainingWorkerCourseValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'master_worker_id' => 'require',
+        'training_task_id' => 'require',
+        'training_course_id' => 'require',
+        'play_time' => 'require',
+        'exam_start_time' => 'require',
+        'exam_end_time' => 'require',
+        'study_status' => 'require',
+        'question_all_score' => 'require',
+        'question_qualified_score' => 'require',
+        'exam_score' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'master_worker_id' => '师傅id',
+        'training_task_id' => '培训任务ID',
+        'training_course_id' => '课程ID',
+        'play_time' => '播放时间秒',
+        'exam_start_time' => '考试开始时间秒',
+        'exam_end_time' => '考试结束时间秒',
+        'study_status' => '状态 0未学习  1学习中  2待考试  3考试中  4考试不合格   5已学完',
+        'question_all_score' => '试题总分',
+        'question_qualified_score' => '合格分',
+        'exam_score' => '实际考试得分',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return TrainingWorkerCourseValidate
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['master_worker_id','training_task_id','training_course_id','play_time','exam_start_time','exam_end_time','study_status','question_all_score','question_qualified_score','exam_score']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return TrainingWorkerCourseValidate
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','master_worker_id','training_task_id','training_course_id','play_time','exam_start_time','exam_end_time','study_status','question_all_score','question_qualified_score','exam_score']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return TrainingWorkerCourseValidate
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return TrainingWorkerCourseValidate
+     * @author likeadmin
+     * @date 2025/02/16 16:44
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 110 - 0
app/adminapi/validate/training/TrainingWorkerTaskValidate.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\training;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * TrainingWorkerTask验证器
+ * Class TrainingWorkerTaskValidate
+ * @package app\adminapi\validate
+ */
+class TrainingWorkerTaskValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'master_worker_id' => 'require',
+        'shop_goods_id' => 'require',
+        'shop_orders_id' => 'require',
+        'training_task_id' => 'require',
+        'training_status' => 'require',
+        'lead_master_worker_id' => 'require',
+        'operate_status' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'master_worker_id' => '师傅id',
+        'shop_goods_id' => '商品id(套餐)',
+        'shop_orders_id' => '购买单号id',
+        'training_task_id' => '培训任务ID',
+        'training_status' => '培训状态',
+        'lead_master_worker_id' => '带徒师傅id',
+        'operate_status' => '实操状态',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return TrainingWorkerTaskValidate
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['master_worker_id','shop_goods_id','training_task_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return TrainingWorkerTaskValidate
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','master_worker_id','shop_goods_id','training_task_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return TrainingWorkerTaskValidate
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return TrainingWorkerTaskValidate
+     * @author likeadmin
+     * @date 2025/02/16 13:49
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 2 - 1
app/api/logic/IssueWorkLogic.php

@@ -111,7 +111,8 @@ class IssueWorkLogic extends BaseLogic
                 'complaint_mobile'=>$params['complaint_mobile'],
                 'user_id'=>$params['user_id'],
                 'create_time' => time(),
-                'update_time' => time()
+                'update_time' => time(),
+                'tenant_id' => $work['tenant_id']
             ]);
             Db::commit();
             $userInfo = User::where('id',$params['user_id'])->findOrEmpty();

+ 38 - 1
app/common.php

@@ -1,5 +1,6 @@
 <?php
 // 应用公共文件
+use app\common\model\goods_category\GoodsCategory;
 use app\common\model\setting\PostageRegion;
 use app\common\service\FileService;
 use think\helper\Str;
@@ -503,4 +504,40 @@ function isPointInPolygon($point, $polygon) {
         $j = $i;
     }
     return $inside;
-}
+}
+
+/**
+ * 获取自己和上级id
+ * @param $point
+ * @param $polygon
+ * @return bool
+ */
+function getSuperiorId($all_category,$id,&$all_category_ids)
+{
+    $all_category_ids[] = $id;
+    $tmp_pid = $all_category[$id];
+    if($tmp_pid > 0) {
+        getSuperiorId($all_category,$tmp_pid,$all_category_ids);
+    }
+    return $all_category_ids;
+}
+
+/**
+ * 获取子分类上级返回树
+ * @param $category_ids array 分类id数组
+ * @return array 分类树结构
+ */
+function getSuperiorCategoryTree($category_ids)
+{
+    $all_category = GoodsCategory::where('status', 1)->column('pid', 'id');
+    $all_category_ids = [];
+    foreach ($category_ids as $v) {
+        getSuperiorId($all_category,$v,$all_category_ids);
+    }
+    $tree_data = GoodsCategory::field('id,pid,name')
+        ->where('status', 1)
+        ->whereIn('id', array_unique($all_category_ids))
+        ->select()
+        ->toArray();
+    return linear_to_tree($tree_data, 'children');
+}

+ 1 - 0
app/common/cache/MasterWokerTokenCache.php

@@ -83,6 +83,7 @@ class MasterWokerTokenCache extends BaseCache
             'sn' => $user->sn,
             'mobile' => $user->mobile,
             'avatar' => $user->avatar,
+            'tenant_id' => $user->tenant_id,
             'team_id' => $user->team_id,
             'team_role' => $user->team_role,
             'terminal' => $userSession->terminal,

+ 3 - 1
app/common/cache/TenantAdminTokenCache.php

@@ -86,7 +86,8 @@ class TenantAdminTokenCache extends BaseCache
             }
             $roleName = trim($roleName, '/');
         }
-
+        // 获取数据权限信息-暂时不处理
+        $data_rules = [];
         $adminInfo = [
             'admin_id' => $admin->id,
             'tenant_id' => $admin->tenant_id,
@@ -99,6 +100,7 @@ class TenantAdminTokenCache extends BaseCache
             'terminal' => $adminSession->terminal,
             'expire_time' => $adminSession->expire_time,
             'login_ip' => request()->ip(),
+            'data_rules' => $data_rules,
         ];
         $this->set($this->prefix . $token, $adminInfo, new \DateTime(Date('Y-m-d H:i:s', $adminSession->expire_time)));
         return $this->getAdminInfo($token);

+ 5 - 1
app/common/http/middleware/LikeAdminAllowMiddleware.php

@@ -65,7 +65,8 @@ class LikeAdminAllowMiddleware
 
         // 获取租户信息
         $tenantModel = new Tenant();
-        $domain = preg_replace('/^https?:\/\/|\/$/', '', $request->domain());
+        //$domain = preg_replace('/^https?:\/\/|\/$/', '', $request->domain());
+        $domain = $request->header('my-origin-domain');
         $pathSegments = explode('/', $request->pathinfo());
         $firstSegment = $pathSegments[0];
 
@@ -107,6 +108,9 @@ class LikeAdminAllowMiddleware
      */
     private function handleTenantAccess(Tenant $tenantModel, string $domain, $request, Closure $next, bool $isPage = false)
     {
+        if (empty($domain)) {
+            return JsonService::fail('非法访问', [], -1001);
+        }
         // 通过别名访问租户
         $tenant = $tenantModel->where(['domain_alias' => $domain])->findOrEmpty();
         if (!$tenant->isEmpty() && $tenant->disable === 0 && $tenant->domain_alias_enable === 0) {

+ 37 - 3
app/common/logic/TableDataLogic.php

@@ -29,6 +29,11 @@ use app\common\model\refund\RefundRecord;
 use app\common\model\sale\Sale;
 use app\common\model\sale\SaleGroup;
 use app\common\model\setting\PostageRegion;
+use app\common\model\tenant\Tenant;
+use app\common\model\shops\ShopGoods;
+use app\common\model\training\TrainingCourse;
+use app\common\model\training\TrainingQuestions;
+use app\common\model\training\TrainingTask;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\WeChatPayService;
 
@@ -78,8 +83,14 @@ class TableDataLogic extends BaseLogic
      */
     public static function masterWorkerLabels()
     {
-        $lists = Labels::where('id','>',0)->where('label_type',2)->field('id,pid,label_name as name,id as value,"data_table_masterWorkerLabels" as type_value')->select()->toArray();
-        return linear_to_tree($lists, 'children', 'id', 'pid');
+        // 缓存优化
+        $data = cache('labelMasterWorkerLabels');
+        if(empty($data)){
+            $lists = Labels::where('id','>',0)->where('label_type',2)->field('id,pid,label_name as name,id as value,"data_table_masterWorkerLabels" as type_value')->select()->toArray();
+            $data =  linear_to_tree($lists, 'children', 'id', 'pid');
+            cache('labelMasterWorkerLabels',$data,3600);
+        }
+        return $data;
     }
     /**
      * @notes 优惠券标签列表
@@ -102,7 +113,7 @@ class TableDataLogic extends BaseLogic
         // 缓存优化
         $data = cache('labelPostageRegion');
         if(empty($data)){
-            $lists = PostageRegion::field(['id', 'pid', 'name as label','id as value','"data_table_postageRegion" as type_value'])->select()->toArray();
+            $lists = PostageRegion::field('id,pid,name as label,id as value,"data_table_postageRegion" as type_value')->select()->toArray();
             $data = linear_to_tree($lists, 'children', 'id', 'pid');
             cache('labelPostageRegion',$data);
         }
@@ -131,4 +142,27 @@ class TableDataLogic extends BaseLogic
         return Admin::where('disable','=',0)->field('id,name,id as value,"data_table_admins" as type_value')->select()->toArray();
     }
 
+    public static function tenant()
+    {
+        return Tenant::where('disable','=',0)->field('id,name,id as value,"data_table_tenant" as type_value')->select()->toArray();
+    }
+
+    public static function trainingQuestions()
+    {
+        return TrainingQuestions::field('id,title as name,id as value,question_type,"data_table_trainingQuestions" as type_value')->select()->toArray();
+    }
+    public static function trainingCourse()
+    {
+        return TrainingCourse::field('id,course_name as name,id as value,"data_table_trainingCourse" as type_value')->select()->toArray();
+    }
+    public static function trainingTask()
+    {
+        return TrainingTask::field('id,task_name as name,id as value,"data_table_trainingTask" as type_value')->select()->toArray();
+    }
+    public static function shopGoods()
+    {
+        return ShopGoods::field('id,goods_name as name,id as value,"data_table_shopGoods" as type_value')->select()->toArray();
+    }
+
+
 }

+ 36 - 0
app/common/model/training/TrainingCourse.php

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

+ 36 - 0
app/common/model/training/TrainingQuestions.php

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

+ 36 - 0
app/common/model/training/TrainingTask.php

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

+ 47 - 0
app/common/model/training/TrainingWorkerCourse.php

@@ -0,0 +1,47 @@
+<?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\training;
+
+
+use app\common\model\BaseModel;
+use app\common\model\master_worker\MasterWorker;
+
+
+/**
+ * TrainingWorkerCourse模型
+ * Class TrainingWorkerCourse
+ * @package app\common\model
+ */
+class TrainingWorkerCourse extends BaseModel
+{
+    
+    protected $name = 'training_worker_course';
+
+    public function trainingCourse()
+    {
+        return $this->hasOne(TrainingCourse::class, 'id', 'training_course_id');
+    }
+    public function masterWorker()
+    {
+        return $this->hasOne(MasterWorker::class, 'id', 'master_worker_id');
+    }
+    public function trainingTask()
+    {
+        return $this->hasOne(TrainingTask::class, 'id', 'training_task_id');
+    }
+
+
+
+}

+ 37 - 0
app/common/model/training/TrainingWorkerQuestion.php

@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\training;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * TrainingWorkerQuestion模型
+ * Class TrainingWorkerQuestion
+ * @package app\common\model
+ */
+class TrainingWorkerQuestion extends BaseModel
+{
+    
+    protected $name = 'training_worker_question';
+
+    public function trainingQuestions()
+    {
+        return $this->hasOne(TrainingQuestions::class, 'id', 'questions_id');
+    }
+    
+}

+ 49 - 0
app/common/model/training/TrainingWorkerTask.php

@@ -0,0 +1,49 @@
+<?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\training;
+
+
+use app\common\model\BaseModel;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\shops\ShopGoods;
+use app\common\model\shops\ShopOrders;
+
+
+/**
+ * TrainingWorkerTask模型
+ * Class TrainingWorkerTask
+ * @package app\common\model
+ */
+class TrainingWorkerTask extends BaseModel
+{
+    
+    protected $name = 'training_worker_task';
+    public function TrainingTask(){
+        return $this->hasOne(TrainingTask::class,'id','training_task_id');
+    }
+    public function MasterWorker(){
+        return $this->hasOne(MasterWorker::class,'id','master_worker_id');
+    }
+    public function LeadMasterWorker(){
+        return $this->hasOne(MasterWorker::class,'id','lead_master_worker_id');
+    }
+    public function ShopGoods(){
+        return $this->hasOne(ShopGoods::class,'id','shop_goods_id');
+    }
+    public function ShopOrders(){
+        return $this->hasOne(ShopOrders::class,'id','shop_orders_id');
+    }
+    
+}

+ 92 - 35
app/common/service/UploadService.php

@@ -15,8 +15,10 @@
 namespace app\common\service;
 
 
+use app\common\enum\AdminTerminalEnum;
 use app\common\enum\FileEnum;
 use app\common\model\file\File;
+use app\common\model\file\TenantFile;
 use app\common\service\storage\Driver as StorageDriver;
 use Exception;
 
@@ -67,15 +69,29 @@ class UploadService
             }
 
             // 4、写入数据库中
-            $file = File::create([
-                'cid'         => $cid,
-                'type'        => FileEnum::IMAGE_TYPE,
-                'name'        => $fileInfo['name'],
-                'uri'         => $saveDir . '/' . str_replace("\\","/", $fileName),
-                'source'      => $source,
-                'source_id'   => $sourceId,
-                'create_time' => time(),
-            ]);
+            if(AdminTerminalEnum::isTenant()){
+                $file = (new TenantFile())->create([
+                    'tenant_id'   => request()->tenantId,
+                    'cid'         => $cid,
+                    'type'        => FileEnum::IMAGE_TYPE,
+                    'name'        => $fileInfo['name'],
+                    'uri'         => $saveDir . '/' . str_replace("\\","/", $fileName),
+                    'source'      => $source,
+                    'source_id'   => $sourceId,
+                    'create_time' => time(),
+                ]);
+            }else{
+                $file = (new File())->create([
+                    'cid'         => $cid,
+                    'type'        => FileEnum::IMAGE_TYPE,
+                    'name'        => $fileInfo['name'],
+                    'uri'         => $saveDir . '/' . str_replace("\\","/", $fileName),
+                    'source'      => $source,
+                    'source_id'   => $sourceId,
+                    'create_time' => time(),
+                ]);
+            }
+
 
             // 5、返回结果
             return [
@@ -136,15 +152,29 @@ class UploadService
             }
 
             // 4、写入数据库中
-            $file = File::create([
-                'cid'         => $cid,
-                'type'        => FileEnum::VIDEO_TYPE,
-                'name'        => $fileInfo['name'],
-                'uri'         => $saveDir . '/' . str_replace("\\","/", $fileName),
-                'source'      => $source,
-                'source_id'   => $sourceId,
-                'create_time' => time(),
-            ]);
+            if(AdminTerminalEnum::isTenant()){
+                $file = (new TenantFile())->create([
+                    'tenant_id'   => request()->tenantId,
+                    'cid'         => $cid,
+                    'type'        => FileEnum::VIDEO_TYPE,
+                    'name'        => $fileInfo['name'],
+                    'uri'         => $saveDir . '/' . str_replace("\\","/", $fileName),
+                    'source'      => $source,
+                    'source_id'   => $sourceId,
+                    'create_time' => time(),
+                ]);
+            }else{
+                $file = (new File())->create([
+                    'cid'         => $cid,
+                    'type'        => FileEnum::VIDEO_TYPE,
+                    'name'        => $fileInfo['name'],
+                    'uri'         => $saveDir . '/' . str_replace("\\","/", $fileName),
+                    'source'      => $source,
+                    'source_id'   => $sourceId,
+                    'create_time' => time(),
+                ]);
+            }
+
 
             // 5、返回结果
             return [
@@ -205,15 +235,29 @@ class UploadService
             }
 
             // 4、写入数据库中
-            $file = File::create([
-                'cid'         => $cid,
-                'type'        => FileEnum::FILE_TYPE,
-                'name'        => $fileInfo['name'],
-                'uri'         => $saveDir . '/' . str_replace("\\", "/", $fileName),
-                'source'      => $source,
-                'source_id'   => $sourceId,
-                'create_time' => time(),
-            ]);
+            if(AdminTerminalEnum::isTenant()) {
+                $file = (new TenantFile())->create([
+                    'tenant_id'   => request()->tenantId,
+                    'cid'         => $cid,
+                    'type'        => FileEnum::FILE_TYPE,
+                    'name'        => $fileInfo['name'],
+                    'uri'         => $saveDir . '/' . str_replace("\\", "/", $fileName),
+                    'source'      => $source,
+                    'source_id'   => $sourceId,
+                    'create_time' => time(),
+                ]);
+            }else{
+                $file = (new File())->create([
+                    'cid'         => $cid,
+                    'type'        => FileEnum::FILE_TYPE,
+                    'name'        => $fileInfo['name'],
+                    'uri'         => $saveDir . '/' . str_replace("\\", "/", $fileName),
+                    'source'      => $source,
+                    'source_id'   => $sourceId,
+                    'create_time' => time(),
+                ]);
+            }
+
 
             // 5、返回结果
             return [
@@ -254,14 +298,27 @@ class UploadService
             }
 
             // 4、写入数据库中
-            $file = File::create([
-                'cid'         => $cid,
-                'type'        => FileEnum::IMAGE_TYPE,
-                'name'        => $file_name,
-                'uri'         => $file_path,
-                'source_id'   => 0,
-                'create_time' => time(),
-            ]);
+            if(AdminTerminalEnum::isTenant()) {
+                $file = (new TenantFile())->create([
+                    'tenant_id'   => request()->tenantId,
+                    'cid'         => $cid,
+                    'type'        => FileEnum::IMAGE_TYPE,
+                    'name'        => $file_name,
+                    'uri'         => $file_path,
+                    'source_id'   => 0,
+                    'create_time' => time(),
+                ]);
+            }else{
+                $file = (new File())->create([
+                    'cid'         => $cid,
+                    'type'        => FileEnum::IMAGE_TYPE,
+                    'name'        => $file_name,
+                    'uri'         => $file_path,
+                    'source_id'   => 0,
+                    'create_time' => time(),
+                ]);
+            }
+
 
             // 5、返回结果
             return [

+ 1 - 1
app/tenantapi/controller/FileController.php

@@ -102,7 +102,7 @@ class FileController extends BaseAdminController
      */
     public function addCate()
     {
-        $params = (new FileValidate())->post()->goCheck('addCate');
+        $params = (new FileValidate())->post()->goCheck('addCate',['tenant_id'=>$this->adminInfo['tenant_id']]);
         FileLogic::addCate($params);
         return $this->success('添加成功', [], 1, 1);
     }

+ 39 - 0
app/tenantapi/controller/finance/AccountLogController.php

@@ -0,0 +1,39 @@
+<?php
+namespace app\tenantapi\controller\finance;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\finance\AccountLogLists;
+use app\common\enum\user\AccountLogEnum;
+
+/***
+ * 账户流水控制器
+ * Class AccountLogController
+ * @package app\tenantapi\controller
+ */
+class AccountLogController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 账户流水明细
+     * @return \think\response\Json
+     * @date 2023/2/24 15:25
+     */
+    public function lists()
+    {
+        return $this->dataLists(new AccountLogLists());
+    }
+
+
+    /**
+     * @notes 用户余额变动类型
+     * @return \think\response\Json
+     * @date 2023/2/24 15:25
+     */
+    public function getUmChangeType()
+    {
+        return $this->data(AccountLogEnum::getUserMoneyChangeTypeDesc());
+    }
+
+
+}

+ 108 - 0
app/tenantapi/controller/finance/MasterWorkerCaseOutLogController.php

@@ -0,0 +1,108 @@
+<?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\finance;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\finance\MasterWorkerCaseOutLogLists;
+use app\tenantapi\logic\finance\MasterWorkerCaseOutLogLogic;
+use app\tenantapi\validate\finance\MasterWorkerCaseOutLogValidate;
+
+
+/**
+ * MasterWorkerCaseOutLog控制器
+ * Class MasterWorkerCaseOutLogController
+ * @package app\tenantapi\controller\finance
+ */
+class MasterWorkerCaseOutLogController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerCaseOutLogLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerCaseOutLogValidate())->post()->goCheck('add');
+        $result = MasterWorkerCaseOutLogLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerCaseOutLogLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerCaseOutLogValidate())->post()->goCheck('edit',['admin_id'=>$this->adminId]);
+        $result = MasterWorkerCaseOutLogLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerCaseOutLogLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerCaseOutLogValidate())->post()->goCheck('delete');
+        MasterWorkerCaseOutLogLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerCaseOutLogValidate())->goCheck('detail');
+        $result = MasterWorkerCaseOutLogLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 72 - 0
app/tenantapi/controller/finance/RefundController.php

@@ -0,0 +1,72 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\controller\finance;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\finance\RefundLogLists;
+use app\tenantapi\lists\finance\RefundRecordLists;
+use app\tenantapi\logic\finance\RefundLogic;
+
+/**
+ * 退款控制器
+ * Class RefundController
+ * @package app\tenantapi\controller\finance
+ */
+class RefundController 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/3/3 12:10
+     */
+    public function stat()
+    {
+        $result = RefundLogic::stat(['tenant_id'=>$this->adminInfo['tenant_id']]);
+        return $this->success('', $result);
+    }
+
+
+    /**
+     * @notes 退款记录
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/3/1 9:47
+     */
+    public function record()
+    {
+        return $this->dataLists(new RefundRecordLists());
+    }
+
+
+    /**
+     * @notes 退款日志
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/3/1 9:47
+     */
+    public function log()
+    {
+        $recordId = $this->request->get('record_id', 0);
+        $result = RefundLogic::refundLog($recordId);
+        return $this->success('', $result);
+    }
+
+}

+ 39 - 0
app/tenantapi/controller/finance/WorkerAccountLogController.php

@@ -0,0 +1,39 @@
+<?php
+namespace app\tenantapi\controller\finance;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\finance\WorkerAccountLogLists;
+use app\common\enum\worker\WorkerAccountLogEnum;
+
+/***
+ * 账户流水控制器
+ * Class AccountLogController
+ * @package app\tenantapi\controller
+ */
+class WorkerAccountLogController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 账户流水明细
+     * @return \think\response\Json
+     * @date 2023/2/24 15:25
+     */
+    public function lists()
+    {
+        return $this->dataLists(new WorkerAccountLogLists());
+    }
+
+
+    /**
+     * @notes 用户余额变动类型
+     * @return \think\response\Json
+     * @date 2023/2/24 15:25
+     */
+    public function getUmChangeType()
+    {
+        return $this->data(WorkerAccountLogEnum::getUserMoneyChangeTypeDesc());
+    }
+
+
+}

+ 112 - 0
app/tenantapi/controller/goods_category/GoodsCategoryController.php

@@ -0,0 +1,112 @@
+<?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\goods_category;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\goods_category\GoodsCategoryLists;
+use app\tenantapi\logic\goods_category\GoodsCategoryLogic;
+use app\tenantapi\validate\goods_category\GoodsCategoryValidate;
+
+
+/**
+ * GoodsCategory控制器
+ * Class GoodsCategoryController
+ * @package app\tenantapi\controller\goods_category
+ */
+class GoodsCategoryController extends BaseAdminController
+{
+
+    public array $notNeedLogin = ['treeData'];
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GoodsCategoryLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function add()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('add');
+        $result = GoodsCategoryLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(GoodsCategoryLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function edit()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('edit');
+        $result = GoodsCategoryLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(GoodsCategoryLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function delete()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('delete');
+        GoodsCategoryLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function detail()
+    {
+        $params = (new GoodsCategoryValidate())->goCheck('detail');
+        $result = GoodsCategoryLogic::detail($params);
+        return $this->data($result);
+    }
+
+   public function treeData()
+   {
+       $result = GoodsCategoryLogic::getTreeData();
+       return $this->data($result);
+   }
+}

+ 119 - 0
app/tenantapi/controller/master_worker/BankAccountController.php

@@ -0,0 +1,119 @@
+<?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\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\BankAccountLists;
+use app\tenantapi\logic\master_worker\BankAccountLogic;
+use app\tenantapi\validate\master_worker\BankAccountValidate;
+use app\common\logic\MasterWorkerExamineLogic;
+
+
+/**
+ * BankAccount控制器
+ * Class BankAccountController
+ * @package app\tenantapi\controller\master_worker
+ */
+class BankAccountController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function lists()
+    {
+        return $this->dataLists(new BankAccountLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function add()
+    {
+        $params = (new BankAccountValidate())->post()->goCheck('add');
+        $result = BankAccountLogic::add($params);
+        if (true === $result) {
+            MasterWorkerExamineLogic::updateEngineerInformation($params['worker_id']);
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(BankAccountLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function edit()
+    {
+        $params = (new BankAccountValidate())->post()->goCheck('edit');
+        $result = BankAccountLogic::edit($params);
+        if (true === $result) {
+            MasterWorkerExamineLogic::updateEngineerInformation($params['worker_id']);
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(BankAccountLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function delete()
+    {
+        $params = (new BankAccountValidate())->post()->goCheck('delete');
+        try {
+            $worker_ids = BankAccountLogic::getWorkerIds($params);
+            BankAccountLogic::delete($params);
+            foreach ($worker_ids as $worker_id) {
+                MasterWorkerExamineLogic::updateEngineerInformation($worker_id);
+            }
+            return $this->success('删除成功', [], 1, 1);
+        } catch (\Exception $e) {
+            return $this->fail('删除失败-'.$e->getMessage());
+        }
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function detail()
+    {
+        $params = (new BankAccountValidate())->goCheck('detail');
+        $result = BankAccountLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 129 - 0
app/tenantapi/controller/master_worker/EngineerBillController.php

@@ -0,0 +1,129 @@
+<?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\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\EngineerBillLists;
+use app\tenantapi\logic\export\ExportLogic;
+use app\tenantapi\logic\financial\MasterSettlementDetailsLogic;
+use app\tenantapi\logic\master_worker\EngineerBillLogic;
+use app\tenantapi\logic\master_worker\EngineerSettlementLogic;
+use app\common\service\ExcelExportService;
+use excel\ExcelWriter;
+use phpseclib3\Common\Functions\Strings;
+use think\facade\Db;
+use think\facade\Log;
+
+/**
+ * EngineerSettlement控制器
+ * Class EngineerSettlementController
+ * @package app\tenantapi\controller
+ */
+class EngineerBillController extends BaseAdminController
+{
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function lists()
+    {
+        // 导入数据
+        $res = EngineerSettlementLogic::insertSettlementDetails();
+        if($res === false){
+            return $this->fail('导入失败');
+        }
+        return $this->dataLists(new EngineerBillLists());
+    }
+
+    public function download()
+    {
+        /*$firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
+        $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
+        $filename = date('Y-m-d',strtotime($firstDay))."-至-".date('Y-m-d',strtotime($lastDay))."最后结算余额";
+        $result = ExportLogic::add([
+            'download_type' => 1,
+            'params' => ['firstDay'=>$firstDay,'lastDay'=>$lastDay],
+            'name' => $filename,
+            'admin_id' => $this->adminId,
+        ]);
+        if (false === $result) {
+            return $this->fail(ExportLogic::getError());
+        }*/
+
+        $params = $this->request->get();
+        $deadline_time = strtotime($params['deadline_time'])+86400;
+        $settlement_type = $params['settlement_type'];
+
+        $allData = $this->dataLists(new EngineerBillLists())->getData()['data']['lists'];
+        if(empty($allData)) return $this->fail('无数据');
+
+        $type = [
+            1=>'周(7天)',
+            2=>'半月',
+            3=>'整月'
+        ];
+        $filename = "截止到".$params['deadline_time'].$type[$settlement_type].'型结算单';
+        $result = ExportLogic::add([
+            'download_type' => 1,
+            'params' => ['settlement_type'=>$settlement_type,'deadline_time'=>$deadline_time],
+            'name' => $filename,
+            'admin_id' => $this->adminId,
+        ]);
+        if (false === $result) {
+            return $this->fail(ExportLogic::getError());
+        }
+        Log::info('导出参数:'.json_encode([$params,$result]));
+        // 暂时 - 立即生成导出文件
+        (new ExcelExportService)->download($result);
+        return $this->success('添加成功-'.$result, [], 1, 1);
+    }
+    public function submitForm()
+    {
+        $params = $this->request->post();
+        $params['adminId'] = $this->adminId;
+        $result = EngineerBillLogic::submitForm($params);
+        if ($result === false){
+            return $this->fail(EngineerBillLogic::getError());
+        }
+        return $this->success('打款成功', [], 1, 1);
+    }
+
+
+    /*
+     * 列表导出 - 不涉及任何后续批量编号逻辑
+     */
+    public function listsDownload()
+    {
+        $params = $this->request->get();
+        $filename = "财务结算工程师";
+        $result = ExportLogic::add([
+            'download_type' => 5,
+            'params' => $params,
+            'name' => $filename,
+            'admin_id' => $this->adminId,
+        ]);
+        if (false === $result) {
+            return $this->fail(ExportLogic::getError());
+        }
+        // 暂时 - 立即生成导出文件
+        (new ExcelExportService)->download($result);
+        return $this->success('添加成功-'.$result, [], 1, 1);
+    }
+
+}

+ 124 - 0
app/tenantapi/controller/master_worker/EngineerSettlementController.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\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\EngineerSettlementLists;
+use app\tenantapi\logic\master_worker\EngineerSettlementLogic;
+use app\tenantapi\validate\master_worker\EngineerSettlementValidate;
+use excel\ExcelWriter;
+use PhpOffice\PhpSpreadsheet\Spreadsheet;
+use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
+
+
+/**
+ * EngineerSettlement控制器
+ * Class EngineerSettlementController
+ * @package app\tenantapi\controller
+ */
+class EngineerSettlementController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function lists()
+    {
+        return $this->dataLists(new EngineerSettlementLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function add()
+    {
+        //$params = (new EngineerSettlementValidate())->post();//->goCheck('add');
+        try {
+            $params = $this->request->post();
+            $params = EngineerSettlementLogic::engineerSettlementValidate($params);
+            $result = EngineerSettlementLogic::add($params,$this->adminId);
+            if (true === $result) {
+                return $this->success('添加成功', [], 1, 1);
+            }
+            return $this->fail(EngineerSettlementLogic::getError());
+        } catch (\Exception $e) {
+            return $this->fail($e->getMessage()?:EngineerSettlementLogic::getError());
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function edit()
+    {
+        $params = (new EngineerSettlementValidate())->post()->goCheck('edit');
+        $result = EngineerSettlementLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(EngineerSettlementLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function delete()
+    {
+        $params = (new EngineerSettlementValidate())->post()->goCheck('delete');
+        EngineerSettlementLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function detail()
+    {
+        $params = (new EngineerSettlementValidate())->goCheck('detail');
+        $result = EngineerSettlementLogic::detail($params);
+        return $this->data($result);
+    }
+
+    public function download()
+    {
+        $lists = EngineerSettlementLogic::downloadLists();
+        (new ExcelWriter())->generateExcelFile([
+            '工程师ID', '工程师编号', '工程师姓名', '工程师原始余额', '工程师总结算金额', '工程师扣款金额', '工程师最终结算金额', '结算时间', '结算明细备注'
+        ], $lists,'template', ['master_worker_id','worker_number','engineer_name','original_balance','total_settlement_amount','deduction_amount',
+            'final_settlement_amount','settlement_time','settlement_details_remarks']);
+    }
+
+}

+ 120 - 0
app/tenantapi/controller/master_worker/MasterWorkerAgreeController.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\tenantapi\controller\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\MasterWorkerAgreeLists;
+use app\tenantapi\logic\master_worker\MasterWorkerAgreeLogic;
+use app\tenantapi\validate\master_worker\MasterWorkerAgreeValidate;
+use app\common\logic\MasterWorkerExamineLogic;
+
+
+/**
+ * MasterWorkerAgree控制器
+ * Class MasterWorkerAgreeController
+ * @package app\tenantapi\controller\master_worker
+ */
+class MasterWorkerAgreeController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerAgreeLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerAgreeValidate())->post()->goCheck('add');
+        $result = MasterWorkerAgreeLogic::add($params);
+        if (true === $result) {
+            MasterWorkerExamineLogic::updateEngineerInformation($params['worker_id']);
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerAgreeLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerAgreeValidate())->post()->goCheck('edit');
+        $result = MasterWorkerAgreeLogic::edit($params);
+        if (true === $result) {
+            $info = MasterWorkerAgreeLogic::detail(['id'=>$params['id']]);
+            MasterWorkerExamineLogic::updateEngineerInformation($info['worker_id']);
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerAgreeLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerAgreeValidate())->post()->goCheck('delete');
+        try {
+            $worker_ids = MasterWorkerAgreeLogic::getWorkerIds($params);
+            MasterWorkerAgreeLogic::delete($params);
+            foreach ($worker_ids as $worker_id) {
+                MasterWorkerExamineLogic::updateEngineerInformation($worker_id);
+            }
+            return $this->success('删除成功', [], 1, 1);
+        } catch (\Exception $e) {
+            return $this->fail('删除失败-'.$e->getMessage());
+        }
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerAgreeValidate())->goCheck('detail');
+        $result = MasterWorkerAgreeLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 129 - 0
app/tenantapi/controller/master_worker/MasterWorkerController.php

@@ -0,0 +1,129 @@
+<?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\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\MasterWorkerLists;
+use app\tenantapi\logic\master_worker\MasterWorkerLogic;
+use app\tenantapi\validate\master_worker\MasterWorkerValidate;
+
+
+/**
+ * MasterWorker控制器
+ * Class MasterWorkerController
+ * @package app\tenantapi\controller\master_worker
+ */
+class MasterWorkerController extends BaseAdminController
+{
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerValidate())->post()->goCheck('add', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = MasterWorkerLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerValidate())->post()->goCheck('edit', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = MasterWorkerLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerValidate())->post()->goCheck('delete');
+        MasterWorkerLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerValidate())->goCheck('detail');
+        $result = MasterWorkerLogic::detail($params);
+        return $this->data($result);
+    }
+
+    /**
+     * 获取加盐密码
+     * @return \think\response\Json
+     */
+    public function saltToPassword()
+    {
+        $params = (new MasterWorkerValidate())->get()->goCheck('saltToPassword');
+        $result = MasterWorkerLogic::saltToPassword($params);
+        if (false === $result) {
+            return $this->fail(MasterWorkerLogic::getError());
+        }
+        return $this->data($result);
+    }
+
+
+    public function getAllWorkers()
+    {
+        $params = (new MasterWorkerValidate())->get();
+        $result = MasterWorkerLogic::getAllWorkers($params);
+        if (false === $result) {
+            return $this->fail(MasterWorkerLogic::getError());
+        }
+        return $this->data($result);
+    }
+}

+ 109 - 0
app/tenantapi/controller/master_worker/MasterWorkerExamineController.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\controller\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\MasterWorkerAgreeLists;
+use app\tenantapi\lists\master_worker\MasterWorkerExamineLists;
+use app\tenantapi\logic\master_worker\MasterWorkerAgreeLogic;
+use app\tenantapi\logic\master_worker\MasterWorkerExamineLogic;
+use app\tenantapi\validate\master_worker\MasterWorkerAgreeValidate;
+
+
+/**
+ * MasterWorkerExamine控制器
+ * Class MasterWorkerExamineController
+ * @package app\tenantapi\controller\master_worker
+ */
+class MasterWorkerExamineController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerExamineLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function add()
+    {
+        return $this->fail('');
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function edit()
+    {
+        $params = $this->request->post();
+        $result = MasterWorkerExamineLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerExamineLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerAgreeValidate())->post()->goCheck('delete');
+        MasterWorkerAgreeLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerAgreeValidate())->goCheck('detail');
+        $result = MasterWorkerAgreeLogic::detail($params);
+        return $this->data($result);
+    }
+
+    public function getStatus()
+    {
+        $result = MasterWorkerAgreeLogic::getStatus();
+        return $this->data(['count'=>$result]);
+    }
+}

+ 116 - 0
app/tenantapi/controller/master_worker/MasterWorkerInfoController.php

@@ -0,0 +1,116 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\tenantapi\controller\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\MasterWorkerInfoLists;
+use app\tenantapi\logic\master_worker\MasterWorkerInfoLogic;
+use app\tenantapi\validate\master_worker\MasterWorkerInfoValidate;
+use app\common\logic\MasterWorkerExamineLogic;
+
+
+/**
+ * MasterWorkerInfo控制器
+ * Class MasterWorkerInfoController
+ * @package app\tenantapi\controller\master_worker
+ */
+class MasterWorkerInfoController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerInfoLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerInfoValidate())->post()->goCheck('add');
+        $result = MasterWorkerInfoLogic::add($params);
+        if (true === $result) {
+            MasterWorkerExamineLogic::updateEngineerInformation($params['worker_id']);
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerInfoLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerInfoValidate())->post()->goCheck('edit');
+        $result = MasterWorkerInfoLogic::edit($params);
+        if (true === $result) {
+            $info = MasterWorkerInfoLogic::detail(['id'=>$params['id']]);
+            MasterWorkerExamineLogic::updateEngineerInformation($info['worker_id']);
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerInfoLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerInfoValidate())->post()->goCheck('delete');
+        $worker_ids = MasterWorkerInfoLogic::getWorkerIds($params);
+        MasterWorkerInfoLogic::delete($params);
+        foreach ($worker_ids as $worker_id) {
+            MasterWorkerExamineLogic::updateEngineerInformation($worker_id);
+        }
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerInfoValidate())->goCheck('detail');
+        $result = MasterWorkerInfoLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 108 - 0
app/tenantapi/controller/master_worker/MasterWorkerRuleController.php

@@ -0,0 +1,108 @@
+<?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\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\MasterWorkerRuleLists;
+use app\tenantapi\logic\master_worker\MasterWorkerRuleLogic;
+use app\tenantapi\validate\master_worker\MasterWorkerRuleValidate;
+
+
+/**
+ * MasterWorkerRule控制器
+ * Class MasterWorkerRuleController
+ * @package app\tenantapi\controller
+ */
+class MasterWorkerRuleController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerRuleLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerRuleValidate())->post()->goCheck('add');
+        $result = MasterWorkerRuleLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRuleLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerRuleValidate())->post()->goCheck('edit');
+        $result = MasterWorkerRuleLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRuleLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerRuleValidate())->post()->goCheck('delete');
+        MasterWorkerRuleLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerRuleValidate())->goCheck('detail');
+        $result = MasterWorkerRuleLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 66 - 0
app/tenantapi/controller/master_worker/MasterWorkerServiceOrderController.php

@@ -0,0 +1,66 @@
+<?php
+namespace app\tenantapi\controller\master_worker;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_commission\MasterWorkerCommissionNoticeLists;
+use app\tenantapi\lists\master_worker\MasterWorkerServiceOrderLists;
+use app\tenantapi\logic\export\ExportLogic;
+use app\common\service\ExcelExportService;
+
+/**
+ * MasterWorkerServiceOrder控制器
+ * Class MasterWorkerServiceOrderController
+ * @package app\tenantapi\controller
+ */
+class MasterWorkerServiceOrderController extends BaseAdminController
+{
+    /**
+     * @notes 获取列表
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerServiceOrderLists());
+    }
+    public function download()
+    {
+        $params = $this->request->get();
+        $tmp_filename = '';
+        if($params['start_time'] && $params['end_time']) $tmp_filename = date('Y-m-d',strtotime($params['start_time']))."-至-".date('Y-m-d',strtotime($params['end_time']));
+        $filename = $tmp_filename."工单统计";
+        $result = ExportLogic::add([
+            'download_type' => 2,
+            'params' => $params,
+            'name' => $filename,
+            'admin_id' => $this->adminId,
+        ]);
+        if (false === $result) {
+            return $this->fail(ExportLogic::getError());
+        }
+        // 暂时 - 立即生成导出文件
+        (new ExcelExportService)->download($result);
+        return $this->success('添加成功-'.$result, [], 1, 1);
+    }
+
+    public function freeNotice()
+    {
+        return $this->dataLists(new MasterWorkerCommissionNoticeLists());
+    }
+
+    public function freeDownload()
+    {
+        $params = $this->request->get();
+        $filename = "免费班工程师统计";
+        $result = ExportLogic::add([
+            'download_type' => 4,
+            'params' => $params,
+            'name' => $filename,
+            'admin_id' => $this->adminId,
+        ]);
+        if (false === $result) {
+            return $this->fail(ExportLogic::getError());
+        }
+        // 暂时 - 立即生成导出文件
+        (new ExcelExportService)->download($result);
+        return $this->success('添加成功-'.$result, [], 1, 1);
+    }
+}

+ 108 - 0
app/tenantapi/controller/master_worker/MasterWorkerTeamController.php

@@ -0,0 +1,108 @@
+<?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\master_worker;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\master_worker\MasterWorkerTeamLists;
+use app\tenantapi\logic\master_worker\MasterWorkerTeamLogic;
+use app\tenantapi\validate\master_worker\MasterWorkerTeamValidate;
+
+
+/**
+ * MasterWorkerTeam控制器
+ * Class MasterWorkerTeamController
+ * @package app\tenantapi\controller
+ */
+class MasterWorkerTeamController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerTeamLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerTeamValidate())->post()->goCheck('add', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = MasterWorkerTeamLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerTeamLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerTeamValidate())->post()->goCheck('edit', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = MasterWorkerTeamLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerTeamLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerTeamValidate())->post()->goCheck('delete');
+        MasterWorkerTeamLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerTeamValidate())->goCheck('detail');
+        $result = MasterWorkerTeamLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 37 - 0
app/tenantapi/controller/master_worker/RetentionMoneyLogController.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\tenantapi\controller\master_worker;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\validate\master_worker\MasterWorkerRetentionMoneyLogValidate;
+use app\common\logic\RetentionMoneyLogic;
+use app\workerapi\lists\MasterWorkerRetentionMoneyLogLists;
+
+class RetentionMoneyLogController extends BaseAdminController
+{
+    public array $notNeedLogin = ['totalAmount'];
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerRetentionMoneyLogLists());
+    }
+
+    public function totalAmount()
+    {
+        $params = (new MasterWorkerRetentionMoneyLogValidate())->get()->goCheck('totalAmount');
+        $result = RetentionMoneyLogic::totalAmount($params);
+        if (false === $result) {
+            return $this->fail(RetentionMoneyLogic::getError());
+        }
+        return $this->success('操作成功',$result, 1, 0);
+    }
+
+    public function add()
+    {
+        $params = (new MasterWorkerRetentionMoneyLogValidate())->post()->goCheck('add');
+        $result = RetentionMoneyLogic::addDeduct($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(RetentionMoneyLogic::getError());
+    }
+}

+ 135 - 0
app/tenantapi/controller/notice/NoticeController.php

@@ -0,0 +1,135 @@
+<?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\notice;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\notice\NoticeSettingLists;
+use app\tenantapi\logic\notice\NoticeLogic;
+use app\tenantapi\validate\notice\NoticeValidate;
+use app\common\enum\notice\NoticeEnum;
+use app\common\model\notice\NoticeSetting;
+use app\common\service\wechat\WeChatOaService;
+
+/**
+ * 通知控制器
+ * Class NoticeController
+ * @package app\tenantapi\controller\notice
+ */
+class NoticeController extends BaseAdminController
+{
+    public array $notNeedLogin = ['testNotice'];
+    /**
+     * @notes 查看通知设置列表
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 11:18
+     */
+    public function settingLists()
+    {
+        return $this->dataLists(new NoticeSettingLists());
+    }
+
+
+    /**
+     * @notes 查看通知设置详情
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 11:18
+     */
+    public function detail()
+    {
+        $params = (new NoticeValidate())->goCheck('detail');
+        $result = NoticeLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 通知设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2022/3/29 11:18
+     */
+    public function set()
+    {
+        $params = $this->request->post();
+        $result = NoticeLogic::set($params);
+        if ($result) {
+            return $this->success('设置成功');
+        }
+        return $this->fail(NoticeLogic::getError());
+    }
+
+    /**
+     * @notes 获取通知弹框信息
+     */
+    public function getInformation()
+    {
+        $params = $this->request->post();
+        $params['tenant_id'] = $this->adminInfo['tenant_id'];
+        if(isset($params['business_codes']) && !empty($params['business_codes'])){
+            $result = NoticeLogic::getInformationBatch($params);
+        }else{
+            $result = NoticeLogic::getInformation($params);
+        }
+        if ($result) {
+            return $this->success('获取成功', $result);
+        }
+        return $this->fail(NoticeLogic::getError());
+    }
+
+    /**
+     * @notes 后台测试通知
+     * http://api.weixiuloc.com:5175/tenantapi/notice.notice/testNotice?scene_id=1&params={}
+     */
+    public function testNotice()
+    {
+        try {
+            $params = $this->request->get();
+            if(!isset($params['scene_id'])){
+                throw new \Exception('scene_id不存在');
+            }
+            $noticeSetting = NoticeSetting::where('scene_id', $params['scene_id'])->findOrEmpty()->toArray();
+            if(isset($noticeSetting['sms_notice']['status'])){
+                $res = event('Notice',  [
+                    'scene_id' => $params['scene_id'],
+                    'params' => json_decode($params['params'],true)
+                    /*[
+                        'user_id' => $params['user_id'],
+                    ]*/
+                ]);
+            }
+            if(isset($noticeSetting['oa_notice']['status'])){
+                $res = event('Notice',  [
+                    'scene_id' => $params['scene_id'],
+                    'params' => json_decode($params['params'],true)
+                    /*[
+                        'user_id' => $params['user_id'],
+                        'order_id' => $params['order_id']?:'',
+                        'thing9' => '测试项目名称'.time(),
+                        'time7' => date("Y-m-d H:i:s", time()),
+                        'thing8' => '预约地址'.time(),
+                        'phone_number6' => 18162757399,
+                    ]*/
+                ]);
+            }
+            dd($params,json_decode($params['params'],true),$noticeSetting,$res??[]);
+        } catch (\Exception  $e) {
+            dd($e->getMessage());
+        }
+    }
+
+
+}

+ 107 - 0
app/tenantapi/controller/recharge/RechargeController.php

@@ -0,0 +1,107 @@
+<?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\recharge;
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\recharge\RechargeLists;
+use app\tenantapi\logic\recharge\RechargeLogic;
+use app\tenantapi\validate\recharge\RechargeRefundValidate;
+
+/**
+ * 充值控制器
+ * Class RechargeController
+ * @package app\tenantapi\controller\recharge
+ */
+class RechargeController extends BaseAdminController
+{
+
+    /**
+     * @notes 获取充值设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/22 16:48
+     */
+    public function getConfig()
+    {
+        $result = RechargeLogic::getConfig();
+        return $this->data($result);
+    }
+
+
+    /**
+     * @notes 充值设置
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/22 16:48
+     */
+    public function setConfig()
+    {
+        $params = $this->request->post();
+        $result = RechargeLogic::setConfig($params);
+        if($result) {
+            return $this->success('操作成功', [], 1, 1);
+        }
+        return $this->fail(RechargeLogic::getError());
+    }
+
+
+    /**
+     * @notes 充值记录
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/24 16:01
+     */
+    public function lists()
+    {
+        return $this->dataLists(new RechargeLists());
+    }
+
+
+    /**
+     * @notes 退款
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/28 17:29
+     */
+    public function refund()
+    {
+        $params = (new RechargeRefundValidate())->post()->goCheck('refund');
+        $result = RechargeLogic::refund($params, $this->adminId);
+        list($flag, $msg) = $result;
+        if(false === $flag) {
+            return $this->fail($msg);
+        }
+        return $this->success($msg, [], 1, 1);
+    }
+
+
+    /**
+     * @notes 重新退款
+     * @return \think\response\Json
+     * @author 段誉
+     * @date 2023/2/28 19:17
+     */
+    public function refundAgain()
+    {
+        $params = (new RechargeRefundValidate())->post()->goCheck('again');
+        $result = RechargeLogic::refundAgain($params, $this->adminId);
+        list($flag, $msg) = $result;
+        if(false === $flag) {
+            return $this->fail($msg);
+        }
+        return $this->success($msg, [], 1, 1);
+    }
+
+}

+ 108 - 0
app/tenantapi/controller/works/IssueWorkController.php

@@ -0,0 +1,108 @@
+<?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\works;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\works\IssueWorkLists;
+use app\tenantapi\logic\works\IssueWorkLogic;
+use app\tenantapi\validate\works\IssueWorkValidate;
+
+
+/**
+ * IssueWork控制器
+ * Class IssueWorkController
+ * @package app\tenantapi\controller\works
+ */
+class IssueWorkController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function lists()
+    {
+        return $this->dataLists(new IssueWorkLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function add()
+    {
+        $params = (new IssueWorkValidate())->post()->goCheck('add', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = IssueWorkLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(IssueWorkLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function edit()
+    {
+        $params = (new IssueWorkValidate())->post()->goCheck('edit',['tenant_id' => $this->adminInfo['tenant_id'], 'approval_admin_id'=>$this->adminId]);
+        $result = IssueWorkLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(IssueWorkLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function delete()
+    {
+        $params = (new IssueWorkValidate())->post()->goCheck('delete');
+        IssueWorkLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function detail()
+    {
+        $params = (new IssueWorkValidate())->goCheck('detail');
+        $result = IssueWorkLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 147 - 0
app/tenantapi/controller/works/ReturnWorkController.php

@@ -0,0 +1,147 @@
+<?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\works;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\works\ReturnWorkLists;
+use app\tenantapi\logic\works\IssueWorkLogic;
+use app\tenantapi\logic\works\ReturnWorkLogic;
+use app\tenantapi\logic\works\ServiceWorkLogic;
+use app\tenantapi\validate\works\ReturnWorkValidate;
+
+
+/**
+ * ReturnWork控制器
+ * Class ReturnWorkController
+ * @package app\tenantapi\controller\works
+ */
+class ReturnWorkController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function lists()
+    {
+        return $this->dataLists(new ReturnWorkLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function add()
+    {
+        $params = (new ReturnWorkValidate())->post()->goCheck('add', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = ReturnWorkLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(ReturnWorkLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function edit()
+    {
+        $params = (new ReturnWorkValidate())->post()->goCheck('edit', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = ReturnWorkLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(ReturnWorkLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function delete()
+    {
+        $params = (new ReturnWorkValidate())->post()->goCheck('delete');
+        ReturnWorkLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function detail()
+    {
+        $params = (new ReturnWorkValidate())->goCheck('detail');
+        $result = ReturnWorkLogic::detail($params);
+        return $this->data($result);
+    }
+
+    /**
+     * 处理返修工单
+     * @return \think\response\Json
+     * @author 林海涛
+     * @date 2024/7/24 下午1:52
+     */
+    public function issueWorkData()
+    {
+        $params = (new ReturnWorkValidate())->post()->goCheck('issueWorkData', ['tenant_id' => $this->adminInfo['tenant_id']]);
+        $result = ReturnWorkLogic::issueWorkData($params);
+        if (true === $result) {
+            $issueWork = IssueWorkLogic::detail(['id'=>$params['issue_work_id']]);
+            // 订单返修通知【给用户】
+            event('Notice',  [
+                'scene_id' => 121,
+                'params' => [
+                    'user_id' => $issueWork['user_id']
+                ]
+            ]);
+            // 返修工程师预约上门通知【给工程师的通知】
+            $returnWork = ReturnWorkLogic::detail(['issue_work_id'=>$params['issue_work_id']]);
+            $workDetail = ServiceWorkLogic::detail(['id'=>$issueWork['service_work_id']]);
+            event('Notice',  [
+                'scene_id' => 124,
+                'params' => [
+                    'user_id' => $returnWork['master_worker_id'],
+                    'order_id' => $params['issue_work_id'],
+                    'thing2' => $issueWork['complaint_type_text'],
+                    'thing3' => $issueWork['complaint_details'],
+                    'thing4' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],
+                    'phone_number6' => asteriskString($issueWork['complaint_mobile']),
+                    'time17' => $returnWork['appointment_time'],
+                ]
+            ]);
+            return $this->success('成功', [], 1, 1);
+        }
+        return $this->fail(ReturnWorkLogic::getError());
+    }
+}

+ 210 - 0
app/tenantapi/controller/works/ServiceWorkController.php

@@ -0,0 +1,210 @@
+<?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\works;
+
+
+use app\tenantapi\controller\BaseAdminController;
+use app\tenantapi\lists\works\ServiceWorkLists;
+use app\tenantapi\logic\master_worker\MasterWorkerLogic;
+use app\tenantapi\logic\works\ServiceWorkLogic;
+use app\tenantapi\validate\works\ServiceWorkValidate;
+use app\api\logic\ServiceOrderLogic;
+
+
+/**
+ * ServiceWork控制器
+ * Class WorksController
+ * @package app\tenantapi\controller\works
+ */
+class ServiceWorkController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function lists()
+    {
+        return $this->dataLists(new ServiceWorkLists());
+    }
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function edit()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('edit');
+        $workDetail = ServiceWorkLogic::detail($params);
+        $result = ServiceWorkLogic::edit($params);
+        if (true === $result) {
+            if(strtotime($workDetail['appointment_time']) !== strtotime($params['appointment_time']) && !empty($workDetail['master_worker_id'])){
+                $masterDetail = MasterWorkerLogic::detail(['id'=>$workDetail['master_worker_id']]);
+                // 修改预约时间通知【给用户的通知】
+                $res = event('Notice',  [
+                    'scene_id' => 117,
+                    'params' => [
+                        'user_id' => $workDetail['user_id'],
+                        'date' => $params['appointment_time'],
+                        'tel' => asteriskString($masterDetail['mobile']),
+                    ]
+                ]);
+                // 修改预约时间通知【给工程师的通知,仅限公众号】
+                $res = event('Notice',  [
+                    'scene_id' => 118,
+                    'params' => [
+                        'user_id' => $workDetail['master_worker_id'],
+                        'order_id' => $workDetail['id'],
+                        'thing4' => $workDetail['title'],
+                        'time5' => $workDetail['appointment_time'],
+                        'time6' => $params['appointment_time'],
+                        'thing11' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],
+                        'phone_number8' => asteriskString($workDetail['mobile']),
+                    ]
+                ]);
+            }
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function delete()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('delete');
+        $result = ServiceWorkLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->success('分配成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function detail()
+    {
+        $params = (new ServiceWorkValidate())->goCheck('detail');
+        $result = ServiceWorkLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+    public function allocateWorker()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('allocateWorker');
+        $result = ServiceWorkLogic::allocateWorker($params,$this->adminInfo);
+        if (true === $result) {
+            // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
+            $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 $this->success('分配工程师成功', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+    public function cancelWorker()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('detail');
+        $result = ServiceWorkLogic::cancel($params);
+        if (true === $result) {
+            return $this->success('取消工单成功!', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+    public function settlementMaster()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('detail');
+        $result = ServiceWorkLogic::settlement($params);
+        if (true === $result) {
+            return $this->success('操作成功!', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+
+    public function notApproved()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('detail');
+        $result = ServiceWorkLogic::notApproved($params);
+        if (true === $result) {
+            return $this->success('操作成功!', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+
+    public function cancelAllocation()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('allocateWorker');
+        $result = ServiceWorkLogic::cancelAllocation($params,$this->adminInfo);
+        if (true === $result) {
+            return $this->success('操作成功!', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+
+
+    public function addCustomerLog()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('detail',[
+            'admin_id' => $this->adminId,
+        ]);
+        $result = ServiceWorkLogic::addCustomerLog($params);
+        if (true === $result) {
+            return $this->success('操作成功!', [], 1, 1);
+        }
+        return $this->fail(ServiceWorkLogic::getError());
+    }
+
+
+    public function confirmServiceFinish()
+    {
+        $params = request()->post();
+        $params['admin_id'] = $this->adminId;
+        $result = ServiceOrderLogic::confirmServiceFinish($params);
+        if (false === $result) {
+            return $this->fail(ServiceOrderLogic::getError());
+        }
+        // 订单完成通知【给用户】 - 全款 -通知
+        ServiceOrderLogic::serviceFinishNotice($params);
+        // 工程师完单的时候设置该规则关闭,以及短信通知工程师
+        ServiceOrderLogic::orderQuantityRule($params);
+        return $this->success('操作成功!', [], 1, 1);
+    }
+}

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

@@ -61,6 +61,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
             $where[] = ['cid', 'in', $cateChild];
         }
 
+        $where['tenant_id'] = $this->adminInfo['tenant_id'];
+
         return $where;
     }
 

+ 119 - 0
app/tenantapi/lists/finance/AccountLogLists.php

@@ -0,0 +1,119 @@
+<?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\finance;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\user\AccountLogEnum;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\user\UserAccountLog;
+use app\common\service\FileService;
+
+
+/**
+ * 账记流水列表
+ * Class AccountLogLists
+ * @package app\tenantapi\lists\finance
+ */
+class AccountLogLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * @notes 搜索条件
+     * @return array
+     * @author 段誉
+     * @date 2023/2/24 15:26
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['al.change_type'],
+        ];
+    }
+
+
+    /**
+     * @notes 搜索条件
+     * @author 段誉
+     * @date 2023/2/24 15:26
+     */
+    public function queryWhere()
+    {
+        $where = [];
+        // 用户余额
+        if (isset($this->params['type']) && $this->params['type'] == 'um') {
+            $where[] = ['change_type', 'in', AccountLogEnum::getUserMoneyChangeType()];
+        }
+
+        if (!empty($this->params['user_info'])) {
+            $where[] = ['u.sn|u.nickname|u.mobile|u.account', 'like', '%' . $this->params['user_info'] . '%'];
+        }
+
+        if (!empty($this->params['start_time'])) {
+            $where[] = ['al.create_time', '>=', strtotime($this->params['start_time'])];
+        }
+
+        if (!empty($this->params['end_time'])) {
+            $where[] = ['al.create_time', '<=', strtotime($this->params['end_time'])];
+        }
+
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @author 段誉
+     * @date 2023/2/24 15:31
+     */
+    public function lists(): array
+    {
+        $field = 'u.nickname,u.account,u.sn,u.avatar,u.mobile,al.action,al.change_amount,al.left_amount,al.change_type,al.source_sn,al.create_time';
+        $lists = UserAccountLog::alias('al')
+            ->join('user u', 'u.id = al.user_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->field($field)
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->order('al.id', 'desc')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+
+        foreach ($lists as &$item) {
+            $item['avatar'] = FileService::getFileUrl($item['avatar']);
+            $item['change_type_desc'] = AccountLogEnum::getChangeTypeDesc($item['change_type']);
+            $symbol = $item['action'] == AccountLogEnum::INC ? '+' : '-';
+            $item['change_amount'] = $symbol . $item['change_amount'];
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2023/2/24 15:36
+     */
+    public function count(): int
+    {
+        return UserAccountLog::alias('al')
+            ->join('user u', 'u.id = al.user_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->where($this->queryWhere())
+            ->where($this->searchWhere)
+            ->count();
+    }
+}

+ 97 - 0
app/tenantapi/lists/finance/MasterWorkerCaseOutLogLists.php

@@ -0,0 +1,97 @@
+<?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\finance;
+
+
+use app\common\model\master_worker\MasterWorker;
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\lists\ListsSearchInterface;
+use think\db\Query;
+
+
+/**
+ * MasterWorkerCaseOutLog列表
+ * Class MasterWorkerCaseOutLogLists
+ * @package app\tenantapi\listsfinance
+ */
+class MasterWorkerCaseOutLogLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['sn', 'worker_id', 'review_status'],
+            '%like%' => ['sn'],
+        ];
+    }
+    public function querySearch():array
+    {
+        $data = [];
+        if(isset($this->params['min_change_amount']) && is_numeric($this->params['min_change_amount'])){
+            $where[] =['change_amount','>=',$this->params['min_change_amount']];
+        }
+        if(isset($this->params['max_change_amount']) && is_numeric($this->params['max_change_amount'])){
+            $where[] =['change_amount','<=',$this->params['max_change_amount']];
+        }
+        return $data;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function lists(): array
+    {
+        $ids = MasterWorker::where('tenant_id',$this->adminInfo['tenant_id'])->column('id')??[0];
+        return MasterWorkerCaseOutLog::where($this->searchWhere)
+            ->with(['masterWorker'=>function(Query $query){
+                $query->field('id,nickname,worker_number');
+            }])
+            ->whereIn('worker_id',$ids)
+            ->where($this->querySearch())
+            ->field(['id', 'sn', 'worker_id', 'change_amount', 'review_status', 'remark'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function count(): int
+    {
+        $ids = MasterWorker::where('tenant_id',$this->adminInfo['tenant_id'])->column('id')??[0];
+        return MasterWorkerCaseOutLog::where($this->searchWhere)->whereIn('worker_id',$ids)->where($this->querySearch())->count();
+    }
+
+}

+ 79 - 0
app/tenantapi/lists/finance/RefundLogLists.php

@@ -0,0 +1,79 @@
+<?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\finance;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\refund\RefundLog;
+
+
+/**
+ * 退款日志列表
+ * Class RefundLogLists
+ * @package app\tenantapi\lists\product
+ */
+class RefundLogLists extends BaseAdminDataLists
+{
+
+    /**
+     * @notes 查询条件
+     * @return array
+     * @author 段誉
+     * @date 2023/3/1 9:55
+     */
+    public function queryWhere()
+    {
+        $where[] = ['record_id', '=', $this->params['record_id'] ?? 0];
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/3/1 9:56
+     */
+    public function lists(): array
+    {
+        $lists = (new RefundLog())
+            ->order(['id' => 'desc'])
+            ->where($this->queryWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->hidden(['refund_msg'])
+            ->append(['handler', 'refund_status_text'])
+            ->select()
+            ->toArray();
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2023/3/1 9:56
+     */
+    public function count(): int
+    {
+        return (new RefundLog())
+            ->where($this->queryWhere())
+            ->count();
+    }
+
+}

+ 151 - 0
app/tenantapi/lists/finance/RefundRecordLists.php

@@ -0,0 +1,151 @@
+<?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\finance;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\RefundEnum;
+use app\common\lists\ListsExtendInterface;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\orders\RechargeOrder;
+use app\common\model\refund\RefundRecord;
+use app\common\service\FileService;
+
+
+/**
+ * 退款记录列表
+ * Class RefundRecordLists
+ * @package app\tenantapi\lists\product
+ */
+class RefundRecordLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface
+{
+
+    /**
+     * @notes 查询条件
+     * @return \string[][]
+     * @author 段誉
+     * @date 2023/3/1 9:51
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['r.sn', 'r.order_sn', 'r.refund_type'],
+        ];
+    }
+
+
+    /**
+     * @notes 查询条件
+     * @param bool $flag
+     * @return array
+     * @author 段誉
+     * @date 2023/3/1 9:51
+     */
+    public function queryWhere($flag = true)
+    {
+        $where = [];
+        if (isset($this->params['work_id']) && !empty($this->params['work_id'])) {
+            $order_ids = RechargeOrder::where('work_id', $this->params['work_id'])->column('id')?:[0];
+            if($order_ids){
+                $where[] = ['r.order_type', '=', 'order'];
+                $where[] = ['r.order_id', 'IN', $order_ids];
+            }
+        }
+        if (!empty($this->params['user_info'])) {
+            $where[] = ['u.sn|u.nickname|u.mobile|u.account', 'like', '%' . $this->params['user_info'] . '%'];
+        }
+        if (!empty($this->params['start_time'])) {
+            $where[] = ['r.create_time', '>=', strtotime($this->params['start_time'])];
+        }
+        if (!empty($this->params['end_time'])) {
+            $where[] = ['r.create_time', '<=', strtotime($this->params['end_time'])];
+        }
+
+        if ($flag == true) {
+            if (isset($this->params['refund_status']) && $this->params['refund_status'] != '') {
+                $where[] = ['r.refund_status', '=', $this->params['refund_status']];
+            }
+        }
+
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @author 段誉
+     * @date 2023/3/1 9:51
+     */
+    public function lists(): array
+    {
+        $lists = (new RefundRecord())->alias('r')
+            ->field('r.*,u.nickname,u.avatar')
+            ->join('user u', 'u.id = r.user_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->order(['r.id' => 'desc'])
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->append(['refund_type_text', 'refund_status_text', 'refund_way_text'])
+            ->select()
+            ->toArray();
+
+        foreach ($lists as &$item) {
+            $item['avatar'] = FileService::getFileUrl($item['avatar']);
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2023/3/1 9:51
+     */
+    public function count(): int
+    {
+        return (new RefundRecord())->alias('r')
+            ->join('user u', 'u.id = r.user_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->count();
+    }
+
+
+    /**
+     * @notes 额外参数
+     * @return mixed|null
+     * @author 段誉
+     * @date 2023/3/1 9:51
+     */
+    public function extend()
+    {
+        $count = (new RefundRecord())->alias('r')
+            ->join('user u', 'u.id = r.user_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->field([
+                'count(r.id) as total',
+                'count(if(r.refund_status='.RefundEnum::REFUND_ING.', true, null)) as ing',
+                'count(if(r.refund_status='.RefundEnum::REFUND_SUCCESS.', true, null)) as success',
+                'count(if(r.refund_status='.RefundEnum::REFUND_ERROR.', true, null)) as error',
+            ])
+            ->where($this->searchWhere)
+            ->where($this->queryWhere(false))
+            ->select()->toArray();
+
+        return array_shift($count);
+    }
+}

+ 101 - 0
app/tenantapi/lists/finance/WorkerAccountLogLists.php

@@ -0,0 +1,101 @@
+<?php
+namespace app\tenantapi\lists\finance;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use app\common\model\user\UserAccountLog;
+use app\common\service\FileService;
+
+
+/**
+ * 账记流水列表
+ * Class WorkerAccountLogLists
+ * @package app\tenantapi\lists\finance
+ */
+class WorkerAccountLogLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * @notes 搜索条件
+     * @return array
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['al.change_type','worker_number'],
+        ];
+    }
+
+
+    /**
+     * @notes 搜索条件
+     */
+    public function queryWhere()
+    {
+        $where = [];
+        // 用户余额
+        if (isset($this->params['type']) && $this->params['type'] == 'um') {
+            $where[] = ['change_type', 'in', WorkerAccountLogEnum::getUserMoneyChangeType()];
+        }
+
+        if (!empty($this->params['user_info'])) {
+            $where[] = ['u.sn|u.nickname|u.mobile|u.account', 'like', '%' . $this->params['user_info'] . '%'];
+        }
+
+        if (!empty($this->params['start_time'])) {
+            $where[] = ['al.create_time', '>=', strtotime($this->params['start_time'])];
+        }
+
+        if (!empty($this->params['end_time'])) {
+            $where[] = ['al.create_time', '<=', strtotime($this->params['end_time'])];
+        }
+
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     */
+    public function lists(): array
+    {
+        $field = 'u.nickname,u.account,u.sn,u.avatar,u.mobile,al.action,al.change_amount,al.left_amount,al.change_type,al.work_sn,al.create_time';
+        $lists = MasterWorkerAccountLog::alias('al')
+            ->with(['serviceWork'])
+            ->join('master_worker u', 'u.id = al.worker_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->field($field)
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->order('al.id', 'desc')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+
+        foreach ($lists as &$item) {
+            $item['avatar'] = FileService::getFileUrl($item['avatar']);
+            $item['change_type_desc'] = WorkerAccountLogEnum::getChangeTypeDesc($item['change_type']);
+            $symbol = $item['action'] == WorkerAccountLogEnum::INC ? '+' : '-';
+            $item['change_amount'] = $symbol . $item['change_amount'];
+            $item['total_amount'] = bcadd($item['left_amount'], $item['change_amount'], 2);
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     */
+    public function count(): int
+    {
+        return MasterWorkerAccountLog::alias('al')
+            ->join('master_worker u', 'u.id = al.worker_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->where($this->queryWhere())
+            ->where($this->searchWhere)
+            ->count();
+    }
+}

+ 79 - 0
app/tenantapi/lists/goods_category/GoodsCategoryLists.php

@@ -0,0 +1,79 @@
+<?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\goods_category;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\goods_category\GoodsCategory;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * GoodsCategory列表
+ * Class GoodsCategoryLists
+ * @package app\tenantapi\listsgoods_category
+ */
+class GoodsCategoryLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['category_type', 'name', 'is_goods', 'status'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function lists(): array
+    {
+        $lists = GoodsCategory::where($this->searchWhere)
+            ->field(['id', 'pid', 'category_type' ,'picture', 'name', 'is_goods', 'status', 'weigh'])
+            ->order(['weigh' => 'desc'])
+            ->select()
+            ->toArray();
+
+        return linear_to_tree($lists, 'children', 'id', 'pid');
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function count(): int
+    {
+        return GoodsCategory::where($this->searchWhere)->count();
+    }
+
+}

+ 107 - 0
app/tenantapi/lists/master_worker/BankAccountLists.php

@@ -0,0 +1,107 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\BankAccount;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\master_worker\MasterWorker;
+
+
+/**
+ * BankAccount列表
+ * Class BankAccountLists
+ * @package app\tenantapi\listsmaster_worker
+ */
+class BankAccountLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['account_holder', 'bank_name', 'province', 'city', 'opening_branch', 'account', 'mobile', 'worker_id', 'audit_state'],
+
+        ];
+    }
+
+    public function queryWhere(){
+        $where = [];
+        if(isset($this->params['range_update_time']) && !empty($this->params['range_update_time'])){
+            $time = [strtotime($this->params['range_update_time'][0]), strtotime($this->params['range_update_time'][1])];
+            $where[] = ['update_time', 'between', $time];
+        }
+        return $where;
+    }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $worker_ids = MasterWorker::where($where)->column('id')??[0];
+            $where = [['worker_id','in' ,$worker_ids]];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function lists(): array
+    {
+        return BankAccount::where($this->searchWhere)->where($this->queryWhere())
+            ->field(['id', 'account_holder', 'bank_name', 'province', 'city', 'opening_branch', 'account', 'bank_image', 'mobile', 'worker_id', 'audit_state','create_time','update_time'])
+            ->where($this->queryDataWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function count(): int
+    {
+        return BankAccount::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
+    }
+
+}

+ 147 - 0
app/tenantapi/lists/master_worker/EngineerBillLists.php

@@ -0,0 +1,147 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\EngineerSettlement;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use think\facade\Db;
+
+
+/**
+ * EngineerSettlement列表
+ * Class EngineerSettlementLists
+ * @package app\tenantapi\lists
+ */
+class EngineerBillLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function setSearch(): array
+    {
+        return [];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function lists(): array
+    {
+        $deadline_time = strtotime($this->params['deadline_time'])+86400;
+        $settlement_type = $this->params['settlement_type'];
+        return Db::name('master_worker')->alias('a')->field([
+            'a.id','a.real_name','a.nickname','a.worker_number','a.user_money','e.account_holder','e.bank_name','e.opening_branch','e.account as bank_account',
+            Db::raw("sum(b.amount_change) as left_amount")
+        ])
+            ->leftJoin('master_settlement_details b', 'a.id = b.master_worker_id AND b.status = 1')
+            ->leftJoin('bank_account e', 'a.id = e.worker_id')
+            ->where('a.audit_state', '=', 1)
+            ->where('a.user_money', '>', 0)
+            ->where('b.status', '=', 1)
+            //->where('a.settlement_type', 'in', $settlement_type)
+            ->where('a.settlement_type', '=', $settlement_type)
+            ->where('b.change_time', '<', $deadline_time)
+            ->group('a.id')
+            ->order('a.id desc')
+            ->having('left_amount > 0')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()->toArray();
+
+        /*return Db::name('master_worker')->alias('a')->field([
+                'a.id','a.real_name','a.nickname','a.worker_number','e.account_holder','e.bank_name','e.opening_branch','e.account as bank_account',
+                Db::raw("IFNULL(c.maxid,0) as maxid"),Db::raw("IFNULL(d.left_amount,0) as left_amount")
+            ])
+            ->leftJoin([Db::name('master_worker_account_log')
+                ->where('create_time','between',[strtotime($firstDay),strtotime($lastDay)])
+                ->field('worker_id as master_worker_id, max(id) as maxid')
+                ->group('worker_id')
+                ->buildSql() => 'c'], 'a.id = c.master_worker_id')
+            ->leftJoin('master_worker_account_log d', 'c.maxid = d.id')
+            ->leftJoin('bank_account e', 'a.id = e.worker_id')
+            ->order('a.id desc')
+            ->limit($this->limitOffset, $this->limitLength)
+            //->where('d.left_amount', '>', 0)
+            ->select()->toArray();*/
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function count(): int
+    {
+        $deadline_time = strtotime($this->params['deadline_time'])+86400;
+        $settlement_type = $this->params['settlement_type'];
+        return Db::name('master_worker')->alias('a')->field([
+                'a.id','a.real_name','a.nickname','a.worker_number','a.user_money','e.account_holder','e.bank_name','e.opening_branch','e.account as bank_account',
+                Db::raw("sum(amount_change) as left_amount")
+            ])
+            ->leftJoin('master_settlement_details b', 'a.id = b.master_worker_id AND b.status = 1')
+            ->leftJoin('bank_account e', 'a.id = e.worker_id')
+            ->where('a.audit_state', '=', 1)
+            ->where('a.user_money', '>', 0)
+            ->where('b.status', '=', 1)
+            //->where('a.settlement_type', 'in', $settlement_type)
+            ->where('a.settlement_type', '=', $settlement_type)
+            ->where('b.change_time', '<', $deadline_time)
+            ->group('a.id')
+            ->count();
+
+        /*$firstDay = date('Y-m-01 00:00:00', strtotime('first day of last month'));
+        $lastDay = date('Y-m-t 23:59:59', strtotime('last day of last month'));
+        return Db::name('master_worker')->alias('a')->field([
+            'a.id','a.real_name','a.nickname','a.worker_number',Db::raw("IFNULL(c.maxid,0) as maxid"),Db::raw("IFNULL(d.left_amount,0) as left_amount")
+        ])
+            ->leftJoin([Db::name('master_worker_account_log')
+                ->where('create_time','between',[strtotime($firstDay),strtotime($lastDay)])
+                ->field('worker_id as master_worker_id, max(id) as maxid')
+                ->group('worker_id')
+                ->buildSql() => 'c'], 'a.id = c.master_worker_id')
+            ->leftJoin('master_worker_account_log d', 'c.maxid = d.id')
+            //->where('d.left_amount', '>', 0)
+            ->count();*/
+    }
+
+    public function setExcelComplexFields(): array
+    {
+        $zh_cn_fields = [
+            '工程师ID','工程师编号', '工程师姓名','工程师银行卡号','工程师开户行','支行信息','工程师上月最后结算余额'
+        ];
+        $data_fields = ['id','worker_number','real_name','bank_account','bank_name','opening_branch','left_amount'];
+        return [
+            'zh_cn_fields' => $zh_cn_fields,
+            'data_fields' => $data_fields
+        ];
+    }
+}

+ 90 - 0
app/tenantapi/lists/master_worker/EngineerSettlementLists.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\tenantapi\lists\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\EngineerSettlement;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * EngineerSettlement列表
+ * Class EngineerSettlementLists
+ * @package app\tenantapi\lists
+ */
+class EngineerSettlementLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['batch_number','master_worker_id', 'worker_number', 'engineer_name', 'original_balance', 'total_settlement_amount', 'deduction_amount', 'final_settlement_amount',  'settlement_details_remarks'],
+
+        ];
+    }
+
+    public function queryWhere()
+    {
+        $where = [];
+        if(isset($this->params['settlement_time']) && $this->params['settlement_time']){
+            $where[] = ['settlement_time','=',date('Y-m-d H:i:s',strtotime($this->params['settlement_time']))];
+        }
+        if(isset($this->params['create_time']) && $this->params['create_time']){
+            $startDateTime = strtotime($this->params['create_time']);
+            $endDateTime = strtotime('+1 day', $startDateTime)-1;
+            $where[] = ['create_time','BETWEEN',[$startDateTime,$endDateTime]];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function lists(): array
+    {
+        return EngineerSettlement::where('is_export',2)->where($this->queryWhere())->where($this->searchWhere)
+            ->field(['id', 'master_worker_id', 'worker_number', 'engineer_name', 'original_balance', 'total_settlement_amount', 'deduction_amount','deduction_describe', 'final_settlement_amount', 'settlement_time', 'settlement_details_remarks','batch_number'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function count(): int
+    {
+        return EngineerSettlement::where($this->searchWhere)->where($this->queryWhere())->count();
+    }
+
+}

+ 106 - 0
app/tenantapi/lists/master_worker/MasterWorkerAgreeLists.php

@@ -0,0 +1,106 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAgree;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerAgree列表
+ * Class MasterWorkerAgreeLists
+ * @package app\tenantapi\listsmaster_worker
+ */
+class MasterWorkerAgreeLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['agree_type', 'worker_id', 'sign', 'audit_state', 'pdf_url', 'create_time'],
+
+        ];
+    }
+    public function queryWhere(){
+        $where = [];
+        if(isset($this->params['range_update_time']) && !empty($this->params['range_update_time'])){
+            $time = [strtotime($this->params['range_update_time'][0]), strtotime($this->params['range_update_time'][1])];
+            $where[] = ['update_time', 'between', $time];
+        }
+        return $where;
+    }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $worker_ids = MasterWorker::where($where)->column('id')??[0];
+            $where = [['worker_id','in' ,$worker_ids]];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function lists(): array
+    {
+        return MasterWorkerAgree::with(['masterWorkerInfo'])->where($this->searchWhere)->where($this->queryWhere())
+            ->field(['id', 'agree_type', 'worker_id', 'sign', 'pdf_url', 'create_time', 'audit_state','update_time'])
+            ->where($this->queryDataWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function count(): int
+    {
+        return MasterWorkerAgree::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
+    }
+
+}

+ 118 - 0
app/tenantapi/lists/master_worker/MasterWorkerExamineLists.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\lists\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\BankAccount;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAgree;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\master_worker\MasterWorkerInfo;
+
+
+/**
+ * MasterWorkerExamineLists列表
+ * Class MasterWorkerExamineLogic
+ * @package app\tenantapi\listsmaster_worker
+ */
+class MasterWorkerExamineLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function setSearch(): array
+    {
+        return [
+        ];
+    }
+    public function queryWhere(){
+        $where = [];
+        if(isset($this->params['audit_state']) && $this->params['audit_state']!=''){
+            $ids = MasterWorker::where('audit_state',$this->params['audit_state'])->column('id');
+            $where[] = ['id', 'IN', $ids?:[0]];
+            //dd($ids);
+        }
+        /*$infoWorkerIds = MasterWorkerInfo::where('audit_state',0)->column('worker_id');
+        $bankWorkerIds = BankAccount::where('audit_state',0)->column('worker_id');
+        $agreeWorkerIds = MasterWorkerAgree::where('audit_state',0)->column('worker_id');
+        $ids = array_merge($infoWorkerIds,$bankWorkerIds,$agreeWorkerIds);*/
+        if(isset($this->params['real_name']) && !empty($this->params['real_name'])){
+            $where[] = ['id', 'IN', MasterWorker::where([['real_name', 'like', "%{$this->params['real_name']}%"]])->column('id')?:[0]];
+        }
+        if(isset($this->params['nickname']) && !empty($this->params['nickname'])){
+            $where[] = ['id', 'IN', MasterWorker::where([['nickname', 'like', "%{$this->params['nickname']}%"]])->column('id')?:[0]];
+        }
+        if(isset($this->params['account']) && !empty($this->params['account'])){
+            $where[] = ['id', 'IN', MasterWorker::where([['account', 'like', "%{$this->params['account']}%"]])->column('id')?:[0]];
+        }
+        return $where;
+    }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function lists(): array
+    {
+        $queryWhere = $this->queryWhere();
+        return MasterWorker::with(['workerInfo','workerAgree','bankAccount'])->where($this->searchWhere)->where($queryWhere)
+            ->where($this->queryDataWhere())
+            ->field(['*'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function count(): int
+    {
+        $queryWhere = $this->queryWhere();
+        return MasterWorker::where($this->searchWhere)->where($queryWhere)->where($this->queryDataWhere())->count();
+    }
+
+}

+ 106 - 0
app/tenantapi/lists/master_worker/MasterWorkerInfoLists.php

@@ -0,0 +1,106 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerInfo;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerInfo列表
+ * Class MasterWorkerInfoLists
+ * @package app\tenantapi\listsmaster_worker
+ */
+class MasterWorkerInfoLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['worker_id', 'real_name', 'id_card', 'mobile', 'address', 'audit_state', 'create_time'],
+
+        ];
+    }
+    public function queryWhere(){
+        $where = [];
+        if(isset($this->params['range_update_time']) && !empty($this->params['range_update_time'])){
+            $time = [strtotime($this->params['range_update_time'][0]), strtotime($this->params['range_update_time'][1])];
+            $where[] = ['update_time', 'between', $time];
+        }
+        return $where;
+    }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if(!empty($where)){
+            $worker_ids = MasterWorker::where($where)->column('id')??[0];
+            $where = [['worker_id','in' ,$worker_ids]];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function lists(): array
+    {
+        return MasterWorkerInfo::where($this->searchWhere)->where($this->queryWhere())
+            ->field(['id', 'worker_id', 'real_name', 'id_card', 'id_card_front_img', 'id_card_opposite_img', 'mobile', 'address', 'audit_state', 'create_time','update_time'])
+            ->where($this->queryDataWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function count(): int
+    {
+        return MasterWorkerInfo::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
+    }
+
+}

+ 225 - 0
app/tenantapi/lists/master_worker/MasterWorkerLists.php

@@ -0,0 +1,225 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\tenantapi\service\DistributeLeafletsService;
+use app\common\model\master_worker\MasterWorker;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\master_worker\MasterWorkerTeam;
+use app\common\model\works\ServiceWork;
+use think\db\Query;
+use think\facade\Db;
+use think\facade\Log;
+
+/**
+ * MasterWorker列表
+ * Class MasterWorkerLists
+ * @package app\tenantapi\listsmaster_worker
+ */
+class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+    public $count = 0;
+    public $range = 0;
+    public $lon = 0;
+    public $lat = 0;
+    //所有派单限制条件: 工程师保护期  工程师可用金额限制(除去保护期工程师)     工程师接单状态   订单产品分类  订单坐标筛选    订单坐标距离排序
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function setSearch(): array
+    {
+        // 派单搜索条件 - 工程师接单状态
+        return [
+            '=' => ['mw.sn', 'mw.real_name', 'mw.city', 'mw.account', 'mw.password', 'mw.mobile', 'mw.sex', 'mw.channel', 'mw.is_disable', 'mw.is_new_user', 'mw.create_time', 'mw.update_time', 'mw.accept_order_status', 'mw.cooperation','mw.audit_state', 'mw.work_status'],
+            //'in' => ['mw.time_period']
+        ];
+    }
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['mw.province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['mw.city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
+    public function queryWhere(){
+        $where = [];
+        $where[] = ['mw.team_role','in',[0,1]];
+        if(isset($this->params['time_period']) && !empty($this->params['time_period'])){
+            $sqls = [];
+            foreach ($this->params['time_period'] as $item) {
+                $sqls[] = "FIND_IN_SET({$item}, time_period) > 0";
+            }
+            $query_sql = implode(' OR ', $sqls);
+            Log::write('query_sql:'.$query_sql);
+
+            $period_ids = MasterWorker::where('time_period','<>', '')->whereRaw($query_sql)->column('id');
+            $where[] = [ 'mw.id','IN',$period_ids?:[0]];
+        }
+        if (isset($this->params['labels']) && !empty($this->params['labels'])) {
+            $sqls = [];
+            foreach ($this->params['labels'] as $item) {
+                $sqls[] = "FIND_IN_SET({$item}, labels) > 0";
+            }
+            $query_sql = implode(' OR ', $sqls);
+            $period_ids = MasterWorker::where('labels','<>', '')->whereRaw($query_sql)->column('id');
+            $where[] = [ 'mw.id','IN',$period_ids?:[0]];
+        }
+        if(isset($this->params['category_ids']) && !empty($this->params['category_ids'])){
+            $sqls = [];
+            $category_ids =[];
+            foreach ($this->params['category_ids'] as $val){
+                ($val = json_decode($val,true))?($category_ids[] = end($val)):($category_ids[] = $val);
+            }
+            foreach ($category_ids as $item) {
+                $sqls[] = "FIND_IN_SET({$item}, category_ids) > 0";
+            }
+            $query_sql = implode(' OR ', $sqls);
+            Log::write('query_sql:'.$query_sql);
+
+            $period_ids = MasterWorker::where('category_ids','<>', '')->whereRaw($query_sql)->column('id');
+            $where[] = [ 'mw.id','IN',$period_ids?:[0]];
+        }
+        if( isset($this->params['longitude']) && isset($this->params['latitude']) && isset($this->params['range'])
+            && !empty($this->params['longitude']) && !empty($this->params['latitude']) && !empty($this->params['range']) ){
+            $this->lon = $this->params['longitude'];
+            $this->lat = $this->params['latitude'];
+            $this->range = $this->params['range'];
+        }
+        // 用户昵称
+        if (isset($this->params['nickname']) && !empty($this->params['nickname'])) {
+            $where[] = ['mw.nickname|mw.worker_number', 'like','%' .$this->params['nickname'] . '%'];
+        }
+        if (isset($this->params['worker_number']) && !empty($this->params['worker_number'])) {
+            $where[] = ['mw.worker_number', 'like','%' .$this->params['worker_number'] . '%'];
+        }
+        if (isset($this->params['worker_exp_type']) && !empty($this->params['worker_exp_type'])) {
+            $where[] = ['mwr.maintain_exp_type', '=', $this->params['worker_exp_type']];
+        }
+        if(isset($this->params['min_work_number']) && is_numeric($this->params['min_work_number'])){
+            $where[] =[ 'mw.work_total','>=',$this->params['min_work_number']];
+        }
+        if(isset($this->params['max_work_number']) && is_numeric($this->params['max_work_number'])){
+            $where[] =[ 'mw.work_total','<= ',$this->params['max_work_number']];
+        }
+        if(isset($this->params['order_id']) && $this->params['order_id']){
+//            $lon_lat = (ServiceWork::where('id',$this->params['order_id'])->column("lon,lat,goods_category_id"))[0];
+//            $this->lon = $lon_lat['lon'];
+//            $this->lat = $lon_lat['lat'];
+//            $goods_category_id = $lon_lat['goods_category_id'];
+            // 派单搜索条件 - 工程师保护期  工程师可用金额限制(除去保护期工程师)  订单产品分类  订单坐标筛选(暂不按距离筛选只按距离排序)
+            //$ids = DistributeLeafletsService::getIntersection($goods_category_id??0);
+            //$where[] = [ 'mw.id','IN',$ids];
+            $where[] = [ 'mw.work_status','=',0];
+        }
+        Log::debug('MasterWorker-where:'.json_encode($where));
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function lists(): array
+    {
+        $fields = ['mw.*','mwr.maintain_exp_type','mwr.other_exp_type'];
+        $orders = ['mw.id' => 'desc'];
+        $having = 'mw.id > 0';
+        $queryWhere = $this->queryWhere();
+        //dd($queryWhere,$this->searchWhere);
+        // 派单搜索条件 - 订单坐标距离排序
+        if($this->lat && $this->lon){
+            $fields[] = Db::raw('ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2) AS user_distance');
+            $orders = 'user_distance';
+            $having = '(user_distance - mw.distance) <= 0';
+            if($this->range){
+                $having = 'user_distance <= '.$this->range;
+            }
+        }
+        $list = MasterWorker::alias('mw')
+            ->leftjoin('master_worker_register mwr', 'mwr.worker_id = mw.id')
+            ->where('mw.tenant_id', $this->adminInfo['tenant_id'])
+            ->where($this->searchWhere)
+            ->where($queryWhere)
+            ->where($this->queryDataWhere())
+            ->field($fields)
+            ->limit($this->limitOffset, $this->limitLength)
+            ->having($having)
+            ->order($orders)
+            ->select()->toArray();
+        $workCount = array_column(ServiceWork::where('master_worker_id','>',0)
+            ->whereNotIn('work_status', [7,8,9])
+            ->whereIn('master_worker_id', array_column($list, 'id'))
+            ->field(['master_worker_id',Db::raw('COUNT(id) as work_total')])
+            ->group('master_worker_id')
+            ->select()->toArray(),'work_total','master_worker_id');
+        $teams = MasterWorkerTeam::whereIn('master_worker_id', array_column($list, 'id'))->column('team_name','master_worker_id');
+        foreach ($list as &$item) {
+            $item['work_total'] = $workCount[$item['id']]??0;
+            $item['team_name'] = $teams[$item['id']]??'';
+        }
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function count(): int
+    {
+        $fields = ['mw.*','mwr.maintain_exp_type','mwr.other_exp_type'];
+        $orders = ['mw.id' => 'desc'];
+        $having = 'mw.id > 0';
+        $queryWhere = $this->queryWhere();
+        // 派单搜索条件 - 订单坐标距离排序
+        if($this->lat && $this->lon){
+            $fields[] = Db::raw('ROUND(6371* 1000 * ACOS(COS(RADIANS('.$this->lat.')) * COS(RADIANS(mw.lat)) * COS(RADIANS(mw.lon) - RADIANS('.$this->lon.')) + SIN(RADIANS('.$this->lat.')) * SIN(RADIANS(mw.lat))), 2) AS user_distance');
+            $orders = 'user_distance';
+            $having = '(user_distance - mw.distance) <= 0';
+            if($this->range){
+                $having = 'user_distance <= '.$this->range;
+            }
+        }
+        return count(MasterWorker::alias('mw')
+            ->leftjoin('master_worker_register mwr', 'mwr.worker_id = mw.id')
+            ->where('mw.tenant_id', $this->adminInfo['tenant_id'])
+            ->where($this->searchWhere)
+            ->where($queryWhere)
+            ->where($this->queryDataWhere())
+            ->field($fields)
+            ->having($having)
+            ->select()->toArray());
+    }
+}

+ 78 - 0
app/tenantapi/lists/master_worker/MasterWorkerRuleLists.php

@@ -0,0 +1,78 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorkerRule;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerRule列表
+ * Class MasterWorkerRuleLists
+ * @package app\tenantapi\lists
+ */
+class MasterWorkerRuleLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['rule_name', 'description', 'sort','scene_id'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function lists(): array
+    {
+        return MasterWorkerRule::where($this->searchWhere)
+            ->field(['id', 'rule_name', 'description', 'sort','scene_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function count(): int
+    {
+        return MasterWorkerRule::where($this->searchWhere)->count();
+    }
+
+}

+ 202 - 0
app/tenantapi/lists/master_worker/MasterWorkerServiceOrderLists.php

@@ -0,0 +1,202 @@
+<?php
+namespace app\tenantapi\lists\master_worker;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\goods_category\GoodsCategory;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\works\ServiceWorkAllocateWorkerLog;
+use think\facade\Db;
+use think\facade\Log;
+
+
+/**
+ * MasterWorkerServiceOrder列表
+ * Class MasterWorkerServiceOrderLists
+ * @package app\tenantapi\lists
+ */
+class MasterWorkerServiceOrderLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    public $sqlJoin = '';
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function setSearch(): array
+    {
+        return [];
+    }
+
+    public function queryWhere()
+    {
+        $where = [];
+        if (isset($this->params['real_name']) && !empty($this->params['real_name'])) {
+            $where[] = ['a.real_name','like' ,"%".$this->params['real_name']."%"];
+        }
+        if (isset($this->params['worker_number']) && !empty($this->params['worker_number'])) {
+            $where[] = ['a.worker_number','like' ,"%".$this->params['worker_number']."%"];
+        }
+        if (isset($this->params['recruiting_behalf']) && !empty($this->params['recruiting_behalf'])) {
+            $where[] = ['a.recruiting_behalf','like' ,"%".$this->params['recruiting_behalf']."%"];
+        }
+        if (isset($this->params['labels']) && !empty($this->params['labels'])) {
+            $sqls = [];
+            foreach ($this->params['labels'] as $item) {
+                $sqls[] = "FIND_IN_SET({$item}, labels) > 0";
+            }
+            $query_sql = implode(' OR ', $sqls);
+            $period_ids = MasterWorker::where('labels','<>', '')->whereRaw($query_sql)->column('id');
+            $where[] = [ 'a.id','IN',$period_ids?:[0]];
+        }
+        if (isset($this->params['is_recruiting_behalf']) && !empty($this->params['is_recruiting_behalf'])) {
+            if ($this->params['is_recruiting_behalf'] == 1)
+                $where[] = ['a.recruiting_behalf','<>' ,""];
+            else
+                $where[] = ['a.recruiting_behalf','=' ,""];
+        }
+        if(isset($this->params['category_ids']) && !empty($this->params['category_ids'])){
+            $sqls = [];
+            $category_ids =[];
+            foreach ($this->params['category_ids'] as $val){
+                ($val = json_decode($val,true))?($category_ids[] = end($val)):($category_ids[] = $val);
+            }
+            foreach ($category_ids as $item) {
+                $sqls[] = "FIND_IN_SET({$item}, category_ids) > 0";
+            }
+            $query_sql = implode(' OR ', $sqls);
+            Log::write('query_sql:'.$query_sql);
+
+            $period_ids = MasterWorker::where('category_ids','<>', '')->whereRaw($query_sql)->column('id');
+            $where[] = [ 'a.id','IN',$period_ids?:[0]];
+        }
+        if (isset($this->params['mobile']) && !empty($this->params['mobile'])) {
+            $where[] = ['a.mobile','like' ,"%".$this->params['mobile']."%"];
+        }
+        if (isset($this->params['cooperation']) && !empty($this->params['cooperation'])) {
+            $where[] = ['a.cooperation','=' ,$this->params['cooperation']];
+        }
+        if (!empty($this->params['start_time'])) {
+            $this->sqlJoin .= '    AND  b.update_time >= '.strtotime($this->params['start_time']);
+        }
+        if (!empty($this->params['end_time'])) {
+            $this->sqlJoin .= '    AND  b.update_time < '.strtotime($this->params['end_time'])+86400;
+        }
+        $where[] = ['a.audit_state','=' ,1];
+        return $where;
+    }
+
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['a.province','in' ,$data_rules['province']];
+            $where[] = ['b.province','in' ,$data_rules['province']];
+
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['a.city','in' ,$data_rules['city']];
+            $where[] = ['b.city','in' ,$data_rules['city']];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function lists(): array
+    {
+        $queryWhere = $this->queryWhere();
+        $lists = Db::name('master_worker')->alias('a')->field([
+                'a.id','a.real_name','a.nickname','a.worker_number','a.recruiting_behalf','a.mobile','a.cooperation','a.category_ids','a.labels','a.remark',
+                Db::raw("COUNT(b.id) AS all_count"),
+                Db::raw("SUM(CASE WHEN b.service_status = 3 THEN 1 ELSE 0 END) AS success_count"),
+                Db::raw("SUM(CASE WHEN b.service_status = 4 OR b.service_status = 5 THEN 1 ELSE 0 END) AS fail_count"),
+                Db::raw("SUM(CASE WHEN b.service_status = 3 THEN b.work_total ELSE 0 END) work_total"),
+                Db::raw("SUM(CASE WHEN b.service_status = 3 THEN b.worker_price ELSE 0 END) worker_price"),
+            ])
+            ->leftJoin('service_work b', 'a.id = b.master_worker_id'.$this->sqlJoin)
+            ->where($queryWhere)
+            ->where($this->queryDataWhere())
+            ->group('a.id')
+            ->order('a.id desc')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()->toArray();
+        $categoryData = GoodsCategory::select()->toArray();
+        foreach ($lists as &$item) {
+            $item['labels'] = $item['labels']?array_map(function ($item) { return intval($item); },explode(',',$item['labels'])):'';
+            $item['category_name'] = $item['category_ids']?implode('、',array_column(get_parent_info($categoryData,explode(',',$item['category_ids'])),'name')):'';
+            $item['allocate_num'] = ServiceWorkAllocateWorkerLog::where(['master_worker_id'=>$item['id']])->count();
+        }
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function count(): int
+    {
+        $queryWhere = $this->queryWhere();
+        return Db::name('master_worker')->alias('a')->field([
+                'a.id','a.real_name','a.nickname','a.worker_number','a.recruiting_behalf',
+                Db::raw("SUM(CASE WHEN b.service_status = 3 THEN 1 ELSE 0 END) AS success_count"),
+                Db::raw("SUM(CASE WHEN b.service_status = 4 OR b.service_status = 5 THEN 1 ELSE 0 END) AS fail_count"),
+                Db::raw("SUM(b.work_total) work_total"),
+                Db::raw("SUM(b.worker_price) worker_price"),
+            ])
+            ->leftJoin('service_work b', 'a.id = b.master_worker_id'.$this->sqlJoin)
+            ->where($queryWhere)
+            ->where($this->queryDataWhere())
+            ->group('a.id')
+            ->count();
+    }
+
+
+    public function setExcelComplexFields(): array
+    {
+        $zh_cn_fields = [
+            '工程师ID', '服务类别', '工程师编号', '工程师姓名', '工程师手机',
+            '工程师备注', '工程师合作形式','代招人姓名', '派单数', '工程师接单数', '标签',
+            '工程师成功单','工程师失败单','工程师成交金额','工程师提成金额'
+        ];
+        $data_fields = [
+            'id', 'category_name', 'worker_number', 'real_name', 'mobile',
+            'remark', function ($row) {
+                return $row['cooperation'] == 0 ? '无' : ($row['cooperation'] == 1 ? '全日接单' : '自由接单');
+            }, 'recruiting_behalf', 'allocate_num', 'all_count', function ($row) {
+                if(!empty($row['labels'])){
+                    $data_table_allLabels = array_column(\app\common\logic\TableDataLogic::allLabels(),'name','id');
+                    foreach ($row['labels'] as &$val){
+                        $val = $data_table_allLabels[$val];
+                    }
+                    $row['labels'] = implode('、', $row['labels']);
+                }
+                return $row['labels']?:'';
+            },
+            'success_count', 'fail_count', 'work_total', 'worker_price'
+        ];
+        return [
+            'zh_cn_fields' => $zh_cn_fields,
+            'data_fields' => $data_fields
+        ];
+    }
+
+
+}

+ 79 - 0
app/tenantapi/lists/master_worker/MasterWorkerTeamLists.php

@@ -0,0 +1,79 @@
+<?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\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorkerTeam;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerTeam列表
+ * Class MasterWorkerTeamLists
+ * @package app\tenantapi\lists
+ */
+class MasterWorkerTeamLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['team_name', 'master_worker_id'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function lists(): array
+    {
+        return MasterWorkerTeam::with(['masterWorker'])->where('tenant_id', $this->adminInfo['tenant_id'])->where($this->searchWhere)
+            ->field(['id', 'team_name', 'master_worker_id'])
+            ->append(['master_worker_name'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function count(): int
+    {
+        return MasterWorkerTeam::where($this->searchWhere)->where('tenant_id', $this->adminInfo['tenant_id'])->count();
+    }
+
+}

+ 104 - 0
app/tenantapi/lists/master_worker/MoneyAnalysis.php

@@ -0,0 +1,104 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\lists\master_worker;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use app\common\model\property\PropertyHead;
+use app\common\model\property\PropertyOrder;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\works\ServiceWork;
+use think\facade\Db;
+
+
+/**
+ * MoneyAnalysis列表
+ * Class MoneyAnalysis
+ * @package app\tenantapi\lists
+ */
+class MoneyAnalysis extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function setSearch(): array
+    {
+        return [
+        ];
+    }
+    public function queryWhere()
+    {
+        $where = [];
+        /*$tmpWhere = [];
+        $workIds = [];
+        isset($this->params['property_name']) && !empty($this->params['property_name']) && $tmpWhere[] = ['property_name', 'LIKE', '%'.$this->params['property_name'].'%'];
+        isset($this->params['village_name']) && !empty($this->params['village_name']) && $tmpWhere[] = ['village_name', 'LIKE', '%'.$this->params['village_name'].'%'];
+        isset($this->params['head_name']) && !empty($this->params['head_name']) && $tmpWhere[] = ['head_name', 'LIKE', '%'.$this->params['head_name'].'%'];
+        isset($this->params['head_mobile']) && !empty($this->params['head_mobile']) && $tmpWhere[] = ['head_mobile', '=', $this->params['head_mobile']];
+        if(!empty($tmpWhere)){
+            $property_head_ids = PropertyHead::where($tmpWhere)->column('id');
+            $property_head_ids && $workIds = PropertyOrder::where('order_status',3)->where('property_head_id','IN',$property_head_ids)->column('work_id');
+        }else{
+            $workIds = PropertyOrder::where('order_status',3)->column('work_id');
+        }*/
+        if(isset($this->params['start_month']) && $this->params['start_month']){
+            $startDateTime = strtotime($this->params['start_month']);
+            $endDateTime = strtotime('+1 month', $startDateTime)-1;
+            $where[] = ['create_time','BETWEEN',[$startDateTime,$endDateTime]];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function lists(): array
+    {
+        return MasterWorkerAccountLog::with(['masterWorker'])->where($this->queryWhere())
+            ->field(Db::raw('worker_id,action,DATE_FORMAT(FROM_UNIXTIME(create_time), "%Y-%m") AS month_format,COUNT(id) as month_num, SUM(change_amount) as month_amount'))
+            ->group('worker_id,action,month_format') //action
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function count(): int
+    {
+        return MasterWorkerAccountLog::with(['masterWorker'])->where($this->queryWhere())
+            ->field(Db::raw('worker_id,DATE_FORMAT(FROM_UNIXTIME(create_time), "%Y-%m") AS month_format,COUNT(id) as month_num, SUM(change_amount) as month_amount'))
+            ->group('worker_id,month_format')
+            ->count();
+    }
+
+}

+ 88 - 0
app/tenantapi/lists/master_worker/RetentionMoneyLogLists.php

@@ -0,0 +1,88 @@
+<?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\master_worker;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
+
+
+
+/**
+ * 账记流水列表
+ * Class AccountLogLists
+ * @package app\tenantapi\lists\finance
+ */
+class RetentionMoneyLogLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * @notes 搜索条件
+     * @return array
+     * @author 段誉
+     * @date 2023/2/24 15:26
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['worker_id','action'],
+        ];
+    }
+
+
+    /**
+     * @notes 搜索条件
+     * @author 段誉
+     * @date 2023/2/24 15:26
+     */
+    public function queryWhere()
+    {
+        $where = [];
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @author 段誉
+     * @date 2023/2/24 15:31
+     */
+    public function lists(): array
+    {
+        $lists = MasterWorkerRetentionMoneyLog::alias('al')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->append(['action_text'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2023/2/24 15:36
+     */
+    public function count(): int
+    {
+        return MasterWorkerRetentionMoneyLog::where($this->queryWhere())
+            ->where($this->searchWhere)
+            ->count();
+    }
+}

+ 71 - 0
app/tenantapi/lists/notice/NoticeSettingLists.php

@@ -0,0 +1,71 @@
+<?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\notice;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\notice\NoticeSetting;
+
+/**
+ * 通知设置
+ * Class NoticeSettingLists
+ * @package app\tenantapi\lists\notice
+ */
+class NoticeSettingLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+    /**
+     * @notes 搜索条件
+     * @return \string[][]
+     * @author ljj
+     * @date 2022/2/17 2:21 下午
+     */
+    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 ljj
+     * @date 2022/2/16 3:18 下午
+     */
+    public function lists(): array
+    {
+        $lists = (new NoticeSetting())->field('*')
+            ->append(['sms_status_desc','oa_status_desc','type_desc'])
+            ->where($this->searchWhere)
+            ->select()
+            ->toArray();
+
+        return $lists;
+    }
+
+    /**
+     * @notes 通知设置数量
+     * @return int
+     * @author ljj
+     * @date 2022/2/16 3:18 下午
+     */
+    public function count(): int
+    {
+        return (new NoticeSetting())->where($this->searchWhere)->count();
+    }
+}

+ 146 - 0
app/tenantapi/lists/recharge/RechargeLists.php

@@ -0,0 +1,146 @@
+<?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\recharge;
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\enum\PayEnum;
+use app\common\lists\ListsExcelInterface;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\recharge\RechargeOrder;
+use app\common\service\FileService;
+
+/**
+ * 充值记录列表
+ * Class RecharLists
+ * @package app\tenantapi\lists
+ */
+class RechargeLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
+{
+    /**
+     * @notes 导出字段
+     * @return string[]
+     * @author 段誉
+     * @date 2023/2/24 16:07
+     */
+    public function setExcelFields(): array
+    {
+        return [
+            'sn' => '充值单号',
+            'nickname' => '用户昵称',
+            'order_amount' => '充值金额',
+            'pay_way_text' => '支付方式',
+            'pay_status_text' => '支付状态',
+            'pay_time' => '支付时间',
+            'create_time' => '下单时间',
+        ];
+    }
+
+
+    /**
+     * @notes 导出表名
+     * @return string
+     * @author 段誉
+     * @date 2023/2/24 16:07
+     */
+    public function setFileName(): string
+    {
+        return '充值记录';
+    }
+
+
+    /**
+     * @notes 搜索条件
+     * @return \string[][]
+     * @author 段誉
+     * @date 2023/2/24 16:08
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['ro.sn', 'ro.pay_way', 'ro.pay_status','ro.work_id'],
+        ];
+    }
+
+
+    /**
+     * @notes 搜索条件
+     * @author 段誉
+     * @date 2023/2/24 16:08
+     */
+    public function queryWhere()
+    {
+        $where = [];
+        // 用户编号
+        if (!empty($this->params['user_info'])) {
+            $where[] = ['u.sn|u.nickname|u.mobile|u.account', 'like', '%' . $this->params['user_info'] . '%'];
+        }
+
+        // 下单时间
+        if (!empty($this->params['start_time']) && !empty($this->params['end_time'])) {
+            $time = [strtotime($this->params['start_time']), strtotime($this->params['end_time'])];
+            $where[] = ['ro.create_time', 'between', $time];
+        }
+
+        return $where;
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @author 段誉
+     * @date 2023/2/24 16:13
+     */
+    public function lists(): array
+    {
+        $field = 'ro.id,ro.sn,ro.order_amount,ro.pay_way,ro.pay_time,ro.pay_status,ro.create_time,ro.refund_status';
+        $field .= ',u.avatar,u.nickname,u.account';
+        $lists = RechargeOrder::alias('ro')
+            ->join('user u', 'u.id = ro.user_id and u.tenant_id = ' . $this->adminInfo['tenant_id'])
+            ->field($field)
+            ->where($this->queryWhere())
+            ->where($this->searchWhere)
+            ->order('ro.id', 'desc')
+            ->limit($this->limitOffset, $this->limitLength)
+            ->append(['pay_status_text', 'pay_way_text'])
+            ->select()
+            ->toArray();
+
+        foreach ($lists as &$item) {
+            $item['avatar'] = FileService::getFileUrl($item['avatar']);
+            $item['pay_time'] = empty($item['pay_time']) ? '' : date('Y-m-d H:i:s', $item['pay_time']);
+        }
+
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author 段誉
+     * @date 2023/2/24 16:13
+     */
+    public function count(): int
+    {
+        return RechargeOrder::alias('ro')
+            ->join('user u', 'u.id = ro.user_id')
+            ->where($this->queryWhere())
+            ->where($this->searchWhere)
+            ->count();
+    }
+
+
+}

+ 162 - 0
app/tenantapi/lists/works/IssueWorkLists.php

@@ -0,0 +1,162 @@
+<?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\works;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyOrder;
+use app\common\model\works\IssueWork;
+use app\common\lists\ListsSearchInterface;
+use think\db\Query;
+use think\facade\Db;
+use think\facade\Log;
+
+
+/**
+ * IssueWork列表
+ * Class IssueWorkLists
+ * @package app\tenantapi\listsworks
+ */
+class IssueWorkLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    public $queryExists = null;
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['work_sn', 'service_work_id', 'master_worker_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details',  'approval_admin_id', ],
+
+        ];
+    }
+
+    public function querySearch():array
+    {
+        $where = [];
+        if(isset($this->params['approval_time']) && !empty($this->params['approval_time'])){
+            $time = [strtotime($this->params['approval_time'][0]), strtotime($this->params['approval_time'][1])];
+            $where[] = ['approval_time', 'between', $time];
+        }
+        if(isset($this->params['finished_time']) && !empty($this->params['finished_time'])){
+            $time = [strtotime($this->params['finished_time'][0]), strtotime($this->params['finished_time'][1])];
+            $where[] = ['finished_time', 'between', $time];
+        }
+        if(isset($this->params['create_time']) && !empty($this->params['create_time'])){
+            $time = [strtotime($this->params['create_time'][0]), strtotime($this->params['create_time'][1])];
+            $where[] = ['create_time', 'between', $time];
+        }
+        if(isset($this->params['update_time']) && !empty($this->params['update_time'])){
+            $time = [strtotime($this->params['update_time'][0]), strtotime($this->params['update_time'][1])];
+            $where[] = ['update_time', 'between', $time];
+        }
+        return $where;
+    }
+
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        $this->queryExists = function (Query $query) { $query->name('service_work')->where('id','>', 0)->field('id'); };
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $this->queryExists = function (Query $query) use ($data_rules) {
+                $p_table = $query->getTable().$query->getName();
+                $query->name('service_work')->alias('b')
+                    ->where('province','in', $data_rules['province'])
+                    ->where($p_table.'.service_work_id', '=', Db::raw('b.id'))
+                    ->field('id');
+            };
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $this->queryExists = function (Query $query) use ($data_rules) {
+                $p_table = $query->getTable().$query->getName();
+                $query->name('service_work')->alias('b')
+                    ->where('city','in', $data_rules['city'])
+                    ->where($p_table.'.service_work_id', '=', Db::raw('b.id'))
+                    ->field('id');
+            };
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
+            $where[] = ['service_work_id','in' ,$work_ids];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
+            $where[] = ['service_work_id','in' ,$work_ids];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
+            $where[] = ['service_work_id','in' ,$work_ids];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function lists(): array
+    {
+        return IssueWork::with([
+                'masterWorker'=>function(Query $query){
+                    $query->field('id,real_name,worker_number,mobile,work_status');
+                },'admin'=>function(Query $query){
+                    $query->field('id,name');
+                },'user'=>function(Query $query){
+                    $query->field('id,sn,real_name,mobile,account,nickname');
+                },'serviceWork'=>function(Query $query){
+                    $query->field('id,title,work_sn,address');
+                },'returnWork'=>function(Query $query){
+                    $query->field('id,work_sn,issue_work_id,finished_images');
+                }
+            ])
+            ->where('tenant_id', $this->adminInfo['tenant_id'])
+            ->where($this->searchWhere)
+            ->where($this->querySearch())
+            ->where($this->queryDataWhere())
+            ->whereExists($this->queryExists)
+            ->field(['id', 'work_sn', 'service_work_id', 'master_worker_id','user_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details', 'complaint_images', 'finished_time', 'approval_admin_id', 'approval_time', 'create_time', 'update_time','appeal_info'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function count(): int
+    {
+       return IssueWork::where($this->searchWhere)->where('tenant_id', $this->adminInfo['tenant_id'])->where($this->querySearch())->where($this->queryDataWhere())->whereExists($this->queryExists)->count();
+    }
+
+}

+ 127 - 0
app/tenantapi/lists/works/ReturnWorkLists.php

@@ -0,0 +1,127 @@
+<?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\works;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyOrder;
+use app\common\model\works\ReturnWork;
+use app\common\lists\ListsSearchInterface;
+use think\db\Query;
+use think\facade\Db;
+
+
+/**
+ * ReturnWork列表
+ * Class ReturnWorkLists
+ * @package app\tenantapi\listsworks
+ */
+class ReturnWorkLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    public $queryExists = null;
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['work_sn', 'service_work_id', 'issue_work_id', 'return_work_status', 'dispatch_time', 'appointment_time', 'finished_time', 'master_worker_id', 'create_time', 'update_time'],
+
+        ];
+    }
+
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        $this->queryExists = function (Query $query) { $query->name('service_work')->where('id','>', 0)->field('id'); };
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $this->queryExists = function (Query $query) use ($data_rules)  {
+                $p_table = $query->getTable().$query->getName();
+                $query->name('service_work')->alias('b')
+                    ->where('province','in', $data_rules['province'])
+                    ->where($p_table.'.service_work_id', '=', Db::raw('b.id'))
+                    ->field('id');
+            };
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $this->queryExists = function (Query $query) use ($data_rules) {
+                $p_table = $query->getTable().$query->getName();
+                $query->name('service_work')->alias('b')
+                    ->where('city','in', $data_rules['city'])
+                    ->where($p_table.'.service_work_id', '=', Db::raw('b.id'))
+                    ->field('id');
+            };
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
+            $where[] = ['service_work_id','in' ,$work_ids];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
+            $where[] = ['service_work_id','in' ,$work_ids];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
+            $where[] = ['service_work_id','in' ,$work_ids];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function lists(): array
+    {
+        return ReturnWork::with(['masterWorker'=>function(Query $query){
+                    $query->field('id,real_name,worker_number');
+                }])
+            ->where('tenant_id', $this->adminInfo['tenant_id'])
+            ->where($this->searchWhere)
+            ->where($this->queryDataWhere())
+            ->whereExists($this->queryExists)
+            ->field(['id', 'work_sn', 'service_work_id', 'issue_work_id', 'return_work_status', 'dispatch_time', 'appointment_time', 'finished_images', 'finished_time', 'master_worker_id', 'create_time', 'update_time'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function count(): int
+    {
+        return ReturnWork::where($this->searchWhere)->where('tenant_id', $this->adminInfo['tenant_id'])->where($this->queryDataWhere())->whereExists($this->queryExists)->count();
+    }
+
+}

+ 200 - 0
app/tenantapi/lists/works/ServiceWorkLists.php

@@ -0,0 +1,200 @@
+<?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\works;
+
+
+use app\tenantapi\lists\BaseAdminDataLists;
+use app\common\model\goods_category\GoodsCategory;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\property\PropertyOrder;
+use app\common\model\works\ServiceWork;
+use app\common\lists\ListsSearchInterface;
+use think\db\Query;
+use think\facade\Log;
+
+
+/**
+ * ServiceWork列表
+ * Class ServiceWorkLists
+ * @package app\tenantapi\listsworks
+ */
+class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+    /**
+     * 获取数据权限
+     * $this->adminInfo['data_rules']
+     * province city admin_id sale_group_id sale_id  property_head_id
+     */
+    public function queryDataWhere(){
+        $where = [];
+        $data_rules = $this->adminInfo['data_rules'];
+        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
+            $where[] = ['province','in' ,$data_rules['province']];
+        }
+        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
+            $where[] = ['city','in' ,$data_rules['city']];
+        }
+        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
+            $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
+            $where[] = ['id','in' ,$work_ids];
+        }
+        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
+            $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
+            $where[] = ['id','in' ,$work_ids];
+        }
+        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
+            $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
+            $where[] = ['id','in' ,$work_ids];
+        }
+        return $where;
+    }
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['id','category_type', 'base_service_fee', 'service_fee', 'work_status', 'service_status',  'data_type',  'finished_images', 'master_worker_id', 'work_amount','work_type','appoint_approval','refund_approval', 'city'],
+            '%like%'=>[ 'work_sn','mobile','real_name', 'title', 'address']
+        ];
+    }
+
+    public function queryWhere(){
+        $where = [];
+        if (isset($this->params['master_worker_name']) && !empty($this->params['master_worker_name'])) {
+            $master_worker_ids = MasterWorker::where([['worker_number|mobile|real_name', 'like','%' .$this->params['master_worker_name'] . '%']])->column('id')??[0];
+            $where[] = ['master_worker_id','in' ,$master_worker_ids];
+        }
+        if(isset($this->params['dispatch_time']) && !empty($this->params['dispatch_time'][0]) && !empty($this->params['dispatch_time'][1])){
+            $time = [strtotime($this->params['dispatch_time'][0]), strtotime($this->params['dispatch_time'][1])];
+            $where[] = ['dispatch_time', 'between', $time];
+        }
+        if(isset($this->params['receive_time']) && !empty($this->params['receive_time'][0]) && !empty($this->params['receive_time'][1])){
+            $time = [strtotime($this->params['receive_time'][0]), strtotime($this->params['receive_time'][1])];
+            $where[] = ['receive_time', 'between', $time];
+        }
+        if(isset($this->params['appointment_time']) && !empty($this->params['appointment_time'][0]) && !empty($this->params['appointment_time'][1])){
+            $time = [strtotime($this->params['appointment_time'][0]), strtotime($this->params['appointment_time'][1])];
+            $where[] = ['appointment_time', 'between', $time];
+        }
+        if(isset($this->params['finished_time']) && !empty($this->params['finished_time'][0]) && !empty($this->params['finished_time'][1])){
+            $time = [strtotime($this->params['finished_time'][0]), strtotime($this->params['finished_time'][1])];
+            $where[] = ['finished_time', 'between', $time];
+        }
+        if(isset($this->params['create_time']) && !empty($this->params['create_time'][0]) && !empty($this->params['create_time'][1])){
+            $time = [strtotime($this->params['create_time'][0]), strtotime($this->params['create_time'][1])];
+            $where[] = ['create_time', 'between', $time];
+        }
+        if(isset($this->params['update_time']) && !empty($this->params['update_time'][0]) && !empty($this->params['update_time'][1])){
+            $time = [strtotime($this->params['update_time'][0]), strtotime($this->params['update_time'][1])];
+            $where[] = ['update_time', 'between', $time];
+        }
+        if(isset($this->params['appoint_approval']) && !empty($this->params['appoint_approval'])){
+            // 时间 超过15分钟未确认
+            $time = time()-15*60;
+            $where[] = ['update_time', '<', $time];
+            $where[] = ['refund_approval', '=', 0]; // 未退款
+            $where[] = ['work_pay_status', '>', 0]; // 已支付
+        }
+        if(isset($this->params['workid']) && !empty($this->params['workid'])){
+            $where[] = ['master_worker_id', '=', $this->params['workid']];
+            $where[] = ['work_status', 'NOT IN', [7,8,9]];
+        }
+        if (isset($this->params['update_time']) && !empty($this->params['goods_category_id'])) {
+            $goodsCategoryId = end($this->params['goods_category_id']);
+            $goodsCategoryData = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])
+                ->select()->toArray();
+            $ids =get_tree_ids($goodsCategoryData,$goodsCategoryId);
+            $ids[] = $goodsCategoryId;
+            $where[] = ['goods_category_id','in' ,$ids];
+        }
+        if(isset($this->params['work_status']) && (!empty($this->params['work_status']) || $this->params['work_status'] != '')){
+            switch ($this->params['work_status']){
+                case 0:
+                    $where[] = ['service_status','<' ,3];
+                    break;
+            }
+        }
+        if(!isset($this->params['work_pay_status']) || (isset($this->params['work_pay_status']) && $this->params['work_pay_status'] == '')){
+            $where[] = ['work_pay_status','>',0];
+        }else{
+            $where[] = ['work_pay_status','=',$this->params['work_pay_status']];
+        }
+
+        if(isset($this->params['property_activity_id']) && !empty($this->params['property_activity_id'])){
+            if($this->params['property_activity_id'] == 2){
+                $where[] = ['order_effective_id','>',0];
+            }else{
+                $where[] = ['property_activity_id','>',0];
+            }
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function lists(): array
+    {
+        return ServiceWork::with([
+            'worker'=>function(Query $query) {
+                $query->field("id,worker_number,real_name,mobile");
+            },
+            'goodsCategory' =>function (Query $query) {
+                $query->field('id,name');
+            },
+            'allocateWorkerLog' =>function(Query $query){
+                $query->field('id,work_id,opera_log,create_time');
+            },
+            'serviceWorkLog' =>function(Query $query){
+                $query->field('id,work_id,opera_log,create_time');
+            },
+            'serviceWorkCustomerLog' =>function(Query $query){
+                $query->field('id,work_id,content,create_time');
+            }
+        ])
+            ->where('tenant_id', $this->adminInfo['tenant_id'])
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->where($this->queryDataWhere())
+            ->field(['id', 'work_sn', 'real_name', 'mobile', 'address', 'title', 'category_type', 'goods_category_ids', 'goods_category_id', 'base_service_fee', 'service_fee', 'work_status','work_pay_status', 'service_status', 'dispatch_time', 'receive_time', 'appointment_time', 'finished_images', 'finished_time', 'master_worker_id', 'work_amount', 'work_type', 'create_time', 'update_time','lon', 'lat','appoint_approval','refund_approval','finally_door_time','property_activity_id','order_effective_id'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function count(): int
+    {
+        return ServiceWork::where($this->searchWhere)->where('tenant_id', $this->adminInfo['tenant_id'])->where($this->queryWhere())->where($this->queryDataWhere())->count();
+    }
+
+}

+ 10 - 1
app/tenantapi/logic/ConfigLogic.php

@@ -14,6 +14,7 @@
 
 namespace app\tenantapi\logic;
 
+use app\common\logic\TableDataLogic;
 use app\tenantapi\logic\article\ArticleCateLogic;
 use app\tenantapi\logic\auth\MenuLogic;
 use app\tenantapi\logic\auth\RoleLogic;
@@ -30,6 +31,7 @@ use app\common\model\dict\DictData;
 use app\common\model\dict\DictType;
 use app\common\service\ConfigService;
 use app\common\service\{FileService};
+use think\facade\Log;
 
 /**
  * 配置类逻辑层
@@ -84,7 +86,14 @@ class ConfigLogic
         
         $type = explode(',', $type);
         $lists = DictData::whereIn('type_value', $type)->select()->toArray();
-
+        foreach ($type as $item) {
+            if (str_contains($item, 'data_table_')) {
+                $table = str_replace('data_table_', '', $item);
+                if (method_exists(TableDataLogic::class, $table)) {
+                    $lists = array_merge($lists, TableDataLogic::$table());
+                }
+            }
+        }
         if (empty($lists)) {
             return [];
         }

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

@@ -86,6 +86,7 @@ class FileLogic extends BaseLogic
     public static function addCate($params)
     {
         TenantFileCate::create([
+            'tenant_id'=> $params['tenant_id'],
             'type' => $params['type'],
             'pid' => $params['pid'],
             'name' => $params['name']

+ 144 - 0
app/tenantapi/logic/effective/EffectiveRulesLogic.php

@@ -0,0 +1,144 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\effective;
+
+
+use app\common\model\effective\EffectiveCategory;
+use app\common\model\effective\EffectiveRules;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * EffectiveRules逻辑
+ * Class EffectiveRulesLogic
+ * @package app\tenantapi\logic\effective
+ */
+class EffectiveRulesLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $effectiveRules = EffectiveRules::create([
+                'effective_num' => $params['effective_num'],
+                'effective_unit' => $params['effective_unit'],
+                'remark' => $params['remark'],
+            ]);
+            if(!empty($params['goods_category_ids'])){
+                $effectiveCategoryArr = [];
+                $ruleId = $effectiveRules->id;
+                foreach($params['goods_category_ids'] as $v){
+                    $effectiveCategoryArr[] = end($v);
+                }
+                $categoryIds = EffectiveCategory::where([['goods_category_id','in',$effectiveCategoryArr],['effective_id','<>',$ruleId]])->column('goods_category_id');
+                if(!empty($categoryIds)){
+                    throw new \Exception('存在已分配的分类:'.implode(',',$categoryIds));
+                }
+                $effectiveRules->effectiveWithCategory()->saveAll($effectiveCategoryArr);
+            }
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            EffectiveRules::where('id', $params['id'])->update([
+                'effective_num' => $params['effective_num'],
+                'effective_unit' => $params['effective_unit'],
+                'remark' => $params['remark'],
+            ]);
+            EffectiveCategory::where('effective_id',$params['id'])->delete();
+            $effectiveCategoryArr = [];
+            if(!empty($params['goods_category_ids'])){
+                foreach($params['goods_category_ids'] as $v){
+                    if(!is_array($v)){
+                        $effectiveCategoryArr[] = $v;
+                        continue;
+                    }
+                    $effectiveCategoryArr[] = end($v);
+                }
+                $categoryIds = EffectiveCategory::where([['goods_category_id','in',$effectiveCategoryArr],['effective_id','<>', $params['id']]])->column('goods_category_id');
+                if(!empty($categoryIds)){
+                    throw new \Exception('存在已分配的分类:'.implode(',',$categoryIds));
+                }
+                $effectiveRules = EffectiveRules::find($params['id']);
+                $effectiveRules->effectiveWithCategory()->saveAll($effectiveCategoryArr);
+            }
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public static function delete(array $params): bool
+    {
+        EffectiveCategory::where('effective_id',$params['id'])->delete();
+        return EffectiveRules::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/17 11:49
+     */
+    public static function detail($params): array
+    {
+
+       $rules = EffectiveRules::findOrEmpty($params['id'])->toArray();
+       if(!empty($rules)){
+           $rules['goods_category_ids'] =  EffectiveCategory::where('effective_id',$params['id'])->column('goods_category_id');
+       }
+       return $rules;
+    }
+}

+ 287 - 0
app/tenantapi/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\tenantapi\logic\effective;
+
+
+use app\tenantapi\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\tenantapi\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;
+        }
+    }
+
+
+
+
+
+}

+ 113 - 0
app/tenantapi/logic/finance/MasterWorkerCaseOutLogLogic.php

@@ -0,0 +1,113 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\finance;
+
+
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerCaseOutLog逻辑
+ * Class MasterWorkerCaseOutLogLogic
+ * @package app\tenantapi\logic\finance
+ */
+class MasterWorkerCaseOutLogLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerCaseOutLog::create([
+                'sn' => generate_sn(MasterWorkerCaseOutLog::class,'sn'),
+                'worker_id' => $params['worker_id'],
+                'action' => $params['action'],
+                'change_amount' => $params['change_amount'],
+                'review_status' => $params['review_status'],
+                'remark' => $params['remark'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerCaseOutLog::where('sn', $params['sn'])->update([
+                'review_status' => $params['review_status'],
+                'remark' => $params['remark'],
+                'admin_id' => $params['admin_id'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerCaseOutLog::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerCaseOutLog::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 97 - 0
app/tenantapi/logic/finance/RefundLogic.php

@@ -0,0 +1,97 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\finance;
+
+
+use app\common\enum\RefundEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\refund\RefundLog;
+use app\common\model\refund\RefundRecord;
+
+
+/**
+ * 退款
+ * Class RefundLogic
+ * @package app\tenantapi\logic\finance
+ */
+class RefundLogic extends BaseLogic
+{
+
+    /**
+     * @notes 退款统计
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/3/3 12:09
+     */
+    public static function stat($params = [])
+    {
+
+
+        $records = RefundRecord::alias('r')->join('user u', 'u.id = r.user_id and u.tenant_id = ' . $params['tenant_id'])->select()->toArray();
+
+        $total = 0;
+        $ing = 0;
+        $success = 0;
+        $error = 0;
+
+        foreach ($records as $record) {
+            $total += $record['order_amount'];
+            switch ($record['refund_status']) {
+                case RefundEnum::REFUND_ING:
+                    $ing += $record['order_amount'];
+                    break;
+                case RefundEnum::REFUND_SUCCESS:
+                    $success += $record['order_amount'];
+                    break;
+                case RefundEnum::REFUND_ERROR:
+                    $error += $record['order_amount'];
+                    break;
+            }
+        }
+
+        return [
+            'total' => round($total, 2),
+            'ing' => round($ing, 2),
+            'success' => round($success, 2),
+            'error' => round($error, 2),
+        ];
+    }
+
+
+    /**
+     * @notes 退款日志
+     * @param $recordId
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 段誉
+     * @date 2023/3/3 14:25
+     */
+    public static function refundLog($recordId)
+    {
+        return (new RefundLog())
+            ->order(['id' => 'desc'])
+            ->where('record_id', $recordId)
+            ->hidden(['refund_msg'])
+            ->append(['handler', 'refund_status_text'])
+            ->select()
+            ->toArray();
+    }
+
+}

+ 133 - 0
app/tenantapi/logic/goods_category/GoodsCategoryLogic.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\tenantapi\logic\goods_category;
+
+
+use app\common\model\goods_category\GoodsCategory;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * GoodsCategory逻辑
+ * Class GoodsCategoryLogic
+ * @package app\tenantapi\logic\goods_category
+ */
+class GoodsCategoryLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsCategory::create([
+                'pid' => $params['pid'],
+                'category_type' => $params['category_type'],
+                'picture' => $params['picture'],
+                'name' => $params['name'],
+                'is_goods' => $params['is_goods'],
+                'status' => $params['status'],
+                'weigh' => $params['weigh'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsCategory::where('id', $params['id'])->update([
+                'pid' => $params['pid'],
+                'category_type' => $params['category_type'],
+                'picture' => $params['picture'],
+                'name' => $params['name'],
+                'is_goods' => $params['is_goods'],
+                'status' => $params['status'],
+                'weigh' => $params['weigh'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function delete(array $params): bool
+    {
+        return GoodsCategory::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function detail($params): array
+    {
+        return GoodsCategory::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function getTreeData():array
+    {
+        $data = GoodsCategory::field('id,pid,name')
+            ->where('status', 1)
+            ->order(['weigh' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+        foreach($data as $k => $v){
+            $v['label'] = $v['name'];
+            $v['value'] = $v['id'];
+            $data[$k] = $v;
+        }
+        return linear_to_tree($data, 'children');
+    }
+}

+ 129 - 0
app/tenantapi/logic/master_worker/BankAccountLogic.php

@@ -0,0 +1,129 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\master_worker;
+
+
+use app\common\model\master_worker\BankAccount;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * BankAccount逻辑
+ * Class BankAccountLogic
+ * @package app\tenantapi\logic\master_worker
+ */
+class BankAccountLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            BankAccount::create([
+                'account_holder' => $params['account_holder'],
+                'bank_name' => $params['bank_name'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'opening_branch' => $params['opening_branch'],
+                'account' => $params['account'],
+                'bank_image' => $params['bank_image'],
+                'mobile' => $params['mobile'],
+                'worker_id' => $params['worker_id'],
+                'audit_state' => $params['audit_state'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            BankAccount::where('id', $params['id'])->update([
+                'account_holder' => $params['account_holder'],
+                'bank_name' => $params['bank_name'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'opening_branch' => $params['opening_branch'],
+                'account' => $params['account'],
+                'bank_image' => $params['bank_image'],
+                'mobile' => $params['mobile'],
+                'worker_id' => $params['worker_id'],
+                'audit_state' => $params['audit_state'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public static function delete(array $params): bool
+    {
+        return BankAccount::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public static function detail($params): array
+    {
+        return BankAccount::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function getWorkerIds($params): array
+    {
+        return BankAccount::where('id',is_array($params['id'])?'in':'=',$params['id'])->column('worker_id');
+    }
+}

+ 121 - 0
app/tenantapi/logic/master_worker/EngineerBillLogic.php

@@ -0,0 +1,121 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\master_worker;
+
+
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\WorkerAccountLogLogic;
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\model\financial\FinancialPaymentRecords;
+use app\common\model\financial\MasterSettlementDetails;
+use app\common\model\master_worker\EngineerSettlement;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorker;
+use think\facade\Db;
+
+
+/**
+ * EngineerSettlement逻辑
+ * Class EngineerSettlementLogic
+ * @package app\tenantapi\logic
+ */
+class EngineerBillLogic extends BaseLogic
+{
+
+    public static function submitForm($params)
+    {
+        Db::startTrans();
+        try {
+            if(!empty($params['left_amount']) && !empty($params['user_money']) && !((float)$params['left_amount'] > (float)$params['user_money'])){
+                $batch_number = 'bn' . date('YmdHis') . rand(1000, 9999);
+                $params['deadline_time'] = $deadline_time = strtotime($params['deadline_time'])+86400;
+
+                FinancialPaymentRecords::create([
+                    'export_conditions' => $params,
+                    'batch_number' => $batch_number,
+                    'upload_status' => 1,
+                    'payment_status' => 1,
+                ]);
+                MasterSettlementDetails::where('master_worker_id',$params['id'])
+                                        ->where('change_time', '<', $deadline_time)
+                                        ->where('status', '=', 1)
+                                        ->update([
+                                            'status' => 2,
+                                            'batch_number' => $batch_number,
+                                        ]);
+
+                $insertXlsData = [];
+                $insertXlsData[0] = [
+                    'master_worker_id' => $params['id'],
+                    'worker_number' => $params['worker_number'],
+                    'engineer_name' => $params['account_holder'],
+
+                    'bank_account' => $params['bank_account'],
+                    'bank_name' => $params['bank_name'],
+                    'opening_branch' => $params['opening_branch'],
+
+                    'original_balance' => $params['user_money'],
+                    'total_settlement_amount' => $params['left_amount'],
+                    'payment_status' => 0,
+                    'is_export' => 1,
+
+                    'batch_number'=> $batch_number,
+                    'create_time'=> time(),
+                    'update_time'=> time(),
+                    'admin_id'=> 0,
+                    'is_deduction'=> 0,
+                ];
+                // 生成 可发 数据表格
+                Db::name('engineer_settlement')->insertAll($insertXlsData);
+
+                $analogData = [];
+                $analogData[0] = [
+                    'master_worker_id' => $params['id'],
+                    'worker_number' => $params['worker_number'],
+                    'engineer_name' => $params['account_holder'],
+                    'bank_account' => $params['bank_account'],
+                    'bank_name' => $params['bank_name'],
+                    'opening_branch' => $params['opening_branch'],
+                    'original_balance' => $params['user_money'],
+                    'total_settlement_amount' => $params['left_amount'],
+                    'batch_number'=> $batch_number,
+                    'deduction_amount' => $params['deduction_amount'],
+                    'deduction_describe' => $params['deduction_describe'],
+                    'final_settlement_amount' => $params['final_settlement_amount'],
+                    'settlement_time' => $params['settlement_time'],
+                    'settlement_details_remarks' => $params['settlement_details_remarks'],
+                ];
+                $resData = EngineerSettlementLogic::engineerSettlementValidate($analogData);
+                if(is_array($resData)){
+                    $result = EngineerSettlementLogic::add($resData,$params['adminId']);
+                    if ($result === false){
+                        throw new \Exception(EngineerSettlementLogic::getError());
+                    }
+                }
+            }else{
+                throw new \Exception('打款失败');
+            }
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+}

+ 346 - 0
app/tenantapi/logic/master_worker/EngineerSettlementLogic.php

@@ -0,0 +1,346 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\master_worker;
+
+
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\WorkerAccountLogLogic;
+use app\common\model\finance\MasterWorkerCaseOutLog;
+use app\common\model\financial\FinancialPaymentRecords;
+use app\common\model\financial\MasterSettlementDetails;
+use app\common\model\master_worker\EngineerSettlement;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorker;
+use think\facade\Db;
+
+
+/**
+ * EngineerSettlement逻辑
+ * Class EngineerSettlementLogic
+ * @package app\tenantapi\logic
+ */
+class EngineerSettlementLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public static function add(array $params, $adminId): bool
+    {
+        Db::startTrans();
+        try {
+            foreach ($params as $param) {
+                //$param['payment_status'] == 1  默认上传的都是已经打款了
+                $engineerSettlement = EngineerSettlement::where('master_worker_id', $param['master_worker_id'])
+                    ->where('batch_number', $param['batch_number'])
+                    ->where('is_export', 1)
+                    ->where('is_deduction', 0)
+                    ->where('payment_status', 0)
+                    ->findOrEmpty();
+                if(!$engineerSettlement->isEmpty()){
+
+                    $masterWorker = MasterWorker::where('id', $param['master_worker_id'])->where('worker_number', $param['worker_number'])->find();
+                    if($masterWorker && $masterWorker->user_money >= $param['total_settlement_amount']){
+                        //$masterWorker->user_money = $masterWorker->user_money - $param['total_settlement_amount'];
+                        //$masterWorker->save();
+                        //实发扣款
+                        if($param['final_settlement_amount']){
+                            $final_res = WorkerAccountLogLogic::masterAccountLog($param['master_worker_id'],(float)$param['final_settlement_amount'],WorkerAccountLogEnum::UM_DEC_ADMIN,WorkerAccountLogEnum::DEC, '实发扣款','',[
+                                'engineerSettlementId'=>$engineerSettlement->id,
+                                'batch_number'=>$param['batch_number'],
+                            ]);
+                            if($final_res->id){
+                                MasterSettlementDetails::create([
+                                    'account_log_id' => $final_res->id,
+                                    'payment_time' => $param['settlement_time']??date('Y-m-d H:i:s'),
+                                    'batch_number' => $param['batch_number'],
+                                    'status' => 3,
+                                    'master_worker_id' => $param['master_worker_id'],
+                                    'amount_change' => -(float)$param['final_settlement_amount'],
+                                    'change_time' => time(),
+                                    'remark' => '实发扣款'
+                                ]);
+                            }
+                        }
+                        //直接扣款
+                        if($param['deduction_amount']){
+                            $deduction_res = WorkerAccountLogLogic::masterAccountLog($param['master_worker_id'],(float)$param['deduction_amount'],WorkerAccountLogEnum::UM_DEC_ADMIN,WorkerAccountLogEnum::DEC, '直接扣款','',[
+                                'engineerSettlementId'=>$engineerSettlement->id,
+                                'batch_number'=>$param['batch_number'],
+                            ]);
+                            if($deduction_res->id){
+                                MasterSettlementDetails::create([
+                                    'account_log_id' => $deduction_res->id,
+                                    'payment_time' => $param['settlement_time']??date('Y-m-d H:i:s'),
+                                    'batch_number' => $param['batch_number'],
+                                    'status' => 3,
+                                    'master_worker_id' => $param['master_worker_id'],
+                                    'amount_change' => -(float)$param['deduction_amount'],
+                                    'change_time' => time(),
+                                    'remark' => '直接扣款'
+                                ]);
+                            }
+                        }
+                        // 提现记录
+                        $case_remark = '应发:'.$param['total_settlement_amount'].($param['deduction_amount']>0?',扣款:'.$param['deduction_amount'].',扣款说明:'.$param['deduction_describe']:'').',实发:'.$param['final_settlement_amount'];
+                        MasterWorkerCaseOutLog::create([
+                            'sn' => generate_sn(MasterWorkerCaseOutLog::class,'sn'),
+                            'worker_id' => $masterWorker->id,
+                            'title' => '财务打款',
+                            'change_amount' => $param['total_settlement_amount'],
+                            'review_status' => 3,
+                            'admin_id' => $adminId,
+                            'remark' => '财务打款-'.$case_remark,
+                            'create_time' => time(),
+                            'update_time' => time(),
+                        ]);
+
+                        $engineerSettlement->deduction_amount = $param['deduction_amount']??0;
+                        $engineerSettlement->deduction_describe = $param['deduction_describe']??'';
+                        $engineerSettlement->final_settlement_amount = $param['final_settlement_amount']??0;
+                        $engineerSettlement->settlement_time = $param['settlement_time']??date('Y-m-d H:i:s');
+                        $engineerSettlement->settlement_details_remarks = $param['settlement_details_remarks']??'';
+                        $engineerSettlement->new_balance = $masterWorker->user_money;
+                        $engineerSettlement->payment_status = 1;
+                        $engineerSettlement->is_export = 2;
+                        $engineerSettlement->admin_id = $adminId;
+                        $engineerSettlement->is_deduction = 1;
+                        $engineerSettlement->save();
+
+                        MasterSettlementDetails::where('master_worker_id', $param['master_worker_id'])
+                            ->where('batch_number', $param['batch_number'])
+                            ->where('status', 2)
+                            ->update([
+                                'payment_time' => $param['settlement_time']??date('Y-m-d H:i:s'),
+                                'status'=>3, 'remark'=>''
+                            ]);
+
+                    }else{
+
+                        $engineerSettlement->deduction_amount = $param['deduction_amount']??0;
+                        $engineerSettlement->deduction_describe = $param['deduction_describe']??'';
+                        $engineerSettlement->final_settlement_amount = $param['final_settlement_amount']??0;
+                        $engineerSettlement->settlement_time = $param['settlement_time']??date('Y-m-d H:i:s');
+                        $engineerSettlement->settlement_details_remarks = ($param['settlement_details_remarks']??'').'-余额不足';
+                        $engineerSettlement->new_balance = $masterWorker->user_money;
+                        $engineerSettlement->payment_status = 1;
+                        $engineerSettlement->is_export = 2;
+                        $engineerSettlement->admin_id = $adminId;
+                        $engineerSettlement->is_deduction = 2;
+                        $engineerSettlement->save();
+
+                        //throw new \Exception('工程师不存在、余额不足');
+                    }
+                }
+            }
+
+            $payment_num = MasterSettlementDetails::where('batch_number', $params[0]['batch_number'])->where('status','<', 3)->count('id');
+            FinancialPaymentRecords::where('batch_number', $params[0]['batch_number'])
+                ->where('upload_status', 1)
+                ->where('payment_status', 1)
+                ->update([
+                    'upload_status' => 3,
+                    'payment_status'=> $payment_num>0?2:3
+                ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            EngineerSettlement::where('id', $params['id'])->update([
+                'master_worker_id' => $params['master_worker_id'],
+                'worker_number' => $params['worker_number'],
+                'engineer_name' => $params['engineer_name'],
+                'original_balance' => $params['original_balance'],
+                'total_settlement_amount' => $params['total_settlement_amount'],
+                'deduction_amount' => $params['deduction_amount'],
+                'final_settlement_amount' => $params['final_settlement_amount'],
+                'settlement_time' => $params['settlement_time'],
+                'settlement_details_remarks' => $params['settlement_details_remarks'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public static function delete(array $params): bool
+    {
+        return EngineerSettlement::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public static function detail($params): array
+    {
+        return EngineerSettlement::findOrEmpty($params['id'])->toArray();
+    }
+    public static function downloadLists(): array
+    {
+        return [EngineerSettlement::where('id','>',0)
+            ->field(['id', 'master_worker_id', 'worker_number', 'engineer_name', 'original_balance', 'total_settlement_amount', 'deduction_amount', 'final_settlement_amount', 'settlement_time', 'settlement_details_remarks'])
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray()[0]];
+    }
+
+    public static function engineerSettlementValidate($params)
+    {
+        //
+        //上传表格中所有批号必须相同
+        //$engineerSettlement 中每条都不能为空
+        // $masterWorker->user_money >= $param['total_settlement_amount']
+        //$param['total_settlement_amount'] = $params['final_settlement_amount']+deduction_amount;
+        // 该批次是否为待上传
+        try {
+            if(empty($params)) throw new \Exception('表格数据为空');
+            $master_worker_ids = array_column($params, 'master_worker_id');
+            //上传表格中所有 master_worker_id 不能存在重复
+            array_filter(array_count_values($master_worker_ids), function($count) {
+                if($count>1) throw new \Exception('上传表格中所有工程师不能存在重复');
+            });
+            //上传表格中所有批号必须相同
+            if(count(array_unique(array_column($params, 'batch_number')))>1){
+                throw new \Exception('上传表格中所有批号必须同批次');
+            }
+            $batch_number = $params[0]['batch_number'];
+            // 该批次是否为待上传
+            $financialRecords = FinancialPaymentRecords::where('batch_number', $batch_number)->where('upload_status', 1)->findOrEmpty();
+            if($financialRecords->isEmpty()){
+                throw new \Exception('该批次不存在或已取消/已上传,禁止上传');
+            }
+            // 每条数据在表 EngineerSettlement 中不能为空即 下载记录必须存在
+            $engineer_worker_ids = EngineerSettlement::where('batch_number', $batch_number)
+                ->where('is_export', 1)
+                ->where('is_deduction', 0)
+                ->where('payment_status', 0)
+                ->column('master_worker_id');
+            $masterWorkers = MasterWorker::where('id', 'in',$master_worker_ids)->column('user_money', 'id');
+
+            foreach ($params as &$param) {
+                $param['deduction_amount'] = $param['deduction_amount']??0;
+                $param['deduction_describe'] = $param['deduction_describe']??'';
+                $param['settlement_details_remarks'] = $param['settlement_details_remarks']??'';
+
+                if(!isset($param['total_settlement_amount']) || $param['total_settlement_amount']<0){
+                    throw new \Exception('应付金额不能为空或负数:'.$param['master_worker_id']);
+                }
+                if(!isset($param['final_settlement_amount']) || $param['final_settlement_amount']<0){
+                    throw new \Exception('实付金额不能为空或负数:'.$param['master_worker_id']);
+                }
+                if(isset($param['deduction_amount']) && $param['deduction_amount']<0){
+                    throw new \Exception('扣款金额不能为负数:'.$param['master_worker_id']);
+                }
+                if($param['deduction_amount'] > 0 && (!isset($param['deduction_describe']) || empty($param['deduction_describe']))){
+                    throw new \Exception('扣款存在,扣款说明不能为空:'.$param['master_worker_id']);
+                }
+                if(!in_array($param['master_worker_id'], $engineer_worker_ids)) throw new \Exception('下载记录不存在:'.$param['master_worker_id']);
+                //判断日期时间格式是否正确 2024/1/1 00:00:00 或 2024-1-1 00:00:00
+                if(
+                    isset($param['settlement_time'])
+                    && !preg_match('/^[0-9]{4}\/[0-9]{1,2}\/[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $param['settlement_time'])
+                    && !preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $param['settlement_time'])
+                    && !preg_match('/^[0-9]{4}\/[0-9]{1,2}\/[0-9]{1,2}$/', $param['settlement_time'])
+                    && !preg_match('/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/', $param['settlement_time'])
+                ){
+                    throw new \Exception('日期时间格式错误:'.$param['master_worker_id']);
+                }
+                $param['settlement_time'] = isset($param['settlement_time'])?date('Y-m-d H:i:s', strtotime($param['settlement_time'])):date('Y-m-d H:i:s');
+                if(!is_numeric($param['original_balance']) || !is_numeric($param['total_settlement_amount']) || !is_numeric($param['deduction_amount']) || !is_numeric($param['final_settlement_amount'])){
+                    throw new \Exception('金额格式错误:'.$param['master_worker_id']);
+                }
+                if (bccomp((float)$param['total_settlement_amount'], bcadd((float)$param['final_settlement_amount'], (float)$param['deduction_amount'], 2), 2) !== 0) {
+                    throw new \Exception('金额计算错误:' . $param['master_worker_id']);
+                }
+                if(!preg_match('/^[0-9]*$/', $param['worker_number'])){
+                    throw new \Exception('工程师编号格式错误:'.$param['master_worker_id']);
+                }
+                if(!preg_match('/^[0-9]*$/', $param['master_worker_id'])){
+                    throw new \Exception('工程师ID格式错误:'.$param['master_worker_id']);
+                }
+                if($masterWorkers[$param['master_worker_id']] < $param['total_settlement_amount']) throw new \Exception('余额不足-'.$param['master_worker_id']);
+            }
+            return $params;
+        } catch (\Exception $e) {
+            throw new \Exception($e->getMessage());
+        }
+
+    }
+    public static function insertSettlementDetails()
+    {
+        $insert_sql = "INSERT INTO la_master_settlement_details (account_log_id, master_worker_id, amount_change, change_time)
+                        SELECT
+                        a.id,
+                        a.worker_id AS master_worker_id,
+                            CASE
+                            WHEN a.change_amount > 0 AND a.action = 1 THEN a.change_amount
+                                WHEN a.change_amount > 0 AND a.action = 2 THEN -a.change_amount
+                                ELSE 0
+                            END AS amount_change,
+                            a.create_time
+                        FROM
+                            `la_master_worker_account_log` a
+                        LEFT JOIN
+                            `la_master_settlement_details` b ON a.id = b.account_log_id
+                        WHERE
+                            a.change_object = 1
+                            AND b.account_log_id IS NULL";
+
+        return Db::execute($insert_sql);
+    }
+
+
+
+}

+ 122 - 0
app/tenantapi/logic/master_worker/MasterWorkerAgreeLogic.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\tenantapi\logic\master_worker;
+
+
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAgree;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerAgree逻辑
+ * Class MasterWorkerAgreeLogic
+ * @package app\tenantapi\logic\master_worker
+ */
+class MasterWorkerAgreeLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerAgree::create([
+                'agree_type' => $params['agree_type'],
+                'worker_id' => $params['worker_id'],
+                'sign' => $params['sign'],
+                'pdf_url' => $params['pdf_url'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerAgree::where('id', $params['id'])->update([
+                'audit_state' => $params['audit_state'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerAgree::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerAgree::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function getWorkerIds($params): array
+    {
+        return MasterWorkerAgree::where('id',is_array($params['id'])?'in':'=',$params['id'])->column('worker_id');
+    }
+
+    public static function getStatus(): int
+    {
+        return MasterWorker::where('audit_state',0)->count();
+    }
+
+
+}

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