Browse Source

工程师工单

whitefang 1 year ago
parent
commit
6fd748284b

+ 11 - 1
app/workerapi/controller/WorksController.php

@@ -4,6 +4,7 @@ namespace app\workerapi\controller;
 use app\adminapi\logic\works\ServiceWorkLogic;
 use app\workerapi\lists\IssueWorkLists;
 use app\workerapi\lists\ReturnWorkLists;
+use app\workerapi\lists\ServiceAssignWorkLists;
 use app\workerapi\lists\ServiceWorkLists;
 use app\workerapi\validate\ServiceWorkValidate;
 
@@ -14,7 +15,7 @@ class WorksController extends BaseApiController
 {
 
     /**
-     * 服务工单列表
+     * 服务工单列表-全部
      * @return \think\response\Json
      */
     public function serviceWorkList()
@@ -22,6 +23,15 @@ class WorksController extends BaseApiController
         return $this->dataLists(new ServiceWorkLists());
     }
 
+    /**
+     * 派单
+     * @return \think\response\Json
+     */
+    public function assignWorkList()
+    {
+        return $this->dataLists(new ServiceAssignWorkLists());
+    }
+
     /**
      * 领取服务单
      * @return \think\response\Json

+ 97 - 0
app/workerapi/lists/ServiceAssignWorkLists.php

@@ -0,0 +1,97 @@
+<?php
+namespace app\workerapi\lists;
+
+use app\common\model\works\ServiceWork;
+use app\common\lists\ListsSearchInterface;
+use DateTime;
+
+/**
+ * ServiceAssignWork列表
+ * Class ServiceAssignWorkLists
+ * @package app\workerapi\listsworks
+ */
+class ServiceAssignWorkLists 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;
+            case 4:
+                $where['work_status'] = 7;
+                break;
+        }
+
+        $list = ServiceWork::where($where)
+            ->field(['work_sn', 'address', 'title', 'work_status', 'service_status', 'appointment_time','receive_time'])
+            ->append(['work_status_text','service_status_text'])
+            ->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;
+    }
+
+}

+ 3 - 42
app/workerapi/lists/ServiceWorkLists.php

@@ -27,50 +27,11 @@ class ServiceWorkLists extends BaseWorkerDataLists
     {
         $where = [
             'master_worker_id'=>$this->userId,
-            'approval'=>1//派单的时候默认审核了
+            'approval'=>1,//派单的时候默认审核了
+            'work_status'=>0,
         ];
-        //条件搜索
-        $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;
-            case 4:
-                $where['work_status'] = 7;
-                break;
-        }
-
         $list = ServiceWork::where($where)
-            ->field(['work_sn', 'address', 'title', 'work_status', 'service_status', 'appointment_time','receive_time'])
+            ->field(['work_sn', 'address', 'title', 'work_status', 'service_status', 'appointment_time','receive_time','base_service_fee','service_fee'])
             ->append(['work_status_text','service_status_text'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])