@ -41,10 +41,10 @@ class FinancePromoteController extends AdminController
$senddata = [];
$senddata = [];
//获取各会长的充值方式
//获取各会长的充值方式
$cash = self::getJoinPromoteData([],$istimeselect);
$cash = self::getJoinPromoteData([],$istimeselect);
foreach($cash as $k=>$v){
foreach($cash as $k=>$v){
$senddata[$v['p_id']] = $v;
$senddata[$v['p_id']] = $v;
}
}
//内冲
//内冲
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){
foreach($inside as $k=>$v){
@ -58,6 +58,30 @@ class FinancePromoteController extends AdminController
};
};
}
}
//官方渠道单算
//判断公司
$gfidlag = true;
$gfgs = true;
if (isset($_REQUEST['company_id'])) {
if($_REQUEST['company_id']!=0){
$gfgs = false;
}
}
if (isset($_REQUEST['promote_id'])) {
if($_REQUEST['promote_id'] == 0){
$gfidlag = true;
}else{
$gfidlag =false;
}
}
if($gfidlag & & $gfgs){
//计算官方渠道
unset($_REQUEST['company_id']);
$_REQUEST['promote_id'] = 0;
$gfcash = self::getJoinPromoteData([],$istimeselect);
$senddata[0] = $gfcash[0];
}
if(!empty($senddata)){
if(!empty($senddata)){
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
if (empty($_REQUEST['company_id'])) {
if (empty($_REQUEST['company_id'])) {
@ -72,7 +96,6 @@ class FinancePromoteController extends AdminController
}
}
}
}
}
}
$data = [];
$data = [];
$count =array(
$count =array(
"cash_count"=>0,
"cash_count"=>0,
@ -83,6 +106,7 @@ class FinancePromoteController extends AdminController
foreach($senddata as $k=>$v){
foreach($senddata as $k=>$v){
if(empty($v['company_name'])) $v['company_name']= "万盟天下科技";
if(empty($v['company_name'])) $v['company_name']= "万盟天下科技";
if(empty($v['p_id'])) $v['p_id']= "0";
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
if(!array_key_exists('cash_count',$v)) $v['cash_count']=0;
if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0;
if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0;
if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0;
if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0;
@ -116,7 +140,6 @@ class FinancePromoteController extends AdminController
$size = $row;
$size = $row;
$data = array_slice($data, ($arraypage - 1) * $size, $size);
$data = array_slice($data, ($arraypage - 1) * $size, $size);
$this->assign('list_data', $data);
$this->assign('list_data', $data);
$this->assign('all_count', $count);
$this->assign('all_count', $count);
$this->meta_title = '公会统计';
$this->meta_title = '公会统计';
@ -126,7 +149,7 @@ class FinancePromoteController extends AdminController
private function getJoinPromoteData($map,$istimeselect,$type="spend")
private function getJoinPromoteData($map,$istimeselect,$type="spend")
{
{
// setPowerPromoteIds($map,"s.promote_id");
// setPowerPromoteIds($map,"s.promote_id");
if ($_REQUEST['promote_id'] != '' ) {
if (isset($_REQUEST['promote_id']) ) {
if ($_REQUEST['promote_id'] == 0) {
if ($_REQUEST['promote_id'] == 0) {
$map['s.promote_id'] = 0;
$map['s.promote_id'] = 0;
} else {
} else {
@ -138,7 +161,9 @@ class FinancePromoteController extends AdminController
}
}
if (isset($_REQUEST['company_id'])) {
if (isset($_REQUEST['company_id'])) {
$map['promote.company_id'] = $_REQUEST['company_id'];
$map['promote.company_id'] = $_REQUEST['company_id'];
}
}
if($type == "spend"){
if($type == "spend"){
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
$map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
@ -146,7 +171,6 @@ class FinancePromoteController extends AdminController
if($istimeselect){
if($istimeselect){
$map['s.pay_time']=$istimeselect;
$map['s.pay_time']=$istimeselect;
}
}
$map['s.pay_status']=1;
$map['s.pay_status']=1;
$field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
$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 = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
@ -167,11 +191,14 @@ class FinancePromoteController extends AdminController
}
}
$map['s.status']=1;
$map['s.status']=1;
$map['s.source_id']=0;
$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";
$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";
return M("promote_coin s","tab_")
return M("promote_coin s","tab_")
->field($field)
->field($field)
->where($map)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id","left")
->group('p_id')
->group('p_id')
->select();
->select();
}
}
@ -208,13 +235,14 @@ class FinancePromoteController extends AdminController
$inside = self::promoteUserData([],$istimeselect,"promote_coin");
$inside = self::promoteUserData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){
foreach($inside as $k=>$v){
if(array_key_exists($v['promote_id'],$senddata)){
if(array_key_exists($v['promote_id'],$senddata)){
$senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount'];
$senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount'] ;
}else{
}else{
$v['inside_cash_count'] = $v['pay_amount'];
$v['inside_cash_count'] = $v['pay_amount']-$v['back_amount'] ;
unset($v['pay_amount']);
unset($v['pay_amount']);
$senddata[$v['promote_id']] = $v;
$senddata[$v['promote_id']] = $v;
};
};
}
}
if(!empty($senddata)){
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){
$pmap['status']=1;
$pmap['status']=1;
if($istimeselect){
if($istimeselect){
@ -226,6 +254,7 @@ class FinancePromoteController extends AdminController
}
}
}
}
}
$count = count($senddata);
$count = count($senddata);
if ($_REQUEST['data_order'] != '') {
if ($_REQUEST['data_order'] != '') {
$data_order = reset(explode(',', $_REQUEST['data_order']));
$data_order = reset(explode(',', $_REQUEST['data_order']));
@ -325,12 +354,13 @@ class FinancePromoteController extends AdminController
}
}
$map['s.status']=1;
$map['s.status']=1;
$map['s.source_id']=0;
$map['s.source_id']=0;
$map['s.type']=1;
$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,
$field= "sum(num) pay_amount,promote_id ";
IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account ";
return M("promote_coin s","tab_")
return M("promote_coin s","tab_")
->field($field)
->field($field)
->where($map)
->where($map)
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote promote ON s.promote_id = promote.id","left")
->join("tab_promote_company company ON promote.company_id = company.id", "left")
->group('promote_id')
->group('promote_id')
->select();
->select();
}
}