public function get_user() { $oUser = new Data_Account(); $sql = 'select name from account where name <> "" limit ' . $this->page_index . ',' . $this->page_num . ';'; $oUser->query($sql); $records = array(); while ($oUser->next_record()) { $records[] = $oUser->get_record(); } $this->page_index += $this->page_num; return $records; }
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); } } }
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); } } } }