Beispiel #1
0
 function listAction()
 {
     //global $_F;
     // $_F["debug"] = true;
     $page = max(1, FRequest::getInt('page'));
     $uid = FRequest::getInt('uid');
     $query_str = "  ( mm.type='pic' or mm.type='text' ) ";
     $where = array();
     if ($uid > 0) {
         $where["mm.from"] = $uid;
         //$query_str=$query_str." and (mm.from='$uid' or mm.to='$uid') and mm.from<>1 and mm.to<>1 ";
         $where["str"] = $query_str;
         $user_detail_table = new FTable("user_detail");
         $user_detail = $user_detail_table->where(array('uid' => $uid))->find();
         $user_avatar = CommonUtil::getMoreSizeImg($user_detail["avatar"], 100, 100);
         $table = new FTable("message", "mm", FDB::$DB_MUMU_MESSAGE);
         $user_messages = $table->fields(array("mm.tm", "mm.from", "mm.to", "mm.content"))->where($where)->groupBy("mm.to")->page($page)->limit(20)->order(array("mm.tm" => "desc"))->select();
         $user_messages1 = $table->fields(array("mm.tm", "mm.from", "mm.to", "mm.content"))->where($where)->groupBy("mm.to")->order(array("mm.tm" => "desc"))->select();
         $total = count($user_messages1);
         foreach ($user_messages as &$user_message) {
             $user_detail_table = new FTable("user_detail");
             $user_detail = $user_detail_table->where(array('uid' => $user_message["to"]))->find();
             $user_message["to_avatar"] = CommonUtil::getMoreSizeImg($user_detail["avatar"], 100, 100);
             $user_message["content"] = json_decode($user_message["content"]);
         }
     }
     if ($uid > 0) {
         $page_info = $table->getPagerInfo();
         $this->assign('page_info', FPager::getPagerInfo($total, $page, '20'));
         $this->assign('user_messages', $user_messages);
         $this->assign('user_avatar', $user_avatar);
     }
     $this->assign('uid', $uid);
     $this->display('admin/usermessage_list');
 }
Beispiel #2
0
 public function listByPage($page, $order = array(), $conditions = null, $per_page = 20)
 {
     $page_option = array('curr_page' => max(1, intval($page)), 'total' => $this->count($conditions), 'per_page' => $per_page);
     FPager::build($page_option);
     $start = $page_option['start'];
     $limit = $page_option['per_page'];
     $results = $this->findAll($conditions, array(), array('*'), $start, $limit, $order);
     return array('data' => $results, 'page_option' => $page_option);
 }
Beispiel #3
0
 /**
  * 获得分页信息
  *
  * @throws Exception
  * @return array
  */
 public function getPagerInfo()
 {
     global $_F;
     $this->options = $this->getPagerOptions();
     $count = $this->count();
     $pagerOptions = $this->getPagerOptions();
     if (!isset($pagerOptions['page'])) {
         if ($_F['debug']) {
             throw new Exception('使用 getPagerInfo 的时候,必须在查询方法上使用 page 参数。如:$table->page(1)->limit(20)->select();');
         } else {
             return false;
         }
     }
     return FPager::getPagerInfo($count, $pagerOptions['page'], $pagerOptions['limit']);
 }
