diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 2d6092dec..5d9edbc81 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -176,6 +176,23 @@ class AjaxController extends ThinkController{ } $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]); } + /** + * 根据公司id获取会长 + */ + public function getPromotersByCompanyid($company_id = -1) + { + $company_id = I('company_id'); + $data = M("Promote","tab_")->field("id,account,nickname,company_id"); + if($company_id == -1){ + $data = $data->where("level = '1'")->select(); + }else{ + $data = $data->where("company_id = '{$company_id}' and level = '1'")->select(); + } + foreach ($data as &$item) { + $item['nickname'] = $item['account'] . ($item['nickname'] ? "({$item['nickname']})" : ""); + } + $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>$data]); + } public function getPromotersByLevelOther() { diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index f18459b7c..9d4a714f3 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -41,13 +41,13 @@ class FinancePromoteController extends AdminController $senddata = []; //获取各会长的充值方式 $cash = self::getJoinPromoteData([],$istimeselect); - foreach($cash as $k=>$v){ $senddata[$v['p_id']] = $v; } - //内冲 - $inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); - foreach($inside as $k=>$v){ + + //内冲 + $inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); + foreach($inside as $k=>$v){ if(array_key_exists($v['p_id'],$senddata)){ $senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount']; }else{ @@ -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(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ if (empty($_REQUEST['company_id'])) { @@ -72,7 +96,6 @@ class FinancePromoteController extends AdminController } } } - $data = []; $count =array( "cash_count"=>0, @@ -81,8 +104,9 @@ class FinancePromoteController extends AdminController "inside_cash_count"=>0, ); foreach($senddata as $k=>$v){ - + 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('balance_coin_count',$v)) $v['balance_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; $data = array_slice($data, ($arraypage - 1) * $size, $size); - $this->assign('list_data', $data); $this->assign('all_count', $count); $this->meta_title = '公会统计'; @@ -126,7 +149,7 @@ class FinancePromoteController extends AdminController private function getJoinPromoteData($map,$istimeselect,$type="spend") { // setPowerPromoteIds($map,"s.promote_id"); - if ($_REQUEST['promote_id'] != '') { + if (isset($_REQUEST['promote_id'])) { if ($_REQUEST['promote_id'] == 0) { $map['s.promote_id'] = 0; } else { @@ -138,7 +161,9 @@ class FinancePromoteController extends AdminController } if (isset($_REQUEST['company_id'])) { $map['promote.company_id'] = $_REQUEST['company_id']; + } + if($type == "spend"){ 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')) ); @@ -146,7 +171,6 @@ class FinancePromoteController extends AdminController if($istimeselect){ $map['s.pay_time']=$istimeselect; } - $map['s.pay_status']=1; $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, @@ -154,28 +178,31 @@ class FinancePromoteController extends AdminController 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) - ->where($map) - ->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') - ->select(); + ->table("tab_spend s") + ->field($field) + ->where($map) + ->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') + ->select(); }else{ if($istimeselect){ $map['s.create_time']=$istimeselect; } $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(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_") - ->field($field) - ->where($map) - ->join("tab_promote promote ON s.promote_id = promote.id","left") - ->group('p_id') - ->select(); + ->field($field) + ->where($map) + ->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') + ->select(); } - + } //渠道查看 @@ -206,25 +233,27 @@ class FinancePromoteController extends AdminController $senddata[$v['promote_id']] = $v; } $inside = self::promoteUserData([],$istimeselect,"promote_coin"); - foreach($inside as $k=>$v){ + foreach($inside as $k=>$v){ 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{ - $v['inside_cash_count'] = $v['pay_amount']; + $v['inside_cash_count'] = $v['pay_amount']-$v['back_amount']; unset($v['pay_amount']); $senddata[$v['promote_id']] = $v; }; } - if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ - $pmap['status']=1; - if($istimeselect){ - $pmap['create_time'] = $istimeselect; - } - $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); - if($admininside['amount'] >0){ - $senddata[0]['inside_cash_count']= $admininside['amount']; + if(!empty($senddata)){ + if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ + $pmap['status']=1; + if($istimeselect){ + $pmap['create_time'] = $istimeselect; + } + $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); + if($admininside['amount'] >0){ + $senddata[0]['inside_cash_count']= $admininside['amount']; + } + } - } $count = count($senddata); if ($_REQUEST['data_order'] != '') { @@ -246,7 +275,7 @@ class FinancePromoteController extends AdminController "inside_cash_count"=>0, ); foreach($senddata as $k=>$v){ - + if(empty($v['company_name'])) $v['company_name']= "万盟天下科技"; if(empty($v['promote_account'])) $v['promote_account']= "官方渠道"; if(!array_key_exists('cash_count',$v)) $v['cash_count']=0; @@ -281,7 +310,7 @@ class FinancePromoteController extends AdminController $this->meta_title = '渠道统计'; $this->display(); // dump($senddata); - + } private function promoteUserData($map,$istimeselect,$type="spend") { @@ -312,27 +341,28 @@ class FinancePromoteController extends AdminController 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"; return M() - ->table("tab_spend s") - ->field($field) - ->where($map) - ->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') - ->select(); + ->table("tab_spend s") + ->field($field) + ->where($map) + ->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') + ->select(); }else{ if($istimeselect){ $map['s.create_time']=$istimeselect; } $map['s.status']=1; $map['s.source_id']=0; - $map['s.type']=1; - $field= "sum(num) pay_amount,promote_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(company_id,0) company_id,company_name,promote_id,promote.account promote_account"; return M("promote_coin s","tab_") - ->field($field) - ->where($map) - ->join("tab_promote promote ON s.promote_id = promote.id","left") - ->group('promote_id') - ->select(); + ->field($field) + ->where($map) + ->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') + ->select(); } # code... } @@ -376,7 +406,7 @@ class FinancePromoteController extends AdminController } $this->assign('promote_level', $level); - //游戏统计列表 + //游戏统计列表 $data =self::gameStatisticsData($map, $row, $p); if(isset($_REQUEST['export'])){ $data =self::gameStatisticsData($map); @@ -429,7 +459,7 @@ class FinancePromoteController extends AdminController public function gameStatisticsDetail($p = 1) { set_time_limit(0); if(isset($_REQUEST['game_id'])){ - + //转化为名称和类型,重新请求 $game = M("game","tab_")->field("relation_game_name,sdk_version")->where(" id = {$_REQUEST['game_id']} ")->find(); if($game === false){ @@ -448,7 +478,7 @@ class FinancePromoteController extends AdminController if (!empty($_REQUEST['pay_order_number'])) { $map['pay_order_number'] = $_REQUEST['pay_order_number']; } - + if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type']) || isset($_REQUEST['partner_id'])) { $map["game_id"] = array("in",implode(',', array_column(getGameidByPartnerNameType($_REQUEST['partner_id'],$_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) ); } @@ -512,7 +542,7 @@ class FinancePromoteController extends AdminController $data = D('spend')->getSpendData($map,$field,$group,$order); }else { $data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row); - } + } foreach($data as $key => $value) { $data[$key]['pay_way'] = getPayType($value['pay_way']); } @@ -625,7 +655,7 @@ class FinancePromoteController extends AdminController } elseif (isset($_REQUEST['time_end'])) { $map['pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399]; } - + if ($_REQUEST['promote_id'] != '') { if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) { $map['tab_spend.promote_id'] = $_REQUEST['promote_id']; @@ -646,7 +676,7 @@ class FinancePromoteController extends AdminController $row = 10; } $map['pay_status'] = 1; - + if (!empty(I('user_account'))) { $map['tab_spend.user_account'] = array('like','%'.I("user_account").'%'); } @@ -670,8 +700,8 @@ class FinancePromoteController extends AdminController $data = D('spend')->getSpendData($map, $field2, $group, $order,0,0, $join); }else { $data = D('spend')->getSpendData($map, $field2, $group, $order, $page, $row, $join); - } - + } + foreach($data as $key => $value) { $data[$key]['pay_way'] = getPayType($value['pay_way']); } @@ -769,15 +799,15 @@ class FinancePromoteController extends AdminController $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") - ->where($pmap); + ->field("order_number,user_account,amount,balance,create_time") + ->join("left join tab_user as u on u.id = p.user_id") + ->where($pmap); if(isset($_REQUEST['export'])){ $admininside = $admininside->select(); }else { $admininside = $admininside->page($page, $row)->select(); - } + } foreach ($admininside as $k => $v) { $temp = [ @@ -793,7 +823,7 @@ class FinancePromoteController extends AdminController $senddata[] = $temp; } } - + }else{ if($istimeselect){ $map['s.create_time']=$istimeselect; @@ -801,9 +831,9 @@ class FinancePromoteController extends AdminController $map['s.status']=1; $map['s.source_id']=0; $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(); + ->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) { @@ -816,7 +846,7 @@ class FinancePromoteController extends AdminController $ininside = $ininside->select(); }else { $ininside = $ininside->page($page, $row)->select(); - } + } foreach ($ininside as $k => $v) { $temp = [ "sn"=>$v['sn'], @@ -853,7 +883,7 @@ class FinancePromoteController extends AdminController if($page) {$this->assign('_page', $page);} $this->assign('data',$senddata); $this->display(); - + } } \ No newline at end of file diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index 9f60ea626..e78c19eaa 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -407,19 +407,24 @@ autoclose: true, pickerPosition: 'bottom-left' }) + var promote_id = "{:I('promote_id')}"; - function getPromotersByLevel() { + var company_id = "{:I('company_id')}"; + function getPromotersByCompanyid() { + var company_id = $("#company_id option:selected").val(); + if(!company_id){ + company_id = -1; + } $.ajax({ - url: "{:U('Ajax/getPromotersByLevel')}", + url: "{:U('Ajax/getPromotersByCompanyid')}", type: "get", - data: { level: 1 }, + data: { company_id:company_id}, dataType: 'json', success: function (response) { - str = ''; - // $.each(response.data, function(index, item){ - // console.log(item.id); - // str += ''; - // }); + str = ''; + if(company_id == 0 || company_id ==-1){ + str +=''; + } data = response.data; for (var i in data) { str += "" @@ -430,7 +435,11 @@ } }) } - getPromotersByLevel(); + getPromotersByCompanyid(); + + $("#company_id").change(function(){ + getPromotersByCompanyid(); + }) }) diff --git a/Application/Admin/View/FinancePromote/promoteUser.html b/Application/Admin/View/FinancePromote/promoteUser.html index 670441488..faee12887 100644 --- a/Application/Admin/View/FinancePromote/promoteUser.html +++ b/Application/Admin/View/FinancePromote/promoteUser.html @@ -382,18 +382,19 @@ pickerPosition: 'bottom-left' }) var promote_id = "{:I('promote_id')}"; - function getPromotersByLevel() { + var company_id = "{:I('company_id')}"; + function getPromotersByCompanyid() { + var company_id = $("#company_id option:selected").val(); + if(!company_id){ + company_id = -1; + } $.ajax({ - url: "{:U('Ajax/getPromotersByLevel')}", + url: "{:U('Ajax/getPromotersByCompanyid')}", type: "get", - data: { level: 1 }, + data: { company_id:company_id}, dataType: 'json', success: function (response) { - str = ''; - // $.each(response.data, function(index, item){ - // console.log(item.id); - // str += ''; - // }); + str = ''; data = response.data; for (var i in data) { str += "" @@ -404,7 +405,11 @@ } }) } - getPromotersByLevel(); + getPromotersByCompanyid(); + + $("#company_id").change(function(){ + getPromotersByCompanyid(); + }) })