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