|
|
|
@ -30,35 +30,11 @@ class FinancePromoteController extends AdminController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$senddata = [];
|
|
|
|
|
//获取各会长的现金充值
|
|
|
|
|
$cash = self::getJoinPromoteData(array("pay_way"=>array("GT",0)),$istimeselect);
|
|
|
|
|
//获取各会长的充值方式
|
|
|
|
|
$cash = self::getJoinPromoteData([],$istimeselect);
|
|
|
|
|
foreach($cash as $k=>$v){
|
|
|
|
|
$v['cash_count'] = $v['pay_amount'];
|
|
|
|
|
unset($v['pay_amount']);
|
|
|
|
|
$senddata[$v['p_id']] = $v;
|
|
|
|
|
}
|
|
|
|
|
//平台币直充支出
|
|
|
|
|
$balance = self::getJoinPromoteData(array("pay_way"=>array("EQ",0)),$istimeselect);
|
|
|
|
|
foreach($balance as $k=>$v){
|
|
|
|
|
if(array_key_exists($v['p_id'],$senddata)){
|
|
|
|
|
$senddata[$v['p_id']]['balance_coin_count']= $v['pay_amount'];
|
|
|
|
|
}else{
|
|
|
|
|
$v['balance_coin_count'] = $v['pay_amount'];
|
|
|
|
|
unset($v['pay_amount']);
|
|
|
|
|
$senddata[$v['p_id']] = $v;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//平台币内充
|
|
|
|
|
$bind = self::getJoinPromoteData(array("pay_way"=>array("LT",0)),$istimeselect);
|
|
|
|
|
foreach($bind as $k=>$v){
|
|
|
|
|
if(array_key_exists($v['p_id'],$senddata)){
|
|
|
|
|
$senddata[$v['p_id']]['bind_coin_count']= $v['pay_amount'];
|
|
|
|
|
}else{
|
|
|
|
|
$v['bind_coin_count'] = $v['pay_amount'];
|
|
|
|
|
unset($v['pay_amount']);
|
|
|
|
|
$senddata[$v['p_id']] = $v;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//内冲
|
|
|
|
|
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
|
|
|
|
|
foreach($inside as $k=>$v){
|
|
|
|
@ -133,7 +109,11 @@ class FinancePromoteController extends AdminController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map['s.pay_status']=1;
|
|
|
|
|
$field= "sum(pay_amount) pay_amount,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";
|
|
|
|
|
$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(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";
|
|
|
|
|
return M()
|
|
|
|
|
->table("tab_spend s")
|
|
|
|
|
->field($field)
|
|
|
|
@ -182,34 +162,10 @@ class FinancePromoteController extends AdminController
|
|
|
|
|
}
|
|
|
|
|
$senddata = [];
|
|
|
|
|
//获取各会长的现金充值
|
|
|
|
|
$cash = self::promoteUserData(array("pay_way"=>array("GT",0)),$istimeselect);
|
|
|
|
|
$cash = self::promoteUserData([],$istimeselect);
|
|
|
|
|
foreach($cash as $k=>$v){
|
|
|
|
|
$v['cash_count'] = $v['pay_amount'];
|
|
|
|
|
unset($v['pay_amount']);
|
|
|
|
|
$senddata[$v['promote_id']] = $v;
|
|
|
|
|
}
|
|
|
|
|
//平台币直充支出
|
|
|
|
|
$balance = self::promoteUserData(array("pay_way"=>array("EQ",0)),$istimeselect);
|
|
|
|
|
foreach($balance as $k=>$v){
|
|
|
|
|
if(array_key_exists($v['promote_id'],$senddata)){
|
|
|
|
|
$senddata[$v['promote_id']]['balance_coin_count']= $v['pay_amount'];
|
|
|
|
|
}else{
|
|
|
|
|
$v['balance_coin_count'] = $v['pay_amount'];
|
|
|
|
|
unset($v['pay_amount']);
|
|
|
|
|
$senddata[$v['promote_id']] = $v;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
//平台币内充
|
|
|
|
|
$bind = self::promoteUserData(array("pay_way"=>array("LT",0)),$istimeselect);
|
|
|
|
|
foreach($bind as $k=>$v){
|
|
|
|
|
if(array_key_exists($v['promote_id'],$senddata)){
|
|
|
|
|
$senddata[$v['promote_id']]['bind_coin_count']= $v['pay_amount'];
|
|
|
|
|
}else{
|
|
|
|
|
$v['bind_coin_count'] = $v['pay_amount'];
|
|
|
|
|
unset($v['pay_amount']);
|
|
|
|
|
$senddata[$v['promote_id']] = $v;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
$inside = self::promoteUserData([],$istimeselect,"promote_coin");
|
|
|
|
|
foreach($inside as $k=>$v){
|
|
|
|
|
if(array_key_exists($v['promote_id'],$senddata)){
|
|
|
|
@ -295,7 +251,10 @@ class FinancePromoteController extends AdminController
|
|
|
|
|
$map['s.pay_time']=$istimeselect;
|
|
|
|
|
}
|
|
|
|
|
$map['s.pay_status']=1;
|
|
|
|
|
$field= "sum(pay_amount) pay_amount,IFNULL(company_id,0) company_id,company_name,promote_id";
|
|
|
|
|
$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";
|
|
|
|
|
return M()
|
|
|
|
|
->table("tab_spend s")
|
|
|
|
|
->field($field)
|
|
|
|
@ -669,6 +628,17 @@ class FinancePromoteController extends AdminController
|
|
|
|
|
}
|
|
|
|
|
$map['s.promote_id'] = $_REQUEST['promote_id'];
|
|
|
|
|
}
|
|
|
|
|
//检索
|
|
|
|
|
if (isset($_REQUEST['sn'])) {
|
|
|
|
|
$pmap['order_number'] = array("LIKE","%".$_REQUEST['sn']."%");
|
|
|
|
|
$map['sn'] = array("LIKE","%".$_REQUEST['sn']."%");
|
|
|
|
|
}
|
|
|
|
|
if (isset($_REQUEST['type'])) {
|
|
|
|
|
if($_REQUEST['type'] == 2){
|
|
|
|
|
$pmap['op_id'] =0;//肯定false
|
|
|
|
|
}
|
|
|
|
|
$map['s.type'] =$_REQUEST['type'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
$senddata = [];
|
|
|
|
@ -679,47 +649,72 @@ class FinancePromoteController extends AdminController
|
|
|
|
|
if($istimeselect){
|
|
|
|
|
$pmap['create_time'] = $istimeselect;
|
|
|
|
|
}
|
|
|
|
|
$admininside = M("provide_user p","tab_")
|
|
|
|
|
->field("order_number,user_account,amount,balance")
|
|
|
|
|
->join("left join tab_user as u on u.id = p.user_id")
|
|
|
|
|
->page($page, $row)
|
|
|
|
|
->where($pmap)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($admininside as $k => $v) {
|
|
|
|
|
$temp = [
|
|
|
|
|
"sn"=>$v['order_number'],
|
|
|
|
|
"op_type"=>"收入",
|
|
|
|
|
"op_sty"=>"后台发放玩家",
|
|
|
|
|
""
|
|
|
|
|
];
|
|
|
|
|
# code...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$admincount = M("provide_user p","tab_")->field("sum(amount) amount,count(*) count")->where($pmap)->find();
|
|
|
|
|
$count = $admincount["count"]?:0;
|
|
|
|
|
$total_cost = $admincount["amount"]?:0;
|
|
|
|
|
if($count >0){
|
|
|
|
|
$admininside = M("provide_user p","tab_")
|
|
|
|
|
->field("order_number,user_account,amount,balance,create_time")
|
|
|
|
|
->join("left join tab_user as u on u.id = p.user_id")
|
|
|
|
|
->page($page, $row)
|
|
|
|
|
->where($pmap)
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($admininside as $k => $v) {
|
|
|
|
|
$temp = [
|
|
|
|
|
"sn"=>$v['order_number'],
|
|
|
|
|
"op_type"=>"收入",
|
|
|
|
|
"op_sty"=>"后台发放玩家",
|
|
|
|
|
"account"=>"管理员",
|
|
|
|
|
"op_num"=>$v['amount'],
|
|
|
|
|
"balance_coin"=>$v['balance']?:'0.00',
|
|
|
|
|
"mark"=>"后台发放平台币",
|
|
|
|
|
"create_time"=>date("Y-m-d H:i:s",$v['create_time'])
|
|
|
|
|
];
|
|
|
|
|
$senddata[] = $temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
if($istimeselect){
|
|
|
|
|
$map['s.create_time']=$istimeselect;
|
|
|
|
|
}
|
|
|
|
|
$map['s.status']=1;
|
|
|
|
|
$map['s.source_id']=0;
|
|
|
|
|
$field= "num,sn,promote.balance_coin,account,s.type";
|
|
|
|
|
$ininside = M("promote_coin s","tab_")
|
|
|
|
|
->field($field)
|
|
|
|
|
->where($map)
|
|
|
|
|
->page($page, $row)
|
|
|
|
|
->join("tab_promote promote ON s.promote_id = promote.id","left")
|
|
|
|
|
->select();
|
|
|
|
|
$ininsidecount = M("promote_coin s","tab_")
|
|
|
|
|
->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,count(*) count")
|
|
|
|
|
->where($map)
|
|
|
|
|
->find();
|
|
|
|
|
$count = $ininsidecount["count"]?:0;
|
|
|
|
|
$total_cost = ($ininsidecount["pay_amount"]-$ininsidecount["back_amount"]);
|
|
|
|
|
if ($count >0) {
|
|
|
|
|
$field= "num,sn,promote.balance_coin,account,s.type,remark,s.create_time";
|
|
|
|
|
$ininside = M("promote_coin s", "tab_")
|
|
|
|
|
->field($field)
|
|
|
|
|
->where($map)
|
|
|
|
|
->page($page, $row)
|
|
|
|
|
->join("tab_promote promote ON s.promote_id = promote.id", "left")
|
|
|
|
|
->select();
|
|
|
|
|
foreach ($ininside as $k => $v) {
|
|
|
|
|
$temp = [
|
|
|
|
|
"sn"=>$v['sn'],
|
|
|
|
|
"op_type"=>($v['type'] == 1) ? "收入":"支出",
|
|
|
|
|
"op_sty"=>($v['type'] == 1) ? "后台发放":"后台回收",
|
|
|
|
|
"account"=>"管理员",
|
|
|
|
|
"op_num"=>$v['num']?:'0.00',
|
|
|
|
|
"balance_coin"=>$v['balance_coin'],
|
|
|
|
|
"mark"=>$v["remark"]?:"后台发放平台币",
|
|
|
|
|
"create_time"=>date("Y-m-d H:i:s",$v['create_time'])
|
|
|
|
|
];
|
|
|
|
|
$senddata[] = $temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assign('total_cost', $total_cost);
|
|
|
|
|
$page = set_pagination($count,$row);
|
|
|
|
|
if($page) {$this->assign('_page', $page);}
|
|
|
|
|
$this->assign('data',$senddata);
|
|
|
|
|
$this->display();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|