@ -45,6 +45,7 @@ class FinancePromoteController extends AdminController
$senddata[$v['p_id']] = $v;
$senddata[$v['p_id']] = $v;
}
}
// dump($cash);die();
//内冲
//内冲
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){
foreach($inside as $k=>$v){
@ -103,9 +104,13 @@ class FinancePromoteController extends AdminController
"bind_coin_count"=>0,
"bind_coin_count"=>0,
"inside_cash_count"=>0,
"inside_cash_count"=>0,
);
);
// dump($senddata);die();
foreach($senddata as $k=>$v){
foreach($senddata as $k=>$v){
if ($v['company_belong']==1) {
$v['company_belong']?$v['company_belong']='外团':$v['company_belong']='内团';
$v['company_belong']='外团';
} else {
$v['company_belong']='内团';
}
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(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;
@ -142,10 +147,10 @@ class FinancePromoteController extends AdminController
$outBelong = 0;
$outBelong = 0;
$insideBelong = 0;
$insideBelong = 0;
// dump($data);die();
foreach ($data as $key => $value) {
foreach ($data as $key => $value) {
if ($value['company_belong']) {
if ($value['company_belong']=='外团' ) {
$outBelong+=$value['allcount'];
$outBelong+=$value['allcount'];
} else {
} else {
$insideBelong+=$value['allcount'];
$insideBelong+=$value['allcount'];
@ -154,9 +159,9 @@ class FinancePromoteController extends AdminController
}
}
//外团占比
//外团占比
$this->assign('outBelong',$outBelong/$count['all_count']*100);
$this->assign('outBelong',number_format( $outBelong/$count['all_count']*100,2,'.','') );
//内团占比
//内团占比
$this->assign('insideBelong',$insideBelong/$count['all_count']*100);
$this->assign('insideBelong',number_format( $insideBelong/$count['all_count']*100,2,'.','') );
$size = $row;
$size = $row;
$data = array_slice($data, ($arraypage - 1) * $size, $size);
$data = array_slice($data, ($arraypage - 1) * $size, $size);
@ -196,7 +201,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 = 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,
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(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,company_belong";
return M()
return M()
->table("tab_spend s")
->table("tab_spend s")
->field($field)
->field($field)
@ -213,7 +218,7 @@ class FinancePromoteController extends AdminController
$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)='',
$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,
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,company_belong";
return M("promote_coin s","tab_")
return M("promote_coin s","tab_")
->field($field)
->field($field)
->where($map)
->where($map)
@ -363,7 +368,7 @@ class FinancePromoteController extends AdminController
$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,
SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_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,company_belong";
return M()
return M()
->table("tab_spend s")
->table("tab_spend s")
->field($field)
->field($field)
@ -379,7 +384,7 @@ 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,
$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,company_belong";
return M("promote_coin s","tab_")
return M("promote_coin s","tab_")
->field($field)
->field($field)
->where($map)
->where($map)