Explorar o código

修改外包服务工单

dongxiaoqin hai 11 meses
pai
achega
888e3c784f

+ 2 - 1
app/adminapi/controller/works/GroupServiceWorkController.php

@@ -151,7 +151,8 @@ class GroupServiceWorkController extends BaseAdminController
     public function import()
     {
         $file = request()->file('file');
-        $result = GroupServiceWorkLogic::import($file);
+        $third_type = request()->request('third_type','2');
+        $result = GroupServiceWorkLogic::import($file,$third_type);
         if (true === $result) {
             return $this->success('导入成功', [], 1, 1);
         }

+ 25 - 8
app/adminapi/logic/works/GroupServiceWorkLogic.php

@@ -46,11 +46,27 @@ class GroupServiceWorkLogic extends BaseLogic
     {
         Db::startTrans();
         try {
-            GroupServiceWork::where('id', $params['id'])->update([
-                'address' => $params['address'],
-                'appointment_time' => strtotime($params['appointment_time']),
-                'remark' => $params['remark'],
-            ]);
+            $work = GroupServiceWork::where('id', $params['id'])->findOrEmpty()->toArray();
+            if (empty($work)) {
+                throw new Exception('工单不存在');
+            }
+            if ($work['third_type'] == 3) {
+                GroupServiceWork::where('id', $params['id'])->update([
+                    'work_total' => $params['work_total'],
+                    'work_amount' => $params['work_amount'],
+                    'settlement_amount' => $params['settlement_amount'],
+                    'settlement_status' => $params['settlement_status'],
+                    'address' => $params['address'],
+                    'appointment_time' => strtotime($params['appointment_time']),
+                    'remark' => $params['remark'],
+                ]);
+            } else {
+                GroupServiceWork::where('id', $params['id'])->update([
+                    'address' => $params['address'],
+                    'appointment_time' => strtotime($params['appointment_time']),
+                    'remark' => $params['remark'],
+                ]);
+            }
             Db::commit();
             return true;
         } catch (\Exception $e) {
@@ -327,7 +343,7 @@ class GroupServiceWorkLogic extends BaseLogic
                 }
             ])
             ->where($work_where)
-            ->field('id,work_sn,real_name,mobile,address,title,category_type,master_worker_id,work_status,user_confirm_status,service_status,dispatch_time,appointment_time,receive_time,work_images,finished_images,finished_time,area_name,finally_door_time,create_time,remark,third_type,work_total,work_amount,settlement_amount,work_pay_status')
+            ->field('id,work_sn,real_name,mobile,address,title,category_type,master_worker_id,work_status,user_confirm_status,service_status,dispatch_time,appointment_time,receive_time,work_images,finished_images,finished_time,area_name,finally_door_time,create_time,remark,third_type,work_total,work_amount,settlement_amount,settlement_status,work_pay_status')
             ->append(['id','work_status_text','service_status_text'])
             ->findOrEmpty()->toArray();
         if (empty($result)) {
@@ -386,7 +402,7 @@ class GroupServiceWorkLogic extends BaseLogic
     /**
      * 导入拼团工单
      */
-    public static function import($file) {
+    public static function import($file,$third_type) {
         
         try {
             // 移动文件到指定目录
@@ -401,6 +417,7 @@ class GroupServiceWorkLogic extends BaseLogic
 
                 // 假设第一行为表头,从第二行开始读取数据
                 for ($row = 2; $row <= $highestRow; $row++) {
+                    
                     $data = [
                         'title' => $worksheet->getCell('A' . $row)->getValue(),
                         'real_name' => $worksheet->getCell('B' . $row)->getValue(),
@@ -417,7 +434,7 @@ class GroupServiceWorkLogic extends BaseLogic
                     if(empty($data['title']) || empty($data['real_name']) || empty($data['mobile']) || empty($data['address'])){
                         continue;
                     }
-                    $data['third_type'] = 2;
+                    $data['third_type'] = $third_type;
                     $data['work_pay_status'] = 2;
                     $data['category_type'] = 2;
                     $data['appointment_time'] = $data['appointment_time'] ? strtotime($data['appointment_time']) : 0;