浏览代码

修复:购物车商品结算时未验证订单是否存在错误

萤火科技 5 年之前
父节点
当前提交
98c611f0f9
共有 1 个文件被更改,包括 5 次插入 和 1 次删除
  1. 5 1
      app/api/controller/Checkout.php

+ 5 - 1
app/api/controller/Checkout.php

@@ -112,7 +112,7 @@ class Checkout extends Controller
         if ($this->request->isGet()) {
             return $this->renderSuccess(['order' => $orderInfo]);
         }
-        // 订单结算提交
+        // 验证订单是否存在错误
         if ($Checkout->hasError()) {
             return $this->renderError($Checkout->getError(), ['is_created' => false]);
         }
@@ -155,6 +155,10 @@ class Checkout extends Controller
         if ($this->request->isGet()) {
             return $this->renderSuccess(['order' => $orderInfo]);
         }
+        // 验证订单是否存在错误
+        if ($Checkout->hasError()) {
+            return $this->renderError($Checkout->getError(), ['is_created' => false]);
+        }
         // 创建订单
         if (!$Checkout->createOrder($orderInfo)) {
             return $this->renderError($Checkout->getError() ?: '订单创建失败');