public function getPayDetailCount($StartTime, $EndTime, $UserId, $oWherePartnerPermission, $PassageId) { //查询列 $select_fields = array('OrderCount' => 'count(*)'); //分类统计列 //初始化查询条件 $whereStartTime = $StartTime ? " PayTime >= " . strtotime($StartTime) . " " : ""; $whereEndTime = $EndTime ? " PayTime <= " . strtotime($EndTime) . " " : ""; $whereUser = $UserId ? " AcceptUserId = " . $UserId . " " : ""; $wherePassage = $PassageId ? " PassageId = " . $PassageId . " " : ""; $whereCondition = array($whereUser, $whereStartTime, $whereEndTime, $oWherePartnerPermission, $wherePassage); //生成查询列 $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_user) . "_" . $position['db_fix']; } else { $Date = date("Ym", strtotime($StartTime)); $table_to_process = Base_Widget::getDbTable($this->table_date) . "_" . $Date; } $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where; $PayCount = $this->db->getOne($sql, false); if ($PayCount) { return $PayCount; } else { return 0; } }
public function InsertCharacterKickOff($KickOffArr) { $this->db->begin(); $position = Base_Common::getUserDataPositionById($KickOffArr['UserId']); $table_user = Base_Common::getUserTable($this->character_kick_off, $position); $user = $this->db->insert($table_user, $KickOffArr); $Date = date("Ym", $KickOffArr['KickOffTime']); $table_date = $this->CreateCharacterKickOffLog($Date); $oSocketType = @(include __APP_ROOT_DIR__ . "/etc/SocketType.php"); $oSocketQueue = new Config_SocketQueue(); $uType = 60221; $TypeInfo = $oSocketType[$uType]; if ($TypeInfo['Type']) { $DataArr = array('PackFormat' => $TypeInfo['PackFormat'], 'Length' => $TypeInfo['Length'], 'Length2' => 0, 'uType' => $uType, 'MsgLevel' => 0, 'Line' => 0, 'UserID' => $KickOffArr['UserId'], 'KickOffReason' => $KickOffArr['KickOffReason'], 'Serial' => $KickOffArr['KickOffId']); } $DataArr = array('ServerId' => $KickOffArr['ServerId'], 'uType' => $uType, 'UserId' => $DataArr['UserID'], 'MessegeContent' => serialize($DataArr), 'QueueTime' => time(), 'SendTime' => 0); $addQueue = $oSocketQueue->insert($DataArr); $log = $this->db->insert($table_date, $KickOffArr); if ($user && $log && $addQueue) { $this->db->commit(); return true; } else { $this->db->rollBack(); return false; } }
public function UserLoginSumDate($UserId, $oWherePartnerPermission) { //初始化查询条件 $whereCondition = array($oWherePartnerPermission); $where = Base_common::getSqlWhere($whereCondition); $position = Base_Common::getUserDataPositionById($UserId); $table_to_process = Base_Widget::getDbTable($this->table_user) . "_" . $position['db_fix']; $sql = "SELECT sum(`LogoutTime`-`LoginTime`) as `LoingTime` FROM {$table_to_process} WHERE `UserId` = {$UserId} and `LogoutTime` > 0 and `LogoutTime` > `LoginTime` " . $where; return $this->db->getOne($sql, false); }
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; } }
public function getPvpLogTotal($whereTime) { $table_to_process = Base_Widget::getDbTable($this->table_pvp_log_total); $sql = "truncate {$table_to_process}"; $this->db->query($sql); for ($i = 0; $i <= 255; $i++) { $position = Base_Common::getUserDataPositionById(sprintf("%03d", $i)); $table_to_get = Base_Common::getUserTable($this->table_pvp_log_user, $position); $sql = "replace into {$table_to_process} (ServerId,UserId,Won,PvpCount) select ServerId,UserId,Won,Count(*) from {$table_to_get} where {$whereTime} group by ServerId,UserId,Won"; echo $this->db->query($sql) . "-"; } }
public function getUserExchangeCount($UserId, $AppId, $PartnerId, $ServerId, $StartDate, $EndDate, $ExchangeStatus) { //查询列 $select_fields = array('ExchangeCount' => 'count(*)'); //初始化查询条件 $whereStartDate = $StartDate ? " CreateExchangeTime >= " . strtotime($StartDate) . " " : ""; $whereEndDate = $EndDate ? " CreateExchangeTime <= " . (strtotime($EndDate) + 86400 - 1) . " " : ""; $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : ""; $wherePartner = $PartnerId ? " PartnerId = " . $PartnerId . " " : ""; $whereApp = $AppId ? " AppId = " . $AppId . " " : ""; $whereUser = $UserId ? " UserId = " . $UserId . " " : ""; $whereCondition = array($whereStartDate, $whereEndDate, $whereServer, $wherePartner, $whereApp, $whereUser); if ($ExchangeStatus == 0) { //进行中 $table_to_process = Base_Widget::getDbTable($this->table_exchange_queue); } elseif ($ExchangeStatus == 1) { //已成功 $position = Base_Common::getUserDataPositionById($UserId); $table_to_process = Base_Widget::getDbTable($this->table_user) . "_user_" . $position['db_fix']; } else { //已失败 $table_to_process = Base_Widget::getDbTable($this->table_exchange_queue_error); } //生成查询列 $fields = Base_common::getSqlFields($select_fields); //生成条件列 $where = Base_common::getSqlWhere($whereCondition); $StatArr = array('ExchangeCount' => 0); $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where; $ExchangeCount = $this->db->getRow($sql, false); if (isset($ExchangeCount)) { $StatArr['ExchangeCount'] += $ExchangeCount['ExchangeCount']; } return $StatArr; }
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; } }
public function asignProductPackCode($UserName, $unsignedCode) { $oUser = new Lm_User(); $UserInfo = $oUser->getUserByName($UserName); if ($UserInfo['UserId']) { if ($unsignedCode['ProductPackCode']) { $PackInfo = $this->getRow($unsignedCode['ProductPackId']); $CodeCount = $this->getUserProductPackCodeListCount($UserInfo['UserId'], 0, 0, $unsignedCode['GenId']); if ($CodeCount < $PackInfo['AsignCountLimit']) { $this->db->begin(); $unsignedCode['AsignTime'] = time(); $unsignedCode['AsignUser'] = $UserInfo['UserId']; $position = Base_Common::getUserDataPositionById($UserInfo['UserId']); $table_user = Base_Common::getUserTable($this->table_code, $position); $user = $this->db->replace($table_user, $unsignedCode); $table_code = Base_Widget::getDbTable($this->table_code); $bind = $unsignedCode; unset($bind['ProductPackCode']); $code = $this->db->update($table_code, $bind, '`ProductPackCode` = ?', $unsignedCode['ProductPackCode']); if ($code && $user) { $this->db->commit(); return true; } else { $this->db->rollback(); return false; } } else { return false; } } else { return false; } } else { return false; } }
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; }
public function getSendErrorList($UserId, $SendId, $fields = '*') { $position = Base_Common::getUserDataPositionById($UserId); $table_user = Base_Common::getUserTable($this->table_send_log_user, $position); $sql = "select {$fields} from {$table_user} where `SendStatus` = 2 and `UserId` = ? and `SendId` = ?"; return $this->db->getAll($sql, array($UserId, $SendId)); }
public function getSlkDetailCount($StartTime, $EndTime, $UserId, $InstMapId, $HeroId, $ServerId, $oWherePartnerPermission) { //查询列 $select_fields = array('SlkCount' => 'count(*)'); //分类统计列 //初始化查询条件 $whereStartTime = $StartTime ? " CharacterSlkEnterTime >= " . strtotime($StartTime) . " " : ""; $whereEndTime = $EndTime ? " CharacterSlkEnterTime <= " . strtotime($EndTime) . " " : ""; $whereUser = $UserId ? " UserId = " . $UserId . " " : ""; $whereServer = $ServerId ? " ServerId = " . $ServerId . " " : ""; $whereInstMap = $InstMapId ? " SlkId = " . $InstMapId . " " : ""; $whereHero = $HeroId != -1 ? " HeroId = " . $HeroId . " " : ""; $whereCondition = array($whereUser, $whereStartTime, $whereEndTime, $whereServer, $whereInstMap, $whereHero, $oWherePartnerPermission); //生成查询列 $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) . "_user_" . $position['db_fix']; } else { $Date = date("Ym", strtotime($StartTime)); $table_to_process = Base_Widget::getDbTable($this->table) . "_" . $Date; } $sql = "SELECT {$fields} FROM {$table_to_process} as log where 1 " . $where; $SlkCount = $this->db->getOne($sql, false); if ($SlkCount) { return $SlkCount; } else { return 0; } }