* @version : HUOSDK 8.0 */ namespace huo\controller\rate; use huo\controller\common\Base; use huo\controller\game\GameCache; use huolib\status\RateStatus; class GameRate extends Base { /** * 设置游戏优惠信息 * * @param int $app_id * @param int $promote_switch * @param array $rate_data * * @return array */ public function setGameRate($app_id, $promote_switch, $rate_data) { $_rc = new RateCheck(); $_rs = $_rc->checkPromote($promote_switch); if (RateStatus::NO_ERROR != $_rs) { return $this->huoError($_rs, RateStatus::getMsg($_rs)); } $_rs = $_rc->checkGameParam($app_id, $rate_data); if (RateStatus::NO_ERROR != $_rs['code']) { return $this->huoReturn($_rs); } $_rc_class = RateCache::ins(); $_rate_data = $_rc_class->getInfoByAppId($app_id); $_rate_data = array_merge($_rate_data, $rate_data); $_rs = $_rc_class->updateGameRate($app_id, $_rate_data); if (false == $_rs) { $_code = RateStatus::CACHE_ERROR; return $this->huoError($_code, RateStatus::getMsg($_code)); } $_gc_class = GameCache::ins(); $_game_data = $_gc_class->getInfoByAppId($app_id); $_game_data['promote_switch'] = $promote_switch; $_gc_class->updateGame($app_id, $_game_data); $_code = RateStatus::NO_ERROR; return $this->huoSuccess($_code, RateStatus::getMsg($_code)); } }