Ver Fonte

提交订单退款

whitefang há 1 ano atrás
pai
commit
5e6e2de281

+ 17 - 0
app/api/controller/ServiceOrderController.php

@@ -264,6 +264,23 @@ class ServiceOrderController extends BaseApiController
         return $this->success('已提交改约', [], 1, 1);
     }
 
+    /**
+     * 提交退款申请
+     * @return \think\response\Json
+     */
+    public function approvalRefund()
+    {
+        $params = (new ServiceOrderValidate())->post()->goCheck('changePrice', [
+            'user_id' => $this->userId,
+            'user_info' => $this->userInfo
+        ]);
+        $result = ServiceOrderLogic::approvalRefund($params);
+        if (false === $result) {
+            return $this->fail(ServiceOrderLogic::getError());
+        }
+        return $this->success('已提交申请,等待客服确认中', [], 1, 1);
+    }
+
 
 
 }

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

@@ -808,4 +808,26 @@ class ServiceOrderLogic extends BaseLogic
         }
     }
 
+    public static function approvalRefund($params)
+    {
+        Db::startTrans();
+        try {
+            $order = RechargeOrder::where('sn',$params['sn'])->findOrEmpty();
+            if($order->isEmpty()){
+                throw new Exception('订单不存在');
+            }
+            $work = ServiceWork::findOrEmpty($order->work_id);
+            if($work->isEmpty()){
+                throw new Exception('工单不存在');
+            }
+            $work->refund_approval = 1;
+            $work->save();
+            Db::commit();
+        }
+        catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
 }