Prechádzať zdrojové kódy

Merge branch 'talksec' into room_detail

huangdong 6 rokov pred
rodič
commit
cb46a1926e

+ 9 - 10
core/framework/core/base.php

@@ -105,15 +105,15 @@ final class Base
 
 		if(!empty($main))
 		{
-			$function = $_GET['op'].'Op';
-			if (method_exists($main,$function)) {
-				$main->$function();
-			} elseif (method_exists($main,'indexOp')) {
-				$main->indexOp();
-			} else {
-				$error = "Base Error: function {$function} not in $class_name!";
-				throw new Exception($error);
-			}
+            $function = $_GET['op'].'Op';
+            if (method_exists($main,$function)) {
+                $main->$function();
+            } elseif (method_exists($main,'indexOp')) {
+                $main->indexOp();
+            } else {
+                $error = "Base Error: function {$function} not in $class_name!";
+                throw new Exception($error);
+            }
 		}
 		else {
 			$error = "Base Error: class {$class_name} isn't exists!";
@@ -121,7 +121,6 @@ final class Base
 		}
 	}
 
-
 	/**
 	 * run
 	 */

+ 18 - 10
core/framework/libraries/log.php

@@ -55,19 +55,27 @@ class Log
         }
     }
 
-    public static function record_path($message, $lev = self::DEBUG)
-    {
-        self::record($message, $lev);
+    static private $cur_path_file_name = '';
+    static private $cur_path_file;
 
-        $now = @date('Y-m-d H:i:s', time());
-        $pid = posix_getpid();
-        $level = 'USER_PATH';
-        $log_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '-path.log';
-        $content = "[{$pid} {$now}] {$level}: {$message}\r\n";
-        file_put_contents($log_file, $content, FILE_APPEND);
-        return;
+    public static function record_path($content)
+    {
+        $path_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '_path.log';
+        if(self::$cur_path_file_name != $path_file)
+        {
+            if(self::$cur_path_file != null) {
+                fclose(self::$cur_path_file);
+            }
+            self::$cur_path_file = fopen($path_file,'a');
+        }
 
+        if (@flock(self::$cur_path_file, LOCK_EX)) {
+            fwrite(self::$cur_path_file,$content);
+            fwrite(self::$cur_path_file,"\r\n");
+            @flock(self::$cur_path_file, LOCK_UN);
+        }
     }
+
     public static function record($message, $lev = self::ERR)
     {
         $now = @date('Y-m-d H:i:s', time());

+ 2 - 0
crontab/control/date.php

@@ -127,6 +127,7 @@ class dateControl extends BaseCronControl
             }
         }
     }
+
     public function init_relationOp()
     {
         $i = 0;
@@ -152,6 +153,7 @@ class dateControl extends BaseCronControl
             }
         }
     }
