whitefang пре 1 година
родитељ
комит
58bde1ff7a
1 измењених фајлова са 9 додато и 12 уклоњено
  1. 9 12
      app/adminapi/logic/works/ServiceWorkLogic.php

+ 9 - 12
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -621,29 +621,26 @@ class ServiceWorkLogic extends BaseLogic
             if((int)$serviceWorkInfo['user_confirm_status'] === 5 || (int)$serviceWorkInfo['service_status'] > 2){
                 throw new \Exception('用户已完结该工单或已取消,已退款,不可执行取消');
             }
+
+            //工单如果存在费用情况,不允许取消
+            $paid_amount = RechargeOrder::where('work_id', $params['id'])->where('pay_status', 1)->value('paid_amount');
+            if($paid_amount > 0){
+                // 4=已上门,5=服务中,6=待结算, 即工程师已上门服务过
+                throw new Exception('工单存在费用情况,不允许取消,请走退费流程');
+            }
+
             ServiceWork::where('id', $params['id'])->update([
                 //'work_status' => 9,
                 'service_status' => 4,
                 'remark' => $params['remark']??''
             ]);
-            /*// 对应订单状态修改
-            RechargeOrder::where('work_id', $params['id'])->update([
-                'pay_status' => 2
-            ]);*/
+
             ServiceWorkLog::create([
                 'work_id' => $params['id'],
                 'master_worker_id' => $serviceWorkInfo['master_worker_id'],
                 'opera_log' => "工单:{$serviceWorkInfo['work_sn']}已取消"
             ]);
 
-            $paid_amount = RechargeOrder::where('work_id', $params['id'])->where('payment_type', 1)->where('order_type', 0)->where('pay_status', 1)->value('paid_amount');
-            if($paid_amount > 0){
-                // 4=已上门,5=服务中,6=待结算, 即工程师已上门服务过
-                if(in_array((int)$serviceWorkInfo['work_status'], [4,5,6])){
-                    WorkerAccountLogLogic::addAccountLog($serviceWorkInfo,$paid_amount,WorkerAccountLogEnum::UM_INC_ADMIN,WorkerAccountLogEnum::INC,$params['remark']??'');
-                }
-            }
-
             Db::commit();
             Log::info('取消工单'.json_encode([$serviceWorkInfo]));
             return true;