* @version : HUOSDK 8.0 */ namespace huo\model\rate; use huo\model\common\CommonModel; use huolib\constant\GameConst; class GameRateModel extends CommonModel { protected $name = 'game_rate'; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = true; /** * 添加游戏折扣数据 * * @param $data * * @return bool */ public function addData($data) { if (empty($data)) { return false; } if ($_obj = self::create($data, true)) { return true; } else { return false; } } /** * 更新游戏折扣数据 * * @param array $data * @param string $app_id * * @return bool */ public function updateData($data, $app_id) { $_map['app_id'] = $app_id; $_data = $data; $_rs = self::update($_data, $_map, true); if (false == $_rs) { return false; } else { return true; } } /** * 获取单条记录 * * @param int $id * * @return array|false */ public function getInfoById($id) { $_map['app_id'] = $id; $_info = $this->where($_map)->find(); if (false === $_info) { return false; } if (is_object($_info)) { return $_info->toArray(); } else { return $_info; } } /** * 优惠类型描述获取器 * * @param $value * * @return string */ public function getBenefitTypeTextAttr($value) { switch ($value) { case GameConst::RATE_BENEFIT_NO: return '无优惠'; case GameConst::RATE_BENEFIT_RATE: return '折扣'; case GameConst::RATE_BENEFIT_REBATE: return 'CPS'; case GameConst::RATE_BENEFIT_REWARD: return 'CPA'; default: return ''; } } /** * 优惠类型描述获取器 * * @param $value * * @return string */ public function getAgentBenefitTypeTextAttr($value) { switch ($value) { case GameConst::RATE_AGENT_BENEFIT_REWARD: return 'CPA'; case GameConst::RATE_AGENT_BENEFIT_REBATE: return 'CPS'; default: return ''; } } }