Sfoglia il codice sorgente

add - 租户工程师、财务、工单管理

liugc 1 anno fa
parent
commit
29699f0113
81 ha cambiato i file con 10415 aggiunte e 5 eliminazioni
  1. 2 1
      app/api/logic/IssueWorkLogic.php
  2. 3 1
      app/common/cache/TenantAdminTokenCache.php
  3. 8 2
      app/common/logic/TableDataLogic.php
  4. 39 0
      app/tenantapi/controller/finance/AccountLogController.php
  5. 108 0
      app/tenantapi/controller/finance/MasterWorkerCaseOutLogController.php
  6. 72 0
      app/tenantapi/controller/finance/RefundController.php
  7. 39 0
      app/tenantapi/controller/finance/WorkerAccountLogController.php
  8. 112 0
      app/tenantapi/controller/goods_category/GoodsCategoryController.php
  9. 119 0
      app/tenantapi/controller/master_worker/BankAccountController.php
  10. 129 0
      app/tenantapi/controller/master_worker/EngineerBillController.php
  11. 124 0
      app/tenantapi/controller/master_worker/EngineerSettlementController.php
  12. 120 0
      app/tenantapi/controller/master_worker/MasterWorkerAgreeController.php
  13. 129 0
      app/tenantapi/controller/master_worker/MasterWorkerController.php
  14. 109 0
      app/tenantapi/controller/master_worker/MasterWorkerExamineController.php
  15. 116 0
      app/tenantapi/controller/master_worker/MasterWorkerInfoController.php
  16. 108 0
      app/tenantapi/controller/master_worker/MasterWorkerRuleController.php
  17. 66 0
      app/tenantapi/controller/master_worker/MasterWorkerServiceOrderController.php
  18. 108 0
      app/tenantapi/controller/master_worker/MasterWorkerTeamController.php
  19. 37 0
      app/tenantapi/controller/master_worker/RetentionMoneyLogController.php
  20. 135 0
      app/tenantapi/controller/notice/NoticeController.php
  21. 107 0
      app/tenantapi/controller/recharge/RechargeController.php
  22. 108 0
      app/tenantapi/controller/works/IssueWorkController.php
  23. 147 0
      app/tenantapi/controller/works/ReturnWorkController.php
  24. 210 0
      app/tenantapi/controller/works/ServiceWorkController.php
  25. 119 0
      app/tenantapi/lists/finance/AccountLogLists.php
  26. 97 0
      app/tenantapi/lists/finance/MasterWorkerCaseOutLogLists.php
  27. 79 0
      app/tenantapi/lists/finance/RefundLogLists.php
  28. 151 0
      app/tenantapi/lists/finance/RefundRecordLists.php
  29. 101 0
      app/tenantapi/lists/finance/WorkerAccountLogLists.php
  30. 79 0
      app/tenantapi/lists/goods_category/GoodsCategoryLists.php
  31. 107 0
      app/tenantapi/lists/master_worker/BankAccountLists.php
  32. 147 0
      app/tenantapi/lists/master_worker/EngineerBillLists.php
  33. 90 0
      app/tenantapi/lists/master_worker/EngineerSettlementLists.php
  34. 106 0
      app/tenantapi/lists/master_worker/MasterWorkerAgreeLists.php
  35. 118 0
      app/tenantapi/lists/master_worker/MasterWorkerExamineLists.php
  36. 106 0
      app/tenantapi/lists/master_worker/MasterWorkerInfoLists.php
  37. 225 0
      app/tenantapi/lists/master_worker/MasterWorkerLists.php
  38. 78 0
      app/tenantapi/lists/master_worker/MasterWorkerRuleLists.php
  39. 202 0
      app/tenantapi/lists/master_worker/MasterWorkerServiceOrderLists.php
  40. 79 0
      app/tenantapi/lists/master_worker/MasterWorkerTeamLists.php
  41. 104 0
      app/tenantapi/lists/master_worker/MoneyAnalysis.php
  42. 88 0
      app/tenantapi/lists/master_worker/RetentionMoneyLogLists.php
  43. 71 0
      app/tenantapi/lists/notice/NoticeSettingLists.php
  44. 146 0
      app/tenantapi/lists/recharge/RechargeLists.php
  45. 162 0
      app/tenantapi/lists/works/IssueWorkLists.php
  46. 127 0
      app/tenantapi/lists/works/ReturnWorkLists.php
  47. 200 0
      app/tenantapi/lists/works/ServiceWorkLists.php
  48. 10 1
      app/tenantapi/logic/ConfigLogic.php
  49. 113 0
      app/tenantapi/logic/finance/MasterWorkerCaseOutLogLogic.php
  50. 97 0
      app/tenantapi/logic/finance/RefundLogic.php
  51. 133 0
      app/tenantapi/logic/goods_category/GoodsCategoryLogic.php
  52. 129 0
      app/tenantapi/logic/master_worker/BankAccountLogic.php
  53. 121 0
      app/tenantapi/logic/master_worker/EngineerBillLogic.php
  54. 346 0
      app/tenantapi/logic/master_worker/EngineerSettlementLogic.php
  55. 122 0
      app/tenantapi/logic/master_worker/MasterWorkerAgreeLogic.php
  56. 143 0
      app/tenantapi/logic/master_worker/MasterWorkerExamineLogic.php
  57. 125 0
      app/tenantapi/logic/master_worker/MasterWorkerInfoLogic.php
  58. 290 0
      app/tenantapi/logic/master_worker/MasterWorkerLogic.php
  59. 112 0
      app/tenantapi/logic/master_worker/MasterWorkerRuleLogic.php
  60. 144 0
      app/tenantapi/logic/master_worker/MasterWorkerTeamLogic.php
  61. 145 0
      app/tenantapi/logic/master_worker/RetentionMoneyLogic.php
  62. 344 0
      app/tenantapi/logic/notice/NoticeLogic.php
  63. 176 0
      app/tenantapi/logic/recharge/RechargeLogic.php
  64. 191 0
      app/tenantapi/logic/works/IssueWorkLogic.php
  65. 187 0
      app/tenantapi/logic/works/ReturnWorkLogic.php
  66. 900 0
      app/tenantapi/logic/works/ServiceWorkLogic.php
  67. 105 0
      app/tenantapi/validate/finance/MasterWorkerCaseOutLogValidate.php
  68. 108 0
      app/tenantapi/validate/goods_category/GoodsCategoryValidate.php
  69. 114 0
      app/tenantapi/validate/master_worker/BankAccountValidate.php
  70. 112 0
      app/tenantapi/validate/master_worker/EngineerSettlementValidate.php
  71. 103 0
      app/tenantapi/validate/master_worker/MasterWorkerAgreeValidate.php
  72. 100 0
      app/tenantapi/validate/master_worker/MasterWorkerInfoValidate.php
  73. 76 0
      app/tenantapi/validate/master_worker/MasterWorkerRetentionMoneyLogValidate.php
  74. 98 0
      app/tenantapi/validate/master_worker/MasterWorkerRuleValidate.php
  75. 100 0
      app/tenantapi/validate/master_worker/MasterWorkerTeamValidate.php
  76. 130 0
      app/tenantapi/validate/master_worker/MasterWorkerValidate.php
  77. 39 0
      app/tenantapi/validate/notice/NoticeValidate.php
  78. 109 0
      app/tenantapi/validate/recharge/RechargeRefundValidate.php
  79. 106 0
      app/tenantapi/validate/works/IssueWorkValidate.php
  80. 112 0
      app/tenantapi/validate/works/ReturnWorkValidate.php
  81. 138 0
      app/tenantapi/validate/works/ServiceWorkValidate.php

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

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

+ 8 - 2
app/common/logic/TableDataLogic.php

@@ -78,8 +78,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 优惠券标签列表

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

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

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

+ 143 - 0
app/tenantapi/logic/master_worker/MasterWorkerExamineLogic.php

@@ -0,0 +1,143 @@
+<?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\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAgree;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorkerInfo;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerExamineLogic逻辑
+ * Class MasterWorkerExamineLogic
+ * @package app\tenantapi\logic\master_worker
+ */
+class MasterWorkerExamineLogic 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 {
+            !empty($params['workerInfo']['id']) && MasterWorkerInfo::where('id', $params['workerInfo']['id'])->update([
+                'audit_state' => $params['workerInfo']['audit_state'],
+            ]);
+            !empty($params['workerAgree']['id']) && MasterWorkerAgree::where('id', $params['workerAgree']['id'])->update([
+                'audit_state' => $params['workerAgree']['audit_state'],
+            ]);
+            !empty($params['bankAccount']['id']) && BankAccount::where('id', $params['bankAccount']['id'])->update([
+                'audit_state' => $params['bankAccount']['audit_state'],
+            ]);
+
+            if(empty($params['workerInfo']['id']) || empty($params['workerAgree']['id']) || empty($params['bankAccount']['id'])) {
+                $audit_state = 3;
+            }elseif ((int)$params['workerInfo']['audit_state'] === 0 || (int)$params['workerAgree']['audit_state'] === 0 || (int)$params['bankAccount']['audit_state'] === 0){
+                $audit_state = 0;
+            }elseif ((int)$params['workerInfo']['audit_state'] === 2 || (int)$params['workerAgree']['audit_state'] === 2 || (int)$params['bankAccount']['audit_state'] === 2){
+                $audit_state = 2;
+            }else{
+                $audit_state = 1;
+            }
+            MasterWorker::where('id', $params['id'])->update([
+                'audit_state' => $audit_state,
+            ]);
+
+            Db::commit();
+
+            if($audit_state == 1){
+                // 工程师基本信息审核通知【给工程师的通知】
+                event('Notice',  [
+                    'scene_id' => 123,
+                    'params' => [
+                        'user_id' => 0,
+                        'mobile' => $params['mobile'],
+                    ]
+                ]);
+            }
+
+            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();
+    }
+}

+ 125 - 0
app/tenantapi/logic/master_worker/MasterWorkerInfoLogic.php

