12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * 修复转账问题
- * @author solu
- */
- require_once realpath(dirname(__FILE__)) . '/../common.php';
- if (!singleProcess(getCurrentCommand(), ROOT_PATH . "/bin/run/fixBalance.pid")) {
- exit("Sorry, this script file has already been running ...\n");
- }
- $st = microtime(true);
- $timeout = 60; // 下注一分钟没处理的
- $objOffer = new Offer();
- $t = date('Y-m-d H:i:s', time() - $timeout);
- $data = [];
- $offers = $objOffer->objTable->getAll(['state' => Offer::STATUS_CLOSE], [
- '_field' => 'id, game_id, player, transfer_trx_id',
- '_where' => "create_time<'{$t}'",
- ]);
- foreach ($offers as $v) {
- $data[$v['game_id']][$v['player']] = $v['transfer_trx_id'];
- }
- $sc = 0;
- $c = 0;
- foreach ($data as $gameId => $players) {
- foreach ($players as $player => $offerTrxId) {
- $c += 1;
- $ret = Eos::balance($gameId, $player, $offerTrxId);
- $resultTrxId = $ret['transaction_id'];
- if ($resultTrxId) {
- $objOffer->objTable->updateObject(['result_trx_id' => $resultTrxId], [
- 'game_id' => $gameId,
- 'player' => $player,
- ]);
- $sc += 1;
- }
- }
- }
- $ct = microtime(true) - $st;
- Eos::log("找到{$c},处理{$sc},耗时{$ct}");
|