Beispiel #1
0
 public function getOnline($StartTime, $EndTime, $ServerId, $oWherePartnerPermission)
 {
     if (($StartTime + $EndTime) / 2 > time()) {
         $Return['AvgOnline'] = 0;
         $Return['LowOnline'] = 0;
         $Return['HighOnline'] = 0;
     } else {
         //查询列
         $select_fields = array('ServerId', 'AvgOnline' => 'avg(CurOnline)', 'LowOnline' => 'min(CurOnline)', 'HighOnline' => 'max(HighestOnline)');
         //初始化查询条件
         $whereStartTime = " Time  >= '" . $StartTime . "' ";
         $whereEndTime = " Time  <= '" . $EndTime . "' ";
         $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
         $whereCondition = array($whereStartTime, $whereEndTime, $whereServer, $oWherePartnerPermission);
         $group_fields = array('ServerId');
         $groups = Base_common::getGroupBy($group_fields);
         //生成查询列
         $fields = Base_common::getSqlFields($select_fields);
         //生成分类汇总列
         $where = Base_common::getSqlWhere($whereCondition);
         $Date = date("Ym", ($StartTime + $EndTime) / 2);
         $table_to_process = Base_Widget::getDbTable($this->table) . "_" . $Date;
         $Return = array('UserCount' => 0, 'OnlineCount' => 0);
         $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where . $groups;
         $Online = $this->db->getAll($sql);
         foreach ($Online as $key => $val) {
             $Return['AvgOnline'] += $val['AvgOnline'];
             $Return['LowOnline'] += $val['LowOnline'];
             $Return['HighOnline'] += $val['HighOnline'];
         }
     }
     return $Return;
 }
Beispiel #2
0
 public function getMailSentUpByMailAddress($StartDate, $EndDate, $MailType)
 {
     //查询列
     $select_fields = array('MailSent' => 'count(*)', 'UserMail');
     //初始化查询条件
     //		$whereStart = $StartDate?" end_date >= '".strtotime($StartDate)."' ":"";
     //		$whereEnd = $EndDate?" end_date <= '".(strtotime($EndDate)+86400-1)."' ":"";
     $whereType = $MailType ? " MailType ='" . $MailType . "' " : "";
     $group_fields = array('UserMail');
     $groups = Base_common::getGroupBy($group_fields);
     $whereCondition = array($whereStart, $whereEnd, $whereType);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $StatArr['MailSent'] = array();
     //		foreach($MailFixList as $key => $value)
     //		{
     //			$StatArr['MailSent'][$value['SubFix']] = array('MailSent'=>0,'Detail'=>array());
     //		}
     //初始化结果数组
     $Date = $StartDate;
     $DateStart = date("Ymd", strtotime($StartDate));
     $DateEnd = date("Ymd", strtotime($EndDate));
     $DateList = array();
     $Date = $StartDate;
     do {
         $D = date("Ymd", strtotime($Date));
         $DateList[] = $D;
         $Date = date("Y-m-d", strtotime("{$Date} +1 day"));
     } while ($D != $DateEnd);
     foreach ($DateList as $k => $v) {
         $table_name = Base_Widget::getDbTable($this->table) . "_log_" . $v;
         $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where . $groups;
         $MailSentArr = $this->db->getAll($sql, false);
         foreach ($MailSentArr as $key => $val) {
             $t = explode("@", $val['UserMail']);
             $MailFix = "@" . $t['1'];
             if (isset($StatArr['MailSent'][$MailFix])) {
                 $StatArr['MailSent'][$MailFix]['MailSent'] += $val['MailSent'];
             } else {
                 $StatArr['MailSent'][$MailFix] = array('MailSent' => 0, 'Detail' => array());
                 $StatArr['MailSent'][$MailFix]['MailSent'] += $val['MailSent'];
             }
             if (isset($StatArr['MailSent'][$MailFix]['Detail'][$val['UserMail']])) {
                 $StatArr['MailSent'][$MailFix]['Detail'][$val['UserMail']] += $val['MailSent'];
             } else {
                 $StatArr['MailSent'][$MailFix]['Detail'][$val['UserMail']] = 0;
                 $StatArr['MailSent'][$MailFix]['Detail'][$val['UserMail']] += $val['MailSent'];
             }
         }
     }
     return $StatArr;
 }
Beispiel #3
0
 public function getCurrentCommonQustion($ConditionList, $fields = '*')
 {
     $table_to_process = Base_Widget::getDbTable($this->table_common);
     //查询列
     $select_fields = array($fields);
     //初始化查询条件
     $time = time();
     $whereDisplay = " display = 1";
     $whereCondition = array($whereDisplay);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $Limit = " limit " . $ConditionList['Count'];
     $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where . $groups . " order by id DESC " . $Limit;
     $CommonQuestion = $this->db->getAll($sql);
     return $CommonQuestion;
 }
Beispiel #4
0
 public function getUsedLine($DepotId)
 {
     //查询列
     $select_fields = array('Y', 'X');
     //初始化查询条件
     $whereDepot = $DepotId ? " DepotId = " . $DepotId . " " : "";
     $whereCondition = array($whereDepot);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_name = Base_Widget::getDbTable($this->table);
     $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where;
     $UsedArr = $this->db->getAll($sql, false);
     foreach ($UsedArr as $key => $Stat) {
         $StatArr[$Stat['X']] = $Stat;
     }
     return $StatArr;
 }
