rabin 6 months ago
parent
commit
e847fefced
1 changed files with 24 additions and 17 deletions
  1. 24 17
      src/place/lib/Vip.php

+ 24 - 17
src/place/lib/Vip.php

@@ -23,23 +23,7 @@ class Vip
         $data = array();
         if (Place::$user[$this->type . '_id'] > 0) {
             $data['info'] = Dever::db($this->type, 'place')->find(Place::$user[$this->type . '_id']);
-            $data['price'] = Dever::db($this->type . '_price', 'place')->select(array($this->type . '_id' => $data['info']['id']), array('col' => 'per,total,type'));
-            if ($data['price']) {
-                foreach ($data['price'] as &$v) {
-                    if ($v['total'] > 0) {
-                        if ($v['type'] == 1) {
-                            $v['total'] = '每日可下载共'.$v['total'].'次';
-                        } elseif ($v['type'] == 2) {
-                            $v['total'] = '每日可使用共'.$v['total'].'次';
-                        } elseif ($v['type'] == 3) {
-                            $v['total'] = '每次最多购买'.$v['total'].'个';
-                        }
-                    }
-                    
-                    $v['per'] = $v['per'] . '%';
-                    $v['name'] = Dever::db('resource', 'place')->value('type', $v['type']);
-                }
-            }
+            $data['price'] = $this->getPrice($data['info']['id']);
         }
         return $data;
     }
@@ -64,11 +48,34 @@ class Vip
                 } elseif ($user && $v['pay'] == 1) {
                     $v['price'] -= $user['price'];
                 }
+                $v['price_list'] = $this->getPrice($v['id']);
             }
         }
         return $data;
     }
 
+    public function getPrice($id)
+    {
+        $price = Dever::db($this->type . '_price', 'place')->select(array($this->type . '_id' => $id), array('col' => 'per,total,type'));
+        if ($price) {
+            foreach ($price as &$v) {
+                if ($v['total'] > 0) {
+                    if ($v['type'] == 1) {
+                        $v['total'] = '每日可下载共'.$v['total'].'次';
+                    } elseif ($v['type'] == 2) {
+                        $v['total'] = '每日可使用共'.$v['total'].'次';
+                    } elseif ($v['type'] == 3) {
+                        $v['total'] = '每次最多购买'.$v['total'].'个';
+                    }
+                }
+                
+                $v['per'] = $v['per'] . '%';
+                $v['name'] = Dever::db('resource', 'place')->value('type', $v['type']);
+            }
+        }
+        return $price;
+    }
+
     # 获取列表
     public function getList($state = true)
     {