rabin 2 jaren geleden
bovenliggende
commit
0fd02b07f9
1 gewijzigde bestanden met toevoegingen van 20 en 3 verwijderingen
  1. 20 3
      app/shop/src/My.php

+ 20 - 3
app/shop/src/My.php

@@ -20,9 +20,26 @@ class My extends Core
 		# 获取拥有的优惠券数量
 		$this->data['coupon_num'] = Dever::db('shop/user_coupon')->total(array('uid' => $this->uid, 'status' => 1));
 
-		$this->data['card_num'] = Dever::db('card/code')->total(array('dh_uid' => $this->uid));
-		if ($this->data['card_num'] > 0) {
-			
+		$card = Dever::db('card/code')->getData(array('dh_uid' => $this->uid));
+		//$this->data['card_num'] = Dever::db('card/code')->total(array('dh_uid' => $this->uid));
+		$this->data['card_num'] = 0;
+		if ($card) {
+			foreach ($card as $k => $v) {
+				$v['info'] = Dever::db('card/info')->find($v['card_id']);
+                if (!$v['info']) {
+                    continue;
+                }
+                if ($v['info']['end_dh_day'] && $v['info']['end_dh_day'] > 0) {
+                    $v['eddate'] = ($v['bdate'] ? $v['bdate'] : $v['cdate']) + ($v['info']['end_dh_day'] * 86400);
+                }
+
+                if (isset($v['eddate']) && $v['eddate'] && $v['eddate'] > 0) {
+                    if ($v['eddate'] <= $time) {
+                        continue;
+                    }
+                }
+                $this->data['card_num']++;
+			}
 		}
 
 		$this->data['score'] = Dever::load('score/lib/core')->getUserScore($this->uid);