Beispiel #4
0
 function list2Action()
 {
     $uid = FRequest::getInt("uid");
     $page = max(1, FRequest::getInt('page'));
     $gender = FRequest::getInt('gender');
     $province = FRequest::getString('province');
     $city = FRequest::getString('city');
     $this->assign("province", $province);
     $this->assign("city", $city);
     $where = array();
     if ($uid > 0) {
         $where["um.uid"] = $uid;
     } else {
         $query_str = " ur.item <> 'all'  ";
         $where["ur.status"] = 0;
         $query_str = $query_str . " and ur.uid >= '5000000'  ";
         if ($city == "长沙") {
             $where["ud.city"] = $city;
         }
         if ($city == "北京") {
             $where["ud.city"] = $city;
         }
         if ($city == "非长沙") {
             $query_str = $query_str . " and ud.city<>'长沙'";
         }
         $where["str"] = $query_str;
     }
     if ($gender) {
         $where["um.gender"] = $gender;
     }
     if ($uid > 0) {
         $table = new FTable("user_main", "um");
         $users = $table->fields(array("um.uid", "um.gender", "um.reg_time", "ud.nickname", "ud.avatar", "ud.province", "ud.city", "ud.age", "ud.height", "ud.marry", "ud.aboutme", "ud.workarea", "ud.job", "ud.interest", "ud.birthday", "ud.workplaceid"))->leftJoin("user_detail", "ud", "um.uid=ud.uid")->where($where)->page($page)->limit(20)->select();
     } else {
         $table = new FTable("update_record", "ur");
         $users = $table->fields(array("um.uid", "um.gender", "um.reg_time", "ud.nickname", "ud.avatar", "ud.province", "ud.city", "ud.age", "ud.height", "ud.marry", "ud.aboutme", "ud.workarea", "ud.job", "ud.interest", "ud.birthday", "ud.workplaceid"))->leftJoin("user_main", "um", "ur.uid=um.uid")->leftJoin("user_detail", "ud", "um.uid=ud.uid")->where($where)->page($page)->limit(20)->groupBy("ur.uid")->order(array("ur.id" => "asc"))->select();
         $table = new FTable("update_record", "ur");
         $user_messages2 = $table->fields(array("um.uid"))->leftJoin("user_main", "um", "ur.uid=um.uid")->leftJoin("user_detail", "ud", "um.uid=ud.uid")->where($where)->groupBy("ur.uid")->select();
         $total = count($user_messages2);
     }
     foreach ($users as &$user) {
         //$user["avatar"] = CommonUtil::getMoreSizeImg($user["avatar"],200,200);
         $user["age"] = CommonUtil::birthdayToAge($user["birthday"]);
         $dynamics = new FTable("dynamics");
         $dynamic = $dynamics->fields(array("count(*) as count"))->where(array("uid" => $user["uid"], "str" => " status in (2,3,4) "))->select();
         $user["dynamics"] = $dynamic[0]['count'];
         $photo_table = new FTable("user_photo_album");
         $photos_o = $photo_table->fields(array("pic", "albumid"))->where(array("uid" => $user["uid"], "str" => " pic <> '" . $user["avatar"] . "'"))->select();
         $photos = array();
         foreach ($photos_o as &$p) {
             $p["pic"] = CommonUtil::getMoreSizeImg($p["pic"], 150, 150);
             array_push($photos, $p);
         }
         $user["photo_arr"] = $photos;
         $update_record = new FTable("update_record");
         $updates = $update_record->fields(array("item"))->where(array("uid" => $user["uid"], "status" => 0))->select();
         $update_arr = array();
         $j = 0;
         foreach ($updates as $update) {
             $update_arr[$j] = $update['item'];
             $j++;
         }
         //echo(json_encode($update_arr));
         if (in_array("nickname", $update_arr)) {
             $user["nicknamecss"] = "red";
         }
         if (in_array("avatar", $update_arr)) {
             $user["avatarcss"] = "red";
         }
         if (in_array("aboutme", $update_arr)) {
             $user["aboutmecss"] = "red";
         }
         $uid_d = $user["uid"];
         $table2 = new FTable("image_md5", "im");
         $image_md5 = $table2->fields(array("im.md5"))->where(array("im.url" => $user["avatar"]))->find();
         // echo($user["avatar"]);
         $table3 = new FTable("image_md5", "im");
         $images = $table3->fields(array("im.url"))->where(array("im.md5" => $image_md5["md5"], "str" => " im.url<>'" . $user["avatar"] . "' "))->select();
         $i = 1;
         foreach ($images as $image) {
             $table4 = new FTable("user_detail", "ud");
             $users4 = $table4->fields(array("ud.uid"))->where(array("ud.avatar" => $image['url']))->find();
             if ($users4) {
                 $i++;
                 $uid_d = $uid_d . "," . $users4['uid'];
             }
         }
         $user["avatar"] = CommonUtil::getMoreSizeImg($user["avatar"], 150, 150);
         $user["uid_d"] = $uid_d;
         $user["uid_i"] = $i;
     }
     if ($uid > 0) {
         $page_info = $table->getPagerInfo();
     } else {
         $page_info = FPager::getPagerInfo($total, $page, 20);
     }
     $this->assign('page_info', $page_info);
     $this->assign("users", $users);
     $this->assign("uid", $uid);
     $this->assign('gender', $gender);
     $this->display('admin/y_user_list2');
 }
