소스 검색

add brand country

stanley-king 8 년 전
부모
커밋
71261d4ee6

+ 0 - 1
admin/templates/default/css/skin_0.css

@@ -1641,7 +1641,6 @@ td.trigger i:hover { color: #27A9E3;}
 .dialog-image-desc { color: #999;}
 #dialog_item_image { max-width: 480px; max-height: 300px;}
 
-
 .brand-mobile-picture img{
 	max-width: 50px;
 	max-height: 50px;

+ 1 - 1
admin/templates/default/layout/index_layout.php

@@ -4,7 +4,7 @@
 <head>
 <meta http-equiv="Content-Type" content="text/html;" charset="<?php echo CHARSET;?>">
 <title><?php echo $output['html_title'];?></title>
-<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/skin_0.css" rel="stylesheet" type="text/css" id="cssfile"/>
+<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/skin_0.css?1" rel="stylesheet" type="text/css" id="cssfile"/>
 
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.js"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.validation.min.js"></script>

+ 1 - 1
admin/templates/default/layout/layout.php

@@ -10,7 +10,7 @@
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/admincp.js"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.cookie.js"></script>
 <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/common.js" charset="utf-8"></script>
-<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/skin_0.css" rel="stylesheet" type="text/css" id="cssfile2" />
+<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/skin_0.css?1" rel="stylesheet" type="text/css" id="cssfile2" />
 <link href="<?php echo RESOURCE_SITE_URL;?>/js/perfect-scrollbar.min.css" rel="stylesheet" type="text/css">
 <link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/font/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
 <!--[if IE 7]>

+ 1 - 1
admin/templates/default/layout/msg_layout.php

@@ -4,7 +4,7 @@
 <head>
 <meta charset="<?php echo CHARSET;?>">
 <title><?php echo $output['html_title'];?></title>
-<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/skin_0.css" rel="stylesheet" type="text/css">
+<link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/skin_0.css?1" rel="stylesheet" type="text/css">
 </head>
 <body>
 <div class="page">

+ 2 - 2
centra_srv.php

@@ -8,9 +8,9 @@ require_once (BASE_ROOT_PATH . '/helper/search/processor.php');
 require_once (BASE_ROOT_PATH . '/helper/search/event_handler.php');
 require_once(BASE_ROOT_PATH . '/helper/search/util.php');
 require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/search/searcher.php');
-require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
-require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
 
 function search_work($sockfd)

+ 120 - 0
helper/brand_helper.php

@@ -0,0 +1,120 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2016/12/28
+ * Time: 下午12:31
+ */
+
+require_once(BASE_ROOT_PATH . '/helper/time_interval.php');
+
+
+class brand_helper
+{
+    static private $stInstance = null;
+    private $mBrandPageResult;
+    private $mTimeInterval;
+    private $mCountries;
+
+    private function __construct()
+    {
+        $this->mTimeInterval = new time_interval(60);
+    }
+
+    static public function instance()
+    {
+        if (self::$stInstance == null) {
+            self::$stInstance = new brand_helper();
+        }
+        if (self::$stInstance->mTimeInterval->need_init()) {
+            self::$stInstance->init();
+        }
+
+        return self::$stInstance;
+    }
+
+    public function country($brand_id)
+    {
+        $brand_id = intval($brand_id);
+        if(array_key_exists($brand_id,$this->mCountries)) {
+            return $this->mCountries[$brand_id];
+        } else {
+            return '';
+        }
+    }
+
+    private function init()
+    {
+        $prefix = 'mb_';
+        $ret = rcache('brandex', $prefix);
+        if (empty($ret)) {
+            $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();
+
+            $this->mCountries = [];
+            $brands = [];
+            foreach ($items as $brand) {
+                $image = UPLOAD_SITE_URL . $brand['brand_logo'];
+                $ret = getimagesize($image, $info);
+                if ($ret != false) {
+                    $brand['brand_logo'] = $image;
+                    $brands[] = $brand;
+                }
+                $brand_id = intval($brand['brand_id']);
+                $this->mCountries[$brand_id] = $brand['brand_country'];
+            }
+            $block = special_helper::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']);
+            $block = unserialize($ret['block']);
+            $result = array("brands" => $brands, "block" => $block);
+        }
+
+        $this->mBrandPageResult = $result;
+    }
+
+    public function brandex()
+    {
+        return $this->mBrandPageResult;
+    }
+
+    //////////for old interface/////////////////////////////////////////////////////////////////////////////////////////
+    static function brands()
+    {
+        $prefix = 'mb_';
+        $ret = rcache('brand', $prefix);
+        if (empty($ret)) {
+            $model = Model();
+            $brand_area_list = $model->table('brand_area')->order('area_sort asc')->limit(false)->select();
+            $filed = 'brand_id,brand_name,brand_pic,brand_img_bg,brand_img_logo,brand_area_id';
+            $brand_c_list = $model->table('brand')->field($filed)->where(array('brand_apply' => '1'))->order('brand_sort asc')->limit(false)->select();
+
+            $brands = array();
+            foreach ($brand_area_list as $brand_area) {
+                foreach ($brand_c_list as $brand) {
+                    $brand['brand_pic'] = image_helper::format_brand_img_rect($brand['brand_pic']);
+                    $brand['brand_img_bg'] = image_helper::format_brand_img_bg($brand['brand_img_bg']);
+                    $brand['brand_img_logo'] = image_helper::format_brand_img_circle($brand['brand_img_logo']);
+                    if ($brand['brand_area_id'] == $brand_area['area_id']) {
+                        if (empty($brand_area['data'])) {
+                            $brand_area['data'] = array();
+                        }
+                        array_push($brand_area['data'], $brand);
+                    }
+                }
+                if (!empty($brand_area['data'])) {
+                    array_push($brands, $brand_area);
+                }
+            }
+
+            wcache("brand", array("brands" => serialize($brands)), $prefix);
+        } else {
+            $brands = unserialize($ret['brands']);
+        }
+
+        return $brands;
+    }
+}

+ 0 - 75
helper/category_helper.php

@@ -170,79 +170,4 @@ class category_helper
 EOD;
         return $content;
     }
-}
-
-class brand_helper
-{
-    static function brandex()
-    {
-        $prefix = 'mb_';
-        $ret = rcache('brandex', $prefix);
-        if(empty($ret))
-        {
-            $model = Model('brand');
-            $items = $model->field('brand_id,brand_logo,brand_name')->where(array('brand_apply' => '1'))->order('brand_sort asc')->limit(false)->select();
-
-            $brands = [];
-            foreach ($items as $brand) {
-                $image = UPLOAD_SITE_URL . $brand['brand_logo'];
-                $ret = getimagesize($image,$info);
-                if($ret != false) {
-                    $brand['brand_logo'] = $image;
-                    $brands[] = $brand;
-                }
-            }
-            $block = special_helper::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']);
-            $block = unserialize($ret['block']);
-            $result = array("brands" => $brands,"block" => $block);
-        }
-
-        return $result;
-    }
-
-    static function brands()
-    {
-        $prefix = 'mb_';
-        $ret = rcache('brand', $prefix);
-        if(empty($ret))
-        {
-            $model = Model();
-            $brand_area_list = $model->table('brand_area')->order('area_sort asc')->limit(false)->select();
-            $filed = 'brand_id,brand_name,brand_pic,brand_img_bg,brand_img_logo,brand_area_id';
-            $brand_c_list = $model->table('brand')->field($filed)->where(array('brand_apply' => '1'))->order('brand_sort asc')->limit(false)->select();
-
-            $brands = array();
-            foreach ($brand_area_list as $brand_area)
-            {
-                foreach ($brand_c_list as $brand) {
-                    $brand['brand_pic'] = image_helper::format_brand_img_rect($brand['brand_pic']);
-                    $brand['brand_img_bg'] = image_helper::format_brand_img_bg($brand['brand_img_bg']);
-                    $brand['brand_img_logo'] = image_helper::format_brand_img_circle($brand['brand_img_logo']);
-                    if ($brand['brand_area_id'] == $brand_area['area_id']) {
-                        if (empty($brand_area['data'])) {
-                            $brand_area['data'] = array();
-                        }
-                        array_push($brand_area['data'], $brand);
-                    }
-                }
-                if (!empty($brand_area['data'])) {
-                    array_push($brands, $brand_area);
-                }
-            }
-
-            wcache("brand", array("brands" => serialize($brands)), $prefix);
-        } else {
-            $brands = unserialize($ret['brands']);
-        }
-
-        return $brands;
-    }
-
-
-
 }

+ 1 - 0
helper/model/goods_summary.php

@@ -88,6 +88,7 @@ class goods_summary
         $summary['goods_jingle'] = $this->goods_info['goods_jingle'];
         $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['goods_price'] = $this->goods_info['goods_price'];

+ 1 - 1
helper/search/searcher.php

@@ -9,7 +9,7 @@
 namespace search;
 
 use algorithm;
-use brand_helper;
+use \brand_helper;
 use category_helper;
 use Model;
 

+ 34 - 0
helper/time_interval.php

@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2016/12/28
+ * Time: 下午2:25
+ */
+class time_interval
+{
+    private $reset_time;
+    private $interval;
+
+    public function __construct($interval = 60) {
+        $this->reset_time = 0;
+        $this->interval = $interval;
+    }
+
+    public function need_init()
+    {
+        if($this->reset_time == 0) {
+            $this->reset_time = time();
+            return true;
+        }
+        else if((time() - $this->reset_time) < $this->interval) {
+            return false;
+        }
+        else
+        {
+            $this->reset_time = time();
+            return true;
+        }
+    }
+}

+ 2 - 1
mobile/control/bonusex.php

@@ -14,6 +14,7 @@ require_once (BASE_ROOT_PATH . '/helper/session_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/sms_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/model_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/brand_helper.php');
 
 class bonusexControl extends mobileControl
 {
@@ -768,7 +769,7 @@ function bonus_brands()
         return;
     }
 
-    $brandsex = brand_helper::brandex();
+    $brandsex = brand_helper::instance()->brandex();
     if(empty($brandsex)) return;
     $brands = $brandsex['brands'];
     if(empty($brands)) return;

+ 2 - 2
mobile/control/brand.php

@@ -6,7 +6,7 @@
 
 defined('InShopNC') or exit('Access Invalid!');
 
-require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 
 class brandControl extends mobileHomeControl
 {
@@ -16,7 +16,7 @@ class brandControl extends mobileHomeControl
 
     public function homeOp()
     {
-        $brands = brand_helper::brandex();
+        $brands = brand_helper::instance()->brandex();
         $blocks = [];
         $blocks[] = $brands['block'];
         self::outsuccess(array("special_list" => $blocks,'mobile_page' => mobile_page(1)));

+ 1 - 0
mobile/control/search.php

@@ -4,6 +4,7 @@
 defined('InShopNC') or exit('Access Invalid!');
 
 require_once (BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once (BASE_ROOT_PATH . '/helper/brand_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/history_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/special_helper.php');
 require_once (BASE_ROOT_PATH . '/helper/goods_helper.php');

+ 1 - 2
test/TestSearch.php

@@ -15,8 +15,7 @@ require_once(BASE_ROOT_PATH . '/helper/search/tcp_client.php');
 require_once(BASE_ROOT_PATH . '/helper/search/util.php');
 require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/search/searcher.php');
-require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
-require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/algorithm.php');
 require_once(BASE_ROOT_PATH . '/helper/special_helper.php');
 

+ 2 - 1
test/account_helperTest.php

@@ -13,6 +13,7 @@ require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/account_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 
 
 class bar
@@ -84,7 +85,7 @@ class account_helperTest extends PHPUnit_Framework_TestCase
         $url = urlencode($url);
 
         $x = mt_rand(1,1);
-        $brands = brand_helper::brandex();
+        $brands = brand_helper::instance()->brandex();
     }
 
     public function testPaysuccess()

+ 1 - 0
test/category_helperTest.php

@@ -10,6 +10,7 @@ define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
 
 require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_ROOT_PATH . '/helper/category_helper.php');
+require_once(BASE_ROOT_PATH . '/helper/brand_helper.php');
 
 
 class category_helperTest extends PHPUnit_Framework_TestCase