* @version : HUOSDK 8.0 */ namespace huo\model\rate; use huo\model\common\CommonModel; use huolib\constant\CacheConst; use think\Cache; class AgentGameRateModel extends CommonModel { protected $name = 'agent_game_rate'; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = true; protected $agent_cache_tag = CacheConst::TAG_AGENT_GAME_LIST; /** * 添加渠道游戏折扣数据 * * @param $data * * @return bool */ public function addData($data) { if (empty($data)) { return false; } if ($_obj = self::create($data, true)) { Cache::clear($this->agent_cache_tag); return true; } else { return false; } } /** * 更新渠道游戏折扣数据 * * @param array $data * @param string $ag_id * * @return bool */ public function updateData($data, $ag_id) { $_map['ag_id'] = $ag_id; $_data = $data; $_rs = self::update($_data, $_map, true); if (false == $_rs) { return false; } else { Cache::clear($this->agent_cache_tag); return true; } } /** * 通过q游戏ID 渠道ID 获取折扣信息 * * @param int $app_id * @param int $agent_id * * @return array|false */ public function getInfoByGameAgent($app_id, $agent_id) { $_map['app_id'] = $app_id; $_map['agent_id'] = $agent_id; $_info = $this->where($_map)->find(); if (false === $_info) { return false; } if (is_object($_info)) { return $_info->toArray(); } else { return $_info; } } /** * 根据渠道分成模式获取id * * @param int $agent_benefit_type 渠道分成模式 * * @return array */ public function getAgIdsByAgentBenefitType($agent_benefit_type) { $_map = [ 'agent_benefit_type' => $agent_benefit_type ]; return $this->where($_map)->column('ag_id'); } }