Beispiel #5
0
 public function getFirstLoginUserByAll($FirstStartDate, $FirstEndDate, $RegStartDate, $RegEndDate, $ServerId, $oWherePartnerPermission, $type)
 {
     //查询列
     if ($type == 1) {
         $select_fields = array('LoginUser' => 'count(distinct(UserId))', 'Date' => "from_unixtime(FirstLoginTime,'%Y-%m-%d')", 'DayLag' => "floor((LoginTime-FirstLoginTime)/86400)");
     } else {
         $select_fields = array('LoginUser' => 'count(distinct(UserId))', 'Date' => "from_unixtime(FirstLoginTime,'%Y-%m-%d')", 'DayLag' => "datediff(from_unixtime(LoginTime,'%Y-%m-%d'),from_unixtime(FirstLoginTime,'%Y-%m-%d'))");
     }
     //分类统计列
     $group_fields = array('Date', 'DayLag');
     //初始化查询条件
     $whereStartDate = $FirstStartDate ? " FirstLoginTime >= '" . strtotime($FirstStartDate) . "' " : "";
     $whereEndDate = $FirstEndDate ? " FirstLoginTime <= '" . (strtotime($FirstEndDate) + 86400 - 1) . "' " : "";
     $whereRegStartDate = $RegStartDate ? " UserRegTime >= '" . strtotime($RegStartDate) . "' " : "";
     $whereRegEndDate = $RegEndDate ? " UserRegTime <= '" . (strtotime($RegEndDate) + 86400 - 1) . "' " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereCondition = array($whereStartDate, $whereEndDate, $whereRegStartDate, $whereRegEndDate, $whereServer, $oWherePartnerPermission);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成分类汇总列
     $groups = Base_common::getGroupBy($group_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $date = $FirstStartDate;
     //初始化结果数组
     do {
         $StatArr['LoginDate'][$date] = array();
         $date = date("Y-m-d", strtotime($date) + 86400);
     } while (strtotime($date) <= strtotime($FirstEndDate));
     $DateStart = date("Ym", strtotime($FirstStartDate));
     $DateEnd = date("Ym", strtotime($FirstEndDate));
     $DateList = array();
     $Date = $FirstStartDate;
     do {
         $D = date("Ym", strtotime($Date));
         $DateList[] = $D;
         $Date = date("Y-m-d", strtotime("{$Date} +1 month"));
     } while ($D != $DateEnd);
     foreach ($DateList as $key => $value) {
         $table_name = Base_Widget::getDbTable($this->table_date) . "_" . $value;
         $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where . $groups;
         $LoginDateArr = $this->db->getAll($sql, false);
         if (is_array($LoginDateArr)) {
             foreach ($LoginDateArr as $key => $Stat) {
                 //累加数据
                 if (isset($StatArr['LoginDate'][$Stat['Date']][$Stat['DayLag']])) {
                     $StatArr['LoginDate'][$Stat['Date']][$Stat['DayLag']]['LoginUser'] += $Stat['LoginUser'];
                 } else {
                     $StatArr['LoginDate'][$Stat['Date']][$Stat['DayLag']] = array('LoginUser' => 0);
                     $StatArr['LoginDate'][$Stat['Date']][$Stat['DayLag']]['LoginUser'] += $Stat['LoginUser'];
                 }
             }
         }
     }
     return $StatArr;
 }
Beispiel #6
0
 public function getSendStatus($Date, $ServerId, $uType)
 {
     $select_fields = array('SendCount' => 'count(*)', 'H' => 'from_unixtime(Sendtime,"%H")', 'm' => 'from_unixtime(SendTime,"%i")');
     $whereuType = $uType ? ' uType = ' . $uType . ' ' : '';
     $whereServer = $ServerId ? ' ServerId = ' . $ServerId . ' ' : '';
     $whereCondition = array($whereuType, $whereServer);
     $group_fields = array('H', 'm');
     //生成分类汇总列
     $groups = Base_common::getGroupBy($group_fields);
     //分类统计列
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_to_process = $this->getDbTable($this->table_date) . "_" . date("Ymd", strtotime($Date));
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where . $groups;
     $return = $this->db->getAll($sql);
     $SendStatus = array();
     if (count($return)) {
         foreach ($return as $key => $value) {
             $SendStatus[$value['H'] * 60 + $value['m']]['SendCount'] = $value['SendCount'];
         }
     }
     return $SendStatus;
 }
Beispiel #7
0
 public function getExchangeDay($StartDate, $EndDate, $ExchangeType, $ServerId, $oWherePartnerPermission)
 {
     //查询列
     $select_fields = array('ExchangeUser' => 'count(distinct(UserId))', 'ExchangeCount' => 'count(*)', 'TotalAppCoin' => 'sum(AppCoin)', 'Date' => "from_unixtime(ExchangeTime,'%Y-%m-%d')");
     //分类统计列
     $group_fields = array('Date', 'AppId', 'PartnerId');
     //初始化查询条件
     $whereStartDate = $StartDate ? " ExchangeTime >= '" . strtotime($StartDate) . "' " : "";
     $whereEndDate = $EndDate ? " ExchangeTime <= '" . (strtotime($EndDate) + 86400 - 1) . "' " : "";
     $whereType = $ExchangeType ? " ExchangeType = " . $ExchangeType . " " : "";
     $whereCondition = array($whereStartTime, $whereEndTime, $oWherePartnerPermission, $whereType);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成分类汇总列
     $groups = Base_common::getGroupBy($group_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $date = $StartDate;
     //初始化结果数组
     $StatArr['TotalData'] = array('ExchangeUser' => 0, 'ExchangeCount' => 0, 'TotalAppCoin' => 0);
     do {
         $StatArr['ExchangeDate'][$date] = array('ExchangeUser' => 0, 'ExchangeCount' => 0, 'TotalAppCoin' => 0);
         $date = date("Y-m-d", strtotime($date) + 86400);
     } while (strtotime($date) <= strtotime($EndDate));
     $DateStart = date("Ym", strtotime($StartDate));
     $DateEnd = date("Ym", strtotime($EndDate));
     $DateList = array();
     $Date = $StartDate;
     do {
         $D = date("Ym", strtotime($Date));
         $DateList[] = $D;
         $Date = date("Y-m-d", strtotime("{$Date} +1 month"));
     } while ($D != $DateEnd);
     $oPartnerApp = new Config_Partner_App();
     $oArea = new Config_Area();
     foreach ($DateList as $key => $value) {
         $table_name = Base_Widget::getDbTable($this->table) . "_date_" . $value;
         $sql = "SELECT  {$fields} FROM {$table_name} as log where 1 " . $where . $groups;
         $ExchangeDateArr = $this->db->getAll($sql);
         if (is_array($ExchangeDateArr)) {
             foreach ($ExchangeDateArr as $key => $Stat) {
                 if (isset($StatArr['ExchangeDate'][$Stat['Date']])) {
                     $StatArr['ExchangeDate'][$Stat['Date']]['ExchangeCount'] += $Stat['ExchangeCount'];
                     $StatArr['ExchangeDate'][$Stat['Date']]['ExchangeUser'] += $Stat['ExchangeUser'];
                     $StatArr['ExchangeDate'][$Stat['Date']]['TotalAppCoin'] += $Stat['TotalAppCoin'];
                 } else {
                     $StatArr['ExchangeDate'][$Stat['Date']] = array('ExchangeUser' => 0, 'ExchangeCount' => 0, 'TotalAppCoin' => 0);
                     $StatArr['ExchangeDate'][$Stat['Date']]['ExchangeCount'] += $Stat['ExchangeCount'];
                     $StatArr['ExchangeDate'][$Stat['Date']]['ExchangeUser'] += $Stat['ExchangeUser'];
                     $StatArr['ExchangeDate'][$Stat['Date']]['TotalAppCoin'] += $Stat['TotalAppCoin'];
                 }
             }
         }
     }
     return $StatArr;
 }
Beispiel #8
0
 public function getCurrentRate($LotoId, $Time)
 {
     $select_fields = array('*');
     $whereTime = $Time ? " (StartTime <= " . $Time . " and EndTime >= " . $Time . ")" : "";
     $whereLoto = $LotoId ? " LotoId = " . $LotoId : "";
     $whereCount = " LotoPrizeCountUsed < LotoPrizeCount ";
     $whereCondition = array($whereLoto, $whereTime, $whereCount);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //生成条件列
     $table_name = Base_Widget::getDbTable($this->table_detail);
     $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where;
     $PrizeArr = $this->db->getAll($sql, false);
     $StatArr = array('PrizeList' => array());
     if (is_array($PrizeArr)) {
         foreach ($PrizeArr as $key => $Stat) {
             $StatArr['PrizeDetailList'][$Stat['LotoPrizeDetailId']] = $Stat;
         }
     }
     return $StatArr;
 }
Beispiel #9
0
 public function getResearchDetailCount($StartDate, $EndDate, $UserId, $ResearchId, $QuestionId)
 {
     //查询列
     $select_fields = array('ResearchCount' => 'count(*)');
     //分类统计列
     //初始化查询条件
     $whereStartDate = $StartDate ? " AnswerTime >= " . strtotime($StartDate) . " " : "";
     $whereEndDate = $EndDate ? " AnswerTime <= " . (strtotime($EndDate) + 86400 - 1) . " " : "";
     $whereUser = $UserId ? " UserId = " . $UserId . " " : "";
     $whereQuestion = $QuestionId ? " QuestionId = " . $QuestionId . " " : "";
     $whereCondition = array($whereUser, $whereStartDate, $whereEndDate, $whereQuestion);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_to_process = Base_Widget::getDbTable($this->table_answer) . "_" . $ResearchId;
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $ResearchCount = $this->db->getOne($sql, false);
     if ($ResearchCount) {
         return $ResearchCount;
     } else {
         return 0;
     }
 }
Beispiel #10
0
 /**
  * 获取用户数量
  * @param $fields  所要获取的数据列
  * @param $params 传入的条件列表
  * @return integer
  */
 public function getAuthLogCount($params)
 {
     //生成查询列
     $fields = Base_common::getSqlFields(array("AuthLOgCount" => "count(auth_id)"));
     //获取需要用到的表名
     $table_to_process = Base_Widget::getDbTable($this->table_auth_log);
     //开始时间
     $whereStartDate = isset($params['StartDate']) ? " op_time >= '" . $params['StartDate'] . "' " : "";
     //开始时间
     $whereEndDate = isset($params['EndDate']) ? " op_time <= '" . date("Y-m-d", strtotime($params['EndDate']) + 86400) . "' " : "";
     //审核结果
     $whereAuthResult = isset($this->auth_status_log[$params['AuthResult']]) ? " auth_result = " . $params['AuthResult'] . " " : "";
     //操作人
     $whereManager = $params['ManagerId'] ? " op_uid = " . $params['ManagerId'] . " " : "";
     //所有查询条件置入数组
     $whereCondition = array($whereStartDate, $whereEndDate, $whereAuthResult, $whereManager);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //生成条件列
     $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where;
     return $this->db->getOne($sql);
 }
Beispiel #11
0
 public function getProductSendQueueDetailCount($UserId, $ProductSendType, $ProductType, $ServerId)
 {
     //查询列
     $select_fields = array('ProductSendQueueCount' => 'count(*)');
     //分类统计列
     //初始化查询条件
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereSendType = $ProductSendType ? " SendType = '" . $ProductSendType . "' " : "";
     $whereType = $ProductType ? " ProductType = '" . $ProductType . "' " : "";
     $whereCondition = array($whereUser, $whereSendType, $whereType, $whereServer);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_to_process = Base_Widget::getDbTable($this->table_send_queue);
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $ProductSendQueueCount = $this->db->getOne($sql, false);
     if ($ProductSendQueueCount) {
         return $ProductSendQueueCount;
     } else {
         return 0;
     }
 }
Beispiel #12
0
 public function getActiveDetailCount($StartDate, $EndDate, $UserId, $oWherePartnerPermission)
 {
     //查询列
     $select_fields = array('ActiveCount' => 'count(*)');
     //分类统计列
     //初始化查询条件
     $whereStartDate = $StartDate ? " ActiveTime >= " . strtotime($StartDate) . " " : "";
     $whereEndDate = $EndDate ? " ActiveTime <= " . (strtotime($EndDate) + 86400 - 1) . " " : "";
     $whereUser = $UserId ? " ActiveUser = "******" " : "";
     $whereCondition = array($whereStartDate, $whereEndDate, $whereUser, $oWherePartnerPermission);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_to_process = Base_Widget::getDbTable($this->table);
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $ActiveCount = $this->db->getOne($sql, false);
     if ($ActiveCount) {
         return $ActiveCount;
     } else {
         return 0;
     }
 }
Beispiel #13
0
 public function getNpcItemPurchaseDetailCount($StartTime, $EndTime, $UserId, $ServerId, $MoneyType, $oWherePartnerPermission, $ItemListText)
 {
     //查询列
     $select_fields = array('PurchaseCount' => 'count(*)');
     //初始化查询条件
     $whereStartTime = $StartTime ? " NpcPurchaseTime >= '" . strtotime($StartTime) . "' " : "";
     $whereEndTime = $EndTime ? " NpcPurchaseTime <= '" . strtotime($EndTime) . "' " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereItemID = $ItemListText ? " ItemID in ( " . $ItemListText . " )" : "";
     $whereUser = $UserId ? " UserId = " . $UserId . " " : "";
     $whereMoney = $MoneyType ? " MoneyType = " . $MoneyType . " " : "";
     $groups = Base_common::getGroupBy($group_fields);
     $whereCondition = array($whereStartTime, $whereEndTime, $whereUser, $whereMoney, $whereServer, $oWherePartnerPermission, $whereItemID);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     if ($UserId) {
         $position = Base_Common::getUserDataPositionById($UserId);
         $table_to_process = Base_Widget::getDbTable($this->table_npc_item_purchase) . "_user_" . $position['db_fix'];
     } else {
         $Date = date("Ym", strtotime($StartTime));
         $table_to_process = Base_Widget::getDbTable($this->table_npc_item_purchase) . "_" . $Date;
     }
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $PurchaseCount = $this->db->getOne($sql, false);
     if ($PurchaseCount) {
         return $PurchaseCount;
     } else {
         return 0;
     }
 }
Beispiel #14
0
 public function getUserProductPackCodeListCount($UserId, $Used, $ProductPackId, $GenId)
 {
     //查询列
     $select_fields = array('UserProductPackCodeCount' => 'count(*)');
     //分类统计列
     //初始化查询条件
     if ($Used == 0) {
         $whereUser = $UserId ? " ((UsedUser = "******") or (AsignUser = "******")) " : "";
     } elseif ($Used == 1) {
         $whereUser = $UserId ? " (UsedUser = "******") " : "";
     } elseif ($Used == 2) {
         $whereUser = $UserId ? " ((UsedUser = 0) and (AsignUser = "******")) " : "";
     }
     $wherePack = $ProductPackId ? " ProductPackId = " . $ProductId . " " : "";
     $whereGen = $GenId ? " GenId = " . $GenId . " " : "";
     $whereCondition = array($whereUser, $wherePack, $whereGen);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $position = Base_Common::getUserDataPositionById($UserId);
     $table_to_process = Base_Common::getUserTable($this->table_code, $position);
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $UserProductPackCodeCount = $this->db->getOne($sql, false);
     if ($UserProductPackCodeCount) {
         return $UserProductPackCodeCount;
     } else {
         return 0;
     }
 }
Beispiel #15
0
 public function changeHeroByLevel($StartDate, $EndDate, $ServerId, $HeroId, $oWherePartnerPermission, $CurHeroId, $NewHeroId)
 {
     //查询列
     $select_fields = array('HeroChangeCount' => 'count(*)', 'UserCount' => 'count(distinct(UserId))', 'CharacterLevel' => 'CharacterLevel', 'HeroChangeDate' => "from_unixtime(HeroChangeTime,'%Y-%m-%d')");
     //初始化查询条件
     $whereStartDate = $StartDate ? " HeroChangeTime >= '" . strtotime($StartDate) . "' " : "";
     $whereEndDate = $EndDate ? " HeroChangeTime <= '" . (strtotime($EndDate) + 86400 - 1) . "' " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereCurHero = $CurHeroId ? " CurHeroId = " . $CurHeroId . " " : "";
     $whereNewHero = $NewHeroId ? " NewHeroId = " . $NewHeroId . " " : "";
     $group_fields = array('CharacterLevel');
     $groups = Base_common::getGroupBy($group_fields);
     $whereCondition = array($whereStartDate, $whereEndDate, $whereServer, $oWherePartnerPermission, $whereReason, $whereCurHero, $whereNewHero);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //初始化结果数组
     $StatArr = array('ChangeHero' => array());
     for ($i = 0; $i <= 50; $i++) {
         $StatArr['ChangeHero'][$i] = array('HeroChangeCount' => 0, 'UserCount' => 0);
     }
     $DateStart = date("Ym", strtotime($StartDate));
     $DateEnd = date("Ym", strtotime($EndDate));
     $DateList = array();
     $Date = $StartDate;
     do {
         $D = date("Ym", strtotime($Date));
         $DateList[] = $D;
         $Date = date("Y-m-d", strtotime("{$Date} +1 month"));
     } while ($D != $DateEnd);
     foreach ($DateList as $k => $v) {
         $table_name = Base_Widget::getDbTable($this->table_change) . "_" . $v;
         $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where . $groups;
         $ChangeHeroLogoutArr = $this->db->getAll($sql, false);
         foreach ($ChangeHeroLogoutArr as $key => $val) {
             $StatArr['ChangeHero'][$val['CharacterLevel']]['HeroChangeCount'] += $val['HeroChangeCount'];
             $StatArr['ChangeHero'][$val['CharacterLevel']]['UserCount'] += $val['UserCount'];
         }
     }
     return $StatArr;
 }
Beispiel #16
0
 public function getUserOrderCount($UserId, $AppId, $PartnerId, $ServerId, $StartDate, $EndDate, $OrderStatus)
 {
     //查询列
     $select_fields = array('OrderCount' => 'count(*)');
     //分类统计列
     //初始化查询条件
     $whereStartDate = $StartDate ? " OrderTime >= " . strtotime($StartDate) . " " : "";
     $whereEndDate = $EndDate ? " OrderTime <= " . (strtotime($EndDate) + 86400 - 1) . " " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $wherePartner = $PartnerId ? " PartnerId = " . $PartnerId . " " : "";
     $whereApp = $AppId ? " AppId = " . $AppId . " " : "";
     $whereStatus = $OrderStatus != 5 ? " OrderStatus = " . $OrderStatus . " " : "";
     $whereUser = $UserId ? " AcceptUserId = " . $UserId . " " : "";
     $whereCondition = array($whereStartDate, $whereEndDate, $whereStatus, $whereServer, $wherePartner, $whereApp, $whereUser);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $StatArr = array('OrderCount' => 0);
     $position = Base_Common::getUserDataPositionById($UserId);
     $table_name = Base_Widget::getDbTable($this->table_user) . "_" . $position['db_fix'];
     $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where;
     $OrderCount = $this->db->getRow($sql, false);
     if (isset($OrderCount)) {
         $StatArr['OrderCount'] += $OrderCount['OrderCount'];
     }
     return $StatArr;
 }
Beispiel #17
0
 /**
  * 获取用户数量
  * @param $fields
  * @param $params
  * @return array
  */
 public function getUserCount($params)
 {
     //生成查询列
     $fields = Base_common::getSqlFields(array("UserCount" => "count(user_id)"));
     //获取需要用到的表名
     $table_to_process = Base_Widget::getDbTable($this->table);
     //性别判断
     $whereSex = isset($this->sex[$params['Sex']]) ? " sex = '" . $params['Sex'] . "' " : "";
     //实名认证判断
     $whereAuth = isset($this->auth_status[$params['AuthStatus']]) ? " auth_state = '" . $params['AuthStatus'] . "' " : "";
     //姓名
     $whereName = isset($params['Name']) && trim($params['Name']) ? " name like '%" . $params['Name'] . "%' " : "";
     //昵称
     $whereNickName = isset($params['NickName']) && trim($params['NickName']) ? " nick_name like '%" . $params['NickName'] . "%' " : "";
     //所有查询条件置入数组
     $whereCondition = array($whereSex, $whereName, $whereNickName, $whereAuth);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //生成条件列
     $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where;
     return $this->db->getOne($sql);
 }
Beispiel #18
0
 public function getQuestionNumList($ConditionList)
 {
     $table_to_process = Base_Widget::getDbTable($this->table_question_num);
     //查询列
     $select_fields = array('QuestionNum' => 'sum(questions)', 'QuestionType' => 'question_type', 'Qtype' => 'qtype');
     //分类统计列
     $group_fields = array('QuestionType', 'Qtype');
     //初始化查询条件
     if ($ConditionList['StartDate'] == $ConditionList['EndDate']) {
         $whereDate = $ConditionList['StartDate'] ? " date = '" . $ConditionList['StartDate'] . "' " : "";
         $whereStartDate = "";
         $whereEndDate = "";
     } else {
         $whereStartDate = $ConditionList['StartDate'] ? " date >= '" . $ConditionList['StartDate'] . "' " : "";
         $whereEndDate = $ConditionList['EndDate'] ? " date <= '" . $ConditionList['EndDate'] . "' " : "";
         $whereDate = "";
     }
     $whereQtype = $ConditionList['QtypeId'] ? " qtype = " . $ConditionList['QtypeId'] . " " : "";
     //$whereQuestionType = $ConditionList['QuestionType']?" question_type in (".$ConditionList['QuestionType'].")":"";
     $QuestionTypeArrTemp = explode(',', $ConditionList['QuestionType']);
     $QuestionTypeArr = $this->config->QuestionTypeList;
     foreach ($QuestionTypeArr as $key => $value) {
         if (!in_array($key, $QuestionTypeArrTemp)) {
             unset($QuestionTypeArr[$key]);
         }
     }
     if (count($QuestionTypeArr) < 1) {
         $QuestionTypeArr = $this->config->QuestionTypeList;
     }
     $t = array();
     foreach ($QuestionTypeArr as $key => $value) {
         $t[] = "'" . $key . "'";
     }
     $whereQuestionType = "question_type in (" . implode(",", $t) . ")";
     $whereCondition = array($whereDate, $whereStartDate, $whereEndDate, $whereQtype, $whereQuestionType);
     //print_R($whereCondition);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成分类汇总列
     $groups = Base_common::getGroupBy($group_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //初始化问题分类数组
     //获取所有需要显示的主分类列表
     $QtypeList = $this->getAllQtype(1, 'name,id,trading,pid');
     //初始化结果数组
     $QuestionNum = array();
     foreach ($QuestionTypeArr as $QuestionType => $QuestionTypeName) {
         $oCategory = new Kubao_Category();
         $CategoryInfo = $oCategory->getCategoryByQuestionType($QuestionType, 'name');
         $QuestionNum[$QuestionType] = array('content' => $CategoryInfo['name'] . "总量:", 'QuestionNum' => 0, 'QuestionNumList' => array());
         foreach ($QtypeList as $key => $QtypeInfo) {
             if ($QuestionType == "complain") {
                 $TradingConfig = unserialize($QtypeInfo['trading']);
                 //如果该投诉下的问题分类不可直接提交订单申诉则留在列表中,否则去除
                 if (trim($TradingConfig['directOrderUrl']) == "") {
                     $OrderCount = $this->getOrderCount($QtypeInfo['id'], 'order_count');
                     $OrderCount = isset($OrderCount['order_count']) ? intval($OrderCount['order_count']) : 0;
                     $QuestionNum[$QuestionType]['QuestionNumList'][$QtypeInfo['id']] = array('QuestionNum' => 0, 'OrderCount' => $OrderCount, 'QtypeId' => $QtypeInfo['id'], 'content' => $QtypeInfo['name'], 'url' => 'http://sc.5173.com/?index/questionTypeDetail/' . $QtypeInfo['id'] . '/' . $QuestionType);
                     $QuestionNum[$QuestionType]['OrderCount'] += $OrderCount;
                 }
             } else {
                 $QuestionNum[$QuestionType]['QuestionNumList'][$QtypeInfo['id']] = array('QuestionNum' => 0, 'QtypeId' => $QtypeInfo['id'], 'content' => $QtypeInfo['name'], 'url' => 'http://sc.5173.com/?index/questionTypeDetail/' . $QtypeInfo['id'] . '/' . $QuestionType);
             }
         }
         foreach ($QtypeList as $key => $QtypeInfo) {
             if ($QtypeInfo['pid'] > 0) {
                 unset($QuestionNum[$QuestionType]['QuestionNumList'][$QtypeInfo['pid']]);
             }
         }
     }
     $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where . $groups;
     $data = $this->db->getAll($sql);
     foreach ($data as $key => $value) {
         //数据累加
         if (isset($QuestionNum[$value['QuestionType']]['QuestionNumList'][$value['Qtype']])) {
             if ($value['QuestionType'] == "complain") {
                 $QuestionNum[$value['QuestionType']]['QuestionNum'] += $value['QuestionNum'];
                 if ($QuestionNum[$value['QuestionType']]['QuestionNumList'][$value['Qtype']]['OrderCount'] > 0) {
                     $value['QuestionNum'] = $value['QuestionNum'] / $QuestionNum[$value['QuestionType']]['QuestionNumList'][$value['Qtype']]['OrderCount'];
                     if ($value['QuestionNum'] > 1 || $value['QuestionNum'] < 1 / 100 / 100) {
                         $value['QuestionNum'] = "0.01%";
                         //$value['QuestionNum'] = $QuestionNum[$value['QuestionType']]['OrderCount'];
                     } else {
                         $value['QuestionNum'] = sprintf("%2.2f", $value['QuestionNum'] * 100) . "%";
                     }
                 } else {
                     $value['QuestionNum'] = "0.01%";
                     //$value['QuestionNum'] = $value['QuestionNum'];//$QuestionNum[$value['QuestionType']]['OrderCount'];
                 }
                 $QuestionNum[$value['QuestionType']]['QuestionNumList'][$value['Qtype']]['QuestionNum'] = $value['QuestionNum'];
             } else {
                 $QuestionNum[$value['QuestionType']]['QuestionNumList'][$value['Qtype']]['QuestionNum'] = $value['QuestionNum'];
                 $QuestionNum[$value['QuestionType']]['QuestionNum'] += $value['QuestionNum'];
             }
         }
     }
     //初始化为json可识别对象
     foreach ($QuestionTypeArr as $QuestionType => $QuestionTypeName) {
         $QuestionNum[$QuestionType]['QuestionNumList2'] = array();
         foreach ($QuestionNum[$QuestionType]['QuestionNumList'] as $key => $value) {
             $QuestionNum[$QuestionType]['QuestionNumList2'][] = $value;
         }
         $QuestionNum[$QuestionType]['QuestionNumList'] = $QuestionNum[$QuestionType]['QuestionNumList2'];
         unset($QuestionNum[$QuestionType]['QuestionNumList2']);
     }
     if (isset($QuestionNum["complain"])) {
         $Q = sprintf("%2.2f", $QuestionNum["complain"]['QuestionNum'] / $QuestionNum["complain"]['OrderCount'] * 100) . "%";
         if ($Q > 1 || $Q < 1 / 100 / 100) {
             $QuestionNum["complain"]['QuestionNum'] = "0.01%";
         } else {
             $QuestionNum["complain"]['QuestionNum'] = sprintf("%2.2f", $Q) . "%";
         }
     }
     return $QuestionNum;
 }
Beispiel #19
0
 public function getItemPickUpCount($StartTime, $EndTime, $UserId, $ServerId, $oWherePartnerPermission, $ItemListText)
 {
     //查询列
     $select_fields = array('PickUpCount' => 'count(*)');
     //初始化查询条件
     $whereStartTime = $StartTime ? " ItemPickUpTime >= '" . strtotime($StartTime) . "' " : "";
     $whereEndTime = $EndTime ? " ItemPickUpTime <= '" . strtotime($EndTime) . "' " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereItemID = $ItemListText ? " ItemID in ( " . $ItemListText . " )" : "";
     $whereUser = $UserId ? " UserId = " . $UserId . " " : "";
     $whereCondition = array($whereStartTime, $whereEndTime, $whereUser, $whereServer, $oWherePartnerPermission, $whereItemID);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     if ($UserId) {
         $position = Base_Common::getUserDataPositionById($UserId);
         $table_to_process = Base_Common::getUserTable($this->table_list['pickitem_user'], $position);
     } else {
         $Date = date("Ymd", strtotime($StartTime));
         $table_to_process = Base_Widget::getDbTable($this->table_list['pickitem']) . "_" . $Date;
     }
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $PickUpCount = $this->db->getOne($sql, false);
     if ($PickUpCount) {
         return $PickUpCount;
     } else {
         return 0;
     }
 }
Beispiel #20
0
 public function getCharacterFreeze($UserId, $ServerId)
 {
     //查询列
     $select_fields = array('FreezeCount' => 'count(*)', 'MaxTime' => 'max(EndTime)');
     //分类统计列
     $time = time();
     //初始化查询条件
     $whereStartTime = " StartTime <= " . $time . " ";
     $whereEndTime = " EndTime >= " . $time . " ";
     $whereUser = $UserId ? " UserId = " . $UserId . " " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereCondition = array($whereUser, $whereStartTime, $whereEndTime, $whereServer);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     if ($UserId) {
         $position = Base_Common::getUserDataPositionById($UserId);
         $table_to_process = Base_Common::getUserTable($this->character_freeze, $position);
     }
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $Freeze = $this->db->getRow($sql, false);
     if ($Freeze['FreezeCount']) {
         return $Freeze;
     } else {
         return array('FreezeCount' => 0);
     }
 }
Beispiel #21
0
 public function getTotalPayUser($Date, $oWherePartnerPermission)
 {
     //查询列
     $select_fields = array('PayUser' => 'count(distinct(AcceptUserId))');
     //分类统计列
     //初始化查询条件
     $whereDate = $Date ? " PayedTime < '" . (strtotime($Date) + 86400) . "' " : "";
     $whereCondition = array($whereDate, $oWherePartnerPermission);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_name = Base_Widget::getDbTable($this->table_first);
     $sql = "SELECT {$fields} FROM {$table_name} as log where 1 " . $where;
     $PayUser = $this->db->getOne($sql, false);
     return $PayUser;
 }
Beispiel #22
0
 public function getLevelUpDetailCount($StartTime, $EndTime, $UserId, $ServerId, $oWherePartnerPermission)
 {
     //查询列
     $select_fields = array('LevelUpCount' => 'count(*)');
     //分类统计列
     //初始化查询条件
     $whereStartTime = $StartTime ? " CharacterLevelUpTime >= " . strtotime($StartTime) . " " : "";
     $whereEndTime = $EndTime ? " CharacterLevelUpTime <= " . strtotime($EndTime) . " " : "";
     $whereUser = $UserId ? " UserId = " . $UserId . " " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereCondition = array($whereUser, $whereStartTime, $whereEndTime, $whereServer, $oWherePartnerPermission);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $Date = date("Ym", strtotime($StartTime));
     if (!$UserId) {
         $table_to_process = Base_Widget::getDbTable($this->table_levelup_log) . "_" . $Date;
     } else {
         $position = Base_Common::getUserDataPositionById($UserId);
         $table_to_process = Base_Widget::getDbTable($this->table_levelup_log) . "_user_" . $position['db_fix'];
     }
     $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where;
     $LevelUpCount = $this->db->getOne($sql, false);
     if ($LevelUpCount) {
         return $LevelUpCount;
     } else {
         return 0;
     }
 }
Beispiel #23
0
 public function getComplainList($ConditionList, $fields = "*", $order = "desc")
 {
     $table_to_process = Base_Widget::getDbTable($this->table);
     //查询列
     $select_fields = array($fields);
     //初始化查询条件
     $whereStartTime = $ConditionList['StartDate'] ? " time >= " . strtotime($ConditionList['StartDate']) . " " : "";
     $whereEndTime = $ConditionList['EndDate'] ? " time <= " . (strtotime($ConditionList['EndDate']) + 86400) . " " : "";
     $whereQtype = $ConditionList['QtypeId'] ? " qtype = " . $ConditionList['QtypeId'] . " " : "";
     $whereStartTime = $ConditionList['StartTime'] ? " time >= " . $ConditionList['StartTime'] . " " : $whereStartTime;
     $whereEndTime = $ConditionList['EndTime'] ? " time <= " . $ConditionList['EndTime'] . " " : $whereEndTime;
     $t = explode(",", $ConditionList['Public']);
     if (count($t) >= 2) {
         $wherePublic = ' AND public in (' . implode(',', $t) . ')';
     } else {
         $wherePublic = $ConditionList['Public'] >= 0 ? " public = " . $ConditionList['Public'] . " " : "";
     }
     switch ($ConditionList['QuestionStatus']) {
         case 0:
             $whereQuestionStatus = "";
             break;
         case 1:
             $whereQuestionStatus = " status in (0,4)";
             break;
         case 2:
             $whereQuestionStatus = " status in (1,3)";
             break;
         case 3:
             $whereQuestionStatus = " status = 2";
             break;
     }
     $whereCondition = array($whereStartTime, $whereEndTime, $whereQtype, $wherePublic, $whereQuestionStatus);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //计算记录数量
     $CountSql = "SELECT count(1) as QuestionNum FROM {$table_to_process} where 1 " . $where;
     $QuestionNum = $this->db->getOne($CountSql);
     //如果记录数量大于页码数量
     if ($QuestionNum >= ($ConditionList['Page'] - 1) * $ConditionList['PageSize']) {
         $Limit = " limit " . ($ConditionList['Page'] - 1) * $ConditionList['PageSize'] . "," . $ConditionList['PageSize'];
         $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where . $groups . " order by time " . $order . $Limit;
         $data = $this->db->getAll($sql);
         $ReturnArr = array("QuestionNum" => $QuestionNum, "QuestionList" => $data);
         $ReturnArr['QuestionList'] = $data;
     } else {
         $ReturnArr = array("QuestionNum" => 0, "QuestionList" => array());
     }
     return $ReturnArr;
 }
Beispiel #24
0
 public function getPveTowerSummary($StartTime, $EndTime, $UserId, $InstMapId, $HeroId, $ServerId, $TowerIndex, $oWherePartnerPermission)
 {
     //查询列
     $select_fields = array('UserId', 'PassCount' => 'count(*)', 'FirstPassTime' => 'min(EndTowerTime)', 'TotalTime' => 'sum(RunTime)/1000');
     //分类统计列
     $group_fields = array('UserId');
     $groups = Base_common::getGroupBy($group_fields);
     //初始化查询条件
     $whereStartTime = $StartTime ? " CreateTowerTime >= " . $StartTime . " " : "";
     $whereEndTime = $EndTime ? " CreateTowerTime <= " . $EndTime . " " : "";
     $whereUser = $UserId ? " UserId = " . $UserId . " " : "";
     $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : "";
     $whereInstMap = $InstMapId ? " SlkId = " . $InstMapId . " " : "";
     $whereHero = $HeroId != -1 ? " HeroId = " . $HeroId . " " : "";
     $whereIndex = $TowerIndex ? " TowerIndex = " . $TowerIndex . " " : "";
     $whereCondition = array($whereUser, $whereStartTime, $whereEndTime, $whereServer, $whereInstMap, $whereHero, $whereIndex, $oWherePartnerPermission);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     if ($UserId) {
         //echo "1轮<br>";
         $position = Base_Common::getUserDataPositionById($UserId);
         $table_to_process = Base_Common::getUserTable($this->table_pve_tower_log_user, $position);
         $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where . $groups;
         $PveTowerSummaryArr = $this->db->getAll($sql, false);
         if (isset($PveTowerSummaryArr)) {
             foreach ($PveTowerSummaryArr as $key => $value) {
                 $StatArr['UserList'][$value['UserId']] = $value;
             }
         }
         $StatArr['UserCount'] = count($StatArr['UserList']);
     } elseif (!$UserId && date('m', $StartTime) == date('m', $EndTime)) {
         //echo "1轮<br>";
         $Date = date("Ym", $StartTime);
         $table_to_process = Base_Widget::getDbTable($this->table_pve_tower_log) . "_" . $Date;
         $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where . $groups;
         $PveTowerSummaryArr = $this->db->getAll($sql, false);
         if (isset($PveTowerSummaryArr)) {
             foreach ($PveTowerSummaryArr as $key => $value) {
                 $StatArr['UserList'][$value['UserId']] = $value;
             }
         }
         $StatArr['UserCount'] = count($StatArr['UserList']);
     }
     if (!$UserId && date('m', $StartTime) != date('m', $EndTime)) {
         //echo "256轮<br>";
         for ($i = 0; $i <= 255; $i++) {
             $position = Base_Common::getUserDataPositionById(sprintf("%03d", $i));
             $table_to_process = Base_Common::getUserTable($this->table_pve_tower_log_user, $position);
             $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where . $groups;
             $PveTowerSummaryArr = $this->db->getAll($sql, false);
             if (isset($PveTowerSummaryArr)) {
                 foreach ($PveTowerSummaryArr as $key => $value) {
                     $StatArr['UserList'][$value['UserId']] = $value;
                 }
             }
             $StatArr['UserCount'] = count($StatArr['UserList']);
         }
     }
     return $StatArr;
 }
Beispiel #25
0
 public function getMachineParams($MachineCode, $EstateCode, $MachineName, $Version, $CageId, $AppId, $ServerId, $LocalIP, $WebIP, $User, $field, $order, $Flag, $Owner, $start, $pageSize)
 {
     //初始化查询条件
     $whereMachineCode = $MachineCode ? "MachineCode LIKE '%" . $MachineCode . "%'" : "";
     $whereEstateCode = $EstateCode ? "EstateCode LIKE '%" . $EstateCode . "%'" : "";
     $whereMachineName = $MachineName ? "MachineName LIKE '%" . $MachineName . "%'" : "";
     $whereVersion = $Version ? "Version LIKE '%" . $Version . "%'" : "";
     $whereOwner = $Owner ? "Owner = '" . $Owner . "'" : "";
     $whereCageId = "";
     if ($CageId) {
         if (strchr($CageId, ",")) {
             $whereCageId = "CageId in ( {$CageId} )";
         } else {
             $whereCageId = "CageId = {$CageId}";
         }
     }
     $whereServerId = "";
     if ($AppId || $ServerId) {
         if (strchr($ServerId, ",")) {
             $whereServerId = "ServerId in ( {$ServerId} )";
         } else {
             $whereServerId = $ServerId ? "ServerId = {$ServerId}" : "ServerId =''";
             //存在有运营商但没有服务器的情况
         }
     }
     $whereUser = $User ? "User LIKE '%" . $User . "%'" : "";
     $limit = $pageSize ? " limit {$start},{$pageSize}" : "";
     if ($Flag) {
         if ($Flag == 8) {
             $whereFlag = "Flag in ('2','3','4') ";
         } else {
             $whereFlag = "Flag = " . $Flag;
         }
     }
     if ($field) {
         $order = " ORDER BY {$field} {$order}";
     } else {
         $order = " ORDER BY Udate DESC";
     }
     $whereCondition = array($whereMachineCode, $whereEstateCode, $whereMachineName, $whereVersion, $whereCageId, $whereServerId, $whereLocalIP, $whereUser, $whereFlag, $whereOwner);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     if ($LocalIP != "") {
         if ($LocalIP == 'zero') {
             $LocalIP = '0';
         }
         $where .= " AND LocalIP = " . $LocalIP;
     }
     if ($WebIP != "") {
         if ($WebIP == 'zero') {
             $WebIP = '0';
         }
         $where .= " AND WebIP = " . $WebIP;
     }
     //查询列 查询总记录数
     $select_fields_count = array('MachineCount' => 'count(*)');
     $fields = Base_common::getSqlFields($select_fields_count);
     $sql = "SELECT {$fields} FROM {$this->table} where 1 " . $where;
     $MachineCount = $this->db->getOne($sql, false);
     if ($MachineCount) {
         $select_fields = array('*');
         //生成查询列
         $fields = Base_common::getSqlFields($select_fields);
         $sql = "SELECT {$fields} FROM {$this->table} where 1 " . $where . $order . $limit;
         //echo $sql."<br/>";
         $MachineArr = $this->db->getAll($sql);
     }
     $MachineList['MachineDetail'] = $MachineArr;
     $MachineList['MachineCount'] = $MachineCount;
     return $MachineList;
 }
Beispiel #26
0
 public function getQuestionList($ConditionList, $fields = "*", $order = "desc")
 {
     //如果是历史数据
     if ($ConditionList['History'] > 0) {
         //生成历史表名
         $table_to_process = Base_Widget::getDbTable($this->table . "_h_" . $ConditionList['History']);
         //重新建立与历史数据库的链接
         $this->db_h = Base_Db_Hash::getInstance()->prepare($table_to_process);
         //将当前应用的数据库链接置为历史库
         $db = $this->db_h;
     } else {
         $table_to_process = Base_Widget::getDbTable($this->table);
         //将当前应用的数据库链接置为线上库
         $db = $this->db;
     }
     //查询列
     $select_fields = array($fields);
     //初始化查询条件
     $whereStartTime = $ConditionList['StartDate'] ? " time >= " . strtotime($ConditionList['StartDate']) . " " : "";
     $whereEndTimeTime = $ConditionList['EndDate'] ? " time <= " . (strtotime($ConditionList['EndDate']) + 86400) . " " : "";
     $whereQtype = $ConditionList['QtypeId'] ? " qtype = " . $ConditionList['QtypeId'] . " " : "";
     $whereParent = $ConditionList['Parent'] >= 0 ? " pid =" . $ConditionList['Parent'] . " " : " pid > 0";
     $whereRevocation = $ConditionList['Revocation'] >= 0 ? " revocation = " . $ConditionList['Revocation'] . " " : "";
     $whereHelp = $ConditionList['Help'] >= 0 ? " help_status = " . $ConditionList['Help'] . " " : "";
     $WhereAccepted = $ConditionList['Accepted'] >= 0 ? " is_hawb = " . $ConditionList['Accepted'] . " " : "";
     if (count($ConditionList['AcceptedOperatorList']) >= 1) {
         $t = array();
         foreach ($ConditionList['AcceptedOperatorList'] as $key => $OperatorInfo) {
             $t[] = "'" . $OperatorInfo['login_name'] . "'";
         }
         $text = implode(",", $t);
         $whereAcceptedOperatorList = strlen($text) > 0 ? " js_kf in (" . $text . ") " : "";
     }
     $oCategory = new Kubao_Category();
     if ($ConditionList['QuestionType']) {
         $t = explode(",", $ConditionList['QuestionType']);
         foreach ($t as $k => $v) {
             if ($v == '0') {
                 $t2[$v] = 0;
             } else {
                 $CategoryInfo = $oCategory->getCategoryByQuestionType($v, 'id');
                 if ($CategoryInfo['id'] > 0) {
                     $t2[$v] = $CategoryInfo['id'];
                 }
             }
         }
         $whereCid = $CategoryInfo['id'] ? " cid in (" . implode(",", $t2) . ") " : "";
     }
     $whereHidden = $ConditionList['hidden'] ? " hidden = " . $ConditionList['hidden'] . " " : "";
     switch ($ConditionList['QuestionStatus']) {
         case 0:
             $whereQuestionStatus = "";
             break;
         case 1:
             $whereQuestionStatus = " status = '1'";
             break;
         case 2:
             $whereQuestionStatus = " status != '1'";
             break;
     }
     $whereCondition = array($whereStartTime, $whereEndTimeTime, $whereQtype, $whereCid, $whereParent, $whereRevocation, $whereQuestionStatus, $whereHidden, $whereHelp, $WhereAccepted, $whereAcceptedOperatorList);
     //生成查询列
     $fields = Base_common::getSqlFields($select_fields);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     //计算记录数量
     $CountSql = "SELECT count(1) as QuestionNum FROM {$table_to_process} where 1 " . $where;
     $QuestionNum = $db->getOne($CountSql);
     if ($ConditionList['PageSize'] > 0) {
         //如果记录数量大于页码数量
         if ($QuestionNum >= ($ConditionList['Page'] - 1) * $ConditionList['PageSize']) {
             $Limit = " limit " . ($ConditionList['Page'] - 1) * $ConditionList['PageSize'] . "," . $ConditionList['PageSize'];
             $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where . $groups . " order by time " . $order . " " . $Limit;
             $data = $db->getAll($sql);
             $ReturnArr = array("QuestionNum" => $QuestionNum, "QuestionList" => $data);
             $ReturnArr['QuestionList'] = $data;
         } else {
             $ReturnArr = array("QuestionNum" => 0, "QuestionList" => array());
         }
     } else {
         $sql = "SELECT {$fields} FROM {$table_to_process} where 1 " . $where . $groups . " order by time " . $order;
         $data = $db->getAll($sql);
         $ReturnArr = array("QuestionNum" => $QuestionNum, "QuestionList" => $data);
         $ReturnArr['QuestionList'] = $data;
     }
     return $ReturnArr;
 }