reportGame.php 946 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * 游戏结果上报
  4. * @author solu
  5. */
  6. require_once realpath(dirname(__FILE__)) . '/../common.php';
  7. $index = (int) $argv[1];
  8. if (!singleProcess(getCurrentCommand(), ROOT_PATH . "/bin/run/reportGame.pid")) {
  9. exit("Sorry, this script file has already been running ...\n");
  10. }
  11. $objOffer = new Offer();
  12. $objGame = new Game;
  13. $agoTime = 120;
  14. $t = date('Y-m-d H:i:s', time() - 120);
  15. $gameIds = $objGame->objTable->getCol(['game_state' => Game::STATUS_FINISH], [
  16. '_field' => 'id',
  17. '_where' => "create_time>='{$t}'",
  18. ]);
  19. $offers = $objOffer->objTable->getAll(['game_id' => $gameIds, 'state' => [Offer::STATUS_CLOSE, Offer::STATUS_FINISH]], [
  20. '_field' => 'game_id, sum(offerall_int) offerall_int, sum(win_int) win_int',
  21. '_groupby' => 'game_id',
  22. ]);
  23. foreach ($offers as $v) {
  24. $ret = ThirdApi::reportGameResult($v['game_id'], $v['offerall_int'], $v['win_int']);
  25. }
  26. $c = count($offers);
  27. Eos::log("上报{$c}记录");