فهرست منبع

修改自选配件

dongxiaoqin 10 ماه پیش
والد
کامیت
837b143e73

+ 8 - 8
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -314,7 +314,8 @@ class ServiceWorkLogic extends BaseLogic
                         'original_price' => 0,
                         'spare_number' => $item['spare_number'],
                         'spare_part_id' => 0,
-                        'brand' => $item['brand']
+                        'brand' => $item['brand'],
+                        'status' => 0,
                     ];
                     if (current($spare_parts_ids)) {
                         //修改
@@ -433,18 +434,17 @@ class ServiceWorkLogic extends BaseLogic
             if($work->isEmpty()){
                 throw new Exception('工单不存在');
             }
-            $audit = ServiceWorkSpareAudit::where(['service_work_id'=>$work['id']])->findOrEmpty();
+            $audit = ServiceWorkSpare::where(['id' => $params['id'],'service_work_id'=>$work['id']])->findOrEmpty();
             if(!$audit->isEmpty() && ($audit['status']!=0 && $audit['status']!=2) ){
                 throw new Exception('当前工单配件不允许修改');
             }
             
-            foreach ($params['self_spare_parts'] as $item){
-                if (empty($item['spare_image'])){
-                    throw new Exception('请上传配件图片');
-                }
-                //修改
-                ServiceWorkSpare::where("id",$item['id'])->where('service_worker_id', $work['id'])->update(['spare_image' => $item['spare_image']]);
+            if (empty($params['spare_image'])){
+                throw new Exception('请上传配件图片');
             }
+            //修改
+            ServiceWorkSpare::where("id",$params['id'])->where('service_worker_id', $work['id'])->update(['spare_image' => $params['spare_image']]);
+            
             Db::commit();
             return true;
         } catch (\Exception $e) {

+ 1 - 1
app/common/model/works/ServiceWorkSpare.php

@@ -45,7 +45,7 @@ class ServiceWorkSpare extends BaseModel
         
         $lists = self::where('service_work_id', $service_work_id)
                     ->where($where)
-                    ->field("id,spare_part_id, spare_name, spare_image, company_price, original_price, offering_price, spare_number,spare_unit,brand")
+                    ->field("id,spare_part_id, spare_name, spare_image, company_price, original_price, offering_price, spare_number,spare_unit,brand,status,remark")
                     ->select()
                     ->toArray();
         return $lists;

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

@@ -427,5 +427,21 @@ class WorksController extends BaseApiController
         return $this->success('抢单成功', [], 1, 1);
     }
 
+    /**
+     * 工程师修改自选配件信息
+     * @return \think\response\Json
+     * @author liugc <466014217@qq.com>
+     * @date 2025/5/7 15:08
+     */
+    public function selfSparePart()
+    {
+        $params = (new ServiceWorkValidate())->post()->goCheck('sparepart');
+        $result = ServiceWorkLogic::selfSparePart($params);
+        if (false === $result) {
+            return $this->fail(ServiceWorkLogic::getError());
+        }
+        return $this->success('修改成功', [], 1, 1);
+    }
+
 
 }

+ 7 - 1
app/workerapi/validate/ServiceWorkValidate.php

@@ -39,6 +39,7 @@ class ServiceWorkValidate extends BaseValidate
         'amount'=>'require',
         'finished_images'=>'require',
         'work_images'=>'require',
+        'spare_image'  => 'require',
     ];
 
 
@@ -67,7 +68,8 @@ class ServiceWorkValidate extends BaseValidate
         'order_sn'=>'未获取到扫码信息',
         'amount'=>'报价',
         'finished_images'=>'完结服务拍照',
-        'work_images'=>'工作拍照'
+        'work_images'=>'工作拍照',
+        'spare_image'  =>'配件图片',
     ];
 
     /**
@@ -142,4 +144,8 @@ class ServiceWorkValidate extends BaseValidate
     {
         return $this->only(['id']);
     }
+    public function sceneSparepart()
+    {
+        return $this->only(['id','work_sn','spare_image']);
+    }
 }