Browse Source

fir goods detail

stanley-king 8 years ago
parent
commit
7b284dbf05
3 changed files with 52 additions and 11 deletions
  1. 35 9
      helper/brand_helper.php
  2. 6 2
      helper/model/goods_summary.php
  3. 11 0
      helper/predeposit_helper.php

+ 35 - 9
helper/brand_helper.php

@@ -17,7 +17,7 @@ class brand_helper
 
     private $mBrandPageResult;
     private $mTimeInterval;
-    private $mCountries;
+    private $mBaseInfo;
 
     private function __construct()
     {
@@ -39,8 +39,26 @@ class brand_helper
     public function country($brand_id)
     {
         $brand_id = intval($brand_id);
-        if(array_key_exists($brand_id,$this->mCountries)) {
-            return $this->mCountries[$brand_id];
+        if(array_key_exists($brand_id,$this->mBaseInfo)) {
+            return $this->mBaseInfo[$brand_id]['country'];
+        } else {
+            return '';
+        }
+    }
+    public function country_logo($brand_id)
+    {
+        $brand_id = intval($brand_id);
+        if(array_key_exists($brand_id,$this->mBaseInfo)) {
+            return $this->mBaseInfo[$brand_id]['country_logo'];
+        } else {
+            return '';
+        }
+    }
+    public function author_desc($brand_id)
+    {
+        $brand_id = intval($brand_id);
+        if(array_key_exists($brand_id,$this->mBaseInfo)) {
+            return $this->mBaseInfo[$brand_id]['author_desc'];
         } else {
             return '';
         }
@@ -50,11 +68,12 @@ class brand_helper
     {
         $prefix = 'mb_';
         $ret = rcache('brandex', $prefix);
-        if (empty($ret) || empty($this->mCountries)) {
+        if (empty($ret) || empty($this->mBaseInfo))
+        {
             $model = Model('brand');
-            $items = $model->field('brand_id,brand_logo,brand_name,brand_country')->where(array('brand_apply' => '1'))->order('brand_sort asc')->limit(false)->select();
+            $items = $model->field('brand_id,brand_logo,brand_name,brand_country,brand_country_logo,author_desc')->where(array('brand_apply' => '1'))->order('brand_sort asc')->limit(false)->select();
 
-            $this->mCountries = [];
+            $this->mBaseInfo = [];
             $brands = [];
             foreach ($items as $brand)
             {
@@ -68,13 +87,20 @@ class brand_helper
                 } else {
                     Log::record("cant getimagesize {$image}." ,Log::ERR);
                 }
-                $brand_id = intval($brand['brand_id']);
-                $this->mCountries[$brand_id] = $brand['brand_country'];
+                $brand_id = intval($brand['brand_country_logo']);
+
+                if(empty($brand['brand_logo'])) {
+                    $this->mBaseInfo[$brand_id]['country_logo'] = '';
+                } else {
+                    $this->mBaseInfo[$brand_id]['country_logo'] = UPLOAD_SITE_URL . $brand['brand_country_logo'];
+                }
+
+                $this->mBaseInfo[$brand_id]['country'] = $brand['brand_country'];
+                $this->mBaseInfo[$brand_id]['author_desc'] = $brand['author_desc'];
             }
 
             $block = special_formater::format_grid_brands($brands);
             wcache("brandex", array("brands" => serialize($brands), "block" => serialize($block)), $prefix);
-
             $result = array("brands" => $brands, "block" => $block);
         } else {
             $brands = unserialize($ret['brands']);

+ 6 - 2
helper/model/goods_summary.php

@@ -89,8 +89,10 @@ class goods_summary
         $summary['store_id'] = intval($this->goods_info['store_id']);
         $summary['brand_id'] = intval($this->goods_info['brand_id']);
         $summary['brand_country'] = brand_helper::instance()->country($summary['brand_id']);
-        $summary['gc_id'] = intval($this->goods_info['gc_id']);
+        $summary['brand_country_logo'] = brand_helper::instance()->country_logo($summary['brand_id']);
+        $summary['brand_author_desc'] = brand_helper::instance()->author_desc($summary['brand_id']);
 
+        $summary['gc_id'] = intval($this->goods_info['gc_id']);
         $summary['goods_price'] = $this->goods_info['goods_price'];
         $summary['goods_marketprice'] = $this->goods_info['goods_marketprice'];
         $summary['goods_promotion_price'] = $this->goods_info['goods_promotion_price'];
@@ -146,9 +148,11 @@ class goods_summary
             $summary['act_type'] = $act_type;
         }
         if($act_id == false && empty($this->bundles)) {
-            $summary['bonus_price'] = predeposit_helper::bonus_price($this->goods_info['goods_price'],$rates);
+            $summary['bonus_price']  = predeposit_helper::bonus_price($this->goods_info['goods_price'],$rates);
+            $summary['discount_gap'] = predeposit_helper::discount_gap($summary['bonus_price'],$this->goods_info['goods_price']);
         } else {
             $summary['bonus_price'] = $this->goods_info['goods_price'];
+            $summary['discount_gap'] = 0;
         }
 
         return $summary;

+ 11 - 0
helper/predeposit_helper.php

@@ -312,6 +312,17 @@ class predeposit_helper
             return $goods_price;
         }
     }
+    static public function discount_gap($bonus_price,$goods_price)
+    {
+        $bonus_price = intval($bonus_price* 100 + 0.5);
+        $discount = intval($goods_price * 70 + 0.5);
+
+        if($bonus_price <= $discount) {
+            return 0;
+        } else {
+            return ($discount - $bonus_price) / 100;
+        }
+    }
 
     public function bonus_state() {
         return $this->mBonusState;