|
|
|
|
<?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) {
|
|
|
|
|
//为数据权限修改 2019-12-19 lww
|
|
|
|
|
$query = M("Promote","tab_")->field('id,account,balance_coin');
|
|
|
|
|
$map = array();
|
|
|
|
|
setPowerPromoteIds($map, 'id');
|
|
|
|
|
|
|
|
|
|
if(is_numeric($id) && $id>=0) {
|
|
|
|
|
$map['parent_id'] = $id;
|
|
|
|
|
} elseif(is_array($id)) {
|
|
|
|
|
$map['parent_id'] = array('in',$id);
|
|
|
|
|
}
|
|
|
|
|
$list = $query->where($map)->select();
|
|
|
|
|
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;
|
|
|
|
|
$map['level']=['lt', 4];
|
|
|
|
|
//为数据权限添加
|
|
|
|
|
setPowerPromoteIds($map, 'id');
|
|
|
|
|
$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[7]=array('key'=>8,'value'=>'金猪');
|
|
|
|
|
$pay_way[9]=array('key'=>9,'value'=>"双乾支付-支付宝");
|
|
|
|
|
$pay_way[10]=array('key'=>10,'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[15]=array('key'=>15,'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;
|
|
|
|
|
case 15:
|
|
|
|
|
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'];
|
|
|
|
|
}
|
|
|
|
|
//判断用户是否玩此游戏 author:yyh
|
|
|
|
|
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){
|
|
|
|
|
if($type){
|
|
|
|
|
$map['level'] = $type;
|
|
|
|
|
} else{
|
|
|
|
|
$map = '';
|
|
|
|
|
}
|
|
|
|
|
//为数据权限添加
|
|
|
|
|
setPowerPromoteIds($map, 'id');
|
|
|
|
|
$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')->order('id')->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'];
|
|
|
|
|
}
|
|
|
|
|
function intFun($v)
|
|
|
|
|
{
|
|
|
|
|
$v=(int)$v;
|
|
|
|
|
return $v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取渠道父类
|
|
|
|
|
* @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_');
|
|
|
|
|
$data = $Promote->field('account,parent_id,chain')->find($promote_id);
|
|
|
|
|
|
|
|
|
|
if(empty($data)){
|
|
|
|
|
return $data["account"]="官方渠道";exit;
|
|
|
|
|
}
|
|
|
|
|
$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'] ?: '------';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取所有苹果证书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;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 统计推广员总流水
|
|
|
|
|
* @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'=>'金猪');
|
|
|
|
|
$pay_way[9]=array('key'=>9,'value'=>"双乾支付-支付宝");
|
|
|
|
|
$pay_way[10]=array('key'=>10,'value'=>"双乾支付-银联");
|
|
|
|
|
$pay_way[15]=array('key'=>15,'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;
|
|
|
|
|
case 7:
|
|
|
|
|
$return = '金猪';
|
|
|
|
|
break;
|
|
|
|
|
case 9:
|
|
|
|
|
$return = '双乾支付-支付宝';
|
|
|
|
|
break;
|
|
|
|
|
case 10:
|
|
|
|
|
$return = '双乾支付-银联';
|
|
|
|
|
break;
|
|
|
|
|
case 15:
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAdminData ($uid) {
|
|
|
|
|
$adminData = M('auth_group_access')
|
|
|
|
|
->field('data_empower_type,data_president')
|
|
|
|
|
->join('left join sys_auth_group on sys_auth_group_access.group_id=sys_auth_group.id')
|
|
|
|
|
->where(array('uid'=>$uid))->find();
|
|
|
|
|
|
|
|
|
|
// $promoteData = M('promote','tab_')->field('id')->where(array('admin_id'=>$uid))->select();
|
|
|
|
|
// $promoteData = implode(',',array_column($promoteData,'id'));
|
|
|
|
|
// $adminData['data_president'] = $adminData['data_president'].','.$promoteData;
|
|
|
|
|
|
|
|
|
|
return $adminData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取当前管理员有权限查看所有推广员id
|
|
|
|
|
* @return mixed|string 格式如;all-全部;1,2,3;为空表示都没有权限
|
|
|
|
|
*/
|
|
|
|
|
function getPowerPromoteIds()
|
|
|
|
|
{
|
|
|
|
|
//session已存在当前管理员可查看数据的推广员id,则直接返回,权限有变化事删除此session
|
|
|
|
|
if (!empty(session('user_auth_promote_ids'))) {
|
|
|
|
|
return session('user_auth_promote_ids');
|
|
|
|
|
}
|
|
|
|
|
$userAuth = session('user_auth');
|
|
|
|
|
$promoteIds = 'all';
|
|
|
|
|
$userAuth['data_president']= trim($userAuth['data_president'], ",");
|
|
|
|
|
if (!empty($userAuth['data_empower_type'])) {//数据权限 1 全部 2 部分数据 3 自己底下的会长
|
|
|
|
|
//等于1默认全部数据,不进行筛选
|
|
|
|
|
if (in_array($userAuth['data_empower_type'], [2, 3])) {
|
|
|
|
|
$promoteIds = '';
|
|
|
|
|
//自己创建的会长
|
|
|
|
|
$myPromote_ids = M('promote', 'tab_')
|
|
|
|
|
->field('GROUP_CONCAT(id) as promote_ids')
|
|
|
|
|
->where(['admin_id' => $userAuth['uid']])
|
|
|
|
|
->find();
|
|
|
|
|
$myPromote_ids = $myPromote_ids['promote_ids'];
|
|
|
|
|
|
|
|
|
|
if ($myPromote_ids) {
|
|
|
|
|
if ($userAuth['data_empower_type'] == 2) {//部分会长加上自己创建的会长
|
|
|
|
|
|
|
|
|
|
// $userAuth['data_president'] .= "," . $myPromote_ids;
|
|
|
|
|
} elseif ($userAuth['data_empower_type'] == 3) {//自己创建的会长和底下推广员
|
|
|
|
|
$userAuth['data_president'] = $myPromote_ids;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!empty($userAuth['data_president'])) {//查询有权限查看的会长以及底下的推广员
|
|
|
|
|
$map = array();
|
|
|
|
|
//查询会长底下的推广员(首个斜杆之间的数字)
|
|
|
|
|
$userAuth['data_president']= trim($userAuth['data_president'], ",");
|
|
|
|
|
$where['SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,"/",2),"/",-1)'] = array('exp',"IN({$userAuth['data_president']})");
|
|
|
|
|
$where['id'] = array('in', $userAuth['data_president']);//会长本身
|
|
|
|
|
$where['_logic'] = 'or';
|
|
|
|
|
$map['_complex'] = $where;
|
|
|
|
|
$sqlResult = M('promote', 'tab_')
|
|
|
|
|
->field('GROUP_CONCAT(id) as promote_ids')
|
|
|
|
|
->where($map)
|
|
|
|
|
->find();
|
|
|
|
|
$promoteIds = $sqlResult['promote_ids'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// var_dump(in_array('-1',explode(',',$userAuth['data_president'])));die();
|
|
|
|
|
if (in_array('-1',explode(',',$userAuth['data_president']))) {
|
|
|
|
|
$promoteIds = $promoteIds .',0';
|
|
|
|
|
}
|
|
|
|
|
// var_dump($promoteIds);die();
|
|
|
|
|
session('user_auth_promote_ids', $promoteIds);
|
|
|
|
|
return $promoteIds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 为数据权限添加筛选参数
|
|
|
|
|
* @param array $map 查询条件
|
|
|
|
|
* @param string $column 字段名,默认为promote_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
function setPowerPromoteIds(&$map, $column = 'promote_id') {
|
|
|
|
|
//为数据权限添加
|
|
|
|
|
$promoteIds = getPowerPromoteIds();
|
|
|
|
|
if (empty($promoteIds)) {
|
|
|
|
|
$map[$column] = -1;//没权限时将promote_id置为-1
|
|
|
|
|
} elseif ($promoteIds != 'all') {
|
|
|
|
|
if (isset($map[$column])) {
|
|
|
|
|
if (isset($map['_string'])) {//查询字段中已存在promote_id,不覆盖此条件而处理
|
|
|
|
|
$map['_string'] .= " and $column in($promoteIds)";
|
|
|
|
|
} else {
|
|
|
|
|
$map['_string'] = " $column in($promoteIds)";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$map[$column] = array('in', $promoteIds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_promote_listOther($select='') {
|
|
|
|
|
|
|
|
|
|
// $promoteRoot = getPowerPromoteIds();
|
|
|
|
|
// if ($promoteRoot) {
|
|
|
|
|
// $map['id'] =array('in',$promoteRoot);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
setPowerPromoteIds($map,'id');
|
|
|
|
|
|
|
|
|
|
$list = M("Promote","tab_")->field('id,account,balance_coin')->where($map)->select();//where("status=1")->
|
|
|
|
|
if (empty($list)){return '';}
|
|
|
|
|
if($select==111){
|
|
|
|
|
$new['id']=-1;
|
|
|
|
|
$new['account']="全站用户";
|
|
|
|
|
array_unshift($list,$new);
|
|
|
|
|
}
|
|
|
|
|
return $list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 渠道列表
|
|
|
|
|
* @param $type
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
function promote_listsOther($type){
|
|
|
|
|
if($type){
|
|
|
|
|
$map['level'] = $type;
|
|
|
|
|
} else{
|
|
|
|
|
$map = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $promoteRoot = getPowerPromoteIds();
|
|
|
|
|
// if ($promoteRoot) {
|
|
|
|
|
// $map['id'] =array('in',$promoteRoot);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
setPowerPromoteIds($map,'id');
|
|
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_admin_listOther()
|
|
|
|
|
{
|
|
|
|
|
$nickname = session('user_auth')['username'];
|
|
|
|
|
$list= M("Member")->field('uid,nickname')->where("status=1 and nickname='{$nickname}'")->select();
|
|
|
|
|
if(empty($list)){return false;}
|
|
|
|
|
return $list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据会长id底下的推广员id
|
|
|
|
|
* @param $promote_id
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
function getOffspringByPromoteId($promote_id = null) {
|
|
|
|
|
if (isset($promote_id)) {
|
|
|
|
|
if ($promote_id ==0) {//官方渠道
|
|
|
|
|
$promote_ids = '0';
|
|
|
|
|
} else {
|
|
|
|
|
$where['chain'] = ['like', "%/{$promote_id}/%"];
|
|
|
|
|
$where['id'] = $promote_id;//会长本身
|
|
|
|
|
$where['_logic'] = 'or';
|
|
|
|
|
$map['_complex'] = $where;
|
|
|
|
|
$promote_ids = M('promote', 'tab_')
|
|
|
|
|
->where($map)
|
|
|
|
|
->field('group_concat(id) as promote_ids')
|
|
|
|
|
->find();
|
|
|
|
|
$promote_ids = $promote_ids['promote_ids'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$promote_ids = getPowerPromoteIds();
|
|
|
|
|
}
|
|
|
|
|
return $promote_ids;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* csv 导出函数
|
|
|
|
|
* @param [array] $data 一般为数据库查询结果集
|
|
|
|
|
* @param [string] $title 表格名称
|
|
|
|
|
* @param [array] $fields [字段=>首行名称,...]例如:['name'=>'名称']
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
function data2csv(&$data,$title,$fields){
|
|
|
|
|
set_time_limit(0);
|
|
|
|
|
ini_set('memory_limit', '-1'); //设置内存不受限制
|
|
|
|
|
$csvFileName = $title.'.csv';
|
|
|
|
|
//设置好告诉浏览器要下载excel文件的headers
|
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
|
header('Content-Type: application/vnd.ms-excel;charset=utf-8');
|
|
|
|
|
header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
|
|
|
|
|
header('Expires: 0');
|
|
|
|
|
header('Cache-Control: must-revalidate');
|
|
|
|
|
header('Pragma: public');
|
|
|
|
|
$fp = fopen('php://output', 'a');//打开output流
|
|
|
|
|
fwrite($fp, chr(0xEF).chr(0xBB).chr(0xBF));//转码,防止乱码
|
|
|
|
|
$field = array_keys($fields);
|
|
|
|
|
//生成首行
|
|
|
|
|
$header = array_values($fields);
|
|
|
|
|
fputcsv($fp, $header);
|
|
|
|
|
|
|
|
|
|
$index = 0;
|
|
|
|
|
foreach ($data as $row) {
|
|
|
|
|
$a = [];
|
|
|
|
|
foreach($field as $k=>$v){
|
|
|
|
|
// $a[$v] = $row[$v] . "\t";//防止格式错误
|
|
|
|
|
$a[$v] = $row[$v];
|
|
|
|
|
}
|
|
|
|
|
if ($index == 10000) { //每次写入1000条数据清除内存
|
|
|
|
|
$index = 0;
|
|
|
|
|
ob_flush();//清除内存
|
|
|
|
|
flush();
|
|
|
|
|
}
|
|
|
|
|
$index++;
|
|
|
|
|
fputcsv($fp, $a);
|
|
|
|
|
}
|
|
|
|
|
ob_flush();
|
|
|
|
|
fclose($fp); //每生成一个文件关闭
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//所有支付方式
|
|
|
|
|
function all_pay_way_other($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[7]=array('key'=>7,'value'=>'金猪');
|
|
|
|
|
$pay_way[9]=array('key'=>9,'value'=>"双乾支付-支付宝");
|
|
|
|
|
$pay_way[10]=array('key'=>10,'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[15]=array('key'=>15,'value'=>'双乾支付-快捷');
|
|
|
|
|
return $pay_way;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getMonthOther() {
|
|
|
|
|
$start = date("Y-m", strtotime("now"));
|
|
|
|
|
//开始月份
|
|
|
|
|
$range = [];
|
|
|
|
|
$i = 0;
|
|
|
|
|
do {
|
|
|
|
|
$month = date('Y-m', strtotime($start . ' - ' . $i . ' month'));
|
|
|
|
|
$range[] = $month;
|
|
|
|
|
$i++;
|
|
|
|
|
} while ($i<36);
|
|
|
|
|
|
|
|
|
|
return $range;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取当前管理员id
|
|
|
|
|
function getAdmin($column = 'uid') {
|
|
|
|
|
return session("user_auth")[$column];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取所有有关的公司
|
|
|
|
|
|
|
|
|
|
function getCompanyList() {
|
|
|
|
|
|
|
|
|
|
$sql = "select id,company_name,1 as company_type from tab_promote_company UNION ALL select id,partner,0 as company_type from tab_partner";
|
|
|
|
|
|
|
|
|
|
$data = M()->table("({$sql}) as a")->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//上游cp对账单导出
|
|
|
|
|
function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money) {
|
|
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
ini_set('display_errors', TRUE);
|
|
|
|
|
ini_set('display_startup_errors', TRUE);
|
|
|
|
|
|
|
|
|
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
|
|
|
|
|
|
|
|
|
date_default_timezone_set('Europe/London');
|
|
|
|
|
Vendor("PHPExcel.PHPExcel");
|
|
|
|
|
$objReader = \PHPExcel_IOFactory::createReader('Excel5');
|
|
|
|
|
|
|
|
|
|
//设置模板文件
|
|
|
|
|
$objPHPExcel = $objReader->load("Public/Admin/excel/up_stream.xls");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//增加甲方信息
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D2', $data['first_party_info']['partner']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D3', $data['first_party_info']['link_man']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D4', $data['first_party_info']['link_phone']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D5', $data['first_party_info']['address']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D6', $data['first_party_info']['company_tax_no']);
|
|
|
|
|
|
|
|
|
|
//增加乙方信息
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('J2', $data['second_party_info']['partner']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('J3', $data['second_party_info']['link_man']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('J4', $data['second_party_info']['link_phone']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('J5', $data['second_party_info']['address']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('J6', $data['second_party_info']['company_tax_no']);
|
|
|
|
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D7', $data['receive_company']['partner']); //增加支付给对应公司
|
|
|
|
|
$line = 10;
|
|
|
|
|
//增加结算记录
|
|
|
|
|
foreach ($data['statement_info'] as $key => $value) {
|
|
|
|
|
$objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1)->mergeCells("J$line:K$line");
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['statement_begin_time'] . '-' . $value['statement_end_time']);
|
|
|
|
|
if ($value['statement_type'] > 0) {//罚款
|
|
|
|
|
$product_name = $value['type_name'];
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('F'.$line , '-');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('G'.$line, '-');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('H'.$line, '-');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('I'.$line, '-');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['sum_money']);
|
|
|
|
|
} else {//游戏
|
|
|
|
|
$product_name = $value['game_name'];
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('F'.$line , $value['first_ratio'] . '%');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('G'.$line, $value['second_ratio'] . '%');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('H'.$line, $value['promote_ratio'] . '%');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('I'.$line, $value['fax_ratio']. '%');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['pay_amount']);
|
|
|
|
|
}
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $product_name);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']);
|
|
|
|
|
$line++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//合计
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("E" . ($line), $data['pay_amount']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), $data['statement_money']);
|
|
|
|
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), $big_all_sum_money); //本月分成总金额(人民币大写)
|
|
|
|
|
|
|
|
|
|
//收款方
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("D" . ($line+2), $data['receive_company']['partner']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("D" . ($line+3), $data['receive_company']['bank_account']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("D" . ($line+4), $data['receive_company']['opening_bank']);
|
|
|
|
|
|
|
|
|
|
//付款方
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+2), $data['pay_company']['partner']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+3), $data['pay_company']['bank_account']);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+4), $data['pay_company']['opening_bank']);
|
|
|
|
|
|
|
|
|
|
$statement_begin_time = date('Y.m.d', $data['statement_begin_time']);//对账开始时间
|
|
|
|
|
$statement_end_time = date('Y.m.d',$data['statement_end_time']);//对账截止时间
|
|
|
|
|
|
|
|
|
|
$fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$statement_begin_time}-{$statement_end_time}";
|
|
|
|
|
|
|
|
|
|
ob_end_clean();//清除缓冲区,避免乱码
|
|
|
|
|
header('pragma:public');
|
|
|
|
|
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
|
|
|
|
|
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
|
|
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
|
|
$objWriter->save('php://output');
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//下游工会对账单导出
|
|
|
|
|
function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money) {
|
|
|
|
|
|
|
|
|
|
header("Content-type: text/html; charset=utf-8");
|
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
ini_set('display_errors', TRUE);
|
|
|
|
|
ini_set('display_startup_errors', TRUE);
|
|
|
|
|
|
|
|
|
|
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
|
|
|
|
|
|
|
|
|
|
date_default_timezone_set('Europe/London');
|
|
|
|
|
Vendor("PHPExcel.PHPExcel");
|
|
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
|
|
|
$objReader = \PHPExcel_IOFactory::createReader('Excel5');
|
|
|
|
|
|
|
|
|
|
//设置模板文件
|
|
|
|
|
$objPHPExcel = $objReader->load("Public/Admin/excel/down_stream.xls");
|
|
|
|
|
|
|
|
|
|
$statement_begin_time = date('Y.m.d', $data['statement_begin_time']);//对账开始时间
|
|
|
|
|
$statement_end_time = date('Y.m.d',$data['statement_end_time']);//对账截止时间
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['company_name']} 》结算单
|
|
|
|
|
({$statement_begin_time}-{$statement_end_time}");
|
|
|
|
|
|
|
|
|
|
if ($data['second_party_info']['settlement_type'] == '补点订单') {
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D2' , '补点比例');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$line = 3;
|
|
|
|
|
|
|
|
|
|
foreach ($data['statement_info'] as $key => $value) {
|
|
|
|
|
$objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->removeConditionalStyles();
|
|
|
|
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $value['statement_begin_time'] . '-' . $value['statement_end_time']);
|
|
|
|
|
if ($value['statement_type']>0) {//罚款
|
|
|
|
|
$product_name = $value['type_name'];
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D'.$line, '-');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.$line, '-');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['sum_money']);
|
|
|
|
|
} else {//游戏
|
|
|
|
|
$product_name = $value['game_name'];
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['second_ratio'] . '%');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['fax_ratio'] . '%');
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['pay_amount']);
|
|
|
|
|
}
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.$line, $product_name);
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']);
|
|
|
|
|
$line++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('C'.($line), $data['pay_amount']);//合计-平台总额
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('F'.($line), $data['statement_money']);//合计-结算金额
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额
|
|
|
|
|
//甲方信息
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['first_party_info']['jfCompany']);//甲方
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['first_party_info']['jfPerson']);//联系人
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+5), $data['first_party_info']['jfTel']);//联系电话
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['second_party_info']['invoice_item']);//开票项目
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['second_party_info']['invoice_type']);//发票类型
|
|
|
|
|
|
|
|
|
|
//乙方信息
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+3), $data['second_party_info']['partner']);//乙方
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+4), $data['second_party_info']['link_man']);//联系人
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+5), $data['second_party_info']['link_phone']);//联系电话
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+6), $data['second_party_info']['address']);//邮寄地址
|
|
|
|
|
// $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $value['pay_amount']);//请汇入此账号
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['second_party_info']['bank_account_name']);//户名
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['second_party_info']['bank_account']);//银行账号
|
|
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['second_party_info']['opening_bank']);//开户行
|
|
|
|
|
|
|
|
|
|
$fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['jfCompany']}-对账单{$statement_begin_time}-{$statement_end_time}";
|
|
|
|
|
// dd($fileName);
|
|
|
|
|
ob_end_clean();//清除缓冲区,避免乱码
|
|
|
|
|
header('pragma:public');
|
|
|
|
|
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
|
|
|
|
|
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
|
|
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
|
|
$objWriter->save('php://output');
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getWithdrawNumber() {
|
|
|
|
|
|
|
|
|
|
$map = [];
|
|
|
|
|
|
|
|
|
|
$map['ext_field'] = ['neq',null];
|
|
|
|
|
|
|
|
|
|
$data = M('withdraw',"tab_")
|
|
|
|
|
->field("widthdraw_number")
|
|
|
|
|
->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field")
|
|
|
|
|
->where("ext_field is null")
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//上有流水计算
|
|
|
|
|
function caculateUpstream($game_id,$pay_amount) {
|
|
|
|
|
|
|
|
|
|
$ladderData = M('cp_game_ratio','tab_')
|
|
|
|
|
->where(['game_id'=>$game_id,'begin_total_amount'=>['elt',$pay_amount],'is_del'=>0])
|
|
|
|
|
->limit(0,2)
|
|
|
|
|
->order('begin_total_amount desc')
|
|
|
|
|
->select();
|
|
|
|
|
|
|
|
|
|
foreach($ladderData as $key => $value) {
|
|
|
|
|
|
|
|
|
|
if ($value['instanceof'] == 1 && $value['begin_total_amount'] <= $pay_amount
|
|
|
|
|
|| $value['instanceof'] == 2 && $value['begin_total_amount'] != $pay_amount ) {
|
|
|
|
|
$data['ratio'] = $value['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
$data['ratio'] = $value['ratio'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return number_format($pay_amount*($data['ratio']/100),2,'.','');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取所有有关的公司
|
|
|
|
|
|
|
|
|
|
function getPromoteCompanyList() {
|
|
|
|
|
|
|
|
|
|
$sql = "select id,company_name,1 as company_type from tab_promote_company";
|
|
|
|
|
|
|
|
|
|
$data = M()->table("({$sql}) as a")->select();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//获取游戏cp分成比例 $type=false时返回最低分成比例
|
|
|
|
|
function getGameCpRadio($game_id,$amount,$type) {
|
|
|
|
|
if (!$type) {
|
|
|
|
|
$data = M('cp_game_ratio','tab_')->where(['game_id'=>$game_id])->order('begin_total_amount asc')->find();
|
|
|
|
|
} else {
|
|
|
|
|
//取两条
|
|
|
|
|
$ladderData = M('cp_game_ratio','tab_')->where(['game_id'=>$game_id,'begin_total_amount'=>['elt',$amount]])->limit(0,2)->order('begin_total_amount desc')->select();
|
|
|
|
|
|
|
|
|
|
// dump($ladderData);die();
|
|
|
|
|
|
|
|
|
|
foreach($ladderData as $key => $value) {
|
|
|
|
|
|
|
|
|
|
if ($value['instanceof'] == 1 && $value['begin_total_amount'] <= $amount
|
|
|
|
|
|| $value['instanceof'] == 2 && $value['begin_total_amount'] != $amount ) {
|
|
|
|
|
$data['ratio'] = $value['ratio'];
|
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
$data['ratio'] = $value['ratio'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data['ratio']?$data['ratio']:0;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|