+
     public function skupriceOp()
     {
         $this->add_sku();

+ 2 - 1
data/logic/buy.logic.php

@@ -147,7 +147,8 @@ class buyLogic
      * @param unknown $data 商品信息
      * @return
      */
-    public function getBuyStep1Data($member_id, $data) {
+    public function getBuyStep1Data($member_id, $data)
+    {
         list($goods_list,$store_cart_list) = $data;
         $goods_list = $data['goods_list'];
         $store_cart_list = $data['store_cart_list'];

+ 21 - 0
data/model/behavior.model.php

@@ -0,0 +1,21 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2018/9/1
+ * Time: 下午11:41
+ */
+
+defined('InShopNC') or exit('Access Invalid!');
+
+class behaviorModel extends Model
+{
+    public function __construct()
+    {
+        parent::__construct('stat_behavior');
+    }
+
+    public function addBehavior($data) {
+        $this->insert($data);
+    }
+}

+ 1 - 1
data/model/goods.model.php

@@ -82,7 +82,7 @@ class goodsModel extends Model
         $condition = $this->_getRecursiveClass($condition);
         perfor_period("goods.model",$start,"getGoodsList");
 
-        return $this->table('goods')->field($field)->where($condition)->group($group)->order($order)->limit($limit)->page($page, $count)->lock($lock)->select();
+        return $this->table('goods')->field($field)->where($condition)->group($group)->page($page, $count)->order($order)->limit($limit)->lock($lock)->select();
     }
 
     /**

+ 2 - 2
data/model/room.model.php

@@ -63,8 +63,8 @@ class roomModel extends Model
         $room = $this->table('room')->field('*')->where(['type' => $room_type, 'room_creator' => $user])->limit(1)->find();
         return $room;
     }
-    public function getRooms($cond,$field = '*') {
-        return $this->table('room')->field($field)->where($cond)->select();
+    public function getRooms($cond,$field = '*',$order = 'room_id asc',$limit = 0) {
+        return $this->table('room')->field($field)->where($cond)->order($order)->limit($limit)->select();
     }
 
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

+ 4 - 10
helper/bonus/parameters.php

@@ -72,9 +72,9 @@ class parameters
     {
         $rate_moneys = [
             ['amount' => 10,  'num' => 1, 'rate' => 100],
-            ['amount' => 3,   'num' => 1, 'rate' => 40],
-            ['amount' => 1, 'num' => 1, 'rate' => 40],
-            ['amount' => 0.5,'num' => 1, 'rate' => 40],
+            ['amount' => 5,   'num' => 1, 'rate' => 40],
+            ['amount' => 4, 'num' => 1, 'rate' => 40],
+            ['amount' => 1,'num' => 1, 'rate' => 40],
         ];
 
         $count = count($rate_moneys);
@@ -132,7 +132,6 @@ class parameters
         $rate_moneys = [
             ['amount' => 2, 'num' => $num,   'rate' => 40],
             ['amount' => 1, 'num' => $num, 'rate' => 40],
-            ['amount' => 2, 'num' => $num,   'rate' => 30],
         ];
 
         $count = count($rate_moneys);
@@ -249,12 +248,7 @@ class parameters
         }
         else
         {
-            $rate_moneys = [
-                ['amount' => 0.5, 'num' => 1, 'rate' => 100],
-                ['amount' => 0.25,'num' => 1, 'rate' => 100],
-                ['amount' => 0.10,'num' => 1, 'rate' => 100],
-                ['amount' => 0.05,'num' => 1, 'rate' => 100],
-            ];
+            return [];
         }
 
 

+ 1 - 0
helper/bonus_helper.php

@@ -12,6 +12,7 @@ require_once (BASE_ROOT_PATH . '/helper/text_filter.php');
 
 require_once (BASE_ROOT_PATH . '/helper/bonus/util.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/type.php');
+require_once (BASE_ROOT_PATH . '/helper/bonus/parameters.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/user_bonus.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/generator.php');
 require_once (BASE_ROOT_PATH . '/helper/bonus/grab.php');

+ 0 - 1
helper/buy_first.php

@@ -99,7 +99,6 @@ class buy_first
             $result['discount_gap'] = $discount_gap;
         }
         $result['bonus_rates'] = $this->formate_rates([ 30 => $result['available_bonus'] ]);
-
         $result['earn_bonus'] = $config['bonus_gap']['earn_bonus'];
 
         $result['usable_pred'] = true;

+ 0 - 4
helper/fcgi_server.php

@@ -102,9 +102,6 @@ class fcgi_server
 
                 $file = request_helper::script_file();
                 session::instance()->start();
-
-                $remote_addr = request_helper::remote_addr();
-                Log::record("file={$file} remoteaddr={$remote_addr}",Log::DEBUG);
                 Log::record("member_id=" . session_helper::memberid(),Log::DEBUG);
                 if(file_exists($file))
                 {
@@ -115,7 +112,6 @@ class fcgi_server
                     else
                     {
                         fcgi_header("Content-Type: text/html; charset=UTF-8");
-
                         if(!isset($_GET['act'])) {
                             $_GET['act'] = 'index';
                         }

+ 2 - 2
helper/goods_helper.php

@@ -34,9 +34,9 @@ class goods_helper
         $goods_list = $this->goods_list_extend($goods_list);
         return $goods_list;
     }
-    public function get_infos($goods_ids)
+    public function get_infos($goods_ids,$page=0,$order='goods_id asc')
     {
-        $goods_list = Model('goods')->cls()->getGoodsOnlineList(array('goods_id' => array('in', $goods_ids)),self::fieldstr);
+        $goods_list = Model('goods')->cls()->getGoodsOnlineList(array('goods_id' => array('in', $goods_ids)),self::fieldstr,$page,$order);
         $goods_list = $this->goods_list_extend($goods_list);
         return $goods_list;
     }

+ 13 - 10
helper/push_helper.php

@@ -164,17 +164,20 @@ class push_helper
 
     public static function money_rate_desc($money,$rate)
     {
-        $discount = 100 - $rate;
-        if($discount == 0) {
-            $desc = "全抵";
-        } else {
-            $tmp = $discount / 10;
-            $desc = "{$tmp}折";
-        }
-
-        $desc = "可抵扣";
         $amount = intval($money * 100 + 0.5) / 100;
-        return "{$amount}元{$desc}";
+        return "{$amount}元";
+
+//        $discount = 100 - $rate;
+//        if($discount == 0) {
+//            $desc = "全抵";
+//        } else {
+//            $tmp = $discount / 10;
+//            $desc = "{$tmp}折";
+//        }
+//
+//        $desc = "可抵扣";
+//        $amount = intval($money * 100 + 0.5) / 100;
+//        return "{$amount}元{$desc}";
     }
 
     private static function push($alias, $push_param, $sms_type='',$sms_param=[], $fQueue=false)

+ 1 - 1
helper/request_helper.php

@@ -238,7 +238,7 @@ class request_helper
             $_SERVER['original_querystring'] = $squery;
         }
 
-        Log::record_path("content={$squery}",Log::DEBUG);
+        Log::record("content={$squery}",Log::DEBUG);
         $params = preg_split('/&|=/', $squery);
         if ($method == 'get' || $method == 'post')
         {

+ 7 - 7
helper/room/base_room.php

@@ -153,7 +153,7 @@ abstract class base_room
         try
         {
             $minfo = $this->userinfos($user);
-            $str = "{$minfo['nickname']}贡献了{$amount}元助力共享基金,兑换累计步数{$steps}步。<font color='#4A90E2'>一起参与助力吧!</font>";
+            $str = "{$minfo['nickname']}贡献了{$amount}元助力共享基金,兑换步数{$steps}步。<font color='#4A90E2'>一起参与助力吧!</font>";
             return $str;
         }
         catch (Exception $ex) {
@@ -165,7 +165,7 @@ abstract class base_room
         try
         {
             $minfo = $this->userinfos($user);
-            $str = "{$minfo['nickname']}使用了{$amount}元助力共享基金。<font color='#4A90E2'>一起参与助力吧!</font>";
+            $str = "{$minfo['nickname']}使用了{$amount}元共享基金,成功购物。<font color='#4A90E2'>一起参与助力吧!</font>";
             return $str;
         }
         catch (Exception $ex) {
@@ -210,8 +210,7 @@ abstract class base_room
                 $ret = $this->mod_room->invite($this->room_id(),$invitee,$inviter);
                 if($ret == false) {
                     continue;
-                }
-                else {
+                } else {
                     $user = $users[$invitee];
                     $uinfo = new member_info($user);
                     $this->mParticipants[$invitee] = ['nickname' => $uinfo->nickname(),'avatar' => $uinfo->avatar(),'userid' => intval($invitee)];
@@ -325,9 +324,10 @@ abstract class base_room
         $mod_room = Model('room');
         if($type == proto_type::msg_type_goods) {
             $data = json_decode($content,true);
-            $orgmsg = $data['goods_id'];
-            return $mod_room->addRoomMsg(['room_id' => $this->mRoomid,'member_id' => $userid, 'type' => $type,'msg' => $content, 'orgmsg' => $orgmsg, 'add_time' => time(),'msg_type' => 0]);
-        } else {
+            $goods_id = $data['goods_id'];
+            return $mod_room->addRoomMsg(['room_id' => $this->mRoomid,'member_id' => $userid, 'type' => $type,'msg' => $content, 'orgmsg' => $goods_id, 'add_time' => time(),'msg_type' => 0]);
+        }
+        else {
             return $mod_room->addRoomMsg(['room_id' => $this->mRoomid,'member_id' => $userid, 'type' => $type,'msg' => $content, 'orgmsg' => $orgmsg, 'add_time' => time(),'msg_type' => 0]);
         }
     }

+ 15 - 0
helper/room/factory_client.php

@@ -42,6 +42,7 @@ class factory_client extends tcp_client
         $port = $config['room_factory']['port'];
         return "tcp://{$host}:{$port}";
     }
+
     //////////////////////////////////////fcgi//////////////////////////////////////////////////////////////////////////
     public function create_bargain($goods_id,$user,$lowest_price,$usable_days,$random = true,$total_num = 10,$finvite = true)
     {
@@ -173,6 +174,20 @@ class factory_client extends tcp_client
             return true;
         }
     }
+    public function notice_user($user,$type,$content)
+    {
+        $param = ["act" => 'fcgi','op' => 'notice_user','user' => $room,'type' => $type,'content' => $content];
+        $result = $this->request($param);
+        if(empty($result)) return false;
+
+        $code = intval($result['code']);
+        if($code != 200) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
     public function notice_room($room,$type,$content)
     {
         $param = ["act" => 'fcgi','op' => 'notice_room','room' => $room,'type' => $type,'content' => $content];

+ 3 - 5
helper/room_helper.php

@@ -21,8 +21,6 @@ require_once(BASE_ROOT_PATH . '/helper/room/bargain_manager.php');
 require_once(BASE_ROOT_PATH . '/helper/room/room_parts.php');
 require_once(BASE_ROOT_PATH . '/helper/room/room_avatar.php');
 
-
-
 class room_helper
 {
     const room_name_usercount = 5;
@@ -129,7 +127,7 @@ class room_helper
         return $result;
     }
 
-    public static function user_rooms($user)
+    public static function user_rooms($user,$order='room_id asc',$count = 0)
     {
         $mod_room = Model('room');
         $items = $mod_room->getRoomParts(['member_id' => $user,'state' => 0],'room_id');
@@ -142,7 +140,7 @@ class room_helper
         $result = [];
         if(empty($roomids)) return $result;
 
-        $items = $mod_room->getRooms(['room_id' => ['in',$roomids]]);
+        $items = $mod_room->getRooms(['room_id' => ['in',$roomids]],'*',$order,$count);
         foreach ($items as $item) {
             $room = new room\room_info($item);
             $result[] = $room->format();
@@ -155,7 +153,7 @@ class room_helper
         if($roomid > 0 && intval($amount * 100 + 0.5) > 0 && $userid > 0)
         {
             $mod_room = Model('room');
-            $mod_room->editRoom(['room_id' => $roomid],['shared_bonus' => ['exp',"bonus - {$amount}"]]);
+            $mod_room->editRoom(['room_id' => $roomid],['shared_bonus' => ['exp',"shared_bonus - {$amount}"]]);
             $content = ['user' => session_helper::memberid(),'amount' => $amount];
             room\factory_client::instance()->notice_room($roomid,room\proto_type::msg_stype_spend,$content);
         }

+ 4 - 1
helper/session_helper.php

@@ -272,7 +272,10 @@ class session_helper
         else
         {
             $relay_id = session_helper::relay_id();
-            if (wechat_helper::has_userinfo())
+            if(session_helper::logined()) {
+                return false;
+            }
+            elseif (wechat_helper::has_userinfo())
             {
                 $user_info = wechat_helper::get_userinfo();
                 if(session_helper::logined())

+ 13 - 0
helper/stat_helper.php

@@ -11,6 +11,7 @@ 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');
+require_once (BASE_ROOT_PATH . '/helper/statistics/behavior.php');
 
 class stat_helper
 {
@@ -147,4 +148,16 @@ class stat_helper
             Log::record($ex->getMessage(),Log::ERR);
         }
     }
+    public static function onDaiyBehavior($time)
+    {
+        try
+        {
+            $stat = new statistics\behavior();
+            $stat->analyse($time);
+        }
+        catch(Exception $ex)
+        {
+            Log::record($ex->getMessage(),Log::ERR);
+        }
+    }
 }

+ 157 - 0
helper/statistics/behavior.php

@@ -0,0 +1,157 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: stanley-king
+ * Date: 2018/9/1
+ * Time: 下午11:29
+ */
+
+namespace statistics;
+
+
+class behavior
+{
+    private $mod_behavior;
+    public function __construct()
+    {
+        $this->mod_behavior = Model('behavior');
+    }
+
+    public function analyse($time)
+    {
+        $path_file = BASE_DATA_PATH . '/log/' . date('Ymd', $time) . '_path.log';
+        $fd = @fopen($path_file, "r");
+
+        while (!feof($fd))
+        {
+            $line = fgets($fd,1024);
+            if ($line !== false && !empty($line)) {
+                $this->record($line);
+            }
+        }
+        fclose($fd);
+    }
+    public function analyse_loop($time)
+    {
+        $path_file = BASE_DATA_PATH . '/log/' . date('Ymd', $time) . '_path.log';
+        $fd = @fopen($path_file, "r");
+
+        while (!feof($fd))
+        {
+            $line = fgets($fd,1024);
+            if ($line !== false && !empty($line)) {
+                $this->record($line);
+            }
+        }
+        fclose($fd);
+    }
+
+    private function record($line)
+    {
+        $input = json_decode($line,true);
+        if($input == false) return;
+
+        $content = $input['content'];
+        unset($input['content']);
+
+        $params = $this->parse_act($content);
+
+        $item = array_merge($input,$params);
+        $this->mod_behavior->addBehavior($item);
+    }
+
+    private function parse_act($content)
+    {
+        $result = [];
+        $params = $this->parse_content($content);
+        if(empty($params)) return $result;
+
+        $act = $params['act'];
+        $op  = $params['op'];
+
+        $result['act'] = $act;
+        $result['op'] = $op;
+
+        $type_data = $this->type_data($act,$op,$params);
+        foreach ($type_data as $key => $val)
+        {
+            if($key == 'type') {
+                $result['ktype'] = $val;
+            }
+            if($key == 'data') {
+                $result['kdata'] = $val;
+            }
+        }
+
+        $from = $params['from'];
+        if(!empty($from))
+        {
+            $from = base64_decode($from);
+            $fparams = $this->parse_content($from);
+            $fact = $params['act'];
+            $fop  = $params['op'];
+
+            $result['from_act'] = $act;
+            $result['from_op'] = $op;
+
+            $ftype_data = $this->type_data($fact,$fop,$fparams);
+            foreach ($ftype_data as $key => $val)
+            {
+                if($key == 'type') {
+                    $result['from_ktype'] = $val;
+                }
+                if($key == 'data') {
+                    $result['from_kdata'] = $val;
+                }
+            }
+        }
+
+        return $result;
+    }
+
+    private function type_data($act,$op,$params)
+    {
+        if(empty($act) || empty($op)) return [];
+
+        if($act == 'login')
+        {
+            if($op == 'getcodex' || $op == 'getcode') {
+                $val = $params['mobile'];
+                return ['type' => 'mobile','data' => $val];
+            }
+        }
+        elseif($act == 'special') {
+            $val = intval($params['special_id']);
+            return ['type' => 'special','data' => $val];
+        }
+        elseif($act == 'goods_common')
+        {
+            if($op == 'index' || $op == 'detail' || $op == 'detail_ajax') {
+                $val = intval($params['goods_id']);
+                return ['type' => 'goods','data' => $val];
+            }
+            elseif($op == 'comments') {
+                $val = intval($params['goods_commonid']);
+                return ['type' => 'goods_common','data' => $val];
+            }
+        }
+
+
+        return [];
+    }
+
+    private function parse_content($content)
+    {
+        $result = [];
+        $params = preg_split('/&|=/', $content);
+        for ($i = 0; $i < count($params); ++$i)
+        {
+            $key = $params[$i];
+            $val = $params[++$i];
+            $result[$key] =  urldecode($val);
+        }
+
+        return $result;
+    }
+
+}

+ 14 - 24
logmonitor.php

@@ -5,17 +5,11 @@
  * Date: 2018/8/30
  * Time: 下午2:51
  */
-//ini_set('ignore_user_abort', true);
-//set_time_limit(0);
+
 define('BASE_ROOT_PATH',str_replace('\\','/',dirname(__FILE__)));
 
 require_once (BASE_ROOT_PATH . '/fooder.php');
-Base::run_util();
-$monitor = new Monitor();
-
-while (true) {
-    $monitor->run_loop();
-}
+require_once (BASE_ROOT_PATH . '/helper/event_looper.php');
 
 class Monitor
 {
@@ -55,7 +49,6 @@ class Monitor
                     $this->checkStat();
                 }
 
-
                 usleep(1000);
             }
 
@@ -206,21 +199,6 @@ class Monitor
     }
 }
 
