Exemple #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;
 }
Exemple #2
0
 public function getItemSealList($AppId, $ItemId, $SealTime, $days, $dateType)
 {
     $nowTime = time();
     //初始化查询条件
     $whereAppId = $AppId ? " AppId = '" . $AppId . "' " : "";
     $whereItemId = $ItemId ? " MoneyType in (" . $ItemId . ") " : "";
     $whereStartTime = $SealTime ? " MoneyLogDate = '" . date("Y-m-d", $SealTime) . "' " : "";
     $whereHour = $dateType == "hh" ? " Hour = '" . date("H", $SealTime) . "' " : "";
     $whereReason = " `Reason` != 12 ";
     $whereCondition = array($whereAppId, $whereItemId, $whereStartTime, $whereHour, $whereReason);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $return = array();
     for ($i = 0; $i < $days; $i++) {
         $table_to_process = Base_Widget::getDbTable($this->table_moneylog_compress) . "_" . date("Ymd", $SealTime);
         $sql = "SELECT `UserId`,`MoneyType` as ItemId,sum(`MoneyChanged`) as ItemNum FROM {$table_to_process} as log where 1 " . $where . " GROUP BY `UserId` , `ItemId`";
         $ItemList = $this->db->getAll($sql);
         foreach ($ItemList as $k => $v) {
             if (isset($return[$v['UserId']][$v['ItemId']])) {
                 $return[$v['UserId']][$v['ItemId']] += $v['ItemNum'];
             } else {
                 $return[$v['UserId']][$v['ItemId']] = $v['ItemNum'];
             }
         }
     }
     return $return;
 }
Exemple #3
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;
 }
Exemple #4
0
 public function GetEmptyFirstLoginTimeUserId($table_suffix)
 {
     $table_to_process = Base_Widget::getDbTable($this->table_login_log);
     $table_to_process .= "_" . $table_suffix;
     $group_fields = array('UserId', 'AppId', 'PartnerId', 'ServerId');
     $groups = Base_common::getGroupBy($group_fields);
     $whereFirstLoginTime = " FirstLoginTime = '0' ";
     $whereCondition = array($whereFirstLoginTime);
     $where = Base_common::getSqlWhere($whereCondition);
     $sql = "select UserId,AppId,PartnerId,ServerId from {$table_to_process} where 1 " . $where . $groups . " order by UserId limit 0,100";
     $UserList = $this->db->getAll($sql);
     return $UserList;
 }
Exemple #5
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;
 }
Exemple #6
0
 public function getCageListParams($DepotId, $X, $fields = "*")
 {
     $whereDepot = $DepotId ? " DepotId = " . $DepotId . " " : "";
     $whereX = $X ? " X = '" . $X . "' " : "";
     $whereCondition = array($whereDepot, $whereX);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $sql = "SELECT {$fields} FROM " . $this->getDbTable() . " where 1 " . $where;
     $CageList = $this->db->getAll($sql);
     $returnArr = array();
     foreach ($CageList as $k => $v) {
         $returnArr[$v["CageId"]] = $v;
     }
     return $returnArr;
 }
Exemple #7
0
 public function getUserLoginCountByDate($UserList, $StartDate, $EndDate, $oWherePartnerPermission)
 {
     $whereCondition = array($oWherePartnerPermission);
     $where = Base_common::getSqlWhere($whereCondition);
     //初始化结果数组
     $Date = $StartDate;
     $CountList = array('Count' => array());
     do {
         $CountList['Count'][$Date] = array('UserCount' => 0);
         $Date = date("Y-m-d", strtotime($Date) + 86400);
     } while (strtotime($Date) <= strtotime($EndDate));
     foreach ($CountList['Count'] as $date => $arr) {
         $table_to_process = Base_Widget::getDbTable($this->table_date) . "_" . date("Ym", strtotime($date));
         $sql = "SELECT count(distinct UserId) as `LoginCount` FROM {$table_to_process} WHERE `UserId` in (" . implode(",", $UserList) . ") and LoginTime > '" . strtotime($date) . "' and LoginTime < '" . (strtotime($date) + 86400) . "' " . $where;
         $CountList['Count'][$date]['UserCount'] = $this->db->getOne($sql, false);
     }
     return $CountList;
 }
Exemple #8
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;
 }
Exemple #9
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;
 }
Exemple #10
0
 public function getAllAsignSchedule($StartDate, $EndDate, $fields = '*')
 {
     //初始化查询条件
     $whereStart = $StartDate ? " Date >= '" . $StartDate . "' " : "";
     $whereEnd = $EndDate ? " Date <= '" . $EndDate . "' " : "";
     $whereCondition = array($whereStart, $whereEnd);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $sql = "SELECT {$fields} FROM " . $this->getDbTable($this->table_asign_schedule) . " where 1 " . $where . " ORDER BY GenId ASC";
     $return = $this->db->getAll($sql, false);
     $AllSchedule = array();
     if (count($return)) {
         foreach ($return as $key => $value) {
             $AllSchedule[$value['ScheduleId']] = $value;
         }
     }
     return $AllSchedule;
 }
