stanley-king 8 gadi atpakaļ
vecāks
revīzija
1fc49c8345

+ 3 - 2
helper/model/goods_summary.php

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

+ 147 - 0
helper/statistics_helper.php

@@ -6,7 +6,154 @@
  * Date: 2016/11/2
  * Time: 下午2:57
  */
+
 class statistics_helper
 {
+    private static $stInstance;
+    private $mItems;
+    private $mOther;
+
+    private $mRecordTime;
+
+    public static function instance()
+    {
+        if(self::$stInstance == null) {
+            self::$stInstance = new statistics_helper();
+        }
+        return self::$stInstance;
+    }
+
+    private function __construct()
+    {
+        $this->mItems = [];
+        $this->mOther = [];
+        $this->mRecordTime = time();
+    }
+    public function __destroy()
+    {
+        $this->save();
+    }
+
+    private function expired()
+    {
+        $day = new DateTime();
+        $day->setTimestamp($this->mRecordTime);
+        $day->setTime(0,0,0);
+        $time_stamp = $day->getTimestamp() + 24 * 60 * 60;
+        return ($this->mRecordTime >= $time_stamp);
+    }
+
+    private function save()
+    {
+        $pid = posix_getpid();
+        $date = gmdate('Y-M-d',$this->mRecordTime);
+        $file = BASE_DATA_PATH_PATH . '/log/' . "{$date}-{$pid}.txt";
+        $data = array('star_time'=> $this->mRecordTime,'end_time' => time(),'function' => $this->mItems,'other' => $this->mOther);
+        $data = json_encode($data);
+        file_put_contents($file,$data);
+
+        $this->mRecordTime = time();
+        $this->mOther = [];
+        $this->mItems = [];
+    }
+
+    public function add_call($param)
+    {
+        if($this->expired()) {
+            $this->save();
+        }
+
+        $act = $param['act'];
+        $op  = $param['op'];
+
+        if($this->act($act) == false) return;
+        if($this->op($act,$op) == false) return;
+
+        $this->add_data($act,$op,$param);
+    }
+
+    private function add_data($act,$op,$param)
+    {
+        $oper = &$this->mItems[$act][$op];
+
+        if(empty($oper['count'])) {
+            $oper['count'] = 1;
+        } else {
+            $oper['count'] += 1;
+        }
+
+        if($act == 'goods_common') {
+            return $this->add_goods($op,$param);
+        }
+        if($act == 'special') {
+            return $this->add_special($op,$param);
+        }
+        if($act == 'member_bonus') {
+            return$this->add_bonus($op,$param);
+        }
+    }
+
+    private function add_other($key,$count) {
+        if(array_key_exists($key,$this->mOther) == false) {
+            $this->mOther[$key] = [];
+            $this->mOther[$key]['count'] = $count;
+        } else {
+            $this->mOther[$key]['count'] += $count;
+        }
+        return true;
+    }
+
+    private function add_goods($op,$param)
+    {
+        if($op != 'index') return false;
+
+        $common_id = intval($param['goods_commonid']);
+        $goods_id  = intval($param['goods_id']);
+        if($common_id > 0 && $goods_id > 0) {
+            $key = 'goods_' . $goods_id;
+            return $this->add_other($key,1);
+        } else {
+            return false;
+        }
+    }
+    private function add_special($op,$param) {
+        if($op != 'index') return false;
+
+        $special_id = intval($param['special_id']);
+        if($special_id > 0) {
+            $key = 'special_' . $special_id;
+            return $this->add_other($key,1);
+        } else {
+            return false;
+        }
+    }
+    private function add_bonus($op,$param)
+    {
+        if($op == 'make') {
+            $key = 'make_bonus';
+            $count = intval($param['total_num']);
+            return $this->add_other($key,$count);
+        }
+        else {
+            return false;
+        }
+    }
+
+    private function act($act)
+    {
+        if(empty($act)) return false;
+
+        if(array_key_exists($act,$this->mItems) == false) {
+            $this->mItems[$act] = [];
+        }
+        return true;
+    }
+    private function op($act,$op) {
+        if(empty($op)) return false;
 
+        if(array_key_exists($op,$this->mItems[$act]) == false) {
+            $act[$op] = [];
+        }
+        return true;
+    }
 }

+ 5 - 0
mobile/control/control.php

@@ -9,6 +9,8 @@
 
 defined('InShopNC') or exit('Access Invalid!');
 
+require_once (BASE_ROOT_PATH . "/helper/statistics_helper.php");
+
 /********************************** 前台control父类 **********************************************/
 class mobileControl
 {
@@ -47,7 +49,10 @@ class mobileControl
         initpage($this->page_size, $this->cur_page);
 
         $this->check_app_type();
+
+        statistics_helper::instance()->add_call($_GET);
     }
+
     protected function android()
     {
         return $_SESSION['client_type'] == 'android';

+ 3 - 1
mobile/control/goods_common.php

@@ -24,7 +24,9 @@ class goods_commonControl extends mobileControl
 
         if($common_id > 0 && $goods_id > 0)
         {
-            Model('goods_browse')->addViewedGoods($goods_id,$_SESSION['member_id'],$_SESSION['store_id']);
+            if(!empty($_SESSION['member_id'])) {
+                Model('goods_browse')->addViewedGoods($goods_id,$_SESSION['member_id'],$_SESSION['store_id']);
+            }
 
             $helper = new goods_helper();
             $ret = $helper->get_spu($common_id,$goods_id,$err);

+ 3 - 1
mobile/control/search.php

@@ -180,7 +180,9 @@ class searchControl extends mobileHomeControl
         }
         else
         {
-            if(empty($order) || $order == 'desc') {
+            if(empty($order)) {
+                $order = 'desc';
+            } elseif($order == 'desc') {
                 $order = 'desc';
             } else {
                 $order = 'asc';