-//function monitor_work()
-//{
-//    Base::run_util();
-//    $monitor = new Monitor();
-//
-//    while (true) {
-//        $monitor->run_loop();
-//    }
-//}
-
-//function monitor_work()
-//{
-//    $fd = @fopen(BASE_ROOT_PATH . "/data/log/20180831.log", "r+");
-//
-//}
 
 class Parser
 {
@@ -270,3 +248,15 @@ class Parser
         return false;
     }
 }
+
+function work_proc()
+{
+    Base::run_util();
+    $monitor = new Monitor();
+
+    while (true) {
+        $monitor->run_loop();
+    }
+}
+
+event\util::fork_worker('work_proc',1);

+ 1 - 0
mobile/control/bonusex.php

@@ -67,6 +67,7 @@ class bonusexControl extends mobileControl
         if(empty($type_infos)) {
             return self::outerr(errcode::ErrBonus,"无此红包.");
         }
+
         if(session_helper::need_wechat_author())
         {
             $author = new thrid_author\wxauthor();

+ 1 - 1
mobile/control/brand.php

@@ -16,7 +16,7 @@ class brandControl extends mobileHomeControl
 
     public function homeOp()
     {
-        $brands = brand_helper::instance()->brandex();
+
         $blocks = [];
         $blocks[] = $brands['block'];
         return self::outsuccess(array("special_list" => $blocks,'mobile_page' => mobile_page(1)));

+ 21 - 7
mobile/control/control.php

@@ -30,7 +30,7 @@ class mobileControl
     {
         self::$startime = microtime(true);
 
-        Language::read('mobile');
+        //Language::read('mobile');
         //分页数处理
         if (is_numeric($_GET['page']) && intval(trim($_GET['page'])) > 0) {
             $this->page_size = intval(trim($_GET['page']));
@@ -53,6 +53,24 @@ class mobileControl
         statistics_helper::instance()->add_call($param);
     }
 
+    public function __destruct()
+    {
+        $record = [];
+        $record['user_session'] = session_helper::session_id();
+        $record['member_id'] = session_helper::memberid();
+        $record['relay_id'] = session_helper::relay_id();
+        $record['add_time'] = time();
+        $record['exec_time'] = intval((microtime(true) - self::$startime) * 1000000);
+        $record['content'] = $_SERVER['original_querystring'];
+        $record['client_type'] = session_helper::client_type();
+
+        if(!empty($_GET['from'])) {
+            $from = base64_decode($_GET['from']);
+            Log::record("from={$from}",Log::DEBUG);
+        }
+        Log::record_path(json_encode($record));
+    }
+
     private function set_relay()
     {
         if(isset($_GET['relay_id'])) {
@@ -78,10 +96,6 @@ class mobileControl
         }
     }
 
-    public function __destruct()
-    {
-    }
-
     protected function android()
     {
         return $_SESSION['client_type'] == 'android';
@@ -311,9 +325,9 @@ class mbMemberControl extends mobileControl
 
 function bonus_version()
 {
-    return "v=2018083006";
+    return "v=2018083008";
 }
 function shop_version()
 {
-    return "v=2018083006";
+    return "v=2018083008";
 }

+ 24 - 24
mobile/control/member_bonus.php

@@ -6,8 +6,6 @@
  * Time: 下午6:08
  */
 
-use bonus\account;
-
 require_once(BASE_ROOT_PATH . '/helper/bonus_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/session_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/text_filter.php');
@@ -23,7 +21,7 @@ require_once(BASE_ROOT_PATH . '/helper/push_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/url_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/invite_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/activity_helper.php');
-
+require_once(BASE_ROOT_PATH . '/helper/room_helper.php');
 
 class member_bonusControl extends mbMemberControl
 {
@@ -36,6 +34,29 @@ class member_bonusControl extends mbMemberControl
         $this->mUserAccount = $this->price_calcer();
     }
 
+    public function indexOp()
+    {
+        $result = [];
+        $result['bonus_total']  = $this->mUserAccount->total_bonus();
+        $result['bonus_rate']   = 30;
+        $mine_rooms = room_helper::user_rooms(session_helper::memberid(),'shared_bonus desc',4);
+        if(empty($mine_rooms)) {
+            $result['show_joinroom'] = true;
+            $result['mine_room'] = [];
+        } else {
+            $result['show_joinroom'] = false;
+            $result['mine_room'] = $mine_rooms;
+        }
+
+        return self::outsuccess($result);
+    }
+    public function mine_bonusOp()
+    {
+        $result = [];
+        $result['bonus_total']  = $this->mUserAccount->total_bonus();
+        return $result;
+    }
+
     public function predepositexOp()
     {
         $result = [];
@@ -131,27 +152,6 @@ class member_bonusControl extends mbMemberControl
         $_SESSION['cur_share_id'] = $share['share_id'];
     }
 
-    public function predepositOp()
-    {
-        $result = [];
-        $result['predeposit_total']  = $this->mUserAccount->total_bonus();
-        $result['predeposit_freeze'] = 0;
-
-        $bonus_state = $this->mUserAccount->bonus_state();
-        $result = array_merge($result,$bonus_state);
-
-        $result['bonus_rate'] = $this->format_rates($this->mUserAccount->pay_bonus_rates());
-        $result['share_bonus_rate'] = $this->format_rates($this->mUserAccount->share_bonus_rates());
-
-        $result['avatar'] = session_helper::avatar();
-        $result['sub_titles'] = ['shake' => '偷点地主家的余粮','invite' => '赚百分百红包','friends' => ''];
-        $result['shake_sub']  = "偷点地主家的余粮";
-        $result['invite_sub'] = "赚百分百红包";
-        $result['friends_sub'] = "";
-
-        return self::outsuccess($result);
-    }
-
     private function fill_param($input,$bonus_rate)
     {
         $param = $input;

+ 11 - 3
mobile/control/member_talk.php

@@ -185,6 +185,9 @@ class member_talkControl extends mbMemberControl
             {
                 $msgtype = proto_type::from_msgtype(intval($msg['type']));
                 if($msgtype == false) continue;
+//                if($msgtype == proto_type::msg_stype_goods) {
+//                    $msg['msg'] = json_decode($msg['msg'],true);
+//                }
 
                 $val = [];
                 $val["act"] = $type;
@@ -1072,7 +1075,8 @@ class member_talkControl extends mbMemberControl
             "avatar"=>$member['avatar'],
             "nickname"=>$member['nickname'],
             "charts"=>$charts,
-            "room_steps"=>$room_steps],
+            "room_steps"=>$room_steps,
+            "donate_rate"=>self::donate_rate],
             'talk/steps_detail');
     }
 
@@ -1386,13 +1390,17 @@ class member_talkControl extends mbMemberControl
         $items = $mod_room->getRoomsgList(["room_id"=>$room_id,"type"=>proto_type::msg_type_goods],20);
         $gids = [];
         foreach ($items as $item) {
-            $gids[] = $item['orgmsg'];
+            $goods_id = intval($item['orgmsg']);
+            if($goods_id > 0) $gids[] = $goods_id;
+
         }
 
         $goods = [];
         if(!empty($gids)) {
+            $gids = array_unique($gids);
             $helper = new goods_helper($this->price_calcer());
-            $goods = $helper->get_infos($gids);
+            $order = "field(goods_id,".implode(',',$gids).") asc";
+            $goods = $helper->get_infos($gids,0,$order);
         }
         return self::outsuccess( ["goods" => $goods] ,"/talk/room_goods");
     }

+ 1 - 1
mobile/templates/default/talk/steps_detail.php

@@ -228,7 +228,7 @@
                         bridge.call_native_handler('on_native_click', JSON.stringify(jsInit),function(res){
                             var datas = JSON.parse(res);
                         });
-                        $.toast("捐献成功",1000,function(){
+                        $.alert("您为该群贡献了"+datas.datas.amount+"元基金", "捐献成功",function(){
                             window.location.reload();
                         });
                     });

+ 18 - 0
test/TestLog.php

@@ -18,6 +18,7 @@ class TestLog extends PHPUnit_Framework_TestCase
         Base::run_util();
     }
 
