Kirin 2 years ago
parent
commit
6a21b155a3
1 changed files with 11 additions and 9 deletions
  1. 11 9
      app/admin/controller/store/Placeorder.php

+ 11 - 9
app/admin/controller/store/Placeorder.php

@@ -121,15 +121,17 @@ class Placeorder extends AuthController
         $product = \app\admin\model\store\StoreProduct::get($info['product_id']);
         $discounts = json_decode($product['time_area_discount'], true);
         $discount = 0;
-        foreach ($discounts as $kk => $v) {
-            $times = explode('-', $kk);
-            if (!(count($times) == 2)) {
-                break;
-            }
-            $start = strtotime(date('Y-m-d') . $times[0]);
-            $end = strtotime(date('Y-m-d') . $times[1]);
-            if (time() > $start && time() <= $end) {
-                $discount = $v;
+        if (count($discounts) > 0) {
+            foreach ($discounts as $kk => $v) {
+                $times = explode('-', $kk);
+                if (!(count($times) == 2)) {
+                    break;
+                }
+                $start = strtotime(date('Y-m-d') . $times[0]);
+                $end = strtotime(date('Y-m-d') . $times[1]);
+                if (time() > $start && time() <= $end) {
+                    $discount = $v;
+                }
             }
         }
         if ($discount > 0) {