@@ -0,0 +1,125 @@
+<?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\MasterWorkerInfo;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerInfo逻辑
+ * Class MasterWorkerInfoLogic
+ * @package app\tenantapi\logic\master_worker
+ */
+class MasterWorkerInfoLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerInfo::create([
+                'worker_id' => $params['worker_id'],
+                'real_name' => $params['real_name'],
+                'id_card' => $params['id_card'],
+                'id_card_front_img' => $params['id_card_front_img'],
+                'id_card_opposite_img' => $params['id_card_opposite_img'],
+                'mobile' => $params['mobile'],
+                'address' => $params['address'],
+                '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/07 18:58
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerInfo::where('id', $params['id'])->update([
+                'worker_id' => $params['worker_id'],
+                'real_name' => $params['real_name'],
+                'id_card' => $params['id_card'],
+                'id_card_front_img' => $params['id_card_front_img'],
+                'id_card_opposite_img' => $params['id_card_opposite_img'],
+                'mobile' => $params['mobile'],
+                'address' => $params['address'],
+                '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/07 18:58
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerInfo::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerInfo::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function getWorkerIds($params): array
+    {
+        return MasterWorkerInfo::where('id',is_array($params['id'])?'in':'=',$params['id'])->column('worker_id');
+    }
+}

+ 290 - 0
app/tenantapi/logic/master_worker/MasterWorkerLogic.php

@@ -0,0 +1,290 @@
+<?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\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
+use app\common\service\ConfigService;
+use think\db\Query;
+use think\facade\Config;
+use think\facade\Db;
+
+
+/**
+ * MasterWorker逻辑
+ * Class MasterWorkerLogic
+ * @package app\tenantapi\logic\master_worker
+ */
+class MasterWorkerLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public static function add(array $params): bool
+    {
+        if($params['category_ids']){
+            foreach ($params['category_ids'] as $val){
+                is_array($val)?($ids[] = end($val)):($ids[] = $val);
+            }
+            //$params['category_ids'] = ["goods_category_ids"=>$params['category_ids'],"ids"=>$ids];
+            $params['category_ids'] = implode(',',$ids);
+        }
+        Db::startTrans();
+        try {
+
+            $number = MasterWorker::count();
+            $number += 1;
+            if ($number < 100000) {
+                $number = str_pad($number, 6, '0', STR_PAD_LEFT);
+            }
+            $userSn = MasterWorker::createUserSn();
+            //$passwordSalt = Config::get('project.unique_identification');
+            //$password = create_password($params['mobile'], $passwordSalt);
+            $avatar = ConfigService::get('default_image', 'user_avatar');
+
+            MasterWorker::create([
+                /*'sn' => $params['sn'],
+                'avatar' => $params['avatar'],
+                'real_avatar' => $params['real_avatar'],
+                'real_name' => $params['real_name'],
+                'nickname' => $params['nickname'],
+                'account' => $params['account'],
+                'password' => $params['password'],
+                'mobile' => $params['mobile'],
+                'sex' => $params['sex'],
+                'channel' => $params['channel'],
+                'is_disable' => $params['is_disable'],
+                'login_ip' => $params['login_ip'],
+                'login_time' => $params['login_time'],
+                'is_new_user' => $params['is_new_user'],
+                'estimate_money' => $params['estimate_money'],
+                'user_money' => $params['user_money'],
+                'earnest_money' => $params['earnest_money'],
+                'exp' => $params['exp'],
+                'lon' => $params['lon'],
+                'lat' => $params['lat'],
+                'distance' => $params['distance'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'area_name' => $params['area_name'],
+                'cooperation' => $params['cooperation']??0,
+                'time_period' => $params['time_period']??'',
+                'work_status' => $params['work_status']??0,
+                'recruiting_behalf' => $params['recruiting_behalf']??'',
+                'settlement_type' => $params['settlement_type']??2,
+                'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
+                'remark' => $params['remark']??'',*/
+
+                'sn' => $userSn,
+                'worker_number' => $number,
+                'avatar' => $avatar,
+                'real_avatar' => $params['real_avatar'],
+                'real_name' => $params['real_name'],
+                'nickname' => '用户' . $userSn,
+                'account' => $params['mobile'],
+                'password' => $params['password'],
+                'mobile' => $params['mobile'],
+                'sex' => $params['sex'],
+                'channel' => $params['channel'],
+                'is_disable' => $params['is_disable'],
+                'login_ip' => $params['login_ip'],
+                'login_time' => $params['login_time'],
+                'is_new_user' => $params['is_new_user'],
+                'estimate_money' => $params['estimate_money'],
+                'user_money' => $params['user_money'],
+                'exp' => $params['exp'],
+                'lon' => $params['lon'],
+                'lat' => $params['lat'],
+                'distance' => $params['distance'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'area_name' => $params['area_name'],
+                'earnest_money' => $params['earnest_money'],
+                'earnest_money_usable' => $params['earnest_money_usable'],
+                'earnest_money_freeze' => $params['earnest_money_freeze'],
+                'installment_ratio' => $params['installment_ratio'],
+                'retention_pay_status' => $params['retention_pay_status'],
+                'retention_money_status' => $params['retention_money_status'],
+                'category_ids' => $params['category_ids']??'',
+                'cooperation' => $params['cooperation']??0,
+                'time_period' => $params['time_period']?implode(',',$params['time_period']):'',
+                'work_status' => $params['work_status']??0,
+                'recruiting_behalf' => $params['recruiting_behalf']??'',
+                'settlement_type' => $params['settlement_type']??2,
+                'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
+                'remark' => $params['remark']??'',
+                'tenant_id' => $params['tenant_id'],
+                'audit_state' => 1,
+            ]);
+
+            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/10 18:17
+     */
+    public static function edit(array $params): bool
+    {
+        if($params['category_ids']){
+            foreach ($params['category_ids'] as $val){
+                is_array($val)?($ids[] = end($val)):($ids[] = $val);
+            }
+            //$params['category_ids'] = ["goods_category_ids"=>$params['category_ids'],"ids"=>$ids];
+            $params['category_ids'] = implode(',',$ids);
+        }
+        Db::startTrans();
+        try {
+
+            MasterWorker::where('id', $params['id'])->update([
+                'sn' => $params['sn'],
+                'avatar' => $params['avatar'],
+                'real_avatar' => $params['real_avatar'],
+                'real_name' => $params['real_name'],
+                'nickname' => $params['nickname'],
+                'account' => $params['account'],
+                'password' => $params['password'],
+                'mobile' => $params['mobile'],
+                'sex' => $params['sex'],
+                'channel' => $params['channel'],
+                'is_disable' => $params['is_disable'],
+                'login_ip' => $params['login_ip'],
+                'login_time' => $params['login_time'],
+                'is_new_user' => $params['is_new_user'],
+                'estimate_money' => $params['estimate_money'],
+                'user_money' => $params['user_money'],
+                'exp' => $params['exp'],
+                'lon' => $params['lon'],
+                'lat' => $params['lat'],
+                'distance' => $params['distance'],
+                'province' => $params['province'],
+                'city' => $params['city'],
+                'area_name' => $params['area_name'],
+                'earnest_money' => $params['earnest_money'],
+                'earnest_money_usable' => $params['earnest_money_usable'],
+                'earnest_money_freeze' => $params['earnest_money_freeze'],
+                'installment_ratio' => $params['installment_ratio'],
+                'retention_pay_status' => $params['retention_pay_status'],
+                'retention_money_status' => $params['retention_money_status'],
+                'category_ids' => $params['category_ids']??'',
+                'cooperation' => $params['cooperation']??0,
+                'time_period' => $params['time_period']?implode(',',$params['time_period']):'',
+                'work_status' => $params['work_status']??0,
+                'recruiting_behalf' => $params['recruiting_behalf']??'',
+                'settlement_type' => $params['settlement_type']??2,
+                'labels' => (isset($params['labels']) && $params['labels'])?implode(',',$params['labels']):'',
+                'remark' => $params['remark']??'',
+                'tenant_id' => $params['tenant_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/10 18:17
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorker::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public static function detail($params): array
+    {
+        $info = MasterWorker::with(['workerInfo'=>function(Query $query){
+            $query->field('worker_id,real_name,id_card,id_card_front_img,id_card_opposite_img,mobile,address');
+        },'workerRegister'=>function(Query $query){
+            $query->field('worker_id,maintain_exp_type,other_exp_type,city,vehicle_type,name,age,mobile')->append(['maintain_exp_type_text','other_exp_type_text','vehicle_type_text','city_text']);
+        }])
+            ->append(['time_period'])
+            ->findOrEmpty($params['id'])->toArray();
+        if(!empty($info['category_ids'])){
+            $info['category_ids'] = explode(',',$info['category_ids']);
+            $info['category_ids'] = array_map('intval', $info['category_ids']);
+        }
+        $info['is_up_retention_pay'] = 0;
+        if(MasterWorkerRetentionMoneyLog::where(['worker_id' => $params['id'],'action' => 1])->count('id') > 0){
+            $info['is_up_retention_pay'] = 1;
+        }
+        return $info;
+    }
+
+    /**
+     * 获取加盐密码
+     * @param $params
+     * @return false|string
+     */
+    public static function saltToPassword($params){
+        try{
+            $passwordSalt = Config::get('project.unique_identification');
+            $password = create_password($params['password'], $passwordSalt);
+            return ['password' => $password];
+        } catch (\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+
+    }
+
+    /**
+     * 获取所有工程师选项列表
+     * @param $params
+     * @return false|string
+     */
+    public static function getAllWorkers($params){
+        try{
+            return MasterWorker::where(['is_disable'=>0])->column('id,id as value,worker_number as name,account,mobile');
+        } catch (\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+
+    }
+}

+ 112 - 0
app/tenantapi/logic/master_worker/MasterWorkerRuleLogic.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\logic\master_worker;
+
+
+use app\common\model\master_worker\MasterWorkerRule;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerRule逻辑
+ * Class MasterWorkerRuleLogic
+ * @package app\tenantapi\logic
+ */
+class MasterWorkerRuleLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRule::create([
+                'rule_name' => $params['rule_name'],
+                'description' => $params['description'],
+                'sort' => $params['sort'],
+                'scene_id' => $params['scene_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/09/28 15:31
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRule::where('id', $params['id'])->update([
+                'rule_name' => $params['rule_name'],
+                'description' => $params['description'],
+                'sort' => $params['sort'],
+                'scene_id' => $params['scene_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/09/28 15:31
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerRule::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerRule::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 144 - 0
app/tenantapi/logic/master_worker/MasterWorkerTeamLogic.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\master_worker;
+
+
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerTeam;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerTeam逻辑
+ * Class MasterWorkerTeamLogic
+ * @package app\tenantapi\logic
+ */
+class MasterWorkerTeamLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $masterWorker = \app\common\model\master_worker\MasterWorker::where('id', $params['master_worker_id'])->find();
+            if($masterWorker['team_id']){
+                throw new \Exception('该师傅已加入团队,请先退出团队');
+            }
+            $masterWorkerTeam = MasterWorkerTeam::create([
+                'team_name' => $params['team_name'],
+                'master_worker_id' => $params['master_worker_id'],
+                'tenant_id' => $params['tenant_id'],
+            ]);
+            MasterWorker::where('id', $params['master_worker_id'])->update(
+                [
+                    'team_id' => $masterWorkerTeam->id,
+                    'team_role' => 1,
+                ]
+            );
+            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/20 17:42
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $masterWorkerTeam = MasterWorkerTeam::where('id', $params['id'])->find();
+            $masterWorker = \app\common\model\master_worker\MasterWorker::where('id', $params['master_worker_id'])->find();
+            if(($masterWorkerTeam['master_worker_id'] != $params['master_worker_id']) && $masterWorker['team_id']){
+                throw new \Exception('该师傅已加入团队,请先退出团队');
+            }
+
+            \app\common\model\master_worker\MasterWorker::where('id', $masterWorkerTeam['master_worker_id'])->update(
+                [
+                    'team_id' => 0,
+                    'team_role' => 0,
+                ]
+            );
+            MasterWorkerTeam::where('id', $params['id'])->update([
+                'team_name' => $params['team_name'],
+                'master_worker_id' => $params['master_worker_id'],
+                'tenant_id' => $params['tenant_id'],
+            ]);
+            \app\common\model\master_worker\MasterWorker::where('id', $params['master_worker_id'])->update(
+                [
+                    'team_id' => $params['id'],
+                    'team_role' => 1,
+                ]
+            );
+            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/20 17:42
+     */
+    public static function delete(array $params): bool
+    {
+        $masterWorkerTeam = MasterWorkerTeam::where('id', $params['id'])->find();
+        \app\common\model\master_worker\MasterWorker::where('id', $masterWorkerTeam['master_worker_id'])->update(
+            [
+                'team_id' => 0,
+                'team_role' => 0,
+            ]
+        );
+        return MasterWorkerTeam::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerTeam::with('masterWorker')->findOrEmpty($params['id'])->toArray();
+    }
+}

+ 145 - 0
app/tenantapi/logic/master_worker/RetentionMoneyLogic.php

@@ -0,0 +1,145 @@
+<?php
+/**
+ * @author 林海涛
+ * @date 2024/7/28 下午2:36
+ */
+namespace app\tenantapi\logic\master_worker;
+
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
+use app\common\model\works\ServiceWork;
+use think\facade\Db;
+
+class RetentionMoneyLogic extends BaseLogic
+{
+    public static function totalAmount($params)
+    {
+        try{
+            $model = MasterWorker::findOrEmpty($params['worker_id']);
+            if($model->isEmpty()){
+                throw new \Exception('用户不存在');
+            }
+            $where = [];
+            $where[] = ['worker_id','=',$params['worker_id']] ;
+            $incWhere =$where;
+            $incWhere[] = ['action', '=',WorkerAccountLogEnum::INC];
+            $data = [];
+            //$data['amount_inc_total'] = MasterWorkerRetentionMoneyLog::where($incWhere)->sum('amount');
+            $data['amount_inc_total'] = $model->earnest_money;
+
+            $outWhere = $where;
+            $outWhere[] =['action', '=',WorkerAccountLogEnum::DEC];
+            //$data['amount_dec_total'] = MasterWorkerRetentionMoneyLog::where($outWhere)->sum('amount');
+            $data['amount_dec_total'] = $model->earnest_money_freeze;
+            //$data['amount_available_total'] = $data['amount_inc_total'] - $data['amount_dec_total'];
+            $data['amount_available_total'] = $model->earnest_money_usable;
+
+
+            $data['retention_money_status'] = $model->retention_money_status;
+            $data['retention_money_status_text'] = $model->retention_money_status_text;
+            $data['retention_pay_status'] = $model->retention_pay_status;
+            $data['retention_pay_status_text'] = $model->retention_pay_status_text;
+            $data['worker_number'] = $model->worker_number;
+            $data['real_name'] = $model->real_name;
+            $data['worker_id'] = $model->id;
+            $data['installment_ratio'] = $model->installment_ratio;
+            return $data;
+        } catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function add($params)
+    {
+        Db::startTrans();
+        try {
+            if(isset($params['work_id']) && !empty($params['work_id'])){
+                $workModel = ServiceWork::findOrEmpty($params['work_id']);
+                if($workModel->isEmpty()){
+                    throw new \Exception('工单不存在');
+                }
+            }
+            MasterWorkerRetentionMoneyLog::create([
+                'sn' => generate_sn(MasterWorkerRetentionMoneyLog::class,'sn'),
+                'worker_id' => $params['worker_id'],
+                'action' => $params['action'],
+                'amount' => $params['amount'],
+                'work_id' => $params['work_id'],
+                'remark' => $params['remark'],
+            ]);
+
+            // $params['worker_id']
+            $masterWorkerInfo = MasterWorker::where('id', $params['worker_id'])->findOrEmpty();
+            if($params['action'] == WorkerAccountLogEnum::INC){
+                $earnest_money_usable = $masterWorkerInfo->earnest_money_usable + $params['amount'];
+                if($earnest_money_usable > $masterWorkerInfo->earnest_money){
+                    throw new \Exception('可用质保金超过配置质保金');
+                }
+                $masterWorkerInfo->earnest_money_usable = $earnest_money_usable;
+            }
+            if($params['action'] == WorkerAccountLogEnum::DEC){
+                $earnest_money_usable = $masterWorkerInfo->earnest_money_usable - $params['amount'];
+                if($earnest_money_usable < 0){
+                    throw new \Exception('可用质保金不足');
+                }
+                $masterWorkerInfo->earnest_money_usable = $earnest_money_usable;
+                $masterWorkerInfo->earnest_money_freeze += $params['amount'];
+            }
+            $masterWorkerInfo->save();
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+    public static function refundRetention($params,$to_freeze = true)
+    {
+        Db::startTrans();
+        try {
+            if(isset($params['work_id']) && !empty($params['work_id'])){
+                $workModel = ServiceWork::findOrEmpty($params['work_id']);
+                if($workModel->isEmpty()){
+                    throw new \Exception('工单不存在');
+                }
+            }
+            MasterWorkerRetentionMoneyLog::create([
+                'sn' => generate_sn(MasterWorkerRetentionMoneyLog::class,'sn'),
+                'worker_id' => $params['worker_id'],
+                'action' => WorkerAccountLogEnum::DEC,
+                'amount' => $params['amount'],
+                'work_id' => $params['work_id'],
+                'remark' => $params['remark'],
+                'return_work_id' => isset($params['return_work_id'])?$params['return_work_id']:0,
+            ]);
+
+            // $params['worker_id']
+            $masterWorkerInfo = MasterWorker::where('id', $params['worker_id'])->findOrEmpty();
+            $earnest_money_usable = $masterWorkerInfo->earnest_money_usable - $params['amount'];
+            if($earnest_money_usable < 0){
+                throw new \Exception('退可用质保金不足');
+            }
+            $masterWorkerInfo->earnest_money_usable = $earnest_money_usable;
+            // 是否要扣到 冻结 里面?
+            $to_freeze && $masterWorkerInfo->earnest_money_freeze += $params['amount'];
+            $masterWorkerInfo->save();
+
+            // 记录冻结金额日志
+            if($to_freeze){
+
+            }
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 344 - 0
app/tenantapi/logic/notice/NoticeLogic.php

@@ -0,0 +1,344 @@
+<?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\notice;
+
+use app\common\enum\notice\NoticeEnum;
+use app\common\logic\BaseLogic;
+use app\common\model\master_worker_register\MasterWorkerRegister;
+use app\common\model\notice\NoticeSetting;
+use app\common\model\works\ServiceWork;
+
+/**
+ * 通知逻辑层
+ * Class NoticeLogic
+ * @package app\tenantapi\logic\notice
+ */
+class NoticeLogic extends BaseLogic
+{
+
+    /**
+     * @notes 查看通知设置详情
+     * @param $params
+     * @return array
+     * @author 段誉
+     * @date 2022/3/29 11:34
+     */
+    public static function detail($params)
+    {
+
+        $noticeSetting = NoticeSetting::field('*')->findOrEmpty($params['id'])->toArray();
+        if (empty($noticeSetting)) {
+            return [];
+        }
+        if (empty($noticeSetting['system_notice'])) {
+            $noticeSetting['system_notice'] = [
+                'title' => '',
+                'content' => '',
+                'status' => 0,
+            ];
+        }
+        $noticeSetting['system_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::SYSTEM, $noticeSetting['scene_id']);
+        if (empty($noticeSetting['sms_notice'])) {
+            $noticeSetting['sms_notice'] = [
+                'template_id' => '',
+                'content' => '',
+                'status' => 0,
+            ];
+        }
+        $noticeSetting['sms_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::SMS, $noticeSetting['scene_id']);
+        if (empty($noticeSetting['oa_notice'])) {
+            $noticeSetting['oa_notice'] = [
+                'template_id' => '',
+                'template_sn' => '',
+                'name' => '',
+                'first' => '',
+                'remark' => '',
+                'tpl' => [],
+                'status' => 0,
+            ];
+        }
+        $noticeSetting['oa_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::OA, $noticeSetting['scene_id']);
+        if (empty($noticeSetting['mnp_notice'])) {
+            $noticeSetting['mnp_notice'] = [
+                'template_id' => '',
+                'template_sn' => '',
+                'name' => '',
+                'tpl' => [],
+                'status' => 0,
+            ];
+        }
+        $noticeSetting['mnp_notice']['tips'] = NoticeEnum::getOperationTips(NoticeEnum::MNP, $noticeSetting['scene_id']);
+        $noticeSetting['system_notice']['is_show'] = in_array(NoticeEnum::SYSTEM, explode(',', $noticeSetting['support']));
+        $noticeSetting['sms_notice']['is_show'] = in_array(NoticeEnum::SMS, explode(',', $noticeSetting['support']));
+        $noticeSetting['oa_notice']['is_show'] = in_array(NoticeEnum::OA, explode(',', $noticeSetting['support']));
+        $noticeSetting['mnp_notice']['is_show'] = in_array(NoticeEnum::MNP, explode(',', $noticeSetting['support']));
+        $noticeSetting['default'] = '';
+        //$noticeSetting['type'] = NoticeEnum::getTypeDesc($noticeSetting['type']);
+        $noticeSetting['type'] = $noticeSetting['type'].'';
+        $noticeSetting['recipient'] = $noticeSetting['recipient'].'';
+        return $noticeSetting;
+    }
+
+
+    /**
+     * @notes 通知设置
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2022/3/29 11:34
+     */
+    public static function set($params)
+    {
+        try {
+            // 校验参数
+            //self::checkSet($params);
+
+            // 拼装更新数据
+            $updateData = [];
+            $updateData['scene_id'] = $params['scene_id'];
+            $updateData['scene_name'] = $params['scene_name'];
+            $updateData['scene_desc'] = $params['scene_desc'];
+            $updateData['recipient'] = $params['recipient'];
+            $updateData['designated_user'] = $params['designated_user'];
+            $updateData['type'] = $params['type'];
+            $updateData['support'] = $params['support']??2;
+            foreach ($params['template'] as $item) {
+                if($item['type']??0) $updateData[$item['type'] . '_notice'] = json_encode($item, JSON_UNESCAPED_UNICODE);
+            }
+        
+            $noticeSetting = NoticeSetting::findOrEmpty($params['id'] ?? 0);
+            if ($noticeSetting->isEmpty()) {
+                $noticeSetting->save($updateData);
+                return true;
+            }
+            // 更新通知设置
+            NoticeSetting::where('id', $params['id'])->update($updateData);
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 校验参数
+     * @param $params
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 11:35
+     */
+    public static function checkSet($params)
+    {
+        $noticeSetting = NoticeSetting::findOrEmpty($params['id'] ?? 0);
+
+        if ($noticeSetting->isEmpty()) {
+            throw new \Exception('通知配置不存在');
+        }
+
+        if (!isset($params['template']) || !is_array($params['template']) || count($params['template']) == 0) {
+            throw new \Exception('模板配置不存在或格式错误');
+        }
+
+        // 通知类型
+        $noticeType = ['system', 'sms', 'oa', 'mnp'];
+
+        foreach ($params['template'] as $item) {
+            if (!is_array($item)) {
+                throw new \Exception('模板项格式错误');
+            }
+
+            if (!isset($item['type']) || !in_array($item['type'], $noticeType)) {
+                throw new \Exception('模板项缺少模板类型或模板类型有误');
+            }
+
+            switch ($item['type']) {
+                case "system";
+                    self::checkSystem($item);
+                    break;
+                case "sms";
+                    self::checkSms($item);
+                    break;
+                case "oa";
+                    self::checkOa($item);
+                    break;
+                case "mnp";
+                    self::checkMnp($item);
+                    break;
+            }
+        }
+    }
+
+
+    /**
+     * @notes 校验系统通知参数
+     * @param $item
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 11:35
+     */
+    public static function checkSystem($item)
+    {
+        if (!isset($item['title']) || !isset($item['content']) || !isset($item['status'])) {
+            throw new \Exception('系统通知必填参数:title、content、status');
+        }
+    }
+
+
+    /**
+     * @notes 校验短信通知必填参数
+     * @param $item
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 11:35
+     */
+    public static function checkSms($item)
+    {
+        if (!isset($item['template_id']) || !isset($item['content']) || !isset($item['status'])) {
+            throw new \Exception('短信通知必填参数:template_id、content、status');
+        }
+    }
+
+
+    /**
+     * @notes 校验微信模板消息参数
+     * @param $item
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 11:35
+     */
+    public static function checkOa($item)
+    {
+        if (!isset($item['template_id']) || !isset($item['template_sn']) || !isset($item['name']) || !isset($item['first']) || !isset($item['remark']) || !isset($item['tpl']) || !isset($item['status'])) {
+            throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、first、remark、tpl、status');
+        }
+    }
+
+
+    /**
+     * @notes 校验微信小程序提醒必填参数
+     * @param $item
+     * @throws \Exception
+     * @author 段誉
+     * @date 2022/3/29 11:35
+     */
+    public static function checkMnp($item)
+    {
+        if (!isset($item['template_id']) || !isset($item['template_sn']) || !isset($item['name']) || !isset($item['tpl']) || !isset($item['status'])) {
+            throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、tpl、status');
+        }
+    }
+
+    public static function getInformation($params)
+    {
+        try {
+            $noticeInfo = [
+                'confirm_code' => 0,
+                'massage' => '',
+                'to_router' => '',
+            ];
+            /*if(!in_array($adminId,[1,2])){
+                return $noticeInfo;
+            }*/
+            //$params['business_code']
+            switch ($params['business_code']){
+                case 'service_work':
+                    // 用户下单待派单 service_status
+                    $serviceWorkCount = ServiceWork::where('work_status', 0)->where('tenant_id', $params['tenant_id'])->where('service_status','<', 3)->where('work_pay_status','>', 0)->count('id');
+                    if($serviceWorkCount){
+                        $noticeInfo['confirm_code'] = 101;
+                        $noticeInfo['count'] = $serviceWorkCount;
+                        $noticeInfo['massage'] .= '您有'.$serviceWorkCount.'个工单待派单';
+                        $noticeInfo['to_router'] = '/works/service_work';
+                    }
+                    break;
+                case 'work_status_receive':
+                    // 用户下单待派单 service_status
+                    $serviceWorkCount = ServiceWork::where('work_status', 1)->where('tenant_id', $params['tenant_id'])->where('work_pay_status','>', 0)->count('id');
+                    if($serviceWorkCount){
+                        $noticeInfo['confirm_code'] = 101;
+                        $noticeInfo['count'] = $serviceWorkCount;
+                        $noticeInfo['massage'] .= '您有'.$serviceWorkCount.'个工单待领单';
+                        $noticeInfo['to_router'] = '/works/service_work';
+                    }
+                    break;
+                case 'work_status_contact':
+                    // 用户下单待派单 service_status
+                    $serviceWorkCount = ServiceWork::where('work_status', 2)->where('tenant_id', $params['tenant_id'])->where('work_pay_status','>', 0)->count('id');
+                    if($serviceWorkCount){
+                        $noticeInfo['confirm_code'] = 101;
+                        $noticeInfo['count'] = $serviceWorkCount;
+                        $noticeInfo['massage'] .= '您有'.$serviceWorkCount.'个工单待联系';
+                        $noticeInfo['to_router'] = '/works/service_work';
+                    }
+                    break;
+//                case 'worker_register':
+//                    // 工程师入驻待审核
+//                    $workerRegisterCount = MasterWorkerRegister::where('status', 0)->count('id');
+//                    if($workerRegisterCount){
+//                        $noticeInfo['confirm_code'] = 101;
+//                        $noticeInfo['count'] = $workerRegisterCount;
+//                        $noticeInfo['massage'] .= '您有'.$workerRegisterCount.'个工程师入驻待审核';
+//                        $noticeInfo['to_router'] = '/worker/master_worker_register?master_worker_register.master_worker_register/lists';
+//                    }
+//                    break;
+                case 'appoint_approval':
+                    // 用户更新工单上门时间超过15分钟工程师未确认
+                    $serviceWorkCount = ServiceWork::where('appoint_approval', 1)->where('tenant_id', $params['tenant_id'])->where('refund_approval','=',0)->where('work_pay_status','>',0)->where('update_time','<', time()-15*60)->count('id');
+                    if($serviceWorkCount){
+                        $noticeInfo['confirm_code'] = 101;
+                        $noticeInfo['count'] = $serviceWorkCount;
+                        $noticeInfo['massage'] .= '您有'.$serviceWorkCount.'个工单超过15分钟工程师未确认新上门时间';
+                        $noticeInfo['to_router'] = '/works/service_work';
+                    }
+                    break;
+                case 'refund_approval':
+                    // 用户退款状态审核中
+                    $serviceWorkCount = ServiceWork::where('refund_approval', 1)->where('tenant_id', $params['tenant_id'])->where('work_pay_status','>',0)->count('id');
+                    if($serviceWorkCount){
+                        $noticeInfo['confirm_code'] = 101;
+                        $noticeInfo['count'] = $serviceWorkCount;
+                        $noticeInfo['massage'] .= '您有'.$serviceWorkCount.'个工单退款审核中';
+                        $noticeInfo['to_router'] = '/works/service_work';
+                    }
+                    break;
+            }
+            return $noticeInfo;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+    public static function getInformationBatch($params)
+    {
+        try {
+            $res = [];
+            $params['business_codes'] = explode(',',$params['business_codes']);
+            foreach ($params['business_codes'] as $business_code) {
+                $noticeInfo = self::getInformation(['business_code'=>$business_code,'tenant_id'=>$params['tenant_id']]);
+                if($noticeInfo['confirm_code'] == 101){
+                    $res[$business_code] = $noticeInfo['count'];
+                }else{
+                    $res[$business_code] = 0;
+                }
+            }
+            return $res;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+}

+ 176 - 0
app/tenantapi/logic/recharge/RechargeLogic.php

@@ -0,0 +1,176 @@
+<?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\recharge;
+
+
+use app\common\enum\RefundEnum;
+use app\common\enum\user\AccountLogEnum;
+use app\common\enum\YesNoEnum;
+use app\common\logic\AccountLogLogic;
+use app\common\logic\BaseLogic;
+use app\common\logic\RefundLogic;
+use app\common\model\recharge\RechargeOrder;
+use app\common\model\refund\RefundRecord;
+use app\common\model\user\User;
+use app\common\model\works\ServiceWork;
+use app\common\service\ConfigService;
+use think\facade\Db;
+
+
+/**
+ * 充值逻辑层
+ * Class RechargeLogic
+ * @package app\tenantapi\logic\recharge
+ */
+class RechargeLogic extends BaseLogic
+{
+
+    /**
+     * @notes 获取充值设置
+     * @return array
+     * @author 段誉
+     * @date 2023/2/22 16:54
+     */
+    public static function getConfig()
+    {
+        $config = [
+            'status' => ConfigService::get('recharge', 'status', 0),
+            'min_amount' => ConfigService::get('recharge', 'min_amount', 0)
+        ];
+
+        return $config;
+    }
+
+
+    /**
+     * @notes 充值设置
+     * @param $params
+     * @return bool
+     * @author 段誉
+     * @date 2023/2/22 16:54
+     */
+    public static function setConfig($params)
+    {
+        try {
+            if (isset($params['status'])) {
+                ConfigService::set('recharge', 'status', $params['status']);
+            }
+            if (isset($params['min_amount'])) {
+                ConfigService::set('recharge', 'min_amount', $params['min_amount']);
+            }
+            return true;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 退款
+     * @param $params
+     * @param $adminId
+     * @return array|false
+     * @author 段誉
+     * @date 2023/3/3 11:42
+     */
+    public static function refund($params, $adminId)
+    {
+        Db::startTrans();
+        try {
+            $order = RechargeOrder::findOrEmpty($params['recharge_id']);
+
+            // 更新订单信息, 标记已发起退款状态,具体退款成功看退款日志
+            RechargeOrder::update([
+                'id' => $order['id'],
+                'refund_status' => YesNoEnum::YES,
+            ]);
+
+            // 生成退款记录
+            $recordSn = generate_sn(RefundRecord::class, 'sn');
+            $record = RefundRecord::create([
+                'sn' => $recordSn,
+                'user_id' => $order['user_id'],
+                'order_id' => $order['id'],
+                'order_sn' => $order['sn'],
+                'order_type' => RefundEnum::ORDER_TYPE_ORDER,
+                'order_amount' => $order['order_amount'],
+                'refund_amount' => $order['order_amount'],
+                'refund_type' => RefundEnum::TYPE_ADMIN,
+                'transaction_id' => $order['transaction_id'] ?? '',
+                'refund_way' => RefundEnum::getRefundWayByPayWay($order['pay_way']),
+            ]);
+
+            //更新工单状态
+            ServiceWork::update([
+                'id'=>$order['work_id'],
+                'service_status'=>5
+            ]);
+
+            // 退款
+            $result = RefundLogic::refund($order, $record['id'], $order['order_amount'], $adminId);
+
+            $flag = true;
+            $resultMsg = '操作成功';
+            if ($result !== true) {
+                $flag = false;
+                $resultMsg = RefundLogic::getError();
+            }
+
+            Db::commit();
+            return [$flag, $resultMsg];
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::$error = $e->getMessage();
+            return [false, $e->getMessage()];
+        }
+    }
+
+
+    /**
+     * @notes 重新退款
+     * @param $params
+     * @param $adminId
+     * @return array
+     * @author 段誉
+     * @date 2023/3/3 11:44
+     */
+    public static function refundAgain($params, $adminId)
+    {
+        Db::startTrans();
+        try {
+            $record = RefundRecord::findOrEmpty($params['record_id']);
+            $order = RechargeOrder::findOrEmpty($record['order_id']);
+
+            // 退款
+            $result = RefundLogic::refund($order, $record['id'], $order['order_amount'], $adminId);
+
+            $flag = true;
+            $resultMsg = '操作成功';
+            if ($result !== true) {
+                $flag = false;
+                $resultMsg = RefundLogic::getError();
+            }
+
+            Db::commit();
+            return [$flag, $resultMsg];
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::$error = $e->getMessage();
+            return [false, $e->getMessage()];
+        }
+    }
+
+}

+ 191 - 0
app/tenantapi/logic/works/IssueWorkLogic.php

@@ -0,0 +1,191 @@
+<?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\works;
+
+
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\RetentionMoneyLogic;
+use app\common\logic\WorkerAccountLogLogic;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use app\common\model\master_worker\MasterWorkerFreezeAmountLog;
+use app\common\model\works\IssueWork;
+use app\common\logic\BaseLogic;
+use app\common\model\works\ReturnWork;
+use app\common\model\works\ServiceWork;
+use think\facade\Db;
+use think\facade\Log;
+
+
+/**
+ * IssueWork逻辑
+ * Class IssueWorkLogic
+ * @package app\tenantapi\logic\works
+ */
+class IssueWorkLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            IssueWork::create([
+                'work_sn' => $params['work_sn'],
+                'service_work_id' => $params['service_work_id'],
+                'master_worker_id' => $params['master_worker_id'],
+                'issue_approval' => $params['issue_approval'],
+                'complaint_status' => $params['complaint_status'],
+                'responsible' => $params['responsible'],
+                'complaint_details' => $params['complaint_details'],
+                'complaint_images' => $params['complaint_images'],
+                'finished_time' => strtotime($params['finished_time']),
+                'approval_admin_id' => $params['approval_admin_id'],
+                'approval_time' => strtotime($params['approval_time']),
+                'tenant_id' => $params['tenant_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/10 15:06
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $issueWork = IssueWork::where('id', $params['id'])->findOrEmpty();
+            IssueWork::where('id', $params['id'])->update([
+                'work_sn' => $params['work_sn'],
+                'service_work_id' => $params['service_work_id'],
+                'master_worker_id' => $params['master_worker_id'],
+                'issue_approval' => $params['issue_approval'],
+                'complaint_status' => $params['complaint_status'],
+                'responsible' => $params['responsible'],
+                'complaint_details' => $params['complaint_details'],
+                'complaint_images' => $params['complaint_images'],
+                'finished_time' => strtotime($params['finished_time']),
+                'approval_admin_id' =>$params['approval_admin_id'],
+                'approval_time' => time()
+            ]);
+
+            Log::info('IssueWorkLogic-edit-error:'.$issueWork);
+            // 投诉- 非完成状态时工程师的质保金可用金额 被冻结
+            if(!in_array($issueWork->issue_approval,[5,4]) && $issueWork->is_refunded_payment == 0 && !in_array($params['issue_approval'],[5,4])){
+                if(RetentionMoneyLogic::warrantyDepositFreeze($issueWork)){
+                    // 原工程师返修收成款是否被冻结 is_refunded_payment
+                    $issueWork->is_refunded_payment = 1;
+                    $issueWork->save();
+                }
+            }
+
+            // 投诉完成-质保金可用金额 解冻
+            if($issueWork->issue_approval != 4 &&  $issueWork->is_refunded_payment == 1 && $params['issue_approval'] == 4){
+                $serviceWork = ServiceWork::where('id',$issueWork->service_work_id)->findOrEmpty();
+                if(!$serviceWork->isEmpty()){
+                    // 查询出该投诉的冻结金额 master_worker_freeze_amount_log  issue_work_id master_worker_id
+                    $amount = MasterWorkerFreezeAmountLog::where([
+                        'action'=>WorkerAccountLogEnum::INC,'source'=>1,
+                        'issue_work_id'=>$issueWork->id,'master_worker_id'=>$issueWork->master_worker_id])->value('amount');
+
+                    // 是否存在返修工单?
+                    $work = ReturnWork::where('issue_work_id',$issueWork->id)->findOrEmpty();
+                    if(!$work->isEmpty()){
+                        $work->finished_time = time();
+                        $work->return_work_status = 4;
+                        $work->save();
+                    }
+                    /*to_freeze source remark work_id amount  worker_id issue_work_id*/
+                    // 对原工程师的 质保金解冻质保金 / 清零
+                    RetentionMoneyLogic::warrantyDepositRelease([
+                        'to_freeze'=>2,
+                        'source'=>1,
+                        'remark'=>'对原工程师的质保金解冻质保金/清零',
+                        'work_id'=>$issueWork->service_work_id,'worker_id'=>$issueWork->master_worker_id,
+                        'issue_work_id'=>$issueWork->id,
+                        'amount'=>$amount,
+                    ],false);
+                }
+            }
+
+            Db::commit();
+            // 受理中向工程师发微信通知
+            if((int)$params['issue_approval'] === 1){
+                $workDetail = ServiceWorkLogic::detail(['id'=>$issueWork->service_work_id]);
+                event('Notice',  [
+                    'scene_id' => 127,
+                    'params' => [
+                        'user_id' => $issueWork->master_worker_id,
+                        'order_id' => $issueWork->service_work_id,
+                        'thing13' => '投诉工单-'.$workDetail['title'],
+                        'character_string2' => $workDetail['work_sn'],
+                        'thing9' => $workDetail['real_name'],
+                        'phone_number15' => asteriskString($workDetail['mobile']),
+                    ]
+                ]);
+            }
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            Log::info('IssueWorkLogic-edit-error:'.$e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public static function delete(array $params): bool
+    {
+        return IssueWork::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public static function detail($params): array
+    {
+        return IssueWork::with(['masterWorker','user'])->append(['complaint_type_text'])->findOrEmpty($params['id'])->toArray();
+    }
+}

+ 187 - 0
app/tenantapi/logic/works/ReturnWorkLogic.php

@@ -0,0 +1,187 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\logic\works;
+
+
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\RetentionMoneyLogic;
+use app\common\logic\WorkerAccountLogLogic;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
+use app\common\model\works\IssueWork;
+use app\common\model\works\ReturnWork;
+use app\common\logic\BaseLogic;
+use app\common\model\works\ServiceWork;
+use think\db\Query;
+use think\facade\Db;
+
+
+/**
+ * ReturnWork逻辑
+ * Class ReturnWorkLogic
+ * @package app\tenantapi\logic\works
+ */
+class ReturnWorkLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ReturnWork::create([
+                'work_sn' => $params['work_sn'],
+                'service_work_id' => $params['service_work_id'],
+                'issue_work_id' => $params['issue_work_id'],
+                'return_work_status' => $params['return_work_status'],
+                'dispatch_time' => $params['dispatch_time'],
+                'appointment_time' => $params['appointment_time'],
+                'finished_images' => $params['finished_images'],
+                'finished_time' => $params['finished_time'],
+                'master_worker_id' => $params['master_worker_id'],
+                'tenant_id' => $params['tenant_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/10 15:06
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ReturnWork::where('id', $params['id'])->update([
+                'work_sn' => $params['work_sn'],
+                'service_work_id' => $params['service_work_id'],
+                'issue_work_id' => $params['issue_work_id'],
+                'return_work_status' => $params['return_work_status'],
+                'dispatch_time' => $params['dispatch_time'],
+                'appointment_time' => $params['appointment_time'],
+                'finished_images' => $params['finished_images'],
+                'finished_time' => $params['finished_time'],
+                'master_worker_id' => $params['master_worker_id'],
+                'tenant_id' => $params['tenant_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/10 15:06
+     */
+    public static function delete(array $params): bool
+    {
+        return ReturnWork::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public static function detail($params): array
+    {
+        if(isset($params['issue_work_id'])){
+            return ReturnWork::with(['worker'=>function(Query $query) {
+                $query->field("id,worker_number,real_name");
+            },])->where('issue_work_id',$params['issue_work_id'])->append(['return_work_status_text'])->findOrEmpty()->toArray();
+        }
+        return ReturnWork::with(['worker'=>function(Query $query) {
+            $query->field("id,worker_number,real_name");
+        },])->append(['return_work_status_text'])->findOrEmpty($params['id'])->toArray();
+    }
+
+
+    public static function issueWorkData($params)
+    {
+        Db::startTrans();
+        try {
+            $model = ReturnWork::where('issue_work_id',$params['issue_work_id'])->findOrEmpty();
+            $flag = true;
+            if($model->isEmpty()){
+                $flag = false;
+                $model = new ReturnWork();
+            } else {
+                if($model->return_work_status !== 0){
+                    //throw new \Exception('返修工单状态非待返修,无法修改'); 1111内测要求放开
+                }
+            }
+            $issueWork = IssueWork::findOrEmpty($params['issue_work_id']);
+            if($issueWork->isEmpty()){
+                throw  new  \Exception('投诉工单不存在');
+            }
+            if($issueWork->complaint_status == 4){
+                throw new \Exception('投诉工单投诉状态为已完结,无需生成返修工单');
+            }
+            $model->work_sn = generate_sn(ReturnWork::class,'work_sn');
+            $model->service_work_id = $issueWork->service_work_id;
+            $model->issue_work_id = $issueWork->id;
+            if(empty($model->dispatch_time)){
+                $model->dispatch_time = time();
+            }
+            $model->appointment_time = strtotime($params['appointment_time']);
+            if($flag){
+                MasterWorker::setWorktotal('dec',$model->master_worker_id);
+            }
+            $model->master_worker_id = $params['master_worker_id'];
+            MasterWorker::setWorktotal('inc', $params['master_worker_id']);
+            $model->user_id = $issueWork->user_id;
+            $model->tenant_id = $params['tenant_id'];
+            $model->save();
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+}

+ 900 - 0
app/tenantapi/logic/works/ServiceWorkLogic.php

@@ -0,0 +1,900 @@
+<?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\works;
+
+
+use app\api\logic\PerformanceLogic;
+use app\common\enum\worker\WorkerAccountLogEnum;
+use app\common\logic\WorkerAccountLogLogic;
+use app\common\model\coupon\CouponCategory;
+use app\common\model\coupon\UserCoupon;
+use app\common\model\dict\DictData;
+use app\common\model\master_commission\MasterWorkerCommissionConfig;
+use app\common\model\master_commission\MasterWorkerCommissionRatio;
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerAccountLog;
+use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
+use app\common\model\orders\OrderEffectiveLog;
+use app\common\model\performance\PerformanceRules;
+use app\common\model\recharge\OrderGoods;
+use app\common\model\recharge\RechargeOrder;
+use app\common\model\spare_part\SparePart;
+use app\common\model\works\ServiceWork;
+use app\common\logic\BaseLogic;
+use app\common\model\works\ServiceWorkAllocateWorkerLog;
+use app\common\model\works\ServiceWorkAppointmentLog;
+use app\common\model\works\ServiceWorkCustomerLog;
+use app\common\model\works\ServiceWorkLog;
+use app\common\model\works\ServiceWorkSpare;
+use app\workerapi\logic\ServiceWorkerAllocateWorkerLogic;
+use app\workerapi\logic\ServiceWorkLogLogic;
+use think\db\Query;
+use think\Exception;
+use think\facade\Db;
+use think\facade\Log;
+
+
+/**
+ * ServiceWork逻辑
+ * Class ServiceWorkLogic
+ * @package app\tenantapi\logic\works
+ */
+class ServiceWorkLogic extends BaseLogic
+{
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ServiceWork::where('id', $params['id'])->update([
+                'address' => $params['address'],
+                'appointment_time' => strtotime($params['appointment_time']),
+                'lon' => $params['lon'],
+                'lat' => $params['lat'],
+            ]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+    /**
+     *
+     * @return false|void
+     */
+    public static function pickWork($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+            $receive_time = time();
+            $work->work_status = 2;//待联系
+            $work->service_status = 1;//服务中
+            $work->receive_time = $receive_time;
+            $work->save();
+
+            //添加变更日志
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',$receive_time).'领取了工单',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 预约成功,等待上门
+     * @return false|void
+     */
+    public static function appointWork($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+
+            if($work->work_status != 2){
+                throw new Exception('请勿重复点击');
+            }
+
+            //验证更改的预约时间必须是在领单时间内的半小内修改,否则不允许修改
+            if(strtotime($work->appointment_time) != strtotime($params['appointment_time']) && (time()-strtotime($work->receive_time))>1800){
+                throw new Exception('距离领单时间已超过半小时,无法修改预约时间,请联系客服');
+            }
+
+            $work->work_status = 3;//待上门
+            $work->appointment_time = strtotime($params['appointment_time']);
+            $work->save();
+
+            //添加变更日志
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'联系了客户,确认了于'.$params['appointment_time'].$params['address'].'预约上门',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 工程师确认上门
+     * @param $params
+     * @return false|void
+     */
+    public static function confirmDoor($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+
+            if($work->work_status != 3){
+                throw new Exception('请勿重复点击');
+            }
+
+            $work->finally_door_time = time();//最后上门时间
+            $work->work_status = 4;//已上门
+            $work->save();
+
+            //添加变更日志
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'已上门',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 工程师确认报价单
+     * @param $params
+     * @return false|void
+     */
+    public static function confirmPrice($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+            //搜索待支付订单
+            $paid_order = RechargeOrder::where(['work_id'=>$work['id'],'pay_status'=>1])->findOrEmpty()->toArray();
+            if(empty($paid_order)){
+                throw new Exception('订单错误');
+            }
+
+            if($work->work_status != 4){
+                throw new Exception('请勿重复操作');
+            }
+
+            // 关联配件信息.计算配件总价  id  company_price original_price offering_price number
+            $spare_total = 0;
+
+            isset($params['spare_parts']) && $params['spare_parts'] && $params['spare_parts'] = json_decode($params['spare_parts'], true);
+            if(isset($params['spare_parts']) && $params['spare_parts']){
+                $spare_parts = $params['spare_parts'];
+                foreach ($spare_parts as $spare){
+                    $spare_total += $spare['company_price']*$spare['number'];
+                }
+                $work->spare_total = $spare_total;
+
+                $service_work_spare = ServiceWorkSpare::where(['service_work_id'=>$work['id']])->findOrEmpty();
+                if($service_work_spare->isEmpty()){
+                    //新增
+                    $service_work_spare = ServiceWorkSpare::create([
+                        'service_work_id'=>$work['id'],
+                        'spare_parts'=>$params['spare_parts'],
+                        'remark'=>''
+                    ]);
+                }else{
+                    //修改
+                    $service_work_spare->spare_parts = $params['spare_parts'];
+                    $service_work_spare->save();
+                }
+                $work->service_work_spare_id = $service_work_spare->id;
+            }
+            // order_amount 原 =  $params['amount'] 修改为 = 配件总价 + 服务尾款
+            $order_amount = $params['amount'] + $spare_total;
+
+            //定金存在尾款结算功能,全款直接提交
+            if($paid_order['payment_type']==1){
+                $un_order = RechargeOrder::where(['work_id'=>$work['id'],'pay_status'=>0])->findOrEmpty();
+                if($un_order->isEmpty()){
+                    //新增待支付尾款
+                    $order_data = [
+                        'order_type'=>$paid_order['order_type'],
+                        'sn'=>generate_sn(\app\common\model\orders\RechargeOrder::class, 'sn'),
+                        'work_id'=>$paid_order['work_id'],
+                        'user_id'=>$paid_order['user_id'],
+                        'payment_type'=>2,
+                        'order_total'=>$order_amount,
+                        //'order_amount'=>$params['amount'],
+                        'order_amount'=>$order_amount,
+                        'order_terminal'=>$paid_order['order_terminal']
+                    ];
+                    RechargeOrder::create($order_data);
+                }else{
+                    //修改尾款信息
+                    $un_order->order_total = $order_amount;
+                    //$un_order->order_amount = $params['amount'];
+                    $un_order->order_amount = $order_amount;
+                    $un_order->save();
+                }
+
+                //更新服务费用
+                $work->service_fee = $paid_order['paid_amount']+$params['amount'];
+            }
+            //总工单费用
+            $work->work_total = $work->service_fee+$spare_total;
+            $work->work_images = $params['work_images'];
+            $work->explanation = $params['explanation']??'';
+            $work->user_confirm_status = 1;//待确认报价
+            $work->price_approval = 0;
+            $work->save();
+
+            //添加变更日志
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'提交了报价单',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 工程师确认服务完成
+     * @param $params
+     * @return false|void
+     */
+    public static function confirmServiceFinish($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+
+            if($work->user_confirm_status !=2){
+                throw new Exception('请勿重复操作');
+            }
+
+            $work->finished_images = $params['finished_images'];
+            $work->user_confirm_status = 3;//待确认服务完成
+            $work->save();
+
+            //添加变更日志
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'编号['.$params['user_info']['worker_number'].']'.$params['user_info']['real_name'].'于'.date('y-m-d H:i:s',time()).'于'.date('Y-m-d H:i:s',time()).'提交了待用户确认服务完成',
+            ];
+            ServiceWorkLogLogic::add($work_log);
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function allocateWorker($params,$userInfo){
+        Db::startTrans();
+        try {
+            $work = ServiceWork::findOrEmpty($params['id']);
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+            if($work->work_status >=6 ){
+                throw new \Exception('工单状态只能修改待结算之前的');
+            }
+            if($work->master_worker_id == $params['master_worker_id']){
+                throw new \Exception('分配的工程师相同');
+            }
+            $worker = MasterWorker::where(['id'=>$params['master_worker_id'],'is_disable' =>0])->findOrEmpty();
+            if($worker->isEmpty()){
+                throw new \Exception('工程师不存在或被禁用');
+            }
+            if($worker->master_worker_id){
+                MasterWorker::setWorktotal('dec',$worker->master_worker_id);
+            }
+            $work->master_worker_id = $params['master_worker_id'];
+            $work->work_status = 1;
+            $work->dispatch_time = time();
+            MasterWorker::setWorktotal('inc',$params['master_worker_id']);
+            $work->save();
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$work->master_worker_id,
+                'opera_log'=>'后台用户['.$userInfo['admin_id'].']'.$userInfo['name'].'于'.date('Y-m-d H:i:s',time()).'分配了工程师'.'编号['.$worker->worker_number.']'.$worker->real_name
+            ];
+            ServiceWorkerAllocateWorkerLogic::add($work_log);
+            Db::commit();
+            // 工程师派单通知【给工程师的通知】【公众号通知,不发短信】
+            $workDetail = ServiceWorkLogic::detail($params);
+            $res = event('Notice',  [
+                'scene_id' => 113,
+                'params' => [
+                    'user_id' => $params['master_worker_id'],
+                    'order_id' => $params['id'],
+                    'thing9' => $workDetail['title'],
+                    'time7' => $workDetail['appointment_time'],
+                    'thing8' => (iconv_strlen($workDetail['address'])>15)?(mb_substr($workDetail['address'],0,15,'UTF-8').'...'):$workDetail['address'],
+                    'phone_number6' => asteriskString($workDetail['mobile']),
+                ]
+            ]);
+            return true;
+        }catch(\Exception $e){
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 工单详情
+     * @param $params
+     * @return array|false
+     */
+    public static function detail($params){
+        $work_where = !empty($params['work_sn'])?['work_sn'=>$params['work_sn']]:['id'=>$params['id']];
+        $result = ServiceWork::with([
+            'worker'=> function(Query $query) {
+                $query->field('id,worker_number,real_name,mobile');
+            },
+            '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');
+            }
+        ])->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('您没有权限操作该工单');
+        }
+        //工程师工单按钮状态
+        $work_service_status = 0;
+        $work_service_status_text = '待派单';
+        //工单状态
+        if($result['work_status'] == 1){
+            $work_service_status = 1;
+            $work_service_status_text = '待领单';
+        }
+        if($result['work_status'] == 2){
+            $work_service_status = 2;
+            $work_service_status_text = '预约上门';
+        }
+        if($result['work_status'] == 3){
+            $work_service_status = 3;
+            $work_service_status_text = '等待上门';
+            if(date('Y-m-d') === date('Y-m-d',strtotime($result['appointment_time']))){
+                $work_service_status = 4;
+                $work_service_status_text = '确认上门';
+            }
+        }
+        if($result['work_status'] == 4 and $result['user_confirm_status']==0){
+            $work_service_status = 5;
+            $work_service_status_text = '确认报价';
+        }
+        if($result['work_status'] == 4 and $result['user_confirm_status']==1){
+            $work_service_status = 6;
+            $work_service_status_text = '用户确认报价中';
+        }
+        if($result['work_status'] == 5 and $result['user_confirm_status']==2){
+            $work_service_status = 7;
+            $work_service_status_text = '完成服务';
+        }
+        if($result['work_status'] == 5 and $result['user_confirm_status']==3){
+            $work_service_status = 8;
+            $work_service_status_text = '用户确认完成服务中';
+        }
+        if($result['work_status'] ==6){
+            $work_service_status = 9;
+            $work_service_status_text = '待结算';
+        }
+        if($result['work_status'] ==7){
+            $work_service_status = 10;
+            $work_service_status_text = '已完结';
+        }
+        if($result['work_status'] ==8){
+            $work_service_status = 11;
+            $work_service_status_text = '已评价';
+        }
+        if($result['work_status'] ==9){
+            $work_service_status = 12;
+            $work_service_status_text = '已退费';
+        }
+
+        $result['work_service_status'] = $work_service_status;
+        $result['work_service_status_text'] = $work_service_status_text;
+
+
+        //搜索当前工单下的所有订单记录
+        $result['pay_orders'] = RechargeOrder::with(['orderGoods'=>function(Query $query){
+            $query->field('id,sn,goods_id,goods_name,goods_image,goods_number,good_unit,goods_size,goods_payment_type,goods_type,goods_brand,base_service_fee,service_total,service_fee')->order(['id'=>'desc']);
+        }])->where(['work_id'=>$result['id']])->field('id as order_id,sn,order_type,pay_status,payment_type,pay_way,pay_time,order_amount,order_total,coupon_price,create_time')->order('id asc')->select()->toArray();
+        $pay_status_data = DictData::where('type_value','pay_status')->column('name','value');
+        $payment_type_data = DictData::where('type_value','payment_type')->column('name','value');
+        $pay_way_data = DictData::where('type_value','pay_way')->column('name','value');
+        $order_type_data = DictData::where('type_value','order_type')->column('name','value');
+        $coupon_price = 0;
+
+        foreach ($result['pay_orders'] as $k=>&$v){
+            $v['pay_status_name'] = $pay_status_data[$v['pay_status']];
+            $v['payment_type_name'] = $payment_type_data[$v['payment_type']];
+            $v['pay_way_name'] = $pay_way_data[$v['pay_way']];
+            $v['order_type_name'] = $order_type_data[$v['order_type']];
+            $v['pay_time'] = $v['pay_time'] && is_numeric($v['pay_time']) ? date('Y-m-d H:i:s',$v['pay_time']):'';
+            if($v['payment_type']!=1 and !empty($result['spare_total'])){
+                $v['order_total'] = $v['order_total'] - $result['spare_total'];
+                $v['order_amount'] = $v['order_amount'] - $result['spare_total'];
+            }
+            $coupon_price += $v['coupon_price'];
+            //服务支付类别
+            if(!empty($v['orderGoods'][0]['goods_payment_type'])){
+                $goods_payment_type = $v['orderGoods'][0]['goods_payment_type'];
+            }
+        }
+
+        $result['goods_payment_type'] = !empty($goods_payment_type)?$goods_payment_type:1;
+
+        //汇总优惠卷额度
+        $result['coupon_price'] = $coupon_price;
+
+        //工单总支付金额
+        $result['worker_account'] = $result['work_amount'];
+
+        // 配件信息
+        $result['spare_parts'] = [];
+        if($result['service_work_spare_id']){
+            $work_spare_parts = json_decode(ServiceWorkSpare::where('id',$result['service_work_spare_id'])->value('spare_parts'),true);
+            $spare_parts = SparePart::where('id','in',array_column($work_spare_parts,'id'))
+                ->field(['id', 'goods_category_id', 'spare_name', 'spare_image', 'spare_number', 'spare_unit','spare_status'])
+                ->select()
+                ->toArray();
+            $spare_parts = array_column($spare_parts,null,'id');
+            foreach (array_column($work_spare_parts,null,'id') as $k=>&$v){
+                $spare_parts[$k] = array_merge($spare_parts[$k],$v);
+            }
+            $result['spare_parts'] = array_values($spare_parts)??[];
+        }
+        // 保修卡信息
+        $result['order_effectives'] = OrderEffectiveLog::with(['goods'=>function ($query) {
+                                            $query->with(['goodsCategory'=>function ($query1) {
+                                                $query1->field(['name','picture']);
+                                            }]);
+                                        }])->where('work_id',$result['id'])
+                                        ->field(['id','goods_id','sn','effective_unit','effective_num','remark','end_effective_time'])
+                                        ->append(['effective_unit_text'])
+                                        ->order('create_time desc')
+                                        ->select()
+                                        ->toArray();
+
+        //查收工程师提成金额
+        $change_amount = MasterWorkerAccountLog::where(['work_sn'=>$result['work_sn'],'action'=>1])->value('change_amount');
+        $result['change_amount'] = !empty($change_amount)?$change_amount:0;
+
+        //质保金相关金额
+        $result['retention'] = MasterWorkerRetentionMoneyLog::where('work_id',$result['id'])->visible(['action','amount'])->select()
+            ->each(function ($item){
+                $item['amount'] = $item['action'] == 1 ? '+'.$item['amount'] : '-'.$item['amount'];
+            })->toArray();
+        //保修工单时的信息
+        $result['effective_income_amount'] = 0;
+        if(!empty($result['order_effective_id'])){
+            $order_effective = OrderEffectiveLog:: findOrEmpty($result['order_effective_id']);
+            $serviceWork = ServiceWork::findOrEmpty($order_effective->work_id);
+            if($serviceWork->master_worker_id != $result['master_worker_id']){
+                $result['effective_income_amount'] = \app\tenantapi\logic\effective\OrderEffectiveLogLogic::commissionAndAssuranceDeposit($serviceWork);
+            }
+        }
+        return  $result;
+    }
+
+    public static function getUserCouponDetails($params)
+    {
+        try{
+            $work = ServiceWork::where('id',$params['id'])->findOrEmpty();
+            if(!$work){
+                throw new \Exception('工单不存在');
+            }
+
+            $coupon_all_ids =UserCoupon::where('user_id',$work['user_id'])
+                ->where('voucher_count','>',0)
+                ->where('voucher_status',0)
+                ->where('expire_time','>',time())
+                ->column('coupon_id');
+            $coupon_ids = CouponCategory::where('goods_category_id',$work['goods_category_id'])->whereIn('coupon_id',$coupon_all_ids)->column('coupon_id');
+            $data = UserCoupon::where('user_id',$work['user_id'])
+                ->where('voucher_count','>',0)
+                ->where('voucher_status',0)
+                ->whereIn('coupon_id',$coupon_ids)
+                ->append(['discount_ratio_text'])
+                ->where('expire_time','>',time())
+                ->visible(['id','coupon_id','amount','amount_require','begin_use','discount_ratio','event_name','expire_time','max_deductible_price','server_category_name','mold_type'])
+                ->select()->toArray();
+            foreach($data as $k => $v){
+                $data[$k]['begin_use'] = date("Y-m-d H:i:s",$v['begin_use'] );
+                $data[$k]['expire_time'] = date("Y-m-d H:i:s",$v['expire_time'] );
+                $data[$k]['amount_require'] = '满'.$v['amount_require'].'可用';
+            }
+            return $data;
+        } catch(\Exception $e){
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function getDetailWorkServiceStatus($params)
+    {
+        $result = ServiceWork::where('id',$params['id'])->field('work_status,user_confirm_status,appointment_time,price_approval,appoint_approval')->findOrEmpty()->toArray();
+        //工程师工单按钮状态
+        $work_service_status = 0;
+        //工单状态
+        if($result['work_status'] == 1){
+            $work_service_status = 1;
+        }
+        if($result['work_status'] == 2){
+            $work_service_status = 2;
+        }
+        if($result['work_status'] == 3){
+            $work_service_status = 3;
+            if(date('Y-m-d') === date('Y-m-d',strtotime($result['appointment_time']))){
+                $work_service_status = 4;
+            }
+        }
+        if($result['work_status'] == 4 and $result['user_confirm_status']==0){
+            $work_service_status = 5;
+        }
+        if($result['work_status'] == 4 and $result['user_confirm_status']==1){
+            $work_service_status = 6;
+        }
+        if($result['work_status'] == 5 and $result['user_confirm_status']==2){
+            $work_service_status = 7;
+        }
+        if($result['work_status'] == 5 and $result['user_confirm_status']==3){
+            $work_service_status = 8;
+        }
+        if($result['work_status'] ==6){
+            $work_service_status = 9;
+        }
+        if($result['work_status'] ==7){
+            $work_service_status = 10;
+        }
+        if($result['work_status'] ==8){
+            $work_service_status = 11;
+        }
+        if($result['work_status'] ==9){
+            $work_service_status = 12;
+        }
+        return ['work_service_status'=>$work_service_status,'price_approval'=>$result['price_approval'],'appoint_approval'=>$result['appoint_approval']];
+    }
+
+    /**
+     * @notes 取消操作
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function cancel(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            // 04-11-12 不做任何限制强制取消,已支付的费用给工程师余额
+            $serviceWorkInfo = ServiceWork::find($params['id']);
+            if((int)$serviceWorkInfo['user_confirm_status'] === 5 || (int)$serviceWorkInfo['service_status'] > 2){
+                throw new \Exception('用户已完结该工单或已取消,已退款,不可执行取消');
+            }
+
+            //工单如果存在费用情况,不允许取消
+            $paid_amount = RechargeOrder::where('work_id', $params['id'])->where('pay_status', 1)->value('paid_amount');
+            if($paid_amount > 0){
+                // 4=已上门,5=服务中,6=待结算, 即工程师已上门服务过
+                throw new Exception('工单存在费用情况,不允许取消,请走退费流程');
+            }
+
+            ServiceWork::where('id', $params['id'])->update([
+                //'work_status' => 9,
+                'service_status' => 4,
+                'remark' => $params['remark']??''
+            ]);
+
+            ServiceWorkLog::create([
+                'work_id' => $params['id'],
+                'master_worker_id' => $serviceWorkInfo['master_worker_id'],
+                'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消"
+            ]);
+
+            Db::commit();
+            Log::info('取消工单'.json_encode([$serviceWorkInfo]));
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            Log::info('取消工单-Error'.json_encode([$e->getMessage()]));
+            return false;
+        }
+    }
+
+    /**
+     * @notes 工程师结算操作
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/19 10:48
+     */
+    public static function settlement(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $serviceWorkInfo = ServiceWork::find($params['id']);
+            if((int)$serviceWorkInfo['work_pay_status'] !== 3){
+                throw new \Exception('该工单非待结算状态');
+            }
+            $ratio = 0;
+            $commissionConfig = MasterWorkerCommissionConfig::where('master_worker_id',$serviceWorkInfo->master_worker_id)->where('voucher_status',2)->findOrEmpty();
+            !$commissionConfig->isEmpty() && $ratio = MasterWorkerCommissionRatio::where('commission_config_id',$commissionConfig['id'])->where('goods_category_id',$serviceWorkInfo->goods_category_id)->value('ratio')?:0;
+            if($commissionConfig->isEmpty() || empty($ratio)){
+                //获取工单对应的商品id
+                $order_sns = \app\common\model\orders\RechargeOrder::where('work_id',$serviceWorkInfo->id)->column('sn');
+                $goods_id = OrderGoods::whereIn('sn',$order_sns)->value('goods_id');
+                $rule = PerformanceRules::whereFindInSet('goods_id',$goods_id)->findOrEmpty();
+                if($rule->isEmpty()){
+                    throw new \Exception('请配置商品业绩规则');
+                }
+                PerformanceLogic::calculatePerformance($serviceWorkInfo);
+            }else{
+                // 存在服务分类比例进行结算
+                PerformanceLogic::calculatePerformanceCommission($serviceWorkInfo);
+            }
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * 获取所有改约通知
+     * @param $userId
+     * @return array|false
+     */
+    public static function getAppointmentNotice($userId)
+    {
+        return ServiceWork::where(['master_worker_id'=>$userId,'appoint_approval'=>1])
+            ->where('work_status','>',1)
+            ->where('work_status','<',7)
+            ->field(['id', 'work_sn','real_name','mobile', 'address', 'title', 'appointment_time','work_status'])
+            ->order(['appointment_time' => 'asc'])//上门时间排序
+            ->select()->each(function (&$item){
+                $item['last_appointment_time'] = date('Y-m-d H:i:s',ServiceWorkAppointmentLog::where('work_id',$item['id'])->order('id desc')->value('last_appointment_time'));
+            })
+            ->toArray();
+    }
+
+    /**
+     * @param $params
+     * @return bool
+     */
+    public static function submitAppointment($params)
+    {
+        Db::startTrans();
+        try {
+            $serviceWork = ServiceWork::where('work_sn',$params['work_sn'])->findOrEmpty();
+            if($serviceWork->isEmpty()){
+                throw new \Exception('工单不存在');
+            }
+            $serviceWork->appoint_approval = 2;
+            $serviceWork->save();
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * @param $params
+     * @return bool
+     */
+    public static function submitChangePrice($params)
+    {
+        Db::startTrans();
+        try {
+            $serviceWork = ServiceWork::where('work_sn',$params['work_sn'])->findOrEmpty();
+            if($serviceWork->isEmpty()){
+                throw new \Exception('工单不存在');
+            }
+            $serviceWork->work_status = 4;
+            $serviceWork->user_confirm_status = 0;
+            $serviceWork->price_approval = 2;
+            $serviceWork->save();
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+    public static function notApproved($params)
+    {
+        Db::startTrans();
+        try {
+            $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
+            if($serviceWork->isEmpty()){
+                throw new \Exception('工单不存在');
+            }
+            $serviceWork->refund_approval = 3;
+            $serviceWork->save();
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function againDoor($params)
+    {
+        Db::startTrans();
+        try {
+            $serviceWork = ServiceWork::where('work_sn',$params['work_sn'])->findOrEmpty();
+            if($serviceWork->isEmpty()){
+                throw new \Exception('工单不存在');
+            }
+            //更新预约日志
+            //更新工单未确认上门的状态
+            $serviceWork->work_status = 3;
+            $serviceWork->user_confirm_status = 0;
+
+            $appoint = ServiceWorkAppointmentLog::where(['work_id'=>$serviceWork->id,'worker_id'=>$params['user_id']])->count();
+            if($appoint > 2){
+                throw new Exception('您的修改预约时间次数已到上限,请联系客服处理');
+            }
+
+            ServiceWorkAppointmentLog::create([
+                'work_id'=>$serviceWork->id,
+                'worker_id'=>$params['user_id'],
+                'last_appointment_time'=>strtotime($serviceWork->appointment_time),
+                'this_appointment_time'=>strtotime($params['appointment_time']),
+            ]);
+
+            $serviceWork->appointment_time = strtotime($params['appointment_time']);
+            $serviceWork->save();
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+    public static function cancelAllocation($params,$userInfo){
+        Db::startTrans();
+        try {
+
+            $work = ServiceWork::findOrEmpty($params['id']);
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+            if($work->work_status >=6 ){
+                throw new \Exception('工单状态只能修改待结算之前的');
+            }
+            $worker = MasterWorker::where(['id'=>$work->master_worker_id])->findOrEmpty();
+            if($worker->isEmpty()){
+                throw new \Exception('工程师不存在');
+            }
+            MasterWorker::setWorktotal('dec',$work->master_worker_id);
+            $work->master_worker_id = 0;
+            $work->work_status = 0;
+            $work->dispatch_time = 0;
+            $work->save();
+
+            $work_log = [
+                'work_id'=>$work->id,
+                'master_worker_id'=>$params['master_worker_id'],
+                'opera_log'=>'后台用户['.$userInfo['admin_id'].']'.$userInfo['name'].'于'.date('Y-m-d H:i:s',time()).'取消了工程师'.'编号['.$worker->worker_number.']'.$worker->real_name
+            ];
+            ServiceWorkerAllocateWorkerLogic::add($work_log);
+            Db::commit();
+            return true;
+        }catch(\Exception $e){
+            Db::rollback();
+
+            dd($e->getMessage());
+
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    public static function addCustomerLog($params)
+    {
+        Db::startTrans();
+        try {
+            $serviceWork = ServiceWork::where('id',$params['id'])->findOrEmpty();
+            if($serviceWork->isEmpty()){
+                throw new \Exception('工单不存在');
+            }
+            ServiceWorkCustomerLog::create([
+                'work_id'=>$serviceWork->id,
+                'content'=>$params['content']??'',
+                'admin_id'=>$params['admin_id']??0,
+                'create_time'=>time(),
+            ]);
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+}

+ 105 - 0
app/tenantapi/validate/finance/MasterWorkerCaseOutLogValidate.php

@@ -0,0 +1,105 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\validate\finance;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerCaseOutLog验证器
+ * Class MasterWorkerCaseOutLogValidate
+ * @package app\tenantapi\validate\finance
+ */
+class MasterWorkerCaseOutLogValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'sn' => 'require',
+        'worker_id' => 'require',
+        'action' => 'require',
+        'change_amount' => 'require',
+        'review_status' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'sn' => 'sn',
+        'worker_id' => '用户id',
+        'change_amount' => '变动数量',
+        'review_status' => '审批状态',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['worker_id','change_amount']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['sn','review_status']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerCaseOutLogValidate
+     * @author likeadmin
+     * @date 2024/07/23 09:30
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 108 - 0
app/tenantapi/validate/goods_category/GoodsCategoryValidate.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\validate\goods_category;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * GoodsCategory验证器
+ * Class GoodsCategoryValidate
+ * @package app\tenantapi\validate\goods_category
+ */
+class GoodsCategoryValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'pid' => 'require',
+        'category_type' => 'require',
+        'name' => 'require',
+        'is_goods' => 'require',
+        'status' => 'require',
+        'weigh' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'pid' => '父级ID',
+        'category_type' => '服务类型',
+        'name' => '名称',
+        'is_goods' => '服务产品',
+        'status' => '状态',
+        'weigh' => '权重',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['pid','category_type','picture','name','is_goods','status','weigh']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','pid','category_type','picture','name','is_goods','status','weigh']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 114 - 0
app/tenantapi/validate/master_worker/BankAccountValidate.php

@@ -0,0 +1,114 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * BankAccount验证器
+ * Class BankAccountValidate
+ * @package app\tenantapi\validate\master_worker
+ */
+class BankAccountValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'account_holder' => 'require',
+        'bank_name' => 'require',
+        'province' => 'require',
+        'city' => 'require',
+        'opening_branch' => 'require',
+        'account' => 'require',
+        'mobile' => 'require',
+        'worker_id' => 'require',
+        'audit_state' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'account_holder' => '户主名称',
+        'bank_name' => '银行名称',
+        'province' => '省',
+        'city' => '市',
+        'opening_branch' => '开户支行名称',
+        'account' => '银行卡账号',
+        'mobile' => '预留电话',
+        'worker_id' => '关联师傅ID',
+        'audit_state' => '审核状态',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return BankAccountValidate
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['account_holder','bank_name','province','city','opening_branch','account','mobile','worker_id','audit_state']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return BankAccountValidate
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','account_holder','bank_name','province','city','opening_branch','account','mobile','worker_id','audit_state']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return BankAccountValidate
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return BankAccountValidate
+     * @author likeadmin
+     * @date 2024/10/08 09:41
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 112 - 0
app/tenantapi/validate/master_worker/EngineerSettlementValidate.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\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * EngineerSettlement验证器
+ * Class EngineerSettlementValidate
+ * @package app\tenantapi\validate
+ */
+class EngineerSettlementValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'master_worker_id' => 'require',
+        'worker_number' => 'require',
+        'engineer_name' => 'require',
+        'original_balance' => 'require',
+        'total_settlement_amount' => 'require',
+        'deduction_amount' => 'require',
+        'final_settlement_amount' => 'require',
+        'settlement_time' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'master_worker_id' => '工程师ID',
+        'worker_number' => '工程师编号',
+        'engineer_name' => '工程师姓名',
+        'original_balance' => '工程师原始余额',
+        'total_settlement_amount' => '工程师总结算金额',
+        'deduction_amount' => '工程师扣款金额',
+        'final_settlement_amount' => '工程师最终结算金额',
+        'settlement_time' => '结算时间',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return EngineerSettlementValidate
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['master_worker_id','worker_number','engineer_name','original_balance','total_settlement_amount','deduction_amount','final_settlement_amount','settlement_time']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return EngineerSettlementValidate
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','master_worker_id','worker_number','engineer_name','original_balance','total_settlement_amount','deduction_amount','final_settlement_amount','settlement_time']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return EngineerSettlementValidate
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return EngineerSettlementValidate
+     * @author likeadmin
+     * @date 2024/11/15 17:21
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 103 - 0
app/tenantapi/validate/master_worker/MasterWorkerAgreeValidate.php

@@ -0,0 +1,103 @@
+<?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\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerAgree验证器
+ * Class MasterWorkerAgreeValidate
+ * @package app\tenantapi\validate\master_worker
+ */
+class MasterWorkerAgreeValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'worker_id' => 'require',
+        'sign' => 'require',
+        'pdf_url' => 'require',
+        'audit_state'=>'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'worker_id' => '工程师ID',
+        'sign' => '协议签名',
+        'pdf_url' => 'PDF协议',
+        'audit_state'=>'审核状态'
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerAgreeValidate
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['worker_id','sign','pdf_url']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerAgreeValidate
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','audit_state']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerAgreeValidate
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerAgreeValidate
+     * @author likeadmin
+     * @date 2024/07/17 15:20
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 100 - 0
app/tenantapi/validate/master_worker/MasterWorkerInfoValidate.php

@@ -0,0 +1,100 @@
+<?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\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerInfo验证器
+ * Class MasterWorkerInfoValidate
+ * @package app\tenantapi\validate\master_worker
+ */
+class MasterWorkerInfoValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'worker_id' => 'require',
+        'audit_state' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'worker_id' => '用户id',
+        'audit_state' => '审核状态',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerInfoValidate
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['worker_id','audit_state']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerInfoValidate
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','worker_id','audit_state']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerInfoValidate
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerInfoValidate
+     * @author likeadmin
+     * @date 2024/10/07 18:58
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 76 - 0
app/tenantapi/validate/master_worker/MasterWorkerRetentionMoneyLogValidate.php

@@ -0,0 +1,76 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorker验证器
+ * Class MasterWorkerValidate
+ * @package app\tenantapi\validate\master_worker
+ */
+class MasterWorkerRetentionMoneyLogValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'worker_id' => 'require',
+        'action' => 'require',
+        'amount' => 'require',
+        'remark' => 'require'
+     ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'worker_id' => '工程师ID',
+        'action' => '动作',
+        'amount' => '金额',
+        'remark' => '备注',
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['worker_id','action','amount','remark']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneTotalAmount()
+    {
+        return $this->only(['worker_id']);
+    }
+
+}

+ 98 - 0
app/tenantapi/validate/master_worker/MasterWorkerRuleValidate.php

@@ -0,0 +1,98 @@
+<?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\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerRule验证器
+ * Class MasterWorkerRuleValidate
+ * @package app\tenantapi\validate
+ */
+class MasterWorkerRuleValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'rule_name' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'rule_name' => '规则名称',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['rule_name']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','rule_name']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 100 - 0
app/tenantapi/validate/master_worker/MasterWorkerTeamValidate.php

@@ -0,0 +1,100 @@
+<?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\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerTeam验证器
+ * Class MasterWorkerTeamValidate
+ * @package app\tenantapi\validate
+ */
+class MasterWorkerTeamValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'team_name' => 'require',
+        'master_worker_id' => 'require',
+        'tenant_id' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'team_name' => '团队名称',
+        'master_worker_id' => '负责工程师ID',
+        'tenant_id' => '租户ID',
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerTeamValidate
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['team_name','master_worker_id','tenant_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerTeamValidate
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','team_name','master_worker_id','tenant_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerTeamValidate
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerTeamValidate
+     * @author likeadmin
+     * @date 2024/11/20 17:42
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 130 - 0
app/tenantapi/validate/master_worker/MasterWorkerValidate.php

@@ -0,0 +1,130 @@
+<?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\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorker验证器
+ * Class MasterWorkerValidate
+ * @package app\tenantapi\validate\master_worker
+ */
+class MasterWorkerValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'sn' => 'require',
+        'avatar' => 'require',
+        'real_avatar' => 'require',
+        'real_name' => 'require',
+        'nickname' => 'require',
+        'account' => 'require',
+        'password' => 'require',
+        'mobile' => 'require',
+        'sex' => 'require',
+        'channel' => 'require',
+        'is_disable' => 'require',
+        'login_ip' => 'require',
+        'login_time' => 'require',
+        'is_new_user' => 'require',
+        'exp' => 'require',
+        'tenant_id' => 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'sn' => '编号',
+        'avatar' => '头像',
+        'real_avatar' => '真实头像',
+        'real_name' => '真实姓名',
+        'nickname' => '用户昵称',
+        'account' => '工程师账号',
+        'password' => '工程师密码',
+        'mobile' => '工程师电话',
+        'sex' => '工程师性别',
+        'channel' => '注册渠道',
+        'is_disable' => '是否禁用',
+        'login_ip' => '最后登录IP',
+        'login_time' => '最后登录时间',
+        'is_new_user' => '是否是新注册用户: [1-是, 0-否]',
+        'exp' => '经验值',
+        'tenant_id' => '租户ID',
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['password','mobile','is_disable','tenant_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','password','mobile','is_disable','tenant_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerValidate
+     * @author likeadmin
+     * @date 2024/07/10 18:17
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+    public function sceneSaltToPassword()
+    {
+        return $this->only(['password']);
+    }
+}

+ 39 - 0
app/tenantapi/validate/notice/NoticeValidate.php

@@ -0,0 +1,39 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\tenantapi\validate\notice;
+
+use app\common\validate\BaseValidate;
+
+/**
+ * 通知验证
+ * Class NoticeValidate
+ * @package app\tenantapi\validate\notice
+ */
+class NoticeValidate extends BaseValidate
+{
+    protected $rule = [
+        'id' => 'require',
+    ];
+
+    protected $message = [
+        'id.require' => '参数缺失',
+    ];
+
+    protected function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 109 - 0
app/tenantapi/validate/recharge/RechargeRefundValidate.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\validate\recharge;
+
+
+use app\common\enum\PayEnum;
+use app\common\enum\RefundEnum;
+use app\common\enum\YesNoEnum;
+use app\common\model\recharge\RechargeOrder;
+use app\common\model\refund\RefundRecord;
+use app\common\model\user\User;
+use app\common\validate\BaseValidate;
+
+/**
+ * 充值退款校验
+ * Class RechargeRefundValidate
+ * @package app\tenantapi\validate\recharge
+ */
+class RechargeRefundValidate extends BaseValidate
+{
+    protected $rule = [
+        'recharge_id' => 'require|checkRecharge',
+        'record_id' => 'require|checkRecord',
+    ];
+
+    protected $message = [
+        'recharge_id.require' => '参数缺失',
+        'record_id.require' => '参数缺失',
+    ];
+
+
+    public function sceneRefund()
+    {
+        return $this->only(['recharge_id']);
+    }
+
+
+    public function sceneAgain()
+    {
+        return $this->only(['record_id']);
+    }
+
+
+    /**
+     * @notes 校验充值订单能否发起退款
+     * @param $rechargeId
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @author 段誉
+     * @date 2023/2/28 17:00
+     */
+    protected function checkRecharge($rechargeId, $rule, $data)
+    {
+        $order = RechargeOrder::findOrEmpty($rechargeId);
+
+        if ($order->isEmpty()) {
+            return '订单不存在';
+        }
+
+        if ($order['pay_status'] != PayEnum::ISPAID) {
+            return '当前订单不可退款';
+        }
+
+        // 校验订单是否已退款
+        if ($order['refund_status'] == YesNoEnum::YES) {
+            return '订单已发起退款,退款失败请到退款记录重新退款';
+        }
+
+        return true;
+    }
+
+
+    /**
+     * @notes 校验退款记录
+     * @param $recordId
+     * @param $rule
+     * @param $data
+     * @return bool|string
+     * @author 段誉
+     * @date 2023/3/1 9:40
+     */
+    protected function checkRecord($recordId, $rule, $data)
+    {
+        $record = RefundRecord::findOrEmpty($recordId);
+        if ($record->isEmpty()) {
+            return '退款记录不存在';
+        }
+
+        if($record['refund_status'] == RefundEnum::REFUND_SUCCESS) {
+            return '该退款记录已退款成功';
+        }
+
+        return true;
+    }
+
+}

+ 106 - 0
app/tenantapi/validate/works/IssueWorkValidate.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\validate\works;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * IssueWork验证器
+ * Class IssueWorkValidate
+ * @package app\tenantapi\validate\works
+ */
+class IssueWorkValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'work_sn' => 'require',
+        'master_worker_id' => 'require',
+        'issue_approval' => 'require',
+        'responsible' => 'require',
+        'complaint_details' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'work_sn' => '工单编号',
+        'master_worker_id' => '师傅',
+        'issue_approval' => '投诉审核状态',
+        'responsible' => '定责',
+        'complaint_details' => '投诉详情',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return IssueWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['work_sn','master_worker_id','issue_approval','responsible','complaint_details']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return IssueWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','work_sn','master_worker_id','issue_approval','responsible','complaint_details']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return IssueWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return IssueWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 112 - 0
app/tenantapi/validate/works/ReturnWorkValidate.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\validate\works;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * ReturnWork验证器
+ * Class ReturnWorkValidate
+ * @package app\tenantapi\validate\works
+ */
+class ReturnWorkValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'work_sn' => 'require',
+        'return_work_status' => 'require',
+        'dispatch_time' => 'require',
+        'appointment_time' => 'require',
+        'finished_time' => 'require',
+        'master_worker_id' => 'require',
+        'issue_work_id'=> 'require',
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'work_sn' => '工单编号',
+        'return_work_status' => '返修工单状态',
+        'dispatch_time' => '派单时间',
+        'appointment_time' => '预约上门时间',
+        'finished_time' => '结单时间',
+        'master_worker_id' => '工程师',
+        'issue_work_id' => '投诉工单',
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return ReturnWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['work_sn','return_work_status','dispatch_time','appointment_time','finished_time','master_worker_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return ReturnWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','work_sn','return_work_status','dispatch_time','appointment_time','finished_time','master_worker_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return ReturnWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return ReturnWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+    public function sceneIssueWorkData()
+    {
+        return $this->only(['issue_work_id','master_worker_id','appointment_time']);
+    }
+}

+ 138 - 0
app/tenantapi/validate/works/ServiceWorkValidate.php

@@ -0,0 +1,138 @@
+<?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\validate\works;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * ServiceWork验证器
+ * Class ServiceWorkValidate
+ * @package app\tenantapi\validate\works
+ */
+class ServiceWorkValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'work_sn' => 'require',
+        'mobile' => 'require',
+        'address' => 'require',
+        'title' => 'require',
+        'category_type' => 'require',
+        'goods_category_ids' => 'require',
+        'goods_category_id' => 'require',
+        'base_service_fee' => 'require',
+        'service_fee' => 'require',
+        'work_status' => 'require',
+        'service_status' => 'require',
+        'dispatch_time' => 'require',
+        'receive_time' => 'require',
+        'appointment_time' => 'require',
+        'finished_time' => 'require',
+        'master_worker_id' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'work_sn' => '工单编号',
+        'mobile' => '手机号',
+        'address' => '客户地址',
+        'title' => '工单名称',
+        'category_type' => '服务类别',
+        'goods_category_ids' => '服务类目',
+        'goods_category_id' => '服务产品',
+        'base_service_fee' => '基础服务费',
+        'service_fee' => '服务费用',
+        'work_status' => '工单状态',
+        'service_status' => '订单服务状态',
+        'dispatch_time' => '派单时间',
+        'receive_time' => '领单时间',
+        'appointment_time' => '预约上门时间',
+        'finished_time' => '结单时间',
+        'master_worker_id' => '工程师',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return ServiceWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['work_sn','mobile','address','title','category_type','goods_category_ids','goods_category_id','base_service_fee','service_fee','work_status','service_status','dispatch_time','receive_time','appointment_time','finished_time','master_worker_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return ServiceWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','address','appointment_time','lon','lat']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return ServiceWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return ServiceWorkValidate
+     * @author likeadmin
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+    /**
+     * 分配工程师场景
+     * @return ServiceWorkValidate
+     * @author 林海涛
+     * @date 2024/7/16 下午4:38
+     */
+    public function sceneAllocateWorker()
+    {
+        return $this->only(['id','master_worker_id']);
+    }
+}