Beispiel #5
0
 /**
  * 主报表查询
  */
 public function reportAction()
 {
     global $_F;
     $_F["debug"] = true;
     $page_size = 7;
     $page = max(1, FRequest::getInt('page'));
     $user_type = CommonUtil::getComParam(FRequest::getInt('user_type'), -1);
     $stats_date = FRequest::getString('stats_date');
     $where = array("s.interval" => "day");
     if ($user_type >= 0) {
         // $where["user_type"] = $user_type;
     }
     if ($stats_date && $stats_date != "") {
         $where["tm"] = $stats_date . " 00:00:00";
     }
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $c_names_key = array(array("key" => "1617", "key_1" => "1617_1", "key_2" => "1617_2"), array("key" => "1000", "key_1" => "1000_1", "key_2" => "1000_2"));
     foreach ($c_names as $key => $value) {
         $sub_arr = array("key" => $key, "key_1" => $key . "_1", "key_2" => $key . "_2");
         array_push($c_names_key, $sub_arr);
     }
     // echo(json_encode($c_names_key));
     $this->assign('c_names_key', $c_names_key);
     $fields = array("s.tm", "s.channel", "s.gender", "sum(s.value) as sum");
     $table2 = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $total_rs = $table2->fields($fields)->where($where)->groupBy("s.tm")->order(array("s.tm" => "desc"))->select();
     $total = count($total_rs);
     $jieshu_time = $total_rs[$page_size * ($page - 1)][tm];
     if ($page_size * $page > $total) {
         $kaishi_time = $total_rs[$total - 1][tm];
     } else {
         $kaishi_time = $total_rs[$page_size * $page - 1][tm];
     }
     // echo($kaishi_time.$jieshu_time);
     if ($total > 0) {
         $query_str = " s.tm >= '" . $kaishi_time . "' and  s.tm <= '" . $jieshu_time . "'   ";
         $where["str"] = $query_str;
     }
     $table = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $Stat = $table->fields($fields)->where($where)->groupBy("s.tm,s.channel,s.gender")->order(array("s.tm" => "desc"))->select();
     $Stats = array();
     foreach ($Stat as &$s) {
         $sub_arr = array();
         $s["tm"] = substr($s["tm"], 0, 10);
         if (array_key_exists($s["tm"], $Stats)) {
             $sub_arr = $Stats[$s["tm"]];
         }
         array_push($sub_arr, $s);
         $Stats[$s["tm"]] = $sub_arr;
     }
     //echo(json_encode($Stats));
     $Stats2 = array();
     foreach ($Stats as &$s) {
         $sub_arr = array("tm" => "");
         foreach ($s as &$s_x) {
             $sub_arr["tm"] = $s_x["tm"];
             $stats_key = $s_x["channel"] . "_" . $s_x["gender"];
             $sub_arr[$stats_key] = $s_x["sum"];
         }
         /*foreach($c_names_key as &$c) {
         
                                     $sub_arr[$c["key"] . "_1"] = $sub_arr[$c["key"] . "_1"];
                                     $sub_arr[$c["key"] . "_2"] = $sub_arr[$c["key"] . "_2"];
         
                             }*/
         array_push($Stats2, $sub_arr);
     }
     $page_info = FPager::getPagerInfo($total, $page, $page_size);
     //echo(json_encode($Stats2));
     $this->assign('page_info', $page_info);
     $this->assign('Stat', $Stats2);
     $this->assign('stats_date', $stats_date);
     $this->display('admin/stats_spm');
 }
