Bläddra i källkod

修改工单配件

dongxiaoqin 11 månader sedan
förälder
incheckning
e8cca4a17c

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

@@ -51,6 +51,7 @@ use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
 use app\common\model\master_commission\MasterWorkerCommissionRatio;
 use app\common\model\master_commission\MasterWorkerCommissionRatio;
 use app\common\model\master_commission\MasterWorkerCommissionConfig;
 use app\common\model\master_commission\MasterWorkerCommissionConfig;
 use app\common\model\service_area\ServiceArea;
 use app\common\model\service_area\ServiceArea;
+use app\common\model\works\ServiceWorkSpareAudit;
 
 
 /**
 /**
  * ServiceWork逻辑
  * ServiceWork逻辑
@@ -407,6 +408,40 @@ class ServiceWorkLogic extends BaseLogic
         }
         }
     }
     }
 
 
+    /**
+     * 工程师修改自选配件的图片
+     * @param $params
+     * @return false|void
+     */
+    public static function selfSparePart($params)
+    {
+        Db::startTrans();
+        try {
+            $work = ServiceWork::where(['master_worker_id'=>$params['user_id'],'work_sn'=>$params['work_sn']])->findOrEmpty();
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+            $audit = ServiceWorkSpareAudit::where(['service_work_id'=>$work['id']])->findOrEmpty();
+            if($audit->isEmpty()){
+                throw new Exception('当前工单不存在配件审核信息');
+            }
+            if($audit['status']!=2){
+                throw new Exception('当前工单配件不允许修改');
+            }
+            
+            foreach ($params['self_spare_parts'] as $item){
+                //修改
+                ServiceWorkSpare::where("id",$item['id'])->where('service_worker_id', $work['id'])->update(['spare_image' => $item['spare_image']]);
+            }
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
     /**
     /**
      * 工程师确认服务完成
      * 工程师确认服务完成
      * @param $params
      * @param $params

+ 5 - 0
app/api/logic/ServiceOrderLogic.php

@@ -33,6 +33,7 @@ use app\common\model\works\ServiceWork;
 use app\common\model\works\ServiceWorkAppointmentLog;
 use app\common\model\works\ServiceWorkAppointmentLog;
 use app\common\model\works\ServiceWorkDeterminedPrice;
 use app\common\model\works\ServiceWorkDeterminedPrice;
 use app\common\model\works\ServiceWorkSpare;
 use app\common\model\works\ServiceWorkSpare;
+use app\common\model\works\ServiceWorkSpareAudit;
 use app\workerapi\logic\ServiceWorkLogLogic;
 use app\workerapi\logic\ServiceWorkLogLogic;
 use think\Exception;
 use think\Exception;
 use think\facade\Db;
 use think\facade\Db;
@@ -530,9 +531,13 @@ class ServiceOrderLogic extends BaseLogic
             $order_info['spare_total'] = $order_info['service_work']['spare_total']??0;
             $order_info['spare_total'] = $order_info['service_work']['spare_total']??0;
             $order_info['spare_parts'] = [];
             $order_info['spare_parts'] = [];
             $order_info['self_spare_parts'] = [];
             $order_info['self_spare_parts'] = [];
+            $result['spare_parts_audit_status'] = 0;//自选配件审核状态
             if($order_info['service_work']['spare_total']){
             if($order_info['service_work']['spare_total']){
                 $order_info['spare_parts'] = ServiceWorkSpare::getLists($order_info['work_id'], 1);
                 $order_info['spare_parts'] = ServiceWorkSpare::getLists($order_info['work_id'], 1);
                 $order_info['self_spare_parts'] = ServiceWorkSpare::getLists($order_info['work_id'], 2);
                 $order_info['self_spare_parts'] = ServiceWorkSpare::getLists($order_info['work_id'], 2);
+                if ($result['self_spare_parts']) {
+                    $result['spare_parts_audit_status'] = (int)ServiceWorkSpareAudit::where(['service_work_id' => $result['id']])->value('status');
+                }
             }
             }
 
 
             //获取所有的改约记录
             //获取所有的改约记录