Bläddra i källkod

Merge branch 'bonus_manager' into ugc

stanley-king 7 år sedan
förälder
incheckning
9981762cf6

+ 270 - 0
admin/control/stat_daily.php

@@ -10,6 +10,276 @@ class stat_dailyControl extends SystemControl
 
     public function indexOp()
     {
+        if (chksubmit()) {
+        }
+
+        $mod_stat = Model('stat');
+        $stat_list = $mod_stat->statDailyList([], '*', 30);
+
+        Tpl::output('page',$mod_stat->showpage());
+        Tpl::output('dailies',$stat_list);
+        Tpl::output('colomns',$this->daily_colomns());
+
         Tpl::showpage('stat.daily.list');
+
+    }
+    private function daily_colomns()
+    {
+        return ['日期','可用金额','可用个数','今日发送金额','今日未领金额','今日发送个数','今日领取个数','红包支付金额','红包转发金额','红包转发次数','新增用户','总用户','日活','周活','月活','订单总数','订单总额','客单价'];
+    }
+
+    public function interactive_listOp()
+    {
+        $mod_stat = Model('stat');
+        $stat_list = $mod_stat->statDailyList([], 'date_id,call_record', 30);
+
+        Tpl::output('page',$mod_stat->showpage());
+        Tpl::output('dailies',$stat_list);
+        Tpl::output('colomns',$this->call_colomns());
+
+        Tpl::showpage('stat.interactive.list');
+    }
+
+    private function call_colomns()
+    {
+        return ['日期','IOS','android','H5','首页','品牌页','专题','搜索','功效','商品详情','获取验证码','红包打开','发送','从红包发送','摇一摇','红包分享','邀请','收藏','我的F码','商城','我的订单'];
+    }
+
+    public function interactive_goodsOp()
+    {
+        Tpl::showpage('stat.interactive.goods');
+    }
+
+    public function interactive_specialOp()
+    {
+        $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);
+        $specials = $this->all_special($record);
+
+        Tpl::output('dailies',$specials);
+        Tpl::output('colomns',$this->special_colomns());
+
+        Tpl::showpage('stat.interactive.special');
+    }
+    private function special_colomns()
+    {
+        return ['专题编号','名称','点击量','子专题'];
+    }
+    private function all_special($record)
+    {
+        $other = $record['other'];
+        if(empty($other)) return false;
+
+        $specials = [];
+        foreach ($other as $key => $value)
+        {
+            $params = preg_split('/_/', $key);
+            if($params != false && count($params) == 2)
+            {
+                if($params[0] == 'special')
+                {
+                    $special_id = intval($params[1]);
+                    $count = $value['count'];
+                    $specials[] = new special_item($special_id,$count);
+                }
+            }
+        }
+        if(!empty($specials)) {
+            uasort($specials,['special_item','count_desc']);
+
+        }
+        return $specials;
+    }
+}
+class special_item
+{
+    private $mSpId;
+    private $mCount;
+    public function __construct($special_id,$count)
+    {
+        $this->mSpId = $special_id;
+        $this->mCount = $count;
+    }
+    public function count() {
+        return $this->mCount;
+    }
+    public function fields()
+    {
+        $result = [];
+        $result[] = $this->mSpId;
+        $result[] = $this->special_name();
+        $result[] = $this->mCount;
+
+        return $result;
+    }
+    private function special_name()
+    {
+        $mod = Model('mb_special');
+        $special = $mod->getMbSpecialList(['special_id' => $this->mSpId]);
+        if(empty($special)) return false;
+        return $special[0]['special_desc'];
+    }
+    private function sub_specials()
+    {
+    }
+
+    static public function count_desc($left,$right)
+    {
+        $t_l = intval($left->count());
+        $t_r = intval($right->count());
+
+        if($t_l > $t_r) return -1;
+        elseif($t_l < $t_r) return 1;
+        else return 0;
+    }
+}
+
+class call_item
+{
+    private $mDateID;
+    private $mRecord;
+    public function __construct($item)
+    {
+        $this->mDateID = $item['date_id'];
+        $srecord = $item['call_record'];
+        if(empty($srecord)) {
+            $this->mRecord = [];
+        }
+        else{
+            $this->mRecord = json_decode($srecord,true);
+        }
+    }
+    public function date_id() {
+        return $this->mDateID;
+    }
+    public function date()
+    {
+        return strftime('%Y-%m-%d',intval($this->mDateID));
+    }
+    public function fields()
+    {
+        $result = [];
+        $result[] = $this->date();
+        if(empty($this->mRecord)) return $result;
+
+        $result[] = $this->mRecord['ios_count'];
+        $result[] = $this->mRecord['android_count'];
+        $result[] = $this->mRecord['wap_count'];
+
+        $funs = $this->mRecord['function'];
+        $result[] = $this->accumulate($funs['index']);
+        $result[] = $this->accumulate($funs['brand']);
+        $result[] = $this->accumulate($funs['special']);
+        $result[] = $this->accumulate($funs['search']);
+        $result[] = $this->accumulate($funs['category']);
+        $result[] = $this->accumulate($funs['goods_common']);
+        $result[] = $this->accumulate_op($funs['login'],'getcodex');
+
+        $result[] = $this->accumulate_op($funs['bonusex'],'open');
+        $result[] = $this->accumulate_op($funs['member_bonus'],'make');
+        $result[] = $this->accumulate_op($funs['member_bonus'],'makeby_bonus');
+        $result[] = $this->accumulate_op($funs['member_bonus'],'shake');
+        $result[] = $this->accumulate_op($funs['member_bonus'],'share');
+        $result[] = $this->accumulate_op($funs['member_bonus'],'invite');
+        $result[] = $this->accumulate($funs['member_favorites']);
+        $result[] = $this->accumulate($funs['member_fcode']);
+        $result[] = $this->accumulate($funs['mshop']);
+        $result[] = $this->accumulate($funs['member_order']);
+
+        return $result;
+    }
+    private function accumulate($act)
+    {
+        if(empty($act)) return 0;
+
+        $count = 0;
+        foreach ($act as $op => $val) {
+            $count += $val['count'];
+        }
+        return $count;
+    }
+    private function accumulate_op($act,$op)
+    {
+        if(empty($act)) return 0;
+        foreach ($act as $key => $val)
+        {
+            if($key == $op) {
+                return $val['count'];
+            }
+        }
+        return 0;
+    }
+}
+
+class daily_item
+{
+    private $mItem;
+    public function __construct($item)
+    {
+        $this->mItem = $item;
+    }
+    public function date()
+    {
+        return strftime('%Y-%m-%d',intval($this->mItem['date_id']));
+    }
+    public function fields()
+    {
+        $result = [];
+        $result[] = $this->date();
+        $result[] = $this->accumulate($this->mItem['available_total_amount']);
+        $result[] = $this->mItem['available_count'];
+        $result[] = $this->accumulate($this->mItem['all_total_amount']);
+        $result[] = $this->accumulate($this->mItem['all_remain_amount']);
+        $result[] = $this->mItem['all_bonus_count'];
+        $result[] = $this->mItem['all_bind_count'];
+        $result[] = $this->accumulatex($this->mItem['bonus_pay_amount']);
+        $result[] = $this->accumulatex($this->mItem['person_send_amount']);
+        $result[] = $this->mItem['all_bonus_count'] - $this->mItem['admin_bonus_count'];
+        $result[] = 0;
+        $result[] = $this->mItem['member_total_num'];
+        $result[] = $this->mItem['day_active_member'];
+        $result[] = $this->mItem['week_active_member'];
+        $result[] = $this->mItem['month_active_member'];
+        $result[] = $this->mItem['order_total_num'];
+        $result[] = $this->mItem['order_amount'];
+        $result[] = $this->mItem['order_price_avg'];
+
+        return $result;
+    }
+    private function accumulate($input)
+    {
+        $total = 0;
+        if(empty($input)) return $total;
+
+        $moneys = unserialize($input);
+        if($moneys == false) return $total;
+
+        foreach ($moneys as $val)
+        {
+            if(empty($val)) continue;
+            foreach ($val as $rate => $money) {
+                $total += $money;
+            }
+        }
+        return $total;
+    }
+    private function accumulatex($input)
+    {
+        $total = 0;
+        if(empty($input)) return $total;
+
+        $moneys = unserialize($input);
+        if($moneys == false) return $total;
+
+        foreach ($moneys as $rate => $money)
+        {
+            $total += $money;
+        }
+        return $total;
     }
 }

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