Beispiel #6
0
 public function countForGroupBy($count, $page, $limit)
 {
     global $_F;
     return FPager::getPagerInfo($count, $page, $limit);
 }
Beispiel #7
0
 function listAction()
 {
     //global $_F;
     //$_F["debug"] = true;
     $page = max(1, FRequest::getInt('page'));
     $table = new FTable("user_star_level", "usl");
     $usls = $table->fields(array("usl.uid"))->where(array('uid' => array('gte' => 5000000)))->select();
     $user_ids1 = array();
     foreach ($usls as $usl) {
         array_push($user_ids1, $usl['uid']);
     }
     $table = new FTable("user_ban", "ub");
     $user_bans = $table->fields(array("ub.uid"))->where(array('uid' => array('gte' => 5000000)))->select();
     $user_ids2 = array();
     foreach ($user_bans as $user_ban) {
         array_push($user_ids2, $user_ban['uid']);
     }
     //$user_ids1=array(1,2,3,4,5);
     // $user_ids2=array(6,7,3,4,8);
     $user_ids = array_merge($user_ids1, $user_ids2);
     $user_ids = array_unique($user_ids);
     $user_ids = implode(",", $user_ids);
     $guolv_xingji_yonghu = "";
     if ($user_ids) {
         //$guolv_xingji_yonghu=" and mm.from not in (".$user_ids.") ";
         $guolv_xingji_yonghu = " and mm.uid not in (" . $user_ids . ") ";
     }
     $table = new FTable("honesty_record", "hr");
     $users = $table->fields(array("hr.uid"))->where(array("item" => 2))->select();
     $user_ins1 = array();
     foreach ($users as $user) {
         array_push($user_ins1, $user['uid']);
     }
     $users = $table->fields(array("hr.uid"))->where(array("item" => 3))->select();
     $user_ins2 = array();
     foreach ($users as $user) {
         array_push($user_ins2, $user['uid']);
     }
     $user_ins = array_intersect($user_ins1, $user_ins2);
     $user_ins = implode(",", $user_ins);
     if ($user_ins) {
         $guolv_xingji_yonghu = $guolv_xingji_yonghu . " and mm.uid  in (" . $user_ins . ") ";
     }
     //echo($guolv_xingji_yonghu);
     $where = array();
     $users = array();
     $datetime_qitian = date("Y-m-d ", time() - 86400 * 7);
     // $query_str = " mm.from>'5000000' and ( mm.tm>='" . $datetime_qitian . " 00:00:00' ) and type in ('text','pic','voice') ".$guolv_xingji_yonghu."";
     //$query_str = " 1=1";
     $query_str = " 1=1  " . $guolv_xingji_yonghu . "";
     $where["str"] = $query_str;
     $where["um.stat"] = 0;
     $where["ud.avatarlevel"] = array('gte' => '3');
     $table = new FTable("user_message_7", "mm");
     $user_messages = $table->fields(array("um.uid", "um.stat", "um.gender", "um.reg_time", "ud.nickname", "ud.avatar", "ud.province", "ud.city", "ud.age", "ud.height", "ud.marry", "ud.aboutme", "um.phonestat", "um.certify_video", "um.certify_idcard"))->leftJoin("user_main", "um", "um.uid=mm.uid")->leftJoin("user_detail", "ud", "ud.uid=mm.uid")->where($where)->page($page)->limit(50)->groupBy("mm.uid")->select();
     $table = new FTable("user_message_7", "mm");
     $user_messages2 = $table->fields(array("um.uid"))->leftJoin("user_main", "um", "um.uid=mm.uid")->leftJoin("user_detail", "ud", "ud.uid=mm.uid")->where($where)->groupBy("mm.uid")->select();
     $total = count($user_messages2);
     foreach ($user_messages as &$user_message) {
         $user_message['avatar'] = CommonUtil::getMoreSizeImg($user_message['avatar'], 222, 222);
         $photo_table = new FTable("user_photo_album");
         $photos = $photo_table->fields(array("pic"))->where(array("uid" => $user_message['uid']))->limit(3)->select();
         $photo_arr = array();
         foreach ($photos as $photo) {
             array_push($photo_arr, CommonUtil::getMoreSizeImg($photo["pic"], 222, 222));
         }
         $user_message['photo_arr'] = $photo_arr;
     }
     //echo(json_encode($user_messages));
     //$users=$user_messages;
     $page_info = FPager::getPagerInfo($total, $page, 50);
     $this->assign('page_info', $page_info);
     $this->assign('users', $user_messages);
     $this->display('admin/user_xingji_list');
 }
