fixBalance.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * 修复转账问题
  4. * @author solu
  5. */
  6. require_once realpath(dirname(__FILE__)) . '/../common.php';
  7. if (!singleProcess(getCurrentCommand(), ROOT_PATH . "/bin/run/fixBalance.pid")) {
  8. exit("Sorry, this script file has already been running ...\n");
  9. }
  10. $st = microtime(true);
  11. $timeout = 60; // 下注一分钟没处理的
  12. $objOffer = new Offer();
  13. $t = date('Y-m-d H:i:s', time() - $timeout);
  14. $data = [];
  15. $offers = $objOffer->objTable->getAll(['state' => Offer::STATUS_CLOSE], [
  16. '_field' => 'id, game_id, player, transfer_trx_id',
  17. '_where' => "create_time<'{$t}'",
  18. ]);
  19. foreach ($offers as $v) {
  20. $data[$v['game_id']][$v['player']] = $v['transfer_trx_id'];
  21. }
  22. $sc = 0;
  23. $c = 0;
  24. foreach ($data as $gameId => $players) {
  25. foreach ($players as $player => $offerTrxId) {
  26. $c += 1;
  27. $ret = Eos::balance($gameId, $player, $offerTrxId);
  28. $resultTrxId = $ret['transaction_id'];
  29. if ($resultTrxId) {
  30. $objOffer->objTable->updateObject(['result_trx_id' => $resultTrxId], [
  31. 'game_id' => $gameId,
  32. 'player' => $player,
  33. ]);
  34. $sc += 1;
  35. }
  36. }
  37. }
  38. $ct = microtime(true) - $st;
  39. Eos::log("找到{$c},处理{$sc},耗时{$ct}");