@@ -1698,4 +1698,35 @@ td.trigger i:hover { color: #27A9E3;}
 .mb-item-edit-content .search-goods-list a { background-color: #F9F9F9; padding: 4px 12px; border: solid 1px #CCC; border-radius: 4px; position: absolute; z-index: 1; bottom: 10px; right: 10px;}
 .mb-item-edit-content .home7 .content img { max-width: 200px;max-height: 200px;}
 .mb-item-edit-content .home2 .content img { max-width: 150px;width: 100%;}
-.mb-item-edit-content .goods-list .content img { max-width: 200px;max-height: 200px;}
+.mb-item-edit-content .goods-list .content img { max-width: 200px;max-height: 200px;}
+
+
+/*红包日常统计*/
+.label {
+	position: absolute;
+	left: 50%;
+	margin-left: -400px;
+	z-index: 999;
+	display: none;
+	background: #fff;
+	box-shadow: 0 0 20px #888888;
+}
+.close_btn {
+	position: absolute;
+	right: 5px;
+	top: 5px;
+	width: 20px;
+	height: 23px;
+	background: url(../images/sky/bg_position.gif) no-repeat 0 -148px;
+	z-index: 999;
+	cursor: pointer;
+}
+.close_btn:hover {
+	background: url(../images/sky/bg_position.gif) no-repeat -20px -148px;
+}
+.stat_daily_type {
+	cursor: pointer;
+}
+.stat_daily_type:hover {
+	color: red;
+}

+ 54 - 6
admin/templates/default/stat.daily.list.php

@@ -1,5 +1,4 @@
-<?php defined('InShopNC') or exit('Access Invalid!');?>
-<?php defined('InShopNC') or exit('Access Invalid!');?>
+<?php defined('InShopNC') or exit('Access Invalid!'); ?>
 
 <!—日常统计分析—>
 <div class="page">
@@ -7,24 +6,73 @@
     <div class="fixed-bar">
         <div class="item-title">
             <h3>日常统计</h3>
+            <ul class="tab-base">
+                <li><a href="javascript:void(0)" class="current"><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>
+            </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 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>
+                    <li>可以查询红包日常相关统计信息</li>
+                    <li>点击项目可以查看各项具体信息</li>
                 </ul>
             </td>
         </tr>
         </tbody>
     </table>
+
+    <form method="post">
+        <table class="table tb-type2">
+            <thead>
+            <tr class="space">
+                <th colspan="15" class="nobg"><?php echo $lang['nc_list']; ?></th>
+            </tr>
+            <tr class="thead">
+                <?php
+                    $colomns = $output['colomns'];
+                    foreach ($colomns as $name) {
+                        echo "<th class=\"w60 align-left\">{$name}</th>";
+                    }
+                ?>
+            </tr>
+            </thead>
+            <tbody>
+                <?php
+                    $dailies = $output['dailies'];
+                    foreach ($dailies as $stat)
+                    {
+                        $item = new daily_item($stat);
+                        $fields = $item->fields();
+
+                        echo '<tr class="hover">';
+                        foreach ($fields as $field) {
+                            echo  "<td class=\"w60 align-left\">{$field}</td>";
+                        }
+                        echo '</tr>';
+                    }
+                ?>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="16">
+                    <div class="pagination"><?php echo $output['page']; ?> </div>
+                </td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
 </div>

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

@@ -0,0 +1,76 @@
+<?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="javascript:void(0)" class="current"><span>商品统计</span></a></li>
+                <li><a href="index.php?act=stat_daily&op=interactive_special"><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"><?php echo $lang['nc_list']; ?></th>
+            </tr>
+            <tr class="thead">
+                <?php
+                $colomns = $output['colomns'];
+                foreach ($colomns as $name) {
+                    echo "<th class=\"w60 align-left\">{$name}</th>";
+                }
+                ?>
+            </tr>
+            </thead>
+            <tbody>
+            <?php
+            $dailies = $output['dailies'];
+            foreach ($dailies as $stat)
+            {
+                $item = new daily_item($stat);
+                $fields = $item->fields();
+
+                echo '<tr class="hover">';
+                foreach ($fields as $field) {
+                    echo  "<td class=\"w60 align-left\">{$field}</td>";
+                }
+                echo '</tr>';
+            }
+            ?>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="16">
+                    <div class="pagination"><?php echo $output['page'];?> </div></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>

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

@@ -0,0 +1,83 @@
+<?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="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>
+            </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"><?php echo $lang['nc_list']; ?></th>
+            </tr>
+            <tr class="thead">
+                <?php
+                $colomns = $output['colomns'];
+                foreach ($colomns as $name) {
+                    echo "<th class=\"w60 align-left\">{$name}</th>";
+                }
+                ?>
+            </tr>
+            </thead>
+            <tbody>
+            <?php
+            $dailies = $output['dailies'];
+            foreach ($dailies as $stat)
+            {
+                $item = new call_item($stat);
+                $fields = $item->fields();
+
+                $date_id = $item->date_id();
+                echo "<tr class=\"hover\" date_id=\"{$date_id}\">";
+                foreach ($fields as $field) {
+                    echo  "<td class=\"w60 align-left\">{$field}</td>";
+                }
+                echo '</tr>';
+            }
+            ?>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="16">
+                    <div class="pagination"><?php echo $output['page'];?> </div></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+    <script type="text/javascript">
+        $('.hover').on('click',function(){
+            var date_id = $(this).attr('date_id');
+            window.location.href = 'index.php?act=stat_daily&op=interactive_special&date_id='+ date_id;
+        })
+    </script>
+</div>

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

@@ -0,0 +1,75 @@
+<?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="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"><?php echo $lang['nc_list']; ?></th>
+            </tr>
+            <tr class="thead">
+                <?php
+                $colomns = $output['colomns'];
+                foreach ($colomns as $name) {
+                    echo "<th class=\"w60 align-left\">{$name}</th>";
+                }
+                ?>
+            </tr>
+            </thead>
+            <tbody>
+            <?php
+            $specials = $output['dailies'];
+            foreach ($specials as $special)
+            {
+                $fields = $special->fields();
+
+                echo '<tr class="hover">';
+                foreach ($fields as $field) {
+                    echo  "<td class=\"w60 align-left\">{$field}</td>";
+                }
+                echo '</tr>';
+            }
+            ?>
+            </tbody>
+            <tfoot>
+            <tr class="tfoot">
+                <td colspan="16">
+                    <div class="pagination"><?php echo $output['page'];?> </div></td>
+            </tr>
+            </tfoot>
+        </table>
+    </form>
+</div>

+ 5 - 0
data/model/stat.model.php

@@ -509,4 +509,9 @@ class statModel extends Model
             return $this->table($tablename)->field($field)->where($where)->group($group)->page($page)->limit($limit)->order($order)->select();
         }
     }