Beispiel #8
0
 /**
  * 主报表查询
  */
 public function reportAction()
 {
     //global $_F;
     //$_F["debug"] = true;
     $page_size = 7;
     $page = max(1, FRequest::getInt('page'));
     $c_uid = CommonUtil::getDefStr(FRequest::getString('c_uid'), "");
     $c_sid = CommonUtil::getDefStr(FRequest::getString('c_sid'), "");
     $user_type = CommonUtil::getComParam(FRequest::getInt('user_type'), -1);
     $user_xinlao = CommonUtil::getComParam(FRequest::getInt('user_xinlao'), -1);
     $stats_date = FRequest::getString('stats_date');
     $where = array("s.interval" => "day");
     if ($c_uid != "") {
         $where["channel"] = $c_uid;
     }
     if ($c_sid != "") {
         $where["sub_channel"] = $c_sid;
     }
     if ($user_type >= 0) {
         // $where["user_type"] = $user_type;
     }
     if ($stats_date && $stats_date != "") {
         $where["tm"] = $stats_date . " 00:00:00";
     }
     $table1 = new FTable("Config", "c", FDB::$DB_MUMU_STAT);
     $Config = $table1->order(array("c.action" => "asc"))->select();
     foreach ($Config as &$c) {
         $c["id_0"] = $c["id"] . "_0";
         $c["id_1"] = $c["id"] . "_1";
         $c["id_2"] = $c["id"] . "_2";
     }
     $fields = array("s.tm", "s.key", "s.gender", "sum(s.value) as sum");
     $table2 = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $total_rs = $table2->fields($fields)->where($where)->groupBy("s.tm")->order(array("s.tm" => "desc"))->select();
     $total = count($total_rs);
     $jieshu_time = $total_rs[$page_size * ($page - 1)][tm];
     if ($page_size * $page > $total) {
         $kaishi_time = $total_rs[$total - 1][tm];
     } else {
         $kaishi_time = $total_rs[$page_size * $page - 1][tm];
     }
     // echo($kaishi_time.$jieshu_time);
     if ($total > 0) {
         $query_str = " s.tm >= '" . $kaishi_time . "' and  s.tm <= '" . $jieshu_time . "'   ";
         $where["str"] = $query_str;
     }
     $table = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $Stat = $table->fields($fields)->where($where)->groupBy("s.tm,s.key,s.gender")->order(array("s.tm" => "desc"))->select();
     $Stats = array();
     foreach ($Stat as &$s) {
         $sub_arr = array();
         $s["tm"] = substr($s["tm"], 0, 10);
         if (array_key_exists($s["tm"], $Stats)) {
             $sub_arr = $Stats[$s["tm"]];
         }
         array_push($sub_arr, $s);
         $Stats[$s["tm"]] = $sub_arr;
     }
     // echo(json_encode($Stats));
     $Stats2 = array();
     foreach ($Stats as &$s) {
         $sub_arr = array("tm" => "");
         foreach ($s as &$s_x) {
             $sub_arr["tm"] = $s_x["tm"];
             $stats_key = $s_x["key"] . "_" . $s_x["gender"];
             $sub_arr[$stats_key] = $s_x["sum"];
         }
         foreach ($Config as &$c) {
             if ($c["id"] == "follow_users") {
                 $sub_arr[$c["id"] . "_0"] = $sub_arr[$c["id"] . "_lc_0_0"];
                 $sub_arr[$c["id"] . "_1"] = $sub_arr[$c["id"] . "_lc_0_1"];
                 $sub_arr[$c["id"] . "_2"] = $sub_arr[$c["id"] . "_lc_0_2"];
             } else {
                 $sub_arr[$c["id"] . "_0"] = $sub_arr[$c["id"] . "_0"];
                 $sub_arr[$c["id"] . "_1"] = $sub_arr[$c["id"] . "_1"];
                 $sub_arr[$c["id"] . "_2"] = $sub_arr[$c["id"] . "_2"];
             }
         }
         array_push($Stats2, $sub_arr);
     }
     $page_info = FPager::getPagerInfo($total, $page, $page_size);
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $this->assign('page_info', $page_info);
     $this->assign('Stat', $Stats2);
     $this->assign('Config', $Config);
     $this->assign('sc_uid', $c_uid);
     $this->assign('sc_sid', $c_sid);
     $this->assign('user_type', $user_type);
     $this->assign('stats_date', $stats_date);
     $this->display('admin/stats_wxw');
 }
