rabin 3 лет назад
Родитель
Сommit
bd6c762f08
1 измененных файлов с 35 добавлено и 36 удалено
  1. 35 36
      app/card/src/Api.php

+ 35 - 36
app/card/src/Api.php

@@ -274,6 +274,7 @@ class Api extends Core
         $goods_id = Dever::input('goods_id');
         if ($goods_id) {
             $data = array();
+            $data['shop'] = $this->shop;
             Dever::load('shop/lib/sell')->goods($data);
         }
 
@@ -293,6 +294,7 @@ class Api extends Core
         $card = Dever::db('card/code')->getData(array('dh_uid' => $this->uid));
 
         $this->data['card'] = array();
+        $this->data['no_card'] = array();
         if ($card) {
             foreach ($card as $k => $v) {
                 $v['info'] = Dever::db('card/info')->find($v['card_id']);
@@ -343,49 +345,46 @@ class Api extends Core
 
                 if ($v['info']['min'] > 0 && $price < $v['info']['min']) {
                     # 不满足限额 不可用
-                    continue;
+                    $no = true;
                 } else {
-                    $data['card'] = array();
-                    $data['card']['goods'] = $card_goods;
-                    $data['card']['id'] = $check['id'];
-                    $data['card']['card'] = $check['card'];
-                    if ($card_cash >= $price) {
-                        $data['card']['cash'] = $price;
-                        $data['price'] = 0;
-                    } else {
-                        $data['card']['cash'] = $card_cash;
-                        $data['price'] -= $data['card']['cash'];
-                    }
-                    $data['card']['cash'] = round($data['card']['cash'], 2);
+                    # 可用
+                    $no = false;
                 }
 
-                
-                $v['type'] = $type = Dever::db('card/type')->find($v['info']['type_id']);
+                if ($no) {
+                    $this->data['no_card'][] = $v;
+                } else {
+                    $v['type'] = $type = Dever::db('card/type')->find($v['info']['type_id']);
 
-                $type['shop_type'] = explode(',', $type['shop_type']);
-                if (in_array($shop_type, $type['shop_type'])) {
-                    if ($type['city_type'] == 1) {
-                        $this->data['card'][] = $v;
-                    } else {
-                        $city = $v['city'];
-                        if (!$city) {
-                            $card_order = Dever::db('card/order_card')->find($v['order_card_id']);
-                            if ($card_order && $card_order['city']) {
-                                $city = $card_order['city'];
-                            }
-                        }
-                        if ($city && $city == $cur_city) {
-                            $this->data['card'][] = $v;
-                        }
-                        /*
-                        $type['city'] = explode(',', $type['city']);
-                        if (in_array($city, $type['city'])) {
+                    $type['shop_type'] = explode(',', $type['shop_type']);
+                    if (in_array($shop_type, $type['shop_type'])) {
+                        if ($type['city_type'] == 1) {
                             $this->data['card'][] = $v;
+                        } else {
+                            $city = $v['city'];
+                            if (!$city) {
+                                $card_order = Dever::db('card/order_card')->find($v['order_card_id']);
+                                if ($card_order && $card_order['city']) {
+                                    $city = $card_order['city'];
+                                }
+                            }
+                            if ($city && $city == $cur_city) {
+                                $this->data['card'][] = $v;
+                            } else {
+                                $this->data['no_card'][] = $v;
+                            }
+                            /*
+                            $type['city'] = explode(',', $type['city']);
+                            if (in_array($city, $type['city'])) {
+                                $this->data['card'][] = $v;
+                            }
+                            */
                         }
-                        */
+                    } elseif ($v['shop_id'] && $v['shop_id'] == $this->shop_id) {
+                        $this->data['card'][] = $v;
+                    } else {
+                        $this->data['no_card'][] = $v;
                     }
-                } elseif ($v['shop_id'] && $v['shop_id'] == $this->shop_id) {
-                    $this->data['card'][] = $v;
                 }
             }
         }