Browse Source

fix:确认收货的

super-yimizi 2 months ago
parent
commit
716d828318
1 changed files with 9 additions and 13 deletions
  1. 9 13
      application/api/controller/Order.php

+ 9 - 13
application/api/controller/Order.php

@@ -286,31 +286,27 @@ class Order extends Base
     {
     {
         // 验证请求参数
         // 验证请求参数
         $validate = new \app\api\validate\Order();
         $validate = new \app\api\validate\Order();
-        $params = ['order_sn' => $this->request->post('order_sn')];
+        $orderId = $this->request->post('orderId');
+        $params = ['orderId' => $orderId];
         if (!$validate->scene('detail')->check($params)) {
         if (!$validate->scene('detail')->check($params)) {
             $this->error($validate->getError());
             $this->error($validate->getError());
-        }
-        
-        $order_sn = $this->request->post('order_sn');
-        $order = OrderModel::getByOrderSn($order_sn);
+        }        
+        $order = OrderService::getByOrderId($orderId);
         if (empty($order)) {
         if (empty($order)) {
             $this->error('订单不存在');
             $this->error('订单不存在');
         }
         }
         if ($order->user_id != $this->auth->id) {
         if ($order->user_id != $this->auth->id) {
-            $this->error('不能越权操作');
-        }
-        if ($order->status == 'hidden') {
-            $this->error('订单已失效!');
+            $this->error('该订单不属于当前用户');
         }
         }
-        if ($order->paystate == 1 && !$order->orderstate && $order->shippingstate == 1) {
-            $order->shippingstate = 2;
-            $order->receivetime = time();
+        if ($order->canConfirmHandle()) {
+            $order->order_status = OrderEnum::STATUS_CONFIRM;
+            $order->receive_time = time();
             $order->save();
             $order->save();
             //记录操作
             //记录操作
             OrderAction::push($order->order_sn, '系统', '订单确认收货成功');
             OrderAction::push($order->order_sn, '系统', '订单确认收货成功');
             $this->success('确认收货成功');
             $this->success('确认收货成功');
         }
         }
-        $this->error('未可确认收货');
+        $this->error('订单不允许确认收货');
     }
     }
 
 
     //查询物流
     //查询物流