Beispiel #9
0
 /**
  * 按小时查询详情
  * @throws Exception
  */
 public function hoursDetailAction()
 {
     global $_F;
     $page_size = 24;
     //$flag == 1 获取时间段相主渠道数据, flag ==2 获取时间段某子渠道时间段数据
     $flag = FRequest::getInt('flag');
     $page = max(1, FRequest::getInt('page'));
     $c_uid = CommonUtil::getDefStr(FRequest::getString('c_uid'), "");
     $c_sid = CommonUtil::getDefStr(FRequest::getString('c_sid'), "");
     $user_type = CommonUtil::getComParam(FRequest::getInt('user_type'), -1);
     $stats_date = FRequest::getString('stats_date');
     $this->assign('sc_uid', $c_uid);
     $this->assign('sc_sid', $c_sid);
     $this->assign('user_type', $user_type);
     $this->assign('stats_date', $stats_date);
     $this->assign('flag', $flag);
     $fields = array("stats_date", "hours", "c_uid", "c_sid", "user_type", "sum(reg_cnt) as reg_cnt", "sum(charge_user_cnt) as charge_user_cnt", "sum(charge_sum) as charge_sum", "sum(gived_sum) as gived_sum");
     $stats_table = new FTable("stats");
     $stats_table->fields($fields);
     $where = array();
     if ($c_uid != "") {
         $where["c_uid"] = $c_uid;
     }
     if ($c_sid != "") {
         $where["c_sid"] = $c_sid;
     }
     if ($stats_date && $stats_date != "") {
         $where["stats_date"] = $stats_date;
     }
     if ($user_type >= 0) {
         $where["user_type"] = $user_type;
     }
     $group_by = "stats_date,hours";
     if ($flag == 2) {
         $group_by = "stats_date,hours";
     }
     $logList = $stats_table->where($where)->groupBy($group_by)->order(array("hours" => "asc"))->page($page)->limit($page_size)->select();
     $stats_table2 = new FTable("stats");
     $total_rs = $stats_table2->fields(array("id"))->where($where)->groupBy($group_by)->select();
     $total = count($total_rs);
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmList', $spmList);
     $c_name = Service_Edit::getSpmMap($spmList);
     $c_s_name = Service_Edit::getSubSpmMap($spmList);
     $this->assign('spmarr', json_encode($spmList));
     $this->assign('spmList', $c_name);
     foreach ($logList as &$item) {
         $item["c_name"] = "";
         if (array_key_exists($item["c_uid"], $c_name)) {
             $item["c_name"] = $c_name[$item["c_uid"]];
         }
         $item["c_s_name"] = "";
         if (array_key_exists($item["c_sid"], $c_s_name)) {
             $item["c_s_name"] = $c_s_name[$item["c_sid"]];
         }
         $item["charge_sum"] = $item["charge_sum"] / 100;
     }
     $this->assign('logList', $logList);
     $this->assign('page_info', FPager::getPagerInfo($total, $page, $page_size));
     $this->display('admin/stats_hours_detail');
     //  echo(json_encode($logList));
 }
