Просмотр исходного кода

师傅工单流程-到领取工单了

whitefang 1 год назад
Родитель
Сommit
8ed9097972
26 измененных файлов с 965 добавлено и 151 удалено
  1. 1 1
      app/adminapi/controller/works/ServiceWorkController.php
  2. 2 2
      app/adminapi/lists/orders/RechargeOrderLists.php
  3. 23 99
      app/adminapi/logic/works/ServiceWorkLogic.php
  4. 12 6
      app/api/lists/recharge/ServiceOrderLists.php
  5. 2 0
      app/common/cache/MasterWokerTokenCache.php
  6. 17 0
      app/common/model/works/ServiceWork.php
  7. 17 0
      app/common/model/works/ServiceWorkLog.php
  8. 6 6
      app/workerapi/config/route.php
  9. 6 6
      app/workerapi/controller/BaseApiController.php
  10. 6 6
      app/workerapi/controller/LoginController.php
  11. 1 1
      app/workerapi/controller/MasterWorkerController.php
  12. 60 0
      app/workerapi/controller/WorksController.php
  13. 6 6
      app/workerapi/http/middleware/InitMiddleware.php
  14. 6 6
      app/workerapi/http/middleware/LoginMiddleware.php
  15. 63 0
      app/workerapi/lists/IssueWorkLists.php
  16. 62 0
      app/workerapi/lists/ReturnWorkLists.php
  17. 93 0
      app/workerapi/lists/ServiceWorkLists.php
  18. 111 0
      app/workerapi/logic/IssueWorkLogic.php
  19. 107 0
      app/workerapi/logic/ReturnWorkLogic.php
  20. 37 0
      app/workerapi/logic/ServiceWorkLogLogic.php
  21. 127 0
      app/workerapi/logic/ServiceWorkLogic.php
  22. 6 6
      app/workerapi/service/MasterWokerTokenService.php
  23. 55 0
      app/workerapi/validate/IssueWorkValidate.php
  24. 58 0
      app/workerapi/validate/ReturnWorkValidate.php
  25. 75 0
      app/workerapi/validate/ServiceWorkValidate.php
  26. 6 6
      app/workerapi/validate/SetMasterWorkerInfoValidate.php

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

@@ -24,7 +24,7 @@ use app\adminapi\validate\works\ServiceWorkValidate;
 
 /**
  * ServiceWork控制器
- * Class ServiceWorkController
+ * Class WorksController
  * @package app\adminapi\controller\works
  */
 class ServiceWorkController extends BaseAdminController

+ 2 - 2
app/adminapi/lists/orders/RechargeOrderLists.php

@@ -38,7 +38,7 @@ class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterf
     public function setSearch(): array
     {
         return [
-            '=' => ['sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id', 'address', 'create_time', 'update_time'],
+            '=' => ['sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id', 'create_time', 'update_time'],
 
         ];
     }
