浏览代码

add to local

stanley-king 8 年之前
父节点
当前提交
52533df3d4

+ 4 - 0
core/framework/function/core.php

@@ -1743,6 +1743,8 @@ function dkcache($key)
 function rcache($key = null, $prefix = '', $fields = '*')
 {
     if ($key===null || !C('cache_open')) return array();
+
+    $start = microtime(true);
     $ins = Cache::getInstance('cacheredis');
     $cache_info = $ins->hget($key,$prefix,$fields);
     if ($cache_info === false) {
@@ -1770,6 +1772,8 @@ function rcache($key = null, $prefix = '', $fields = '*')
     if (isset($data['cache_expiration_time']) && $data['cache_expiration_time'] < time()) {
         $data = array();
     }
+
+    perfor_period("rcache",$start,$key);
     return $data;
 }
 

+ 2 - 1
core/framework/libraries/cache.php

@@ -34,7 +34,8 @@ class Cache
 	 *
 	 * @return object
 	 */
-	public static function getInstance(){
+	public static function getInstance()
+    {
 		$args = func_get_args();
 		return get_obj_instance(__CLASS__,'connect',$args);
 	}

+ 15 - 10
core/framework/libraries/model.php

@@ -50,20 +50,25 @@ class Model
         if (empty($table)) return false;
         //只取主键,find(2)等自动匹配主键时使用
 
-        if (C('cache_open')) {
-            $this->fields = rkcache('field/_pk', __CLASS__ . '::fetchTablePkArray');
-        } 
-        else 
+        static $stFields = null;
+        if($stFields == null)
         {
-            if (file_exists(BASE_DATA_PATH.'/cache/fields/_pk.php')){
-                $this->fields = require(BASE_DATA_PATH.'/cache/fields/_pk.php');
-            } else {
-                $_pk_array = self::fetchTablePkArray();
-                F('_pk', $_pk_array, 'cache/fields');
-                $this->fields = $_pk_array;
+            if (C('cache_open')) {
+                $stFields = rkcache('field/_pk', __CLASS__ . '::fetchTablePkArray');
+            }
+            else
+            {
+                if (file_exists(BASE_DATA_PATH.'/cache/fields/_pk.php')){
+                    $stFields = require(BASE_DATA_PATH.'/cache/fields/_pk.php');
+                } else {
+                    $_pk_array = self::fetchTablePkArray();
+                    F('_pk', $_pk_array, 'cache/fields');
+                    $stFields = $_pk_array;
+                }
             }
         }
 
+        $this->fields = $stFields;
         return $this->fields[$table];
     }
 

+ 2 - 1
helper/activity/version_checker.php

@@ -47,8 +47,9 @@ class version_checker
                 if($version > $this->cur_version) {
                     $need_reset = true;
                     $this->cur_version = $version;
-                    $this->reset_time = time();
                 }
+
+                $this->reset_time = time();
             }
 
             return $need_reset;

+ 1 - 0
helper/buy_first.php

@@ -58,6 +58,7 @@ class buy_first
         //红包信息
         $result['total_pred'] = doubleval($this->mLogicOut['available_predeposit']);
         $result['available_pred']  = doubleval($this->available_pred($goods_amount,$full_discount,$result['total_pred']));
+
         $result['usable_pred'] = true;
         $result['pay_cash_pred'] = $result['goods_amount'] + $result['freight'] - $result['full_discount'] - $result['available_pred'];
         $result['pay_cash_nopred'] = $result['goods_amount'] + $result['freight'] - $result['full_discount'];

+ 1 - 3
helper/model/goods_summary.php

@@ -75,9 +75,7 @@ class goods_summary
         $summary['brand_id'] = intval($this->goods_info['brand_id']);
         $summary['gc_id'] = intval($this->goods_info['gc_id']);
 
-        $bonus_cents = intval($this->goods_info['goods_price'] * (1 - predeposit_helper::scale()) * 100 + 0.5);
-
-        $summary['bonus_price'] = $bonus_cents / 100;
+        $summary['bonus_price'] = predeposit_helper::bonus_price($this->goods_info['goods_price']);
         $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'];

+ 85 - 11
helper/predeposit_helper.php

@@ -67,7 +67,6 @@ class RateMoney
         }
     }
 