Exemple #11
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;
     }
 }
Exemple #12
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;
     }
 }
Exemple #13
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;
     }
 }
Exemple #14
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);
 }
Exemple #15
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;
 }
Exemple #16
0
 public function getFAQCount($FaqTypeId = 0, $KeyWord = "")
 {
     $whereType = $FaqTypeId ? " FaqTypeId = " . $FaqTypeId . " " : "";
     $whereKeyWord = $KeyWord ? " (name like '%" . $KeyWord . "%' or Answer like '%" . $KeyWord . "%') " : "";
     $whereCondition = array($whereType, $whereKeyWord);
     $where = Base_common::getSqlWhere($whereCondition);
     //生成条件列
     $limit = $Count ? " limit {$Start},{$Count}" : "";
     $sql = "SELECT count(*) as FaqCount FROM " . $this->getDbTable() . " where 1 " . $where . " ORDER BY FaqTypeId,FaqId ASC" . $limit;
     $FaqCount = $this->db->getOne($sql);
     return $FaqCount;
 }
Exemple #17
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;
     }
 }
Exemple #18
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;
     }
 }
Exemple #19
0
 public function getLogsManagerParams($fields, $LogInfo, $StartDate, $EndDate)
 {
     //$whereId = $ManageId ? "manager_id=".$ManageId:"";
     $whereLog = $LogInfo ? "log LIKE '%" . $LogInfo . "%'" : "";
     $whereStartDate = $StartDate ? " addtime >= '" . strtotime($StartDate) . "' " : "";
     $whereEndDate = $EndDate ? " addtime <= '" . (strtotime($EndDate) + 86400 - 1) . "' " : "";
     $whereCondition = array($whereLog, $whereStartDate, $whereEndDate);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $sql = "SELECT {$fields} FROM {$this->table} where 1 " . $where . " ORDER BY addtime ASC";
     //echo $sql."<br/>";
     $MachineLog = $this->db->getAll($sql);
     $MachineLogList = array();
     foreach ($MachineLog as $key => $LogInfo) {
         $MachineList[$key]['Udate'] = $LogInfo['addtime'];
         $LogArr = explode("\n\n", $LogInfo['log']);
         $MachineIdStr = explode(":", $LogArr[2]);
         $MachineId = $MachineIdStr[1];
         $Tip = mb_substr($LogArr[0], 0, 2, "utf-8");
         $BeforeMachineInfo = json_decode($LogArr[3], true);
         if ($LogArr[4]) {
             $NextMachineInfo = json_decode($LogArr[4], true);
             foreach ($NextMachineInfo as $key => $val) {
                 if ($key == "Comment") {
                     $NextComment = json_decode($val, true);
                     $NextMachineInfo["Comment"] = $NextComment;
                     $BeforeComment = json_decode($BeforeMachineInfo["Comment"], true);
                     foreach ($NextComment as $ckey => $cval) {
                         if ($cval != $BeforeComment[$ckey]) {
                             if ($ckey == "Status") {
                                 $NextMachineInfo["Comment"][$ckey . "_span"] = $cval;
                             } else {
                                 $NextMachineInfo["Comment"][$ckey] = "<span style='color:red;'>" . $cval . "</span>";
                             }
                         }
                     }
                     $NextMachineInfo["Comment"] = json_encode($NextMachineInfo["Comment"]);
                 } elseif ($val != $BeforeMachineInfo[$key]) {
                     if ($key == "CageId" || $key == "ServerId" || $key == "LocalIP" || $key == "WebIP" || $key == "IntellectProperty" || $key == "Flag") {
                         $NextMachineInfo[$key . "_span"] = $val;
                     } else {
                         $NextMachineInfo[$key] = "<span style='color:red;'>" . $val . "</span>";
                     }
                 }
             }
             $NextMachineInfo['LogDate'] = date("Y-m-d H:i:s", $LogInfo['addtime']);
             $NextMachineInfo['Name'] = $LogInfo['name'];
             unset($NextMachineInfo['Udate']);
             $NextMachineInfo['Tip'] = $Tip;
             $MachineLogList[$MachineId][] = $NextMachineInfo;
         } else {
             $BeforeMachineInfo['LogDate'] = date("Y-m-d H:i:s", $LogInfo['addtime']);
             $BeforeMachineInfo['Name'] = $LogInfo['name'];
             $BeforeMachineInfo['Tip'] = $Tip;
             $MachineLogList[$MachineId][] = $BeforeMachineInfo;
         }
     }
     /*foreach($MachineLog as $key=> $LogInfo)
     		{
     			$MachineList[$key]['Udate'] = $LogInfo['addtime'];
     			//echo $LogInfo['log'];
     			$LogArr = explode("\n\n",$LogInfo['log']);
     			//echo "<pre>";
     			//	print_r($LogArr);
     			$MachineIdStr = explode(":",$LogArr[2]);
     			$MachineId = $MachineIdStr[1];
     			$Tip = mb_substr($LogArr[0],0,2,"utf-8");
     			$BeforeMachineInfo = json_decode($LogArr[3],true);
     				
     			if($LogArr[4]) //有5个值的是修改,没有的是 添加和删除
     			{
     				$NextMachineInfo = json_decode($LogArr[4],true);
     			
     				$NextMachineInfo['LogDate'] = date("Y-m-d H:i:s",$LogInfo['addtime']);
     				$NextMachineInfo['Name'] = $LogInfo['name'];	
     				unset($NextMachineInfo['Udate']);
     				$NextMachineInfo['Tip'] = $Tip;
     				$MachineLogList[$MachineId][] = $NextMachineInfo;
     				
     			}else{
     			
     				$BeforeMachineInfo['LogDate'] = date("Y-m-d H:i:s",$LogInfo['addtime']);
     				$BeforeMachineInfo['Name'] = $LogInfo['name'];	
     				$BeforeMachineInfo['Tip'] = $Tip;
     				$MachineLogList[$MachineId][] = $BeforeMachineInfo;				
     			}
     
     		}*/
     return $MachineLogList;
 }
