فهرست منبع

工程师后台弹框改约列表和确认改约

whitefang 1 سال پیش
والد
کامیت
5e35991a4c

+ 37 - 0
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -613,6 +613,43 @@ class ServiceWorkLogic extends BaseLogic
         }
         }
     }
     }
 
 
+    /**
+     * 获取所有改约通知
+     * @param $userId
+     * @return array|false
+     */
+    public static function getAppointmentNotice($userId)
+    {
+        return ServiceWork::where(['master_worker_id'=>$userId,'appoint_approval'=>1])
+            ->field(['id', 'work_sn','mobile', 'address', 'title', 'appointment_time'])
+            ->order(['appointment_time' => 'asc'])//上门时间排序
+            ->select()
+            ->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;
+        }
+    }
+
 
 
 
 
 }
 }

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

@@ -250,4 +250,59 @@ class WorksController extends BaseApiController
         return $this->dataLists(new GoodsFeeStandardsLists());
         return $this->dataLists(new GoodsFeeStandardsLists());
     }
     }
 
 
+    /**
+     * 预约通知提醒
+     * @return \think\response\Json
+     */
+    public function appointmentNotice()
+    {
+        $result = ServiceWorkLogic::getAppointmentNotice($this->userId);
+        return $this->data($result);
+    }
+
+    /**
+     * 预约通知确认
+     * @return \think\response\Json
+     */
+    public function appointmentSubmitNotice()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('submitAppointment', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceWorkLogic::submitAppointment($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('操作成功,已确定新的预约时间', [], 1, 1);
+    }
+
+    /**
+     * 改价通知提醒
+     * @return \think\response\Json
+     */
+    public function ChangePriceNotice()
+    {
+        $params = (new ServiceWorkValidate())->goCheck('detail',[
+            'user_id' => $this->userId,
+        ]);
+        if(empty($params['id']) && empty($params['work_sn'])){
+            $this->fail('参数错误');
+        }
+        $result = ServiceWorkLogic::detail($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->data($result);
+    }
+
+    /**
+     * 改价通知确认
+     * @return \think\response\Json
+     */
+    public function ChangePriceSubmitNotice()
+    {
+
+    }
+
 }
 }

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

@@ -119,4 +119,9 @@ class ServiceWorkValidate extends BaseValidate
     {
     {
         return $this->only(['work_sn']);
         return $this->only(['work_sn']);
     }
     }
+
+    public function sceneSubmitAppointment()
+    {
+        return $this->only(['work_sn']);
+    }
 }
 }