+
+    public function statDailyList($where, $field = '*', $page = 0, $limit = 0,$order = 'date_id desc')
+    {
+        return $this->table('stat_daily')->field($field)->where($where)->page($page)->limit($limit)->order($order)->select();
+    }
 }

+ 1 - 0
helper/stat_helper.php

@@ -10,6 +10,7 @@ require_once (BASE_ROOT_PATH . '/helper/statistics/stat_base.php');
 require_once (BASE_ROOT_PATH . '/helper/statistics/stbonus.php');
 require_once (BASE_ROOT_PATH . '/helper/statistics/stmember.php');
 require_once (BASE_ROOT_PATH . '/helper/statistics/statorder.php');
+require_once (BASE_ROOT_PATH . '/helper/statistics/statcall.php');
 
 class stat_helper
 {

+ 42 - 0
helper/statistics/statcall.php

@@ -0,0 +1,42 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2017/7/9
+ * Time: 下午10:19
+ */
+
+namespace statistics;
+
+class statcall extends stat_base
+{
+    public function __construct($stime)
+    {
+        parent::__construct($stime);
+    }
+
+    public function read()
+    {
+        $this->calc_time(stat_base::cur_date_type);
+        $result = $this->mModel->get_one($this->mDateId,'call_record',true);
+        if(empty($result)) {
+            return false;
+        }
+        else
+        {
+            $record = $result['call_record'];
+            if(empty($record)) {
+                return false;
+            } else {
+                return json_decode($record,true);
+            }
+        }
+    }
+    public function update($data)
+    {
+        $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' => json_encode($data)]);
+    }
+}

+ 82 - 65
helper/statistics_helper.php

@@ -7,15 +7,21 @@
  * Time: 下午2:57
  */
 
+require_once (BASE_ROOT_PATH . '/helper/stat_helper.php');
+
 class statistics_helper
 {
     private static $stInstance;
+
     private $mItems;
     private $mOther;
+    private $mIOSCount;
+    private $mAndroidCount;
+    private $mWapCount;
+
     private $mRecordTime;
-    private $mSaveTime;
 
-    const interval_time = 1800;
+    const interval_time = 600;
 
     public static function instance()
     {
@@ -27,30 +33,50 @@ class statistics_helper
 
     private function __construct()
     {
-        $this->mItems = [];
-        $this->mOther = [];
-        $this->reset_time();
+        $this->reinit();
     }
 
-    public function __destroy()
+    public function add_logs($params)
     {
-        $this->save();
+        $record_time = $params['star_time'];
+        if($this->read_data($record_time))
+        {
+            $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,
+                'ios_count' => $this->mIOSCount,'android_count' => $this->mAndroidCount,'wap_count' => $this->mWapCount];
+            $stat_call = new \statistics\statcall($record_time);
+            $stat_call->update($data);
+        }
     }
 
-    public function add_logs($params)
+    private function read_data($time)
     {
-        $this->add_items($params);
-        $this->add_others($params);
+        if($time <= 0) return false;
 
-        if($this->expired()) {
-            $this->save();
+        $stat_call = new \statistics\statcall($time);
+        $record = $stat_call->read();
+        if($record == false) {
+            $this->reinit();
+        } else {
+            $this->mIOSCount     = $record['ios_count'];
+            $this->mAndroidCount = $record['android_count'];
+            $this->mWapCount = $record['wap_count'];
+            $this->mItems = $record['function'];
+            $this->mOther = $record['other'];
         }
+        return true;
     }
 
     private function add_others($params)
     {
         $others = $params['other'];
-        foreach ($others as $key => $count) {
+        foreach ($others as $key => $val) {
+            $count = $val['count'];
             $this->add_other($key,$count);
         }
     }
@@ -74,7 +100,6 @@ class statistics_helper
                         if(empty($oper['count'])) {
                             $oper['count'] = 0;
                         }
-
                         $oper['count'] += intval($value);
                     }
                 }
@@ -82,56 +107,24 @@ class statistics_helper
         }
     }
 
