123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- /**
- * GameRateModel.php UTF-8
- * 游戏折扣模型
- *
- * @date : 2018/5/14 13:41
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : wuyonghong <wyh@huosdk.com>
- * @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 '';
- }
- }
- }
|