Browse Source

订单验证

shish 4 years ago
parent
commit
361d72840b

+ 2 - 2
app-mall/controllers/OrderController.php

@@ -220,7 +220,7 @@ class OrderController extends BaseController
         //验证支付密码是否正确
         UserService::validPayPassword($payPassword, $user);
         //支付前验证订单有效性
-        OrderService::checkBeforePay($order, $this->userId);
+        OrderService::checkBeforePay($order);
         $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
         $totalFee = $order['prePrice'];
         $sourceType = 0;
@@ -248,7 +248,7 @@ class OrderController extends BaseController
         }
 
         //支付前验证订单有效性
-        OrderService::checkBeforePay($order, $this->userId);
+        OrderService::checkBeforePay($order);
 
         $name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品';
         $totalFee = $order['realPrice'];

+ 2 - 5
biz-hd/order/services/OrderService.php

@@ -339,16 +339,13 @@ class OrderService extends BaseService
     }
 
     //支付前验证订单 ssh 2019.12.6
-    public static function checkBeforePay($order, $customId)
+    public static function checkBeforePay($order)
     {
         $now = time();
-        OrderClass::setExpire($order);
         if (empty($order)) {
             util::fail('订单无效');
         }
-        if (isset($order['userId']) && $order['userId'] != $customId) {
-            util::fail('非法访问');
-        }
+
         if ($order['status'] != 0) {
             util::fail('订单不是待付款状态');
         }

+ 5 - 8
biz-mall/order/services/OrderService.php

@@ -32,16 +32,17 @@ class OrderService extends BaseService
         $shopId = $data['shopId'] ?? 0;
         $userId = $data['userId'] ?? 0;
         $mainId = $data['mainId'] ?? 0;
-
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
-        $custom = [];
         $customId = 0;
         $hdId = 0;
         if (!empty($userId)) {
             $custom = CustomClass::getByCondition(['shopId' => $shopId, 'userId' => $userId], true);
+            if (empty($custom)) {
+                util::fail('没有找到客户');
+            }
             $customId = $custom->id ?? 0;
         } else {
             $defaultCustomId = $shop->defaultCustomId ?? 0;
@@ -242,20 +243,16 @@ class OrderService extends BaseService
     }
 
     //支付前验证订单 ssh 2019.12.6
-    public static function checkBeforePay($order, $userId)
+    public static function checkBeforePay($order)
     {
         $now = time();
-        OrderClass::setExpire($order);
         if (empty($order)) {
             util::fail('订单无效');
         }
-        if (isset($order['userId']) && $order['userId'] != $userId) {
-            util::fail('非法访问');
-        }
         if ($order['status'] != 1) {
             util::fail('订单不是待付款状态');
         }
-        if (!empty($order['deadline']) && $now > $order['deadline']) {
+        if ($order['deadline'] <= ($now - 60)) {
             util::fail('订单已过期');
         }
         if (ceil($order['actPrice']) <= 0) {