Bladeren bron

add search 统计

stanley-king 7 jaren geleden
bovenliggende
commit
c77772ba87

+ 80 - 0
admin/control/stat_daily.php

@@ -88,6 +88,30 @@ class stat_dailyControl extends SystemControl
 
         Tpl::showpage('stat.interactive.special');
     }
+
+    public function interactive_searchOp()
+    {
+        if(empty( $_GET['date_id'])) {
+            $date_id = strtotime(date('Y-m-d',time()));
+        } else {
+            $date_id = $_GET['date_id'];
+        }
+
+        $mod_stat = Model('stat');
+        $stat_list = $mod_stat->statDailyList(['date_id' => $date_id], 'date_id,call_record');
+        if(empty($stat_list) || empty($stat_list[0]['call_record'])) {
+            return;
+        }
+        $record = json_decode($stat_list[0]['call_record'],true);
+        $words = $this->all_keyword($record);
+
+        Tpl::output('words',$words);
+        Tpl::output('word_colomns',$this->word_colomns());
+
+        Tpl::showpage('stat.interactive.search');
+    }
+
+
     private function special_colomns()
     {
         return ['序号','专题编号','名称','点击量','子专题'];
@@ -98,6 +122,57 @@ class stat_dailyControl extends SystemControl
         return ['序号','商品编号','商品货架号','名称','点击量'];
     }
 
+    private function brand_colomns()
+    {
+        return ['序号','品牌编号','名称','点击量'];
+    }
+    private function word_colomns()
+    {
+        return ['序号','关键词','搜索量'];
+    }
+
+    function compatible_decode($unicode)
+    {
+        $str = '';
+        $arr = array_filter(explode('u', $unicode));
+        foreach ($arr as $k => $v) {
+            if (strlen($v) == 4) {
+                $num = (int)hexdec($v);
+                $ord_1 = decbin(0xe0 | ($num >> 12));
+                $ord_2 = decbin(0x80 | (($num >> 6) & 0x3f));
+                $ord_3 = decbin(0x80 | ($num & 0x3f));
+                $str  .= chr(bindec($ord_1)) . chr(bindec($ord_2)) . chr(bindec($ord_3));
+            }else{
+                $str .= chr(hexdec($v));
+            }
+        }
+        return $str;
+    }
+
+    private function all_keyword($record)
+    {
+        $other = $record['other'];
+        if(empty($other)) return false;
+
+        $words = [];
+        foreach ($other as $key => $value)
+        {
+            $params = preg_split('/_/', $key);
+            if($params != false && count($params) == 2)
+            {
+                if($params[0] == 'keyword') {
+                    $keyword = $this->compatible_decode($params[1]);
+                    $count = $value['count'];
+                    $words[] = array('keyword' => $keyword,'count' => $count);
+                }
+            }
+        }
+        if(!empty($words)) {
+//            uasort($words,['special_item','count_desc']);
+        }
+        return $words;
+    }
+
     private function all_special($record)
     {
         $other = $record['other'];
@@ -254,6 +329,11 @@ class special_item
     }
 }
 
+class search_item
+{
+
+}
+
 class call_item
 {
     private $mDateID;

+ 1 - 0
admin/templates/default/stat.interactive.goods.php

@@ -11,6 +11,7 @@
                 <li><a href="index.php?act=stat_daily&op=interactive_list"><span>交互行为统计</span></a></li>
                 <li><a href="javascript:void(0)" class="current"><span>商品统计</span></a></li>
                 <li><a href="index.php?act=stat_daily&op=interactive_special"><span>专题统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_search"><span>搜索统计</span></a></li>
             </ul>
         </div>
     </div>

+ 2 - 0
admin/templates/default/stat.interactive.list.php

@@ -11,6 +11,7 @@
                 <li><a href="javascript:void(0)" class="current"><span>交互行为统计</span></a></li>
                 <li><a href="index.php?act=stat_daily&op=interactive_goods"><span>商品统计</span></a></li>
                 <li><a href="index.php?act=stat_daily&op=interactive_special"><span>专题统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_search"><span>搜索统计</span></a></li>
             </ul>
         </div>
     </div>
@@ -68,6 +69,7 @@
                 echo "<td class=\"w60 align-left\">
                         <a href='index.php?act=stat_daily&op=interactive_goods&date_id={$date_id}'>商品</a>
                         <a href='index.php?act=stat_daily&op=interactive_special&date_id={$date_id}'>专题</a>
+                        <a href='index.php?act=stat_daily&op=interactive_search&date_id={$date_id}'>搜索</a>
                       </td>";
                 echo '</tr>';
             }

+ 78 - 0
admin/templates/default/stat.interactive.search.php

