Exemple #1
0
 public function run()
 {
     $oUser = new Data_Account();
     $oPlayer = new Data_Player();
     $sql = 'select player_id,name from account;';
     $oUser->query($sql);
     $records = array();
     while ($oUser->next_record()) {
         $records[] = $oUser->get_record();
     }
     foreach ($records as $user) {
         if ($user['name']) {
             $player_id = $user['player_id'];
             $cache_key = 'data|player:' . $player_id;
             $data = $oPlayer->redis()->hash_get($cache_key);
             if ($data) {
                 $ret = $oPlayer->backup_to_db($data, '_field');
                 echo "backup player player_id:{$player_id} ret:{$ret}\n";
                 unset($ret);
             }
             unset($data, $cache_key);
         }
     }
 }
Exemple #2
0
 /**
  * 获取公共数据
  *
  */
 public function get_pub_data($data)
 {
     $player_id = $data['player_id'];
     if (!isset(self::$_player_info[$player_id]) || empty(self::$_player_info[$player_id]['name']) || empty(self::$_player_info[$player_id]['user_account']) || empty(self::$_player_info[$player_id]['reg_time'])) {
         $objPlayer = new Data_Player();
         $arr_player_info = $objPlayer->get_player_info($player_id, array('name', 'user_account', 'ad_info', 'reg_time', 'career_type'));
         if ($arr_player_info['name']) {
             self::$_player_info[$player_id] = $arr_player_info;
         }
         if (empty(self::$_player_info[$player_id]['name'])) {
             $objAccount = new Data_Account();
             self::$_player_info[$player_id] = $objAccount->get_account_bypid($player_id);
         }
     }
     if (!isset($data['player_name'])) {
         $data['player_name'] = self::$_player_info[$player_id]['name'] ? self::$_player_info[$player_id]['name'] : '';
     }
     if (!isset($data['career_type'])) {
         $data['career_type'] = self::$_player_info[$player_id]['career_type'] ? self::$_player_info[$player_id]['career_type'] : 0;
     }
     if (!isset($data['user_account'])) {
         $data['user_account'] = self::$_player_info[$player_id]['user_account'] ? self::$_player_info[$player_id]['user_account'] : '';
     }
     if (!isset($data['ad_info'])) {
         $data['ad_info'] = self::$_player_info[$player_id]['ad_info'] ? self::$_player_info[$player_id]['ad_info'] : 0;
     }
     if (!isset($data['reg_time'])) {
         $data['reg_time'] = self::$_player_info[$player_id]['reg_time'] ? self::$_player_info[$player_id]['reg_time'] : 0;
     }
     $data['server_id'] = SERVER_ID;
     $data['operator_id'] = OPERATOR_ID;
     //        if(!isset($data['player_level'])){
     //            $data['player_level'] = intval(self::$_player_info[$player_id]['level']);//再想办法及时更新
     //        }
     //
     //        if(!isset($data['vip_level'])){
     //            $data['vip_level'] = intval(self::$_player_info[$player_id]['vip']);//再想办法及时更新
     //        }
     return $data;
 }
 public function run()
 {
     if (1 == OPERATOR_ID && SERVER_ID > 2) {
         $url = "http://api.uuzu.com/platform/user/info";
         $oPlayer = new Data_Player();
         $oAccount = new Data_Account();
         $sql = 'select * from account where plat_reg_time=-1;';
         $oAccount->query($sql);
         $records = array();
         while ($oAccount->next_record()) {
             $records[] = $oAccount->get_record();
         }
         foreach ($records as $user) {
             $arrData = array();
             $arrData['account'] = $user['user_account'];
             $arrData['game_id'] = 1;
             $arrData['fields'] = 'reg_time';
             ksort($arrData);
             $auth = $this->createAuth($arrData);
             $arrData['verify'] = md5($auth . 'NBg5akoBBLiiqKsW');
             $dataArr = json_decode(Com_System::open_url($url, 'post', $arrData, 5), true);
             if ($dataArr['status'] == 0 && isset($dataArr['userinfo']) && isset($dataArr['userinfo']['reg_time']) && !empty($dataArr['userinfo']['reg_time'])) {
                 $oPlayer->start_trans();
                 if (date('Ymd', $user['add_time']) == date('Ymd', $dataArr['userinfo']['reg_time'])) {
                     $new_acc = 1;
                 } else {
                     $new_acc = 0;
                 }
                 $arr = array('plat_reg_time' => $dataArr['userinfo']['reg_time'], 'new_plat_account' => $new_acc);
                 $sql = 'update account set  plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=' . $new_acc . ' where player_id=' . $user['player_id'];
                 $ret = $oAccount->query($sql);
                 if ($ret) {
                     if ($user['name'] && $user['new_plat_account'] != $new_acc) {
                         $ret = $oPlayer->update_player_info($user['player_id'], $arr);
                         if ($ret) {
                             $sql = 'update player set plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=' . $new_acc . ' where player_id=' . $user['player_id'];
                             $oPlayer->query($sql);
                             if ($oPlayer->affected_rows() > 0) {
                                 $ret = true;
                             } else {
                                 $ret = false;
                             }
                         }
                     }
                 }
                 if ($ret) {
                     $oPlayer->commit();
                 } else {
                     $oPlayer->rollback();
                 }
             } else {
                 $arr = array('plat_reg_time' => 1, 'new_plat_account' => 0);
                 $oPlayer->start_trans();
                 $sql = 'update account set  plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=0 where player_id=' . $user['player_id'];
                 $ret = $oAccount->query($sql);
                 if ($ret) {
                     if ($user['name']) {
                         $ret = $oPlayer->update_player_info($user['player_id'], $arr);
                         if ($ret) {
                             $sql = 'update player set plat_reg_time=' . $arr['plat_reg_time'] . ' , new_plat_account=0 where player_id=' . $user['player_id'];
                             $oPlayer->query($sql);
                             if ($oPlayer->affected_rows() > 0) {
                                 $ret = true;
                             } else {
                                 $ret = false;
                             }
                         } else {
                             $ret = false;
                         }
                     }
                 }
                 if ($ret) {
                     $oPlayer->commit();
                 } else {
                     $oPlayer->rollback();
                 }
             }
             $rd = rand(1, 10);
             if (1 == $rd) {
                 sleep(1);
             }
         }
     }
 }