Exemple #20
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;
 }
Exemple #21
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);
 }
Exemple #22
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);
     }
 }
Exemple #23
0
 /**
  * 获取指定合作商的app区服
  * @param integer $AppId
  * @param integer $PartnerId
  * @param string $fields
  * @return array
  */
 public function getByAppPartner($AppId, $PartnerId, $fields = '*', $is_show = 0)
 {
     $whereApp = $AppId ? " AppId = {$AppId}" : "";
     $wherePartner = $PartnerId ? " PartnerId = {$PartnerId}" : "";
     $whereCondition = array($whereApp, $wherePartner);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $table_to_process = Base_Widget::getDbTable($this->table);
     if (!$is_show) {
         $sql = "SELECT {$fields} FROM " . $table_to_process . " where 1 " . $where;
     } else {
         $sql = "SELECT {$fields} FROM " . $table_to_process . " where is_show = {$is_show} " . $where;
     }
     $return = $this->db->getAll($sql);
     if ($return) {
         foreach ($return as $key => $value) {
             $AllServer[$value['ServerId']] = $value;
         }
     }
     return $AllServer;
 }
Exemple #24
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;
 }
Exemple #25
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;
 }
Exemple #26
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;
 }
Exemple #27
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;
 }
Exemple #28
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;
 }
Exemple #29
0
 public function getIpList($CageIdList, $start, $pageSize)
 {
     if ($CageIdList) {
         $whereCageId = "CageId in ( {$CageIdList} )";
     }
     $limit = $pageSize ? " limit {$start},{$pageSize}" : "";
     //生成条件列
     $where = Base_common::getSqlWhere(array($whereCageId));
     $sql = "SELECT count(*) as MachineCount FROM {$this->table} where 1 " . $where;
     $MachineCount = $this->db->getOne($sql, false);
     if ($MachineCount) {
         $sql = "SELECT MachineId,MachineCode,EstateCode,LocalIP,WebIP,Purpose,ServerId FROM  {$this->table} where 1 " . $where . " ORDER BY Udate DESC " . $limit;
         $MachineArr = $this->db->getAll($sql);
     }
     $MachineList['MachineDetail'] = $MachineArr;
     $MachineList['MachineCount'] = $MachineCount;
     return $MachineList;
 }
Exemple #30
0
 public function getAll($SourceList)
 {
     if ($SourceList) {
         foreach ($SourceList as $Key => $value) {
             $t[$Key] = $Key;
         }
         $whereSource = " SourceId in (" . implode(",", $t) . ")";
     } else {
         $whereSource = "";
     }
     $whereCondition = array($whereSource);
     //生成条件列
     $where = Base_common::getSqlWhere($whereCondition);
     $sql = "SELECT * FROM " . $this->getDbTable() . " where 1 " . $where . " ORDER BY SourceId ASC";
     $return = $this->db->getAll($sql);
     if (count($return)) {
         foreach ($return as $key => $value) {
             $AllSourceDetail[$value['SourceDetail']] = $value;
         }
     }
     return $AllSourceDetail;
 }