dever 3 rokov pred
rodič
commit
d43b723b96
2 zmenil súbory, kde vykonal 19 pridanie a 1 odobranie
  1. 11 0
      app/shop/lib/Sell.php
  2. 8 1
      app/shop/src/Buy.php

+ 11 - 0
app/shop/lib/Sell.php

@@ -79,6 +79,17 @@ class Sell
             }
             # 使用优惠券
             $this->useCoupon($user_coupon_id);
+
+            if ($card) {
+                # 更新礼品卡状态
+                $card_update['where_id'] = $card['id'];
+                $card_update['status'] = 2;
+                $card_update['uid'] = $uid;
+                $card_update['shop_id'] = $shop['id'];
+                $card_update['order_id'] = $id;
+                $card_update['ddate'] = time();
+                Dever::db('goods/card_code')->update($card_update);
+            }
         	return 'ok';
         }
 

+ 8 - 1
app/shop/src/Buy.php

@@ -306,7 +306,14 @@ class Buy extends Core
             if (!$this->data['card']) {
                 Dever::alert('卡号/密码错误');
             }
-            $goods = Dever::array_decode($this->data['card']['goods']);
+            if (time() > $this->data['card']['edate']) {
+                Dever::alert('礼品卡已失效');
+            }
+            $card_info = Dever::db('goods/card_code')->find($this->data['card']['card_id']);
+            if (!$card_info) {
+                Dever::alert('卡号/密码错误');
+            }
+            $goods = Dever::array_decode($card_info['goods']);
 
             $goods_id = array();
             $num = array();