@ -110,11 +110,7 @@ class FinancePromoteController extends AdminController
"inside_cash_count"=>0,
);
foreach($senddata as $k=>$v){
if ($v['company_belong']==1) {
$v['company_belong']='外团';
} else {
$v['company_belong']='内团';
}
$v['company_belong'] = getCompanyBlong($v['company_belong']);
if(empty($v['company_name'])) $v['company_name']= $this->COMPANY_NAME;
if(empty($v['p_id'])) $v['p_id']= "0";
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
@ -209,7 +205,7 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count,
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_id,0) company_id,company_name,promote.company_belong";
IFNULL(company_id,0) company_id,company_name,IFNULL( promote.company_belong,0) company_belong";
return M()
->table("tab_spend s")
->field($field)
@ -226,7 +222,7 @@ class FinancePromoteController extends AdminController
$map['s.source_id']=0;
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,IFNULL(if(substring_index(substring_index(`chain`,'/',2),'/',-1)='',
s.promote_id,substring_index(substring_index(`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_id,0) company_id,company_name,promote.company_belong";
IFNULL(company_id,0) company_id,company_name,IFNULL( promote.company_belong,0) company_belong";
return M("promote_coin s","tab_")
->field($field)
->where($map)
@ -308,7 +304,7 @@ class FinancePromoteController extends AdminController
);
foreach($senddata as $k=>$v){
$v['company_belong']?$v['company_belong']='外团':$v['company_belong']='内团' ;
$v['company_belong'] = getCompanyBlong($v['company_belong']) ;
if(empty($v['company_name'])) $v['company_name']= $this->COMPANY_NAME;
if(empty($v['promote_account'])) $v['promote_account']= "官方渠道";
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
@ -363,7 +359,7 @@ class FinancePromoteController extends AdminController
$field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,promote.company_belong";
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL( promote.company_belong,0) company_belong";
return M()
->table("tab_spend s")
->field($field)
@ -379,7 +375,7 @@ class FinancePromoteController extends AdminController
$map['s.status']=1;
$map['s.source_id']=0;
$field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,promote.company_belong";
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account,IFNULL( promote.company_belong,0) company_belong";
return M("promote_coin s","tab_")
->field($field)
->where($map)
@ -414,7 +410,8 @@ class FinancePromoteController extends AdminController
//获取推广员
$title = '';
self::setPromoteMap($map,"s.promote_id",$title);
self::setPromoteMap($map,"s.promote_id",$title,false);
// dd($map);
$title .= "游戏统计";
$this->assign('title', $title);
@ -430,14 +427,14 @@ class FinancePromoteController extends AdminController
$value['balance_coin_count']?:0;
$value['inside_cash_count']?:0;
$value['all_cash_count'] = $value['cash_count'] + $value['balance_coin_count'] + $value['inside_cash_count'];
if(!$value['partner_name']) $value['partner_name'] = "无" ;
$value['company_belong'] =getCompanyBlong($value['company_belong']) ;
if(!$value['game_name']) $value['game_name'] = "无";
}
if (isset($_REQUEST['export'])) {
data2csv($data,$title, array(
"company_name"=>"推广公司",
"account"=>"会长账号",
"partner_name"=>"合作公司 ",
"company_belong"=>"团体类型 ",
"game_name"=>"游戏",
"cash_count"=>"游戏现金金额",
"balance_coin_count"=>"平台币直充支出",
@ -590,7 +587,7 @@ class FinancePromoteController extends AdminController
SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as inside_cash_count,
IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,
IFNULL(company_name,'{$this->COMPANY_NAME}') company_name")
IFNULL(company_name,'{$this->COMPANY_NAME}') company_name,IFNULL(promote.company_belong,0) company_belong ")
->join('LEFT JOIN tab_game as g ON s.game_id=g.id')
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left")
@ -877,7 +874,7 @@ class FinancePromoteController extends AdminController
$this->display();
}
private function setPromoteMap(& $map,$field,& $title)
private function setPromoteMap(& $map,$field,& $title,$ptype = true )
{
//公司判断
$pmap = false; //非特意推广员检索
@ -895,23 +892,24 @@ class FinancePromoteController extends AdminController
}
if (isset($_REQUEST['company_belong'])) {
$pmap['company_belong'] = $_REQUEST['company_belong'];
if($_REQUEST['company_belong'] == 0){
$title .= "内团-";
}else{
$gfflg = false;
$title .= "外团-";
}
$title .= (getCompanyBlong($_REQUEST['company_belong'])."-");
}
if (isset($_REQUEST['promote_id'])) {
$pmap = false; //取消非特异推广员检索
if($ptype){
$pmap = false;//取消非特异推广员检索
}else{
$pmap['id'] = $_REQUEST['promote_id'];
}
$title .= (get_promote_name($_REQUEST['promote_id'])."-");
if ($_REQUEST['promote_id'] != 0){
$gfflg = false;
}
}
if($pmap){
$promoter_ids = D("Promote")->where($pmap)->field('id')->select();
if ($promoter_ids) {
if($gfflg){
$t_in = "0,".implode(',', array_column($promoter_ids, 'id'));
@ -923,22 +921,30 @@ class FinancePromoteController extends AdminController
$map[$field] = ['in',"-1"];
}
}
//判断是否有推广员
$level = 1;
if ($_REQUEST['promote_id'] != '') {
if ($_REQUEST['promote_id'] != 0){
$level = M('promote', 'tab_')->field('level')->where(array('id' => $_REQUEST['promote_id']))->find()['level'];
}
if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) {
$map[$field] = $_REQUEST['promote_id'];
} else {
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
if ($promoter_ids) {
$map[$field] = ['in', implode(',', array_column($promoter_ids, 'id'))];
// if($ptype){
//判断是否有推广员
$level = 1;
if ($_REQUEST['promote_id'] != '') {
if ($_REQUEST['promote_id'] != 0){
$level = M('promote', 'tab_')->field('level')->where(array('id' => $_REQUEST['promote_id']))->find()['level'];
}
if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) {
$map[$field] = $_REQUEST['promote_id'];
} else {
if ($ptype) {
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
}else{
unset($pmap['id']);
$promoter_ids = D("Promote")->where($pmap)->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
}
if ($promoter_ids) {
$map[$field] = ['in', implode(',', array_column($promoter_ids, 'id'))];
}
}
}
}
$_POST['promote_level'] = $level;
$_POST['promote_level'] = $level;
// }
}
}