You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
3.4 KiB
PHTML

5 years ago
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Home\Model;
/**
* 分类模型
*/
class SiteGameModel extends SiteModel{
protected $_validate = array(
array('game_id', 'check_game', '该游戏已经存在', self::EXISTS_VALIDATE, 'callback', self::MODEL_BOTH),
array('game_rebate', 'is_numeric', '返利参数必须是数字', self::EXISTS_VALIDATE, 'function', self::MODEL_BOTH),
array('game_rebate', [0,100], '返利参数不正确', self::EXISTS_VALIDATE, 'between', self::MODEL_BOTH),
array('game_dow_url', 'url', '链接地址错误', self::VALUE_VALIDATE, 'regex', self::MODEL_BOTH),
);
protected $_auto = array(
array('create_time', NOW_TIME, self::MODEL_INSERT),
array('top_time', NOW_TIME, self::MODEL_INSERT),
array('update_time', NOW_TIME, self::MODEL_BOTH),
array('status', '1', self::MODEL_BOTH),
array('promote_id', PID, self::MODEL_BOTH),
array('game_id','deal_game_id',self::MODEL_INSERT,'callback')
);
/**
* @param int $promote_id
* @return mixed
*/
public function get_promote_data($promote_id=PID){
$map['promote_id'] = $promote_id;
$map['status'] = 1;
$data = $this->where($map)->order('top_time desc')->select();
return $data;
}
/**
* 检查游戏是否存在
* @return bool
*/
public function check_game(){
$map['id'] = ['neq',I('id')];
$map['promote_id'] = PID;
$map['game_id'] = I('game_id');
$map['game_name'] = I('game_name');
$map['game_source'] = I('game_source');
$map['sdk_version'] = I('sdk_version');
$data = $this->where($map)->find();
if(empty($data)){
return true;
}else{
return false;
}
}
/**
* 处理游戏ID
* 平台官方游戏 添加区服
* @return int
*/
public function deal_game_id()
{
$data = I('post.');
if($data['game_source'] == 2){//第三方游戏
$game_id = 0;
}else{//平台官方
$game_id = $data['game_id'];
}
return $game_id;
}
/**
* 获取第三方游戏
* @return mixed
*/
public function get_self_game(){
// $map['game_id'] = 0;
$map['status'] = 1;
$map['promote_id'] = PID;
$data = $this->where($map)->group('game_name,game_source,sdk_version')->select();
return $data;
}
public function get_site_game_detail($id=0) {
if (!is_numeric($id) || $id<1) {return null;}
$map['tab_site_game.promote_id']=PID;
$map['tab_site_game.id']=$id;
$data = $this->where($map)->find();
if ($data['game_source'] == 1) {
$data = $this->field('tab_site_game.*,tab_game.game_type_id,tab_game.game_type_name as game_type,tab_game.sdk_version')->join('tab_game on tab_game.id=tab_site_game.game_id','left')->where($map)->find();
}
return $data;
}
}