<?php

/**
 * 同步玩家战力排行
 * Created by PhpStorm.
 * User: zhouliting
 * Date: 15-06-10
 * Time: 上午10:15
 */
set_time_limit(9999999999);
ini_set('memory_limit', '10240M');
define('UUZU_AUTH', 0);
require dirname(__FILE__) . '/../global.php';
TenYear::getInstance();
$objPlayer = new Data_Player();
$objPlayer->sys_player_sum_fpower();
Exemple #5
0
 protected function _make_user_info($player_id)
 {
     if ($player_id == 0) {
         return array();
     }
     //        if(!isset($this->_player_info[$player_id]) && !empty($player_id)){
     $objPlayer = new Data_Player();
     $data = $objPlayer->get_player_info($player_id, array('name', 'user_account', 'ad_info', 'level', 'vip_level', 'ticket', 'silver', 'gold', 'exp', 'reg_time'));
     if ($data == false) {
         $objAccount = new Data_Account();
         $data = $objAccount->get_account_bypid($player_id);
     }
     //            $this->_player_info[$player_id] = $data;
     //        }
     //        Com_Log::log("make_user_info:".var_export($data,true),'data_center',1);
     //        $user_data = $this->_player_info[$player_id];
     $user_data = $data;
     if (empty($user_data['level'])) {
         $user_data['level'] = 1;
     }
     //        Com_Log::log("user_level:".var_export($user_data['level'],true),'data_center',1);
     //        Com_Log::write('data_center_level',"player_id:{$player_id}".var_export($user_data['level'],true));
     $user_info = array('uid' => $player_id, 'passport' => $user_data['user_account'], "user_level" => intval($user_data['level']), "vip_level" => intval($user_data['vip_level']), "moneycoin" => intval($user_data['gold']), "blackmoneycoin" => $user_data['ticket'], "is_test" => "0", "version" => "2.1", "entrance" => "", "device" => "", "user_exp" => intval($user_data['exp']), "firstintime" => intval($user_data['reg_time']), "gamecoin" => intval($user_data['silver']));
     return $user_info;
 }
<?php

/**
 * 初始添加没有公会玩家
 * @author zhouliting
 * @date 2015-06-02
 */
require dirname(__FILE__) . '/../global.php';
TenYear::getInstance();
ini_set('default_socket_timeout', -1);
Com_AdCache::factory()->set_timeout(0);
$objPlayer = new Data_Player();
$objPlayer->sys_no_union_player();