-
     public function resort()
     {
         ksort($this->mRates);
@@ -138,6 +137,55 @@ class RateMoney
     public function clean() {
         $this->mDirty = false;
     }
+
+    public function calc_price($price)
+    {
+        $disc = 0;
+        $left = intval($price * 100 + 0.5);
+        foreach ($this->mRates as $rate => $total)
+        {
+            if($left <= 0) break;
+            if($rate > 100) continue;
+
+            $total = intval($total * 100 + 0.5);
+            if($total <= 0) {
+                continue;
+            }
+            else
+            {
+                if($rate == 100)
+                {
+                    if($total >= $left) {
+                        $disc += $left;
+                        $left = 0;
+                    } else {
+                        $disc += $total;
+                        $left -= $total;
+                    }
+                }
+                else
+                {
+                    $max_rate = intval($left * $rate / 100 + 0.5);
+                    if($total >= $max_rate) {
+                        $disc += $max_rate;
+                        $left = 0;
+                    } else {
+                        $disc += $total;
+                        $left -= intval($total * 100 / $rate + 0.5);
+                    }
+                }
+            }
+        }
+
+        $cur_price = $price * 100 - $disc;
+        $min_price = intval($price * (100 - self::PRED_RATE) + 0.5);
+
+        if($cur_price < $min_price) {
+            return $cur_price / 100;
+        } else {
+            return $min_price / 100;
+        }
+    }
 }
 
 class predeposit_helper
@@ -216,6 +264,42 @@ class predeposit_helper
             $this->del_rates();
         }
     }
+    private function bonus_rate() {
+        return $this->mRates;
+    }
+    static public function bonus_price($goods_price)
+    {
+        if(session_helper::isLogin())
+        {
+            if(isset($_SESSION['bonus_rate']) == false) {
+                $pred = new predeposit_helper($_SESSION['member_id']);
+                $bonus_rate = $pred->bonus_rate();
+            } else {
+                $bonus_rate = new RateMoney($_SESSION['bonus_rate']);
+            }
+
+            return $bonus_rate->calc_price($goods_price);
+        }
+        else
+        {
+            if(is_pushoms()) {
+                $scale = 0.30;
+            } else {
+                $scale = 0.99;
+            }
+            return $scale * $goods_price;
+        }
+    }
+
+    static public function scale()
+    {
+        if(is_pushoms()) {
+            $scale = 0.30;
+        } else {
+            $scale = 0.99;
+        }
+        return $scale;
+    }
 
     public function bonus_state() {
         return $this->mBonusState;
@@ -639,16 +723,6 @@ class predeposit_helper
         return $pdlogs;
     }
 
-    static public function scale()
-    {
-        if(is_pushoms()) {
-            $scale = 0.30;
-        } else {
-            $scale = 0.99;
-        }
-        return $scale;
-    }
-
     public function calc_pred($order_info,$pd_amount,&$no_cash)
     {
         $order_id = intval($order_info['order_id']);

+ 6 - 4
helper/special_helper.php

@@ -272,15 +272,17 @@ class special_helper
     private function filter($specials,&$goods_ids)
     {
         $blocks = [];
-        $goods_ids = array();
-
+        $goods_ids = [];
         foreach($specials as $key => $special)
         {
-            $block = $this->filter_item($special,$goods_ids,$scale);
+            $ids = [];
+            $block = $this->filter_item($special,$ids,$scale);
             if($scale != false && !empty($block)) {
                 $blocks[] = $block;
+                $goods_ids = array_merge($goods_ids,$ids);
             }
         }
+        $goods_ids = array_unique($goods_ids);
 
         return $blocks;
     }
@@ -420,7 +422,7 @@ class special_helper
         }
 
         if(self::check_goods($ids)) {
-            array_push($goods_ids,$goods_id);
+            $goods_ids = array_merge($goods_ids,$ids);
             $items[] = $item;
             return $items;
         } else {