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.

1519 lines
38 KiB
PHTML

5 years ago
<?php
/**
* 获取大号信息
*
* @param int $id 小号编号[帐号]
* @param bool $flag 判断是否编号, true 不是
*
* @return array|mixed|PDOStatement|string|\think\Model|null
*
* @author: 鹿文学[lwx]<fyj301415926@126.com>
* @since: 2019\4\16 0016 13:42
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
function get_user_big_info($id=0, $flag=false) {
if((is_numeric($id) && $id>0) || (is_string($id) && !empty($id)) ) {
if($flag) {
$map['b.account'] = $id;
} else {
$map['b.id'] = $id;
}
return M('User','tab_')
->alias('a')
->field('a.id,a.account,a.balance')
->join('inner join tab_user b on a.id = b.puid')
->where($map)
->find();
} else {
return '';
}
}
/*
* 获取推广员列表(根据父级编号)
* @param integer $id 父级编号(为负数则是全部)
* @author 鹿文学
*/
function get_promote_list_by_id($id=0) {
if(is_numeric($id) && $id>=0) {
$list = M("Promote","tab_")->field('id,account,balance_coin')->where(['parent_id'=>$id])->select();
} elseif(is_array($id)) {
$list = M("Promote","tab_")->field('id,account,balance_coin')->where(['parent_id'=>array('in',$id)])->select();
} elseif(is_numeric($id) && $id<0){
$list = M("Promote","tab_")->field('id,account,balance_coin')->select();
} else {
$list = '';
}
return $list;
}
/*
* 秒数转时长(时分秒格式)
* @param int $times 秒数
* @author 鹿文学
*/
function second_to_duration($times){
$result = '00:00:00';
if ($times>0) {
$hour = floor($times/3600);
$minute = floor(($times-3600 * $hour)/60);
$second = floor((($times-3600 * $hour) - 60 * $minute) % 60);
$result = $hour.':'.$minute.':'.$second;
}
return $result;
}
/**
* 后台公共文件扩展
* 主要定义后台公共函数库
*/
function get_vip_level_limit($field='',$level=0) {
if(empty($field)) {return '';}
$tool = M('tool',"tab_")->field('config,status')->where(['name'=>'viplevel'])->find();
if(!empty($tool) && $tool['status']==1){
$viplevel = json_decode($tool['config'],true);
$vl='';
if(empty($viplevel)) {return '';}
foreach($viplevel as $k=>$v) {
$cur = intval(str_replace('vip','',$k));
if($level == 0) {$vl = $field . '<' . $v;break;}
if($level>=count($viplevel) && $cur >= count($viplevel)) {$vl = $field . '>=' . $v;break;}
if($level==$cur) {
$vl = $field . '>=' . $v . ' and ' . $field .'<'.$viplevel['vip'.($cur+1)];
break;
}
}
return $vl;
} else {
return '';
}
}
function addZeroToTime($v) {
return $v.':00';
}
function set_date_day_format($day='') {
return strlen($day)==1?'0'.$day:$day;
}
/*
* 异常类型
*/
function get_bug_name_by_id($id=0) {
if (!is_numeric($id) || $id<0 ) {return '';}
$list = get_bug_list();
return $list[$id];
}
function get_bug_list() {
return array(
100=>'开发者注册未审核',
101=>'游戏充值未到账',
102=>'补单失败',
103=>'平台币充值未到账',
104=>'绑币充值未到账',
200=>'开发者提现未处理',
201=>'推广员提现未处理',
300=>'推广员注册未审核',
301=>'推广员混服申请未审核',
302=>'推广员游戏申请未审核',
303=>'推广员游戏申请未打包',
304=>'推广员游戏盒子APP申请未审核',
305=>'推广员游戏盒子APP申请未打包',
400=>'游戏未设置分成比例',
401=>'开发者游戏未审核',
402=>'游戏原包未上传',
403=>'礼包数量不足',
404=>'评论未审核',
405=>'发放平台币失败',
406=>'发放绑币失败',
);
}
/* 获取色系 鹿文学 2017-11-17 */
function get_color_style_list() {
$result = M('config')->field('extra,value')->find(13);
if ($result) {
$list['list'] = parse_config_attr($result['extra']);
$list['value']=$result['value'];
}
return $list;
}
//根据游戏id获取游戏唯一标示
function get_marking($id)
{
$map['id']=$id;
$game=M("game","tab_")->where($map)->find();
return $game['marking'];
}
function get_auth_group_name($uid){
$model = D("auth_group_access");
$res = $model->join("sys_auth_group on sys_auth_group.id = sys_auth_group_access.group_id")
->field("title")
->where("uid=".$uid)
->find();
return empty($res["title"]) ? "空" : $res["title"];
}
//根据发送消息的ID获取通知名字
function get_push_name($id)
{
$map['id']=$id;
$list=M("push","tab_")->where($map)->find();
if(empty($list)){return false;}
return $list['push_name'];
}
//获取推送通知应用
function get_push_list()
{
$list=M("push","tab_")->select();
if(empty($list)){return false;}
return $list;
}
function get_promote_list($select='') {
$list = M("Promote","tab_")->field('id,account,balance_coin')->select();//where("status=1")->
if (empty($list)){return '';}
if($select==111){
$new['id']=-1;
$new['account']="全站用户";
array_unshift($list,$new);
}
return $list;
}
/**
* [获取所有一级推广员]
* @return [type] [description]
*/
function get_all_toppromote(){
$map['status']=1;
5 years ago
$map['level']=['lt', 4];
5 years ago
$list = M("Promote","tab_")->where($map)->select();
if (empty($list)){return '';}
return $list;
}
function time_day($time){
$now = time();
return floor(($now-$time)/(60*60*24));
}
function mdate($time = NULL) {
$text = '';
$time = $time === NULL || $time > time() ? time() : intval($time);
$t = time() - $time; //时间差 (秒)
$y = date('Y', $time)-date('Y', time());//是否跨年
switch($t){
case $t == 0:
$text = '刚刚';
break;
case $t < 60:
$text = $t . '秒前'; // 一分钟内
break;
case $t < 60 * 60:
$text = floor($t / 60) . '分钟前'; //一小时内
break;
case $t < 60 * 60 * 24:
$text = floor($t / (60 * 60)) . '小时前'; // 一天内
break;
case $t < 60 * 60 * 24 * 1:
$text = '昨天 ' . date('H:i', $time);
break;
case $t < 60 * 60 * 24 * 30:
$text = date('m-d H:i', $time); //一个月内
break;
case $t < 60 * 60 * 24 * 365&&$y==0:
$text = date('m-d', $time); //一年内
break;
default:
$text = date('Y-m-d-', $time); //一年以前
break;
}
return $text;
}
//所有支付方式
function all_pay_way($type=false)
{
if($type){
$pay_way[0]=array('key'=>0,'value'=>"平台币");
}
$pay_way[1]=array('key'=>-1,'value'=>"绑币");
$pay_way[2]=array('key'=>1,'value'=>"支付宝");
$pay_way[3]=array('key'=>2,'value'=>"微信");
// $pay_way[3]=array('key'=>3,'value'=>'微信APP');
// $pay_way[4]=array('key'=>4,'value'=>'威富通');
/* $pay_way[4]=array('key'=>5,'value'=>'聚宝云'); */
// $pay_way[5]=array('key'=>6,'value'=>'汇付宝');
/* $pay_way[6]=array('key'=>7,'value'=>"苹果支付");
*/
$pay_way[7]=array('key'=>8,'value'=>'金猪');
return $pay_way;
}
/* //获取支付方式 */
function get_pay_way($id=null)
{
if(!isset($id)){
return false;
}
switch ($id) {
case -1:
return "绑币";
break;
case 0:
return "平台币";
break;
case 1:
return "支付宝";
break;
case 2:
return "微信";
break;
case 3:
return "微信APP";
break;
case 4:
return "威富通";
break;
case 5:
return "聚宝云";
break;
case 6:
return "竣付通";
break;
case 7:
return "苹果支付";
break;
case 8:
return "金猪支付";
break;
case 9:
return "双乾支付-支付宝";
break;
case 10:
return "双乾支付-银联";
break;
}
}
function get_pay_way_map($id) {
if(!isset($id)){
return '';
}
switch ($id) {
case -1:
return -1;
break;
case 0:
return 0;
break;
case 1:
return 1;
break;
case 2:
case 3:
case 4:
return array('in',[2,3,4]);
break;
case 5:
return 5;
break;
case 6:
return 6;
break;
case 7:
return 7;
break;
case 8:
return 8;
break;
case 9:
return 9;
break;
}
}
function get_obtain_pay_way($keys=array()){
$pay_way[0]=array('key'=>0, 'value'=>"平台币");
$pay_way[1]=array('key'=>-1,'value'=>"绑币");
$pay_way[2]=array('key'=>1, 'value'=>"支付宝");
$pay_way[3]=array('key'=>2, 'value'=>"微信");
$pay_way[4]=array('key'=>5, 'value'=>'聚宝云');
$pay_way[6]=array('key'=>7, 'value'=>"苹果支付");
$pay_way[7]=array('key'=>8,'value'=>'竣付通');
if(!empty($keys)){
foreach ($keys as $key) {
unset($pay_way[$key]);
}
}
return $pay_way;
}
//获取支付方式
function get_register_way($id=null)
{
if(!isset($id)){
return false;
}
switch ($id) {
case 1:
return "SDK注册";
break;
case 2:
return "APP注册";
case 3:
return "PC注册";
case 4:
return "WAP注册";
break;
}
}
/**
* 获取所有第三方注册方式
* @param [type] $id [description]
* @return [type] [description]
*/
function get_register_type($id=null){
if(!isset($id)){
return false;
}
switch ($id) {
case 3:
return "微信";
break;
case 4:
return "QQ";
case 5:
return "百度";
case 6:
return "微博";
break;
}
}
/**
* 所有注册方式
* @param boolean $type [description]
* @return [type] [description]
* @author zc <894827077@qq.com>
*/
function all_register_way($type=false)
{
$pay_way[1]=array('key'=>1,'value'=>'SDK注册');
$pay_way[2]=array('key'=>2,'value'=>'APP注册');
$pay_way[3]=array('key'=>3,'value'=>'PC注册');
$pay_way[4]=array('key'=>4,'value'=>'WAP注册');
return $pay_way;
}
/**
* 所有第三方注册方式
* @param boolean $type [description]
* @return [type] [description]
* @author zc <894827077@qq.com>
*/
function all_register_type($type=false)
{
$pay_way[3]=array('key'=>3,'value'=>'微信');
$pay_way[4]=array('key'=>4,'value'=>'QQ');
$pay_way[5]=array('key'=>5,'value'=>'百度');
$pay_way[6]=array('key'=>6,'value'=>'微博');
$pay_way[7]=array('key'=>0,'value'=>'游客');
return $pay_way;
}
/**
* 根据用户账号 获取用户昵称
* @param [type] $account [用户账号]
* @return [type] user_nickname [用户]
* @author [yyh]
*/
function get_user_nickname($account){
$map['account']=$account;
$user=M("user_play","tab_")->field('user_nickname')->where($map)->find();
return $user['user_nickname'];
}
//判断用户是否玩此游戏 authoryyh
function get_play_user($account,$gid){
if(empty($account))return false;
$user = D('User');
$map['account']=$account;
$map['game_id']=$gid;
$data = $user->field('tab_user.id,tab_user.account')
->join('tab_user_play on tab_user.account=tab_user_play.user_account')
->where($map)
->find();
return $data;
}
//生成订单号
function build_order_no(){
return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
}
/**
* [get_game_id description]根据游戏名称 获取游戏id
* @param [type] $name [游戏名称]
* @return [type] [id]
* @author [yyh] <[email address]>
*/
function get_game_id($name){
$game=M('game','tab_');
$map['game_name']=$name;
$data=$game->where($map)->find();
if($data['id']==null){
return false;
}
return $data['id'];
}
/**
* [ratio_stytl 数值转百分比
* @param integer $num [description]
* @return [yyh] [description]
*/
function ratio_stytl($num = 0){
return $num."%";
}
/**
* [get_user_account 根据用户id 获取用户账号]
* @param [type] $uid [用户id]
* @return [type] account [用户账号]
* @author [yyh] <[email address]>
*/
function get_user_account($uid=null){
if(empty($uid)){return false;}
$user = D('User');
$map['id'] = $uid;
$data = $user->field('account')->where($map)->find();
if(empty($data['account'])){return false;}
return $data['account'];
}
/**
* [checked_game description]
* @param [type] $id [description]
* @param [type] $sibling_id [description]
* @return [type] [description]
*/
function checked_game($id,$sibling_id){
if($sibling_id){
$map['id']=array('neq',$id);
$map['sibling_id']=$sibling_id;
$game=M('Game','tab_')->where($map)->find();
if(empty($game)){
return '';
}else{
return $game;
}
}else{
return false;
}
}
/**
* [获取游戏原包文件版本]
* @param [type] $game_id [description]
* @param string $type [description]
* @return [type] [description]
*/
function get_game_version($game_id,$type=''){
$model=M('game_source force index (`game_id`)','tab_');
if($game_id==''){
return '';
}
$map['game_id']=$game_id;
$map['file_type']=$type;
$data=$model
->where($map)
->select();
return $data;
}
/**
* [获取游戏版本]
* @param [type] $id [description]
* @return [type] [description]
*/
function game_version($id){
$game=M('game','tab_');
$map['id']=$id;
$data=$game->field('sdk_version')->where($map)->find();
if($data['id']==null){
return false;
}
return $data['version'];
}
/**
*获取游戏配置的指定字段信息
*/
function get_game_set_field($game_id,$field=""){
$map['id'] = $game_id;
$data = M('GameSet','tab_')->where($map)->getField($field);
if(empty($data)){
return "暂无";
}else{
return $data;
}
}
/**
* 渠道列表
* @param $type
* @return mixed
*/
function promote_lists($type){
5 years ago
if($type){
$map['level'] = $type;
5 years ago
} else{
$map = '';
}
$data = M('promote','tab_')->where($map)->select();
$items = M('PromoteBalanceCoin', 'tab_')->where(['game_id' => 0])->select();
$records = [];
foreach ($items as $item) {
$records[$item['promote_id']] = $item['num'];
}
foreach ($data as $key => $item) {
$item['common_coin'] = isset($records[$item['id']]) ? $records[$item['id']] : $item['balance_coin'];
$data[$key] = $item;
}
return $data;
}
// 获取IOS游戏名称
function get_ios_game_name($game_id=null,$field='id'){
$map[$field]=$game_id;
$map['game_version']=0;
$data=M('Game','tab_')->where($map)->find();
if(empty($data)){return false;}
$game_name=explode("(", $data['game_name']);
return $game_name[0];
}
/**
* [获取区服名称]
* @param [type] $id [description]
* @return [type] [description]
*/
function get_server_name($id){
if($id==''){
return false;
}
$map['id']=$id;
$area=M("Server","tab_")->field('')->where($map)->find();
return $area['server_name'];
}
/**
* [获取游戏区服名称]
* @param [type] $area_id [description]
* @return [type] [description]
*/
function get_area_name($area_id= null){
if(empty($area_id)){return false;}
$area_model = D('Server');
$map['server_num'] = $area_id;
$name = $area_model->field('server_name')->where($map)->find();
if(empty($name['server_name'])){return false;}
return $name['server_name'];
}
/**
* [根据推广员获取所属专员]
* @param [type] $id [description]
* @return [type] [description]
*/
function get_belong_admin($id)
{
$map['id']=$id;
$pro=M("promote","tab_")->where($map)->find();
if($pro){
return get_admin_nickname($pro['parent_id'],$pro['admin_id']);
}else{
return false;
}
}
/**
* [获取管理员列表]
* @return [type] [description]
*/
function get_admin_list()
{
$list= M("Member")->field('uid,nickname')->where("status=1")->select();
if(empty($list)){return false;}
return $list;
}
/**
* [渠道等级]
* @param [type] $pid [description]
* @return [type] [description]
*/
function get_qu_promote($pid){
if($pid==0){
return "一级推广员";
}else{
return "二级推广员";
}
}
/**
* [上线渠道]
* @param [type] $id [description]
* @param [type] $pid [description]
* @return [type] [description]
*/
function get_top_promote($id,$pid){
if($pid==0){
$pro=M("promote","tab_")->field('account')->where(array('id'=>$id))->find();
}else{
$map['id']=$pid;
$pro=M("promote","tab_")->field('account')->where($map)->find();
}
if($pro==''){
return false;
}
return $pro['account'];
}
function get_parent_promote_name($id) {
if(!is_numeric($id) || $id<1) {return '--';}
$promotemodel= M('promote','tab_');
$pro = $promotemodel->field('account,parent_id')->where(['id'=>$id])->find();
if(is_array($pro)) {
if($pro['parent_id']==0) {return $pro['account'];}
$pre = $promotemodel->field('account')->where(['id'=>$pro['parent_id']])->find();
if(is_array($pre)) {
return $pre['account'];
} else {
return $pro['account'];
}
} else {
return '--';
}
}
/**
* 获取管理员昵称 二级跟随一级
* @param [type] $parent_id [description]
* @param [type] $admin_id [description]
* @return [type] ` [description]
*/
function get_admin_nickname($parent_id = 0,$admin_id=null){
$user = D('member');
$map1['uid'] = $parent_id;
$data = $user->field('nickname')->where($map1)->find();
return $data['nickname'];
}
function get_admin_account($id=0) {
$map['id'] = $id;
$data = M('UcenterMember')->field('username')->where($map)->find();
return $data['username'];
}
/**
* [根据推广员获取所属专员]
* @param [type] $id [description]
* @return [type] [description]
*/
function get_admin_promotes($param,$type='admin_id')
{
$map[$type]=$param;
$pro=M("promote","tab_")->where($map)->select();
return $pro;
}
/**
* [根据推广员id获取上级推广员姓名]
* @param [type] $id [description]
* @return [type] [description]
*/
function get_parent_promoteto($id){
if($id==''){
return '';
}
$list=D("promote");
$map['id']=$id;
$pid=$list->field('parent_id')->where($map)->find();
if($pid['parent_id']!=0){
$mapp['id']=$pid['parent_id'];
$pname=$list->field('account')->where($mapp)->find();
if($pname){
return "[".$pname['account']."]";
}
else{
return "";
}
}else{
return "";
}
}
//获取注册来源
function get_registerway($way){
if(!isset($way)){
return false;
}
$arr=array(
1=>'SDK',
2=>'APP',
3=>'PC',
4=>'WAP',
);
return $arr[$way];
}
//获取注册方式
function get_registertype($type){
if(!isset($type)){
return false;
}
$arr=array(
0=>"游客",
1=>"账号",
2 =>"手机",
3=>"微信",
4=>"QQ",
5=>"百度",
6=>"微博",
7=>"Facebook",
8=>"Google",
9=>"邮箱",
);
return $arr[$type];
}
//获取推广员id
function get_promote_id($name){
$promote=M('Promote','tab_');
$map['account']=$name;
$data=$promote->field('id')->where($map)->find();
if(empty($data)){
return '';
}else{
return $data['id'];
}
}
//获取管理员id
function get_admin_id($name){
$promote=M('Member','sys_');
$map['nickname']=$name;
$data=$promote->field('uid')->where($map)->find();
if(empty($data)){
return '';
}else{
return $data['uid'];
}
}
//获取所有用户列表
function get_user_list(){
$user = M('User','tab_');
$list = $user->field('id,account,balance')->select();
return $list;
}
//获取所有用户列表
function get_user_play_group_list(){
$user = M('UserPlay','tab_');
$list = $user->field('user_id,user_account,game_id,game_name,bind_balance')->group("user_id")->select();
return $list;
}
/**
* [array_group_by 二维数组根据里面元素数组的字段 分组]
* @param [type] $arr [description]
* @param [type] $key [description]
* @return [type] [description]
*/
function array_group_by($arr, $key){
$grouped = [];
foreach ($arr as $value) {
$grouped[$value[$key]][] = $value;
}
if (func_num_args() > 2) {
$args = func_get_args();
foreach ($grouped as $key => $value) {
$parms = array_merge([$value], array_slice($args, 2, func_num_args()));
$grouped[$key] = call_user_func_array('array_group_by', $parms);
}
}
return $grouped;
}
/**
* [前几个月]
* @param integer $m [前几个月]
* @return [type] [description]
*/
function before_mounth($m=12){
$time=array();
for ($i=0; $i <$m ; $i++) {
$time[]=date("Y-m", strtotime("-$i month"));
}
return $time;
}
/**
* 获取上周指定日期时间
* @param $str 指定时间
* @return unknown 时间
*/
function get_lastweek_name($str){
switch ($str) {
case '1':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-1,date('Y')));
break;
case '2':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-2,date('Y')));
break;
case '3':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-3,date('Y')));
break;
case '4':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-4,date('Y')));
break;
case '5':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-5,date('Y')));
break;
case '6':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-6,date('Y')));
break;
case '7':
$time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-7,date('Y')));
break;
// case '-1':
// $time = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-7,date('Y')));
// break;
default:
$time =date("Y-m-d",mktime(0,0,0,date('m'),date('d'),date('Y')));
break;
}
return $time;
}
//获取广告图类型
function get_adv_type($type=0){
switch ($type) {
case 1:
return '单图';
break;
case 2:
return '多图';
break;
case 3:
return '文字链接';
break;
case 4:
return '代码';
break;
default:
return '未知类型';
break;
}
}
/**
*获取广告位标题
*@param int $pos_id
*@return string
*@author 小纯洁
*/
function get_adv_pos_title($pos_id=0){
$adv_pos = M('AdvPos',"tab_");
$map['id'] = $pos_id;
$data = $adv_pos->field('title')->where($map)->find();
if(empty($data)){return "没有广告位";}
return $data['title'];
}
function get_relation_game($id,$relation_id){
if($id==$relation_id){
$gdata=M('Game','tab_')->where(array('relation_game_id'=>$relation_id,'id'=>array('neq',$id)))->find();
if(!$gdata){
return false;//未关联游戏 即没有例外一个版本
}else{
return true;
}
}else{
//再次确认关联的游戏
$gdata=M('Game','tab_')->where(array('relation_game_id'=>$relation_id,'id'=>$relation_id))->find();
if($gdata){
return true;
}else{
return -1; //数据出错
}
}
}
function get_kuaijie($type=''){
if($type==''){
return false;
}else{
$data=M('Member')->field('kuaijie_value')->where(array('uid'=>UID))->find();
}
$data=$data['kuaijie_value'];
if(empty($data)){
$data='1,2,3,4,5,6,7,8,9,10';
}
$dataa=explode(',',$data);
if($type==1){
if($data==''){
$dataa='';
}else{
$map['id']=array('in',$data);
$dataa=M('Kuaijieicon')->where($map)->select();
}
}elseif($type==2){
if($data==''){
$dataa=M('Kuaijieicon')->select();
}else{
$map['id']=array('not in',$data);
$dataa=M('Kuaijieicon')->where($map)->select();
}
}
foreach ($dataa as $key => $value) {
foreach ($data as $k => $v) {
if($value==$v['value']){
$dataa[$key]=$v;
}
}
}
return $dataa;
}
/**
* 获取游戏版本
* @param $game_id
* @return string
*/
function get_sdk_version($game_id){
$game = M('Game','tab_')->find($game_id);
$version = empty($game) ? '' : $game['sdk_version'];
return $version;
}
function get_kefu_data(){
$map['status']=1;
$map['istitle']=1;
$list = M('Kefuquestion')
->where($map)
->group('title')
->select();
return $list;
}
//获取短消息未读条数
function get_msg($id = 0){
$id = $id ? $id : session('user_auth.uid');
$map['user_id'] = $id;
$map['status'] = 2;
$count = M('msg', 'tab_')->where($map)->count();
return $count;
}
function array_status2value($status,$param,$array=array()){
foreach ($array as $key => $value) {
if($value[$status]!=1){
unset($array[$key]);
}
}
return $array;
}
/**
* 获取渠道平台币
* @param $promote_id
* @return mixed
*/
function get_promote_coin($promote_id){
$promote = M('promote','tab_')->field('balance_coin')->find($promote_id);
return $promote['balance_coin'];
}
/**
* 获取渠道父类
* @param $promote_id
* @param string $field
* @return mixed
*/
function get_promote_parent($promote_id,$field='account'){
$Promote = M('promote','tab_');
$data = $Promote->field('parent_id')->find($promote_id);
if($data['parent_id'] != 0){
$data = $Promote->find($data['parent_id']);
}
return $data[$field];
}
/**
* 获取渠道父类 父级默认空
*/
function get_promote_parent_acc($promote_id){
$Promote = M('promote','tab_');
5 years ago
$data = $Promote->field('account,parent_id')->find($promote_id);
5 years ago
if(empty($data)){
return $data["account"]="官方渠道";exit;
}
5 years ago
$chain = trim($data['chain'], '/');
if ($chain == '') {
return '------';
} else {
$topPromoteId = explode('/', $chain)[0];
$parent_promote = M('promote', 'tab_')->where(['id' => $topPromoteId])->find();
return $parent_promote['account'] ?: '------';
5 years ago
}
}
//获取所有苹果证书id
function get_applecert(){
$data=M('applecert')->select();
return $data;;
}
/**
* 获取ios游戏描述文件路径等
* @param [type] $game_id 游戏id
* @param [type] $type 1 原包路径 2描述文件路径
* @return [type] 路径
*/
function get_game_url($game_id,$type=1){
$map['game_id']=$game_id;
$find=M('game_source','tab_')->field('file_url,description_url')->where($map)->find();
if($type==1){
return $find['file_url'];
}elseif($type==2){
return $find['description_url'];
}
}
/**
* 检查苹果渠道包打包状态
* @param [type] $pid [渠道id]
* @param [type] $gid [游戏id]
* @return boolean [-2 可以申请 -1 正在打包 1打包成功 2 打包失败 ]
*/
function is_check_pack_for_ios($pid,$gid){
$map['channelid']=$pid;
$map['game_id']=$gid;
$find=M('iospacket')->where($map)->find();
if(null==$find){
return -2;
}elseif(null!==$find&&$find['status']==2){
return -1;
}elseif(null!==$find&&$find['status']==0){
return 1;
}elseif(null!==$find&&$find['status']==-1){
return 2;
}
}
/**
* 根据游戏id获取存入iospacket的原包/描述文件路径
* @param [type] $game_id [description]
* @param [type] $t [description]
* @return [type] [description]
*/
function get_ios_purl($game_id,$t){
$a=explode("/",get_game_url($game_id,$t));
return $a[3]."/".$a[4];
}
/**
* 判断原包是否有更新
* @param [type] $game_id [游戏id]
* @param [type] $promote_id [渠道id]
* @return [type] [1 有更新 0 无鞥下]
*/
function check_iosupdate($game_id,$promote_id){
$map['game_id']=$game_id;
$source=M('game_source','tab_')->field('game_id,file_url')->where($map)->find();
$map['channelid']=$promote_id;
$iospack=M('iospacket')->field('originalpath')->where($map)->find();
if($source['file_url']!=="./Uploads/Ios/".$iospack['originalpath']){
return 1;
}else{
return 0;
}
}
/**
* 获取积分类型列表
* @return mixed
* author: xmy 280564871@qq.com
*/
function get_point_type_lists(){
$data =M("point_type","tab_")->where(['status'=>1])->select();
return $data;
}
/**
* 获取积分商品列表
* author: xmy 280564871@qq.com
*/
function get_point_good_lists(){
$data =M("point_shop","tab_")->where(['status'=>1])->select();
return $data;
}
/**
* 验证退款记录
* @param $pay_order_number
* @return int
*/
function ischeck_refund($pay_order_number){
$map['pay_order_number']=$pay_order_number;
$find=M('refund_record','tab_')->where($map)->find();
if(null==$find){
return 1;
}elseif($find['tui_status']=='2'){
return 2;
}elseif($find['tui_status']=='1'){
return 0;
}
}
/**
* 获取支付方式
* @param $order
* @return mixed
*/
function get_spend_pay_way($order){
$map['pay_order_number']=$order;
$find=M('refund_record','tab_')->field('pay_way')->where($map)->find();
return $find['pay_way'];
}
//得到ios游戏的plist_url
function get_plist($game_id){
$map['game_id'] = $game_id;
$data = M('Game_source','tab_')->where($map)->field('plist_url')->find();
if (empty($data['plist_url'])){
return '';
}else{
return "itms-services://?action=download-manifest&url=".$_SERVER['HTTP_HOST'].substr($data['plist_url'],1);
}
}
/**
*删除数组中特定元素
* @param array $data, 要移除的数据
* @param type $element,要移除的指定元素
* @return array 移除后的新数组
* @author 小纯洁
*/
function remove_array_element($data=null,$element=null){
foreach ($data as $key=>$value) {
if ($value === $element)
{
unset($data[$key]);
}
}
return $data;
}
/**
*获取首冲续充对象名称
*@param int $case 类型
*@return string 返回对象名称
*@author 小纯洁
*/
function get_discount_obj_name($case = 0){
$result = "";
switch ($case) {
case -1:
$result = "全站玩家";
break;
case 0:
$result = "官方渠道";
break;
case -2:
$result = "推广渠道";
break;
default:
$result = "全站玩家";
break;
}
return $result;
}
/**
*根据推广员ID获取商务专员账号名称
*@param int $promote_id
*@return string 返回对象名称
*@author 小纯洁
*/
function get_promote_business_account($promote_id=0){
$promote = M('promote','tab_')->find($promote_id);
if(empty($promote)){
return "错误";
}
$business = M('BusinessAffairs','tab_')->find($promote['ba_id']);
return empty($business['account']) ? "暂无" : $business['account'];
}
function get_highlight_subnav($cate_id=0,$url='Article/index',$param='cate_id'){
$map['sys_category.id'] = $cate_id;
$cate_id = D('category')
->field("tab.id,tab.title,tab.pid,tab.sort")
->join("sys_category AS tab ON sys_category.pid = tab.pid")
->where($map)
->order('tab.sort asc')
->getField('tab.id',1);
$url = U($url,array('cate_id'=>$cate_id));
return $url;
}
/**
*根据唯一字段查找特定的字段值
*@param string field 要返回的字段结果
*@param string fieldMap 要查询的字段名称
*@param string value 要查询的唯一字段的值
*/
function get_spend_fields($field='user_account',$fieldMap='id',$value=''){
$map[$fieldMap] = $value;
$data = M('Spend','tab_')->field($field)->where($map)->find();
if(empty($data)){
return false;
}else{
return $field === 'true' ? $data : $data[$field];
}
}
/**
*根据模板id获取获取模板名称
*/
function get_tepname($id){
$model = M("Template");
$map["id"] = $id;
$reg = $model->where($map)->find();
return $reg["temname"];
}
function open_url($url=null){
$str = "<a href='".$url."' target='_blank'>".$url."</a>";
return $str;
}
/**
*获取自建模板
*/
function templatelist(){
$model = M("Template");
$list = $model->select();
return $list;
}
/**
*返回游戏名称
*/
function get_gamename($gid=0){
if($gid == 0){return "未知";}
$model = D("Game");
$list = $model->where("id=".$gid)->find();
return $list["game_name"];
}
/**
*返回游戏官网名称
*/
function get_self_name($gid=0){
if($gid == 0){return "未知";}
$model = D("Game");
$self=M('selfbuilt')->where(['id'=>$gid])->find();
$list = $model->where("id=".$self['gameid'])->find();
return $list["game_name"];
}
function get_list_data($model=null){
$m = M($model)->select();
return $m;
}
function get_list_row($item = "global",$modelName="Model"){
$list = new \Admin\Event\listRowEvent();
$r = $list->getItem($item);
return $list->listRows();
}
function get_pos_game($type=16){
$map['apply_status'] = 1;
$map['game_status'] = 1;
if($type == 16){
$map['sdk_version'] = 1;
}else{
$map['sdk_version'] = 2;
}
$data = M('game','tab_')->field('id,game_name')->where($map)->select();
return $data;
}
5 years ago
function get_promote_levels($id = 0)
{
$data = M('promote', 'tab_')->field('parent_id, level')->where(array('id' => $id))->find();
switch ($data['level']) {
case '1':
return "一级推广员";
break;
case '2':
return "二级推广员";
break;
case '3':
return "三级推广员";
break;
case '4':
return "四级推广员";
break;
default:
return '';
5 years ago
}
}
/**
* 统计推广员总流水
* @param [type] $id [description]
* @return [type] [description]
*/
function sum_promote_total_money($id){
$map['promote_id']=$id;
$map['pay_status']=1;
$res=M('Spend','tab_')->field("SUM(pay_amount) as pay_amount")->where($map)->select();
return $res[0]['pay_amount']==null ? '0.00':$res[0]['pay_amount'];
}
/**
*后续可用额度
* @param [type] $game_id [description]
* @return [type] $promote_id [description]
*/
function max_quota($game_id,$promote_id){
$map_s['game_id'] =$game_id;
$map_s['promote_id'] =$promote_id;
$map_s['support_type'] =1;
$map_s['notice_status'] =1;
$yishenhe_support_sum=M('support','tab_')->field("SUM(real_support_num) as sum_support_num")->where($map_s)->select();
$map_s['notice_status'] =0;
$map_s['status'] =['neq',0];
$weishenhe_support_sum=M('support','tab_')->field("SUM(support_num) as sum_support_num")->where($map_s)->select();
$support_quota=M('game','tab_')->field('support_quota,support_ratio')->where(['id'=>$game_id])->find();
$max_quota=$support_quota['support_quota']-$support_sum[0]['sum_support_num']; //算法一: 可用额度 = 后台设置额度 - 已申请额度
$map_sp['pay_status']=1;
$map_sp['game_id']=$game_id;
$child_promote = get_zi_promote_id($promote_id);
if($child_promote==0){
$child_promote = $promote_id;
}else{
$child_promote = $child_promote .','.$promote_id;
}
$map_sp['promote_id'] = ['in',$child_promote];
$spend=M('spend','tab_')->field('SUM(pay_amount) as sum_amount')->where($map_sp)->select();
// 该渠道该游戏可用额度 = 该渠道和子渠道的所有玩家的充值量 * 扶持额度 - 待审核额度 - 已申请成功额度
$promote_quota=floor($spend[0]['sum_amount'] * $support_quota['support_ratio']/100 - $weishenhe_support_sum[0]['sum_support_num'] - $yishenhe_support_sum[0]['sum_support_num']);
return $promote_quota < 1 ? 0 : $promote_quota;
}
//现金支付方式
function cash_pay_way()
{
//$pay_way[1]=array('key'=>-1,'value'=>"绑币");
$pay_way[2]=array('key'=>1,'value'=>"支付宝");
$pay_way[3]=array('key'=>2,'value'=>"微信");
// $pay_way[3]=array('key'=>3,'value'=>'微信APP');
// $pay_way[4]=array('key'=>4,'value'=>'威富通');
/* $pay_way[4]=array('key'=>5,'value'=>'聚宝云'); */
// $pay_way[5]=array('key'=>6,'value'=>'汇付宝');
/* $pay_way[6]=array('key'=>7,'value'=>"苹果支付");
*/
$pay_way[7]=array('key'=>8,'value'=>'金猪');
return $pay_way;
}
function getMonth() {
$start = date("Y-m", strtotime("now"));
//开始月份
$range = [];
$i = 1;
do {
$month = date('Y-m', strtotime($start . ' - ' . $i . ' month'));
$range[] = $month;
$i++;
} while ($i<13);
return $range;
}
function getPayType($type) {
$return = '';
switch ($type) {
case -1:
$return = '绑币';
break;
case 0:
$return = '平台币';
break;
case 1:
$return = '支付宝';
break;
case 2:
$return = '微信(扫码)';
break;
case 3:
$return = '微信app';
break;
case 4:
$return = '威富通';
break;
case 5:
$return = '聚宝云';
break;
case 6:
$return = '竣付通';
break;
default:
$return = '未知';
break;
}
return $return;
}
function getPartner() {
$map['status'] = 1;
$data = M('partner','tab_')->field('id,partner')->where($map)->select();
return $data;
}
function getGameList($partner_id) {
if ($partner_id) {
$map['partner_id'] = $partner_id;
}
$data = M('game','tab_')->field("id,game_name")->where($map)->select();
return $data;
}
5 years ago
?>