@@ -56,7 +56,7 @@ class RechargeOrderLists extends BaseAdminDataLists implements ListsSearchInterf
     public function lists(): array
     {
         return RechargeOrder::where($this->searchWhere)
-            ->field(['id', 'sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_total', 'order_amount', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id', 'address', 'create_time', 'update_time'])
+            ->field(['id', 'sn', 'work_id', 'user_id', 'payment_type', 'pay_sn', 'pay_way', 'pay_status', 'pay_time', 'order_total', 'order_amount', 'order_terminal', 'transaction_id', 'refund_status', 'refund_transaction_id', 'create_time', 'update_time'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()

+ 23 - 99
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -17,6 +17,9 @@ namespace app\adminapi\logic\works;
 
 use app\common\model\works\ServiceWork;
 use app\common\logic\BaseLogic;
+use app\common\model\works\ServiceWorkLog;
+use app\workerapi\logic\ServiceWorkLogLogic;
+use think\Exception;
 use think\facade\Db;
 
 
@@ -28,115 +31,36 @@ use think\facade\Db;
 class ServiceWorkLogic extends BaseLogic
 {
 
-
     /**
-     * @notes 添加
-     * @param array $params
-     * @return bool
-     * @author likeadmin
-     * @date 2024/07/10 15:06
+     *
+     * @return false|void
      */
-    public static function add(array $params): bool
+    public static function pickWork($params)
     {
         Db::startTrans();
         try {
-            ServiceWork::create([
-                'work_sn' => $params['work_sn'],
-                'real_name' => $params['real_name'],
-                'mobile' => $params['mobile'],
-                'address' => $params['address'],
-                'title' => $params['title'],
-                'category_type' => $params['category_type'],
-                'goods_category_ids' => $params['goods_category_ids'],
-                'goods_category_id' => $params['goods_category_id'],
-                'base_service_fee' => $params['base_service_fee'],
-                'service_fee' => $params['service_fee'],
-                'work_status' => $params['work_status'],
-                'service_status' => $params['service_status'],
-                'dispatch_time' => strtotime($params['dispatch_time']),
-                'receive_time' => strtotime($params['receive_time']),
-                'appointment_time' => strtotime($params['appointment_time']),
-                'finished_images' => $params['finished_images'],
-                'finished_time' => strtotime($params['finished_time']),
-                'master_worker_id' => $params['master_worker_id'],
-                'worker_amount' => $params['worker_amount'],
-            ]);
+            $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();
-            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 {
-            ServiceWork::where('id', $params['id'])->update([
-                'work_sn' => $params['work_sn'],
-                'real_name' => $params['real_name'],
-                'mobile' => $params['mobile'],
-                'address' => $params['address'],
-                'title' => $params['title'],
-                'category_type' => $params['category_type'],
-                'goods_category_ids' => $params['goods_category_ids'],
-                'goods_category_id' => $params['goods_category_id'],
-                'base_service_fee' => $params['base_service_fee'],
-                'service_fee' => $params['service_fee'],
-                'work_status' => $params['work_status'],
-                'service_status' => $params['service_status'],
-                'dispatch_time' => strtotime($params['dispatch_time']),
-                'receive_time' => strtotime($params['receive_time']),
-                'appointment_time' => strtotime($params['appointment_time']),
-                'finished_images' => $params['finished_images'],
-                'finished_time' => strtotime($params['finished_time']),
-                'master_worker_id' => $params['master_worker_id'],
-                'worker_amount' => $params['worker_amount'],
-            ]);
-
-            Db::commit();
-            return true;
-        } catch (\Exception $e) {
-            Db::rollback();
+        catch (\Exception $e) {
             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 ServiceWork::destroy($params['id']);
-    }
-
-
-    /**
-     * @notes 获取详情
-     * @param $params
-     * @return array
-     * @author likeadmin
-     * @date 2024/07/10 15:06
-     */
-    public static function detail($params): array
-    {
-        return ServiceWork::findOrEmpty($params['id'])->toArray();
-    }
 }

+ 12 - 6
app/api/lists/recharge/ServiceOrderLists.php

@@ -25,6 +25,8 @@ use app\common\model\recharge\RechargeOrder;
  */
 class ServiceOrderLists extends BaseApiDataLists
 {
+    protected $count = 0;
+
     /**
      * @notes 获取列表
      * @return array
@@ -44,10 +46,19 @@ class ServiceOrderLists extends BaseApiDataLists
                 'order_type' => 0,
                 'user_id' => $this->userId,
             ])
+            ->limit($this->limitOffset, $this->limitLength)
             ->group('work_id')
             ->order('id', 'desc')
             ->select()
             ->toArray();
+
+        $this->count = RechargeOrder::where([
+            'order_type' => 0,
+            'user_id' => $this->userId,
+        ])
+            ->group('work_id')
+            ->count();
+
         return $lists;
     }
 
@@ -58,12 +69,7 @@ class ServiceOrderLists extends BaseApiDataLists
      */
     public function count(): int
     {
-        return RechargeOrder::where([
-                'order_type' => 0,
-                'user_id' => $this->userId,
-            ])
-            ->group('work_id')
-            ->count();
+        return $this->count;
     }
 
 }

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

@@ -76,6 +76,8 @@ class MasterWokerTokenCache extends BaseCache
 
         $userInfo = [
             'user_id' => $user->id,
+            'real_name'=>$user->real_name,
+            'worker_number'=>$user->worker_number,
             'nickname' => $user->nickname,
             'token' => $token,
             'sn' => $user->sn,

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

@@ -33,5 +33,22 @@ class ServiceWork extends BaseModel
     {
         return $this->belongsTo(MasterWorker::class, 'master_worker_id', 'id');
     }
+
+    public function getWorkStatusAttr($value,$data)
+    {
+         $status = [0=>'待派单',1=>'待领单',2=>'待联系',3=>'待上门',4=>'已上门',5=>'待结算',6=>'完成服务'];
+        return $status[$data['work_status']];
+    }
+
+    public function getServiceStatusAttr($value,$data)
+    {
+        $status = [0=>'已下单',1=>'服务中',2=>'部分完成',3=>'已完成',4=>'已取消'];
+        return $status[$data['service_status']];
+    }
+
+    public function getAppointmentTimeAttr($value,$data)
+    {
+        return !empty($data['appointment_time'])?date('Y-m-d H:i:s',$data['appointment_time']):'';
+    }
     
 }

+ 17 - 0
app/common/model/works/ServiceWorkLog.php

@@ -0,0 +1,17 @@
+<?php
+namespace app\common\model\works;
+
+
+use app\common\model\BaseModel;
+
+
+/**
+ * ServiceWorkLog模型
+ * Class ServiceWorkLog
+ * @package app\common\model\works
+ */
+class ServiceWorkLog extends BaseModel
+{
+    protected $name = 'service_work_log';
+
+}

+ 6 - 6
app/workerapi/config/route.php

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

+ 6 - 6
app/workerapi/controller/BaseApiController.php

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

+ 6 - 6
app/workerapi/controller/LoginController.php

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

+ 1 - 1
app/workerapi/controller/MasterWorkerController.php

@@ -30,7 +30,7 @@ class MasterWorkerController extends BaseApiController
 
     /**
      * 更改手机号
-     * @return void
+     * @return \think\response\Json
      * @author 林海涛
      * @date 2024/7/10 下午2:23
      */

+ 60 - 0
app/workerapi/controller/WorksController.php

@@ -0,0 +1,60 @@
+<?php
+namespace app\workerapi\controller;
+
+use app\adminapi\logic\works\ServiceWorkLogic;
+use app\workerapi\lists\IssueWorkLists;
+use app\workerapi\lists\ReturnWorkLists;
+use app\workerapi\lists\ServiceWorkLists;
+use app\workerapi\validate\ServiceWorkValidate;
+
+/**
+ * 工单系统
+ */
+class WorksController extends BaseApiController
+{
+
+    /**
+     * 服务工单列表
+     * @return \think\response\Json
+     */
+    public function serviceWorkList()
+    {
+        return $this->dataLists(new ServiceWorkLists());
+    }
+
+    /**
+     * 领取服务单
+     * @return \think\response\Json
+     */
+    public function pickWork()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('pick', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceWorkLogic::pickWork($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('领取成功', [], 1, 1);
+    }
+
+    /**
+     * 投诉工单列表
+     *
+     * @return \think\response\Json
+     */
+    public function issueWorkList()
+    {
+        return $this->dataLists(new IssueWorkLists());
+    }
+
+    /**
+     * 返修工单列表
+     * @return \think\response\Json
+     */
+    public function returnWorkList()
+    {
+        return $this->dataLists(new ReturnWorkLists());
+    }
+}

+ 6 - 6
app/workerapi/http/middleware/InitMiddleware.php

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

+ 6 - 6
app/workerapi/http/middleware/LoginMiddleware.php

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

+ 63 - 0
app/workerapi/lists/IssueWorkLists.php

@@ -0,0 +1,63 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\model\works\IssueWork;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * IssueWork列表
+ * Class IssueWorkLists
+ * @package app\workerapi\listsworks
+ */
+class IssueWorkLists extends BaseWorkerDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author whitef
+     * @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', 'finished_time', 'approval_admin_id', 'approval_time', 'create_time', 'update_time'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function lists(): array
+    {
+        return IssueWork::where($this->searchWhere)
+            ->field(['id', 'work_sn', 'service_work_id', 'master_worker_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details', 'complaint_images', 'finished_time', 'approval_admin_id', 'approval_time', 'create_time', 'update_time'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function count(): int
+    {
+        return IssueWork::where($this->searchWhere)->count();
+    }
+
+}

+ 62 - 0
app/workerapi/lists/ReturnWorkLists.php

@@ -0,0 +1,62 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\model\works\ReturnWork;
+use app\common\lists\ListsSearchInterface;
+
+/**
+ * ReturnWork列表
+ * Class ReturnWorkLists
+ * @package app\workerapi\listsworks
+ */
+class ReturnWorkLists extends BaseWorkerDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author whitef
+     * @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'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function lists(): array
+    {
+        return ReturnWork::where($this->searchWhere)
+            ->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 whitef
+     * @date 2024/07/10 15:06
+     */
+    public function count(): int
+    {
+        return ReturnWork::where($this->searchWhere)->count();
+    }
+
+}

+ 93 - 0
app/workerapi/lists/ServiceWorkLists.php

@@ -0,0 +1,93 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\model\works\ServiceWork;
+use app\common\lists\ListsSearchInterface;
+use DateTime;
+
+/**
+ * ServiceWork列表
+ * Class ServiceWorkLists
+ * @package app\workerapi\listsworks
+ */
+class ServiceWorkLists extends BaseWorkerDataLists
+{
+    protected $count = 0;
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function lists(): array
+    {
+        $where = [
+            'master_worker_id'=>$this->userId,
+            'approval'=>1//派单的时候默认审核了
+        ];
+        //条件搜索
+        $status = $this->params['status'] ?? 0;
+        switch ($status){
+            case 0:
+                $where[] = ['service_status','in','0,1,2'];
+                break;
+             case 1:
+                $where['service_status'] = ['in','0,1,2'];
+                 // 创建 DateTime 对象并设置为今天午夜
+                 $startOfDay = new DateTime('today midnight');
+                // 设置为今天最后一秒
+                 $endOfDay = new DateTime('today midnight');
+                 $endOfDay->modify('+1 day -1 second');
+                 // 转换为时间戳
+                 $startOfDayTimestamp = $startOfDay->getTimestamp();
+                 $endOfDayTimestamp = $endOfDay->getTimestamp();
+                 $where[] = ['appointment_time','between',[$startOfDayTimestamp, $endOfDayTimestamp]];
+                break;
+             case 2:
+                    $where['service_status'] = ['in','0,1,2'];
+                    // 创建一个 DateTime 对象表示当前时间
+                    $dateNow = new DateTime();
+                    // 修改这个对象以表示明天的午夜
+                    $midnightTomorrow = clone $dateNow;
+                    $midnightTomorrow->modify('+1 day midnight');
+                    // 修改这个对象以表示明天的最后一秒
+                    $lastSecondTomorrow = clone $dateNow;
+                    $lastSecondTomorrow->modify('+1 day 23:59:59');
+                    $midnightTimestamp = $midnightTomorrow->getTimestamp();
+                    $lastSecondTimestamp = $lastSecondTomorrow->getTimestamp();
+                    $where[] = ['appointment_time','between',[$midnightTimestamp, $lastSecondTimestamp]];
+                break;
+            case 3:
+                $where['approval'] = 0;
+                break;
+        }
+
+        $list = ServiceWork::where($where)
+            ->field(['work_sn', 'address', 'title', 'work_status', 'service_status', 'appointment_time'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        $this->count = ServiceWork::where($where)->count();
+
+        return $list;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function count(): int
+    {
+        return $this->count;
+    }
+
+}

+ 111 - 0
app/workerapi/logic/IssueWorkLogic.php

@@ -0,0 +1,111 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\model\works\IssueWork;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * IssueWork逻辑
+ * Class IssueWorkLogic
+ * @package app\workerapi\logic\works
+ */
+class IssueWorkLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @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']),
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            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' => strtotime($params['approval_time']),
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function delete(array $params): bool
+    {
+        return IssueWork::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function detail($params): array
+    {
+        return IssueWork::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 107 - 0
app/workerapi/logic/ReturnWorkLogic.php

@@ -0,0 +1,107 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\model\works\ReturnWork;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * ReturnWork逻辑
+ * Class ReturnWorkLogic
+ * @package app\workerapi\logic\works
+ */
+class ReturnWorkLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @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'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @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'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function delete(array $params): bool
+    {
+        return ReturnWork::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function detail($params): array
+    {
+        return ReturnWork::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 37 - 0
app/workerapi/logic/ServiceWorkLogLogic.php

@@ -0,0 +1,37 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\logic\BaseLogic;
+use app\common\model\works\ServiceWorkLog;
+use think\Exception;
+use think\facade\Db;
+
+
+/**
+ * ServiceWorkLog逻辑
+ * Class ServiceWorkLogLogic
+ * @package app\workerapi\logic\works
+ */
+class ServiceWorkLogLogic extends BaseLogic
+{
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @throws Exception
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function add(array $params): bool
+    {
+        if(empty($params['work_id']) || empty($params['master_worker_id']) || empty($params['opera_log'])) {
+            throw new Exception('参数错误');
+        }
+        ServiceWorkLog::create([
+            'work_id' => $params['work_id'],
+            'master_worker_id' => $params['master_worker_id'],
+            'opera_log'=>$params['opera_log']
+        ]);
+
+        return true;
+    }
+}

+ 127 - 0
app/workerapi/logic/ServiceWorkLogic.php

@@ -0,0 +1,127 @@
+<?php
+namespace app\workerapi\logic;
+use app\common\model\works\ServiceWork;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * ServiceWork逻辑
+ * Class ServiceWorkLogic
+ * @package app\workerapi\logic\works
+ */
+class ServiceWorkLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ServiceWork::create([
+                'work_sn' => $params['work_sn'],
+                'real_name' => $params['real_name'],
+                'mobile' => $params['mobile'],
+                'address' => $params['address'],
+                'title' => $params['title'],
+                'category_type' => $params['category_type'],
+                'goods_category_ids' => $params['goods_category_ids'],
+                'goods_category_id' => $params['goods_category_id'],
+                'base_service_fee' => $params['base_service_fee'],
+                'service_fee' => $params['service_fee'],
+                'work_status' => $params['work_status'],
+                'service_status' => $params['service_status'],
+                'dispatch_time' => strtotime($params['dispatch_time']),
+                'receive_time' => strtotime($params['receive_time']),
+                'appointment_time' => strtotime($params['appointment_time']),
+                'finished_images' => $params['finished_images'],
+                'finished_time' => strtotime($params['finished_time']),
+                'master_worker_id' => $params['master_worker_id'],
+                'worker_amount' => $params['worker_amount'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            ServiceWork::where('id', $params['id'])->update([
+                'work_sn' => $params['work_sn'],
+                'real_name' => $params['real_name'],
+                'mobile' => $params['mobile'],
+                'address' => $params['address'],
+                'title' => $params['title'],
+                'category_type' => $params['category_type'],
+                'goods_category_ids' => $params['goods_category_ids'],
+                'goods_category_id' => $params['goods_category_id'],
+                'base_service_fee' => $params['base_service_fee'],
+                'service_fee' => $params['service_fee'],
+                'work_status' => $params['work_status'],
+                'service_status' => $params['service_status'],
+                'dispatch_time' => strtotime($params['dispatch_time']),
+                'receive_time' => strtotime($params['receive_time']),
+                'appointment_time' => strtotime($params['appointment_time']),
+                'finished_images' => $params['finished_images'],
+                'finished_time' => strtotime($params['finished_time']),
+                'master_worker_id' => $params['master_worker_id'],
+                'worker_amount' => $params['worker_amount'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function delete(array $params): bool
+    {
+        return ServiceWork::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public static function detail($params): array
+    {
+        return ServiceWork::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 6 - 6
app/workerapi/service/MasterWokerTokenService.php

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

+ 55 - 0
app/workerapi/validate/IssueWorkValidate.php

@@ -0,0 +1,55 @@
+<?php
+namespace app\workerapi\validate;
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * IssueWork验证器
+ * Class IssueWorkValidate
+ * @package app\workerapi\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 whitef
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 58 - 0
app/workerapi/validate/ReturnWorkValidate.php

@@ -0,0 +1,58 @@
+<?php
+namespace app\workerapi\validate;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * ReturnWork验证器
+ * Class ReturnWorkValidate
+ * @package app\workerapi\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',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'work_sn' => '工单编号',
+        'return_work_status' => '返修工单状态',
+        'dispatch_time' => '派单时间',
+        'appointment_time' => '预约上门时间',
+        'finished_time' => '结单时间',
+        'master_worker_id' => '师傅',
+
+    ];
+
+    /**
+     * @notes 详情场景
+     * @return ReturnWorkValidate
+     * @author whitef
+     * @date 2024/07/10 15:06
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 75 - 0
app/workerapi/validate/ServiceWorkValidate.php

@@ -0,0 +1,75 @@
+<?php
+namespace app\workerapi\validate;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * ServiceWork验证器
+ * Class ServiceWorkValidate
+ * @package app\workerapi\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' => '师傅',
+
+    ];
+
+    /**
+     * 领取场景
+     * @return ServiceWorkValidate
+     */
+    public function scenePick()
+    {
+        return $this->only(['work_sn']);
+    }
+
+}

+ 6 - 6
app/workerapi/validate/SetMasterWorkerInfoValidate.php

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