GameRate.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * GameRate.php UTF-8
  4. *
  5. *
  6. * @date : 2018/5/22 14:58
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\controller\rate;
  13. use huo\controller\common\Base;
  14. use huo\controller\game\GameCache;
  15. use huolib\status\RateStatus;
  16. class GameRate extends Base {
  17. /**
  18. * 设置游戏优惠信息
  19. *
  20. * @param int $app_id
  21. * @param int $promote_switch
  22. * @param array $rate_data
  23. *
  24. * @return array
  25. */
  26. public function setGameRate($app_id, $promote_switch, $rate_data) {
  27. $_rc = new RateCheck();
  28. $_rs = $_rc->checkPromote($promote_switch);
  29. if (RateStatus::NO_ERROR != $_rs) {
  30. return $this->huoError($_rs, RateStatus::getMsg($_rs));
  31. }
  32. $_rs = $_rc->checkGameParam($app_id, $rate_data);
  33. if (RateStatus::NO_ERROR != $_rs['code']) {
  34. return $this->huoReturn($_rs);
  35. }
  36. $_rc_class = RateCache::ins();
  37. $_rate_data = $_rc_class->getInfoByAppId($app_id);
  38. $_rate_data = array_merge($_rate_data, $rate_data);
  39. $_rs = $_rc_class->updateGameRate($app_id, $_rate_data);
  40. if (false == $_rs) {
  41. $_code = RateStatus::CACHE_ERROR;
  42. return $this->huoError($_code, RateStatus::getMsg($_code));
  43. }
  44. $_gc_class = GameCache::ins();
  45. $_game_data = $_gc_class->getInfoByAppId($app_id);
  46. $_game_data['promote_switch'] = $promote_switch;
  47. $_gc_class->updateGame($app_id, $_game_data);
  48. $_code = RateStatus::NO_ERROR;
  49. return $this->huoSuccess($_code, RateStatus::getMsg($_code));
  50. }
  51. }