stanley-king 7 years ago
parent
commit
2562832901
4 changed files with 39 additions and 21 deletions
  1. 2 2
      helper/statistics/statcall.php
  2. 27 15
      helper/statistics_helper.php
  3. 7 3
      mobile/control/control.php
  4. 3 1
      test/orderTest.php

+ 2 - 2
helper/statistics/statcall.php

@@ -28,7 +28,7 @@ class statcall extends stat_base
             if(empty($record)) {
                 return false;
             } else {
-                return unserialize($record);
+                return json_decode($record,true);
             }
         }
     }
@@ -37,6 +37,6 @@ class statcall extends stat_base
         $this->calc_time(stat_base::cur_date_type);
         $result = $this->mModel->get_one($this->mDateId,'call_record',true);
         $fEdit = empty($result) ? false : true;
-        return $this->save($fEdit,['call_record' => serialize($data)]);
+        return $this->save($fEdit,['call_record' => json_encode($data)]);
     }
 }

+ 27 - 15
helper/statistics_helper.php

@@ -15,12 +15,13 @@ class statistics_helper
 
     private $mItems;
     private $mOther;
-    private $mAppCount;
+    private $mIOSCount;
+    private $mAndroidCount;
     private $mWapCount;
 
     private $mRecordTime;
 
-    const interval_time = 30;
+    const interval_time = 600;
 
     public static function instance()
     {
@@ -40,11 +41,14 @@ class statistics_helper
         $record_time = $params['star_time'];
         if($this->read_data($record_time))
         {
-            $this->mAppCount += $params['app_count'];
-            $this->mWapCount += $params['wap_count'];
+            $this->mIOSCount     += $params['ios_count'];
+            $this->mAndroidCount += $params['android_count'];
+            $this->mWapCount     += $params['wap_count'];
             $this->add_items($params);
             $this->add_others($params);
-            $data = ['function' => $this->mItems,'other' => $this->mOther,'app_count' => $this->mAppCount,'wap_count' => $this->mWapCount];
+
+            $data = ['function' => $this->mItems,'other' => $this->mOther,
+                'ios_count' => $this->mIOSCount,'android_count' => $this->mAndroidCount,'wap_count' => $this->mWapCount];
             $stat_call = new \statistics\statcall($record_time);
             $stat_call->update($data);
         }
@@ -59,7 +63,8 @@ class statistics_helper
         if($record == false) {
             $this->reinit();
         } else {
-            $this->mAppCount = $record['app_count'];
+            $this->mIOSCount     = $record['ios_count'];
+            $this->mAndroidCount = $record['android_count'];
             $this->mWapCount = $record['wap_count'];
             $this->mItems = $record['function'];
             $this->mOther = $record['other'];
@@ -94,9 +99,9 @@ class statistics_helper
                     {
                         if(empty($oper['count'])) {
                             $oper['count'] = 0;
+                        } else {
+                            $oper['count'] += intval($value);
                         }
-
-                        $oper['count'] += intval($value);
                     }
                 }
             }
@@ -118,7 +123,7 @@ class statistics_helper
         {
             $data = ['star_time'=> $this->mRecordTime,'end_time' => time(),
                 'function' => $this->mItems,'other' => $this->mOther,
-                'app_count' => $this->mAppCount,'wap_count' => $this->mWapCount];
+                'ios_count' => $this->mIOSCount,'android_count' => $this->mAndroidCount,'wap_count' => $this->mWapCount];
             QueueClient::push("savelog",$data);
             $this->reinit();
         }
@@ -128,9 +133,15 @@ class statistics_helper
 
         if($this->act($act) == false) return;
         if($this->op($act,$op) == false) return;
-        if($param['from_app'] == true) {
-            $this->mAppCount += 1;
-        } else {
+
+        $client_type = $param['client_type'];
+        if($client_type == 'ios') {
+            $this->mIOSCount += 1;
+        }
+        elseif($client_type == 'android') {
+            $this->mAndroidCount += 1;
+        }
+        else {
             $this->mWapCount += 1;
         }
 
@@ -163,7 +174,7 @@ class statistics_helper
 
     private function add_other($key,$count)
     {
-        if(isset($this->mOther[$key]) == false) {
+        if(array_key_exists($key,$this->mOther) == false) {
             $this->mOther[$key] = [];
             $this->mOther[$key]['count'] = $count;
         } else {
@@ -188,7 +199,7 @@ class statistics_helper
         if($op != 'index') return false;
 
         $special_id = intval($param['special_id']);
-        if($special_id > 0) {
+        if($special_id >= 0) {
             $key = 'special_' . $special_id;
             return $this->add_other($key,1);
         } else {
@@ -230,7 +241,8 @@ class statistics_helper
         $this->mItems = [];
         $this->mOther = [];
         $this->mWapCount = 0;
-        $this->mAppCount = 0;
+        $this->mIOSCount = 0;
+        $this->mAndroidCount = 0;
         $this->mRecordTime = time();
     }
 }

+ 7 - 3
mobile/control/control.php

@@ -46,7 +46,8 @@ class mobileControl
         $this->check_app_type();
 
         $param = $_GET;
-        $param['from_app'] = $_SESSION['is_app'];
+        $param['client_type'] = $_SESSION['client_type'];
+
         statistics_helper::instance()->add_call($param);
     }
 
@@ -103,7 +104,8 @@ class mobileControl
         $version = intval($version * 100 + 0.5);
         if($client == 'ios')
         {
-            $lastest_version = 220;
+            $cur_ver = $GLOBALS['setting_config']['mobile_ios_version'];
+            $lastest_version = intval($cur_ver * 100 + 0.5);
             if($version >= $lastest_version) {
                 $_SESSION['is_lasted'] = true;
             } else {
@@ -112,7 +114,9 @@ class mobileControl
         }
         elseif($client == 'android')
         {
-            $lastest_version = 1400;
+            $cur_ver = $GLOBALS['setting_config']['mobile_apk_version'];
+            $lastest_version = intval($cur_ver * 100 + 0.5);
+
             if($version >= $lastest_version) {
                 $_SESSION['is_lasted'] = true;
             } else {

File diff suppressed because it is too large
+ 3 - 1
test/orderTest.php