Beispiel #10
0
 /**
  * 主报表查询
  */
 public function reportAction()
 {
     //global $_F;
     //$_F["debug"] = true;
     $page_size = 30;
     $page = max(1, FRequest::getInt('page'));
     $c_uid = CommonUtil::getDefStr(FRequest::getString('c_uid'), "");
     $user_gender = CommonUtil::getComParam(FRequest::getInt('user_gender'), -1);
     $stats_date = FRequest::getString('stats_date');
     $stats_key = FRequest::getString('stats_key');
     $province = FRequest::getString('province');
     $ver = FRequest::getString('ver');
     $table = new FTable("user_province_area");
     $user_province = $table->groupBy("province")->order(array("id" => "asc"))->select();
     $this->assign('user_province', $user_province);
     $this->assign('province', $province);
     $this->assign('ver', $ver);
     if (!$stats_key) {
         $stats_key = "online_award_users";
         // $stats_key="on_top_users";
         //            $this->showMessage("查询留存不能为空",error,"/admin/ReportLiucun/default");
         //
         //        return;
         //            exit;
     }
     $where = array("s.interval" => "day");
     if ($c_uid != "") {
         $where["channel"] = $c_uid;
     }
     if ($user_gender >= 0) {
         $where["gender"] = $user_gender;
     }
     if ($province) {
         $where["province"] = $province;
     }
     if ($ver) {
         $where["ver"] = $ver;
     }
     $stats_key0 = $stats_key . "_lc_0";
     $stats_key1 = $stats_key . "_lc_1";
     $stats_key2 = $stats_key . "_lc_2";
     $stats_key3 = $stats_key . "_lc_3";
     $stats_key4 = $stats_key . "_lc_4";
     $stats_key5 = $stats_key . "_lc_5";
     $stats_key6 = $stats_key . "_lc_6";
     $stats_key7 = $stats_key . "_lc_7";
     $stats_key15 = $stats_key . "_lc_15";
     $stats_key30 = $stats_key . "_lc_30";
     $stats_key_array = array("'register'", "'" . $stats_key0 . "'", "'" . $stats_key1 . "'", "'" . $stats_key2 . "'", "'" . $stats_key3 . "'", "'" . $stats_key4 . "'", "'" . $stats_key5 . "'", "'" . $stats_key6 . "'", "'" . $stats_key7 . "'", "'" . $stats_key15 . "'", "'" . $stats_key30 . "'");
     $fields = array("s.tm", "s.key", "sum(s.value) as sum");
     //echo(json_encode($stats_key_array));
     $where["s.key"] = array('in' => $stats_key_array);
     $datetime_riqi_qiantian = date("Y-m-d", time() - 86400);
     $query_str = " s.tm <= '" . $datetime_riqi_qiantian . " 00:00:00'  ";
     $where["str"] = $query_str;
     $table2 = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $total_rs = $table2->fields($fields)->where($where)->groupBy("s.tm")->order(array("s.tm" => "desc"))->select();
     //echo(json_encode($where));
     $total = count($total_rs);
     $jieshu_time = $total_rs[$page_size * $page - $page_size][tm];
     if ($page_size * $page > $total) {
         $kaishi_time = $total_rs[$total - 1][tm];
     } else {
         $kaishi_time = $total_rs[$page_size * $page - 1][tm];
     }
     //echo($kaishi_time.$jieshu_time);
     if ($total > 0) {
         $query_str = " s.tm >= '" . $kaishi_time . "' and  s.tm <= '" . $jieshu_time . "'   ";
         $where["str"] = $query_str;
     }
     $table = new FTable("Stat", "s", FDB::$DB_MUMU_STAT);
     $Stat = $table->fields($fields)->where($where)->groupBy("s.tm,s.key")->order(array("s.tm" => "desc"))->select();
     $Stats = array();
     foreach ($Stat as &$s) {
         $sub_arr = array();
         $s["tm"] = substr($s["tm"], 0, 10);
         if (array_key_exists($s["tm"], $Stats)) {
             $sub_arr = $Stats[$s["tm"]];
         }
         array_push($sub_arr, $s);
         $Stats[$s["tm"]] = $sub_arr;
         //            $where["s.tm"] = $s["tm"];
         //            $where["s.key"] = "register";
         //            $table = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data = $table->fields(array("sum(s.value) as sum" )) ->where($where)->find();
         //            $s["register"] = $data["sum"];
         //
         //
         //            if ($stats_key) { $where["s.key"] = $stats_key1;  }
         //         $table1 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data1 = $table1->fields(array("sum(s.value) as sum" )) ->where($where)->find();
         //            $s["stats_key1"] = $data1["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key2;  }
         //            $table2 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data2 = $table2->fields(array("sum(s.value) as sum" )) ->where($where)->find();
         //            $s["stats_key2"] = $data2["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key3;  }
         //            $table3 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data3 = $table3->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key3"] = $data3["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key4;  }
         //            $table4 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data4 = $table4->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key4"] = $data4["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key5;  }
         //            $table5 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data5 = $table5->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key5"] = $data5["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key6;  }
         //            $table6 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data6 = $table6->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key6"] = $data6["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key7;  }
         //            $table7 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data7 = $table7->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key7"] = $data7["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key15;  }
         //            $table15 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data15 = $table15->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key15"] = $data15["sum"];
         //            if ($stats_key) { $where["s.key"] = $stats_key30;  }
         //            $table30 = new FTable("Stat","s",FDB::$DB_MUMU_STAT);
         //            $data30 = $table30->fields(array("sum(s.value) as sum")) ->where($where)->find();
         //            $s["stats_key30"] = $data30["sum"];
         //$s["stats_date"] = substr($s["tm"],0,10);
     }
     /*print_r($Stats);*/
     $Stats2 = array();
     foreach ($Stats as &$s) {
         $sub_arr = array("tm" => "", "register" => 0, $stats_key0 => 0, $stats_key1 => 0, $stats_key2 => 0, $stats_key3 => 0, $stats_key4 => 0, $stats_key5 => 0, $stats_key6 => 0, $stats_key7 => 0, $stats_key15 => 0, $stats_key30 => 0);
         foreach ($s as &$s_x) {
             $sub_arr["tm"] = $s_x["tm"];
             if ($s_x["key"] == "register") {
                 $sub_arr["register"] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key0) {
                 $sub_arr[$stats_key0] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key1) {
                 $sub_arr[$stats_key1] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key2) {
                 $sub_arr[$stats_key2] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key3) {
                 $sub_arr[$stats_key3] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key4) {
                 $sub_arr[$stats_key4] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key5) {
                 $sub_arr[$stats_key5] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key6) {
                 $sub_arr[$stats_key6] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key7) {
                 $sub_arr[$stats_key7] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key15) {
                 $sub_arr[$stats_key15] = $s_x["sum"];
             }
             if ($s_x["key"] == $stats_key30) {
                 $sub_arr[$stats_key30] = $s_x["sum"];
             }
         }
         array_push($Stats2, $sub_arr);
     }
     //echo(json_encode($Stats2));
     // $total = count($Stats);
     $page_info = FPager::getPagerInfo($total, $page, $page_size);
     $spmList = Service_Edit::getAllSpm();
     $this->assign('spmarr', json_encode($spmList));
     $c_names = Service_Edit::getSpmMap($spmList);
     $this->assign('spmList', $c_names);
     $this->assign('page_info', $page_info);
     $this->assign('Stat', $Stats2);
     $this->assign('stats_key', $stats_key);
     $this->assign('sc_uid', $c_uid);
     $this->assign('user_gender', $user_gender);
     $this->assign('stats_date', $stats_date);
     $this->assign('stats_key0', $stats_key0);
     $this->assign('stats_key1', $stats_key1);
     $this->assign('stats_key2', $stats_key2);
     $this->assign('stats_key3', $stats_key3);
     $this->assign('stats_key4', $stats_key4);
     $this->assign('stats_key5', $stats_key5);
     $this->assign('stats_key6', $stats_key6);
     $this->assign('stats_key7', $stats_key7);
     $this->assign('stats_key15', $stats_key15);
     $this->assign('stats_key30', $stats_key30);
     $this->display('admin/stats_liucun');
 }