-    private function expired()
-    {
-        return (time() >= $this->mSaveTime);
-    }
-
-    private function reset_time()
+    private function same_day($cur,$record)
     {
-        $this->mRecordTime = time();
-        $day = new DateTime();
-        $day->setTimestamp($this->mRecordTime);
-        $day->setTime(0,0,0);
-        $morning = $day->getTimestamp();
-
-        $noon = $morning + 12 * 60 * 60;
-        $midnight = $day->getTimestamp() + 24 * 60 * 60;
+        $left = strtotime(date('Y-m-d',$cur));
+        $right = strtotime(date('Y-m-d',$record));
 
-        if(time() < $noon) {
-            $this->mSaveTime = $noon;
-        } else {
-            $this->mSaveTime = $midnight;
-        }
-    }
-
-    private function save()
-    {
-        $pid = posix_getpid();
-        $date = date('Ymd-H',time());
-        $file = BASE_DATA_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->mOther = [];
-        $this->mItems = [];
-        $this->reset_time();
-    }
-
-    public function send_queue()
-    {
-        $data = array('star_time'=> $this->mRecordTime,'end_time' => time(),'function' => $this->mItems,'other' => $this->mOther);
-        QueueClient::push("savelog",$data);
-        $this->mRecordTime = time();
-        $this->mOther = [];
-        $this->mItems = [];
+        return ($left == $right);
     }
 
     public function add_call($param)
     {
-        if(time() >= $this->mRecordTime + self::interval_time) {
-            $this->send_queue();
+        $cur = time();
+        if($cur >= $this->mRecordTime + self::interval_time || $this->same_day($cur,$this->mRecordTime) == false)
+        {
+            $data = ['star_time'=> $this->mRecordTime,'end_time' => time(),
+                'function' => $this->mItems,'other' => $this->mOther,
+                'ios_count' => $this->mIOSCount,'android_count' => $this->mAndroidCount,'wap_count' => $this->mWapCount];
+            QueueClient::push("savelog",$data);
+            $this->reinit();
         }
 
         $act = $param['act'];
@@ -140,6 +133,17 @@ class statistics_helper
         if($this->act($act) == false) return;
         if($this->op($act,$op) == false) return;
 
+        $client_type = $param['client_type'];
+        if($client_type == 'ios') {
+            $this->mIOSCount += 1;
+        }
+        elseif($client_type == 'android') {
+            $this->mAndroidCount += 1;
+        }
+        else {
+            $this->mWapCount += 1;
+        }
+
         $this->add_data($act,$op,$param);
     }
 
@@ -156,16 +160,20 @@ class statistics_helper
         if($act == 'goods_common') {
             return $this->add_goods($op,$param);
         }
-        if($act == 'special') {
+        elseif($act == 'special') {
             return $this->add_special($op,$param);
         }
-        if($act == 'member_bonus') {
+        elseif($act == 'member_bonus') {
             return$this->add_bonus($op,$param);
         }
+        elseif($act == 'search') {
+
+        }
     }
 
-    private function add_other($key,$count) {
-        if(isset($this->mOther[$key]) == false) {
+    private function add_other($key,$count)
+    {
+        if(array_key_exists($key,$this->mOther) == false) {
             $this->mOther[$key] = [];
             $this->mOther[$key]['count'] = $count;
         } else {
@@ -178,9 +186,8 @@ class statistics_helper
     {
         if($op != 'index') return false;
 
-        $common_id = intval($param['goods_commonid']);
         $goods_id  = intval($param['goods_id']);
-        if($common_id > 0 && $goods_id > 0) {
+        if($goods_id > 0) {
             $key = 'goods_' . $goods_id;
             return $this->add_other($key,1);
         } else {
@@ -191,7 +198,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 {
@@ -227,4 +234,14 @@ class statistics_helper
         }
         return true;
     }
+
+    private function reinit()
+    {
+        $this->mItems = [];
+        $this->mOther = [];
+        $this->mWapCount = 0;
+        $this->mIOSCount = 0;
+        $this->mAndroidCount = 0;
+        $this->mRecordTime = time();
+    }
 }

+ 1 - 1
mobile/control/bonusex.php

@@ -820,7 +820,7 @@ function bonus_output_bindedinfo($output)
         if($type->isEnd()) {
             $prompt = "领取 {$type->binded_num()}/{$type->getTotal_num()}";
         } else {
-            $prompt = "领取 {$type->binded_num()}/{$type->getTotal_num()} 还可以继续发送";
+            $prompt = "领取 {$type->binded_num()}/{$type->getTotal_num()} 点击右上角继续分享此红包";
         }
     }
     echo('<p class="prompt pro">' .$prompt. '</p>');

+ 2 - 2
mobile/control/config.php

@@ -16,10 +16,10 @@ class configControl extends mobileHomeControl
     {
         $result['app_config'] = ['sale_mobile' => '021-64260858',
             'index_tip' => '登录后会显示您的专属红包价',
-            'login_tip' => '熊猫美妆是员工福利平台,不提供注册服务。'];
+            'login_tip' => '员工福利平台,仅支持员工及领到红包的亲友登录。'];
         return self::outsuccess($result);
     }
-
+    
     /**
      * 获取配置文件
      * 参数: platform 1:android 2:ios

+ 10 - 3
mobile/control/control.php

@@ -44,7 +44,11 @@ class mobileControl
         }
         initpage($this->page_size, $this->cur_page);
         $this->check_app_type();
-        statistics_helper::instance()->add_call($_GET);
+
+        $param = $_GET;
+        $param['client_type'] = $_SESSION['client_type'];
+
+        statistics_helper::instance()->add_call($param);
     }
 
     public function __destruct()
@@ -100,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 {
@@ -109,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 {

+ 3 - 3
mobile/control/member_bonus.php

@@ -69,7 +69,7 @@ class member_bonusControl extends mbMemberControl
         }
         $result['send_bless'] = $this->cur_bless();
         $result['avatar'] = session_helper::avatar();
-        $result['sub_titles'] = ['shake' => '','invite' => '','friends' => '','bonus_detail' => $warning];
+        $result['sub_titles'] = ['shake' => '','invite' => '领5折红包','friends' => '','bonus_detail' => $warning];
         $this->update_available_bonus($result['bonus_total']);
 
         return self::outsuccess($result);
@@ -143,10 +143,10 @@ class member_bonusControl extends mbMemberControl
             $result['bonus_rate'] = $rates_money;
         }
         $result['avatar'] = session_helper::avatar();
-        $result['sub_titles'] = ['shake' => '偷点地主家的余粮','invite' => '立得30元5折红包','friends' => ''];
+        $result['sub_titles'] = ['shake' => '偷点地主家的余粮','invite' => '5折红包','friends' => ''];
 
         $result['shake_sub']  = "偷点地主家的余粮";
-        $result['invite_sub'] = "立得30元5折红包";
+        $result['invite_sub'] = "5折红包";
         $result['friends_sub'] = "";
 
         return self::outsuccess($result);

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 7 - 0
test/orderTest.php