@@ -0,0 +1,78 @@
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
+
+<!—专题统计分析—>
+<div class="page">
+    <!— 页面导航 —>
+    <div class="fixed-bar">
+        <div class="item-title">
+            <h3>专题统计</h3>
+            <ul class="tab-base">
+                <li><a href="index.php?act=stat_daily&op=index"><span>日常统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_list"><span>交互行为统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_goods"><span>商品统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_special"><span>专题统计</span></a></li>
+                <li><a href="javascript:void(0)" class="current"><span>搜索统计</span></a></li>
+            </ul>
+        </div>
+    </div>
+    <!— 帮助 —>
+    <table class="table tb-type2" id="prompt">
+        <tbody>
+        <tr class="space odd">
+            <th colspan="12" class="nobg">
+                <div class="title nomargin">
+                    <h5><?php echo $lang['nc_prompts']; ?></h5>
+                    <span class="arrow"></span></div>
+            </th>
+        </tr>
+        <tr>
+            <td>
+                <ul>
+                    <li>可以查询用户点击专题次数相关统计信息</li>
+                </ul>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+
+    <form method="post">
+        <table class="table tb-type2">
+            <thead>
+            <tr class="space">
+                <th colspan="15" class="nobg">搜索关键词列表</th>
+            </tr>
+            <tr class="thead">
+                <?php
+                $colomns = $output['word_colomns'];
+                foreach ($colomns as $name) {
+                    echo "<th class=\"w60 align-left\">{$name}</th>";
+                }
+                ?>
+            </tr>
+            </thead>
+            <tbody>
+            <?php
+            $words = $output['words'];
+
+            $no = 1;
+            foreach ($words as $word)
+            {
+                echo '<tr class="hover">';
+                echo  "<td class=\"w60 align-left\">{$no}</td>";
+                foreach ($word as $val) {
+                    echo  "<td class=\"w60 align-left\">{$val}</td>";
+                }
+                echo '</tr>';
+                $no++;
+            }
+            ?>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="16">
+                    <div class="pagination"><?php echo $output['page'];?> </div></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>

+ 1 - 0
admin/templates/default/stat.interactive.special.php

@@ -11,6 +11,7 @@
                 <li><a href="index.php?act=stat_daily&op=interactive_list"><span>交互行为统计</span></a></li>
                 <li><a href="index.php?act=stat_daily&op=interactive_goods"><span>商品统计</span></a></li>
                 <li><a href="javascript:void(0)" class="current"><span>专题统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_search"><span>搜索统计</span></a></li>
             </ul>
         </div>
     </div>

+ 4 - 4
helper/statistics_helper.php

@@ -22,7 +22,7 @@ class statistics_helper
 
     private $mRecordTime;
 
-    const interval_time = 600;
+    const interval_time = 60;
 
     public static function instance()
     {
@@ -230,11 +230,11 @@ class statistics_helper
                 return $this->add_other($key,1);
             }
             if($hot_id > 0) {
-                $key = "brand_{$hot_id}";
+                $key = "hot_{$hot_id}";
                 return $this->add_other($key,1);
             }
             if(!empty($keyword)) {
-                $key = "brand_{$keyword}";
+                $key = "keyword_{$keyword}";
                 return $this->add_other($key,1);
             }
         }
@@ -242,7 +242,7 @@ class statistics_helper
         {
             $keyword  = trim(urldecode($param['keyword']));
             if(!empty($keyword)) {
-                $key = "brand_{$keyword}";
+                $key = "keyword_{$keyword}";
                 return $this->add_other($key,1);
             }
         }

+ 1 - 1
mobile/control/member_info.php

@@ -64,7 +64,7 @@ class member_infoControl extends mbMemberControl
         if($ret['member_sex'] == 2) {
             $ret['member_sex'] = 0;
         }
-        
+
         self::outsuccess($ret);
     }
 

+ 23 - 1
test/TestUGC.php

@@ -146,14 +146,36 @@ class TestUGC extends PHPUnit_Framework_TestCase
         $s = iconv('UTF-8','UTF-16', $str);
 
     }
+
+    function compatible_decode($unicode)
+    {
+        $str = '';
+        $arr = array_filter(explode('u', $unicode));
+        foreach ($arr as $k => $v) {
+            if (strlen($v) == 4) {
+                $num = (int)hexdec($v);
+                $ord_1 = decbin(0xe0 | ($num >> 12));
+                $ord_2 = decbin(0x80 | (($num >> 6) & 0x3f));
+                $ord_3 = decbin(0x80 | ($num & 0x3f));
+                $str .= chr(bindec($ord_1)) . chr(bindec($ord_2)) . chr(bindec($ord_3));
+            }else{
+                $str .= chr(hexdec($v));
+            }
+        }
+        return $str;
+    }
+
     public function testU16()
     {
+        $x = 'u7f8eu5b9du83b2';
+        $y = $this->compatible_decode($x);
+
+        $x = json_decode($x);
         $str = "托尔斯泰🇺🇸🌹😃😄";
         $t = json_encode($str,JSON_UNESCAPED_UNICODE);
         $s = iconv('UTF-16', 'UTF-8', $str);
         $y = iconv_get_encoding();
         $len = iconv_strlen($str,'UTF-8');
-
     }
 }