Ejemplo n.º 1
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));
 }