+
     public function testPairlog()
     {
         $checker = new scope_trace(__METHOD__);
@@ -1144,6 +1145,23 @@ class TestLog extends PHPUnit_Framework_TestCase
             return false;
         }
     }
+
+    public function testPathlog()
+    {
+        $path_file = BASE_DATA_PATH . '/log/' . date('Ymd', time()) . '_path.log';
+        $fd = @fopen($path_file, "r");
+        $stdout = fopen('php://stdout', 'w');
+
+        while (!feof($fd))
+        {
+            $line = fgets($fd,1024);
+            if ($line !== false && !empty($line)) {
+                fwrite($stdout,"{$line}\n\n");
+            }
+        }
+        fclose($fd);
+    }
+
     public function testMonitor()
     {
         $fd = @fopen(BASE_ROOT_PATH . "/data/log/20180831.log", "c+");

+ 2 - 10
test/TestStat.php

@@ -10,7 +10,6 @@
 define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
 require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
-require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
 
 class TestStat extends PHPUnit_Framework_TestCase
 {
@@ -75,15 +74,8 @@ class TestStat extends PHPUnit_Framework_TestCase
         $y = base64_decode($x);
     }
 
-    public function testPath()
+    public function testBehavior()
     {
-        $val = 'YWN0PW1lbWJlcl9pbmZvJm9wPWdldA%253D%253D';
-        $x = 'eyJ0ayI6ImdDM2VJVzVZaDRCT3NaUWlYcE5raXo2eVhhamE3R2c1ZWJYK2lnZjZudGhPTFphVFN1RHVmRVVrbEl5TUtCL1hQNnRTcjg2VmRSdE5HUVQwR0NBMUZwS1REbEFwWEFRYTNKckx2OFVtNDU1R1NVYlVJU3lMcWdzNVVwWFBERFFuRGZZQ3lKdytGdEhIcHUzQW5sMkZCWjF2YjFuWGMweDhBZ0xHRjY3REJMQT0iLCJ2IjoxfQ==';
-        $y = base64_decode($x);
-        $data = json_decode($y,true);
-        $tk = base64_decode($data['tk']);
-
-        $path = urldecode($val);
-        $path = base64_decode($path);
+        stat_helper::onDaiyBehavior(time());
     }
 }