From c1b556b0b1d664c2f6834f02fd30b2f5ee0e04d6 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Wed, 28 Oct 2020 11:14:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=82=E5=9C=BA=E4=B8=9A=E7=BB=A9=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GameRatioMouldController.class.php | 2 +- .../MarketPercentageController.class.php | 20 +-- .../Controller/TimingController.class.php | 169 ++++++++++++++++-- .../MarketPercentage/indexuncaculate.html | 2 +- 4 files changed, 165 insertions(+), 28 deletions(-) diff --git a/Application/Admin/Controller/GameRatioMouldController.class.php b/Application/Admin/Controller/GameRatioMouldController.class.php index 6afd5aac6..530b1faeb 100644 --- a/Application/Admin/Controller/GameRatioMouldController.class.php +++ b/Application/Admin/Controller/GameRatioMouldController.class.php @@ -225,7 +225,7 @@ class GameRatioMouldController extends AdminController $save["create_time"]=time(); $save["begin_time"] = strtotime($params["begin_time"]) ?? 0; - $save["end_time"] = $params["end_time"] ?strtotime($params["end_time"])-1: 0; + $save["end_time"] = $params["end_time"] ?strtotime($params["end_time"])+86399: 0; $save["turnover_type"] = $params["turnover_type"] ?? 0; //判断是否存在 // $where = [ diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index 1a472138a..92cd6bba5 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -97,13 +97,13 @@ class MarketPercentageController extends ThinkController if ($_REQUEST['export']) { $data = $data->where($map) ->group("promote_id,game_name,pay_time,admin_id") - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } else { $data = $data->page($p, $row) ->where($map) ->group("promote_id,game_name,pay_time,admin_id") - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } @@ -275,13 +275,13 @@ class MarketPercentageController extends ThinkController if ($_REQUEST['export']) { $data = $data->where($map) ->group("promote_id,game_name,pay_time,admin_id") - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } else { $data = $data->page($p, $row) ->where($map) ->group("promote_id,game_name,pay_time,admin_id") - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } @@ -470,7 +470,7 @@ class MarketPercentageController extends ThinkController ->field("tab_market_altogether.*,market_percentage") ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } else { $data = $data @@ -478,7 +478,7 @@ class MarketPercentageController extends ThinkController ->join("left join sys_auth_group_access access on tab_market_altogether.admin_id = access.uid") ->join("left join sys_auth_group auth on access.group_id=auth.id") // ->page($p, $row) - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } @@ -896,12 +896,12 @@ class MarketPercentageController extends ThinkController if ($_REQUEST['export']) { $data = $data - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } else { $data = $data // ->page($p, $row) - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->select(); } @@ -1229,13 +1229,13 @@ class MarketPercentageController extends ThinkController if ($_REQUEST['export']) { $data = $data - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->group("admin_id") ->select(); } else { $data = $data // ->page($p, $row) - ->order("pay_time DESC") + ->order("pay_time DESC,company_profit DESC") ->group("admin_id") ->select(); } diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index f6b172497..3ff4e0b7a 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -764,7 +764,10 @@ class TimingController extends AdminController { */ public function getSpecialComplement($start_time=0,$end_time =0,$promote_id = 0) { - $data = M("company_statement","tab_")->where("statement_begin_time<={$start_time} and statement_end_time<={$end_time} and withdraw_type=3")->select(); + $data = M("company_statement","tab_") +// ->where("statement_begin_time<={$start_time} and statement_end_time<={$end_time} and withdraw_type=3") + ->where("(statement_begin_time <={$end_time} AND ( statement_end_time = 0 OR statement_end_time >= {$start_time})) and withdraw_type=3") + ->select(); $return = []; foreach ($data as $key => $value) { @@ -776,6 +779,13 @@ class TimingController extends AdminController { foreach ($statement_info as $skey => $sval) { $info = $sval['game_list']; foreach ($info as $k => $v) { + + $statement_begin_time = strtotime(str_replace('.','-',$v['statement_begin_time'])); + $statement_end_time = strtotime(str_replace('.','-',$v['statement_end_time']))+86399; + + if (date("m",$statement_begin_time)!=date("m",$start_time) || date("m",$statement_end_time)!=date("m",$end_time)) { + continue; + } // if (isset($return[$statement_info['promote_id'].$v['relation_game_id']])) { $return[$value['company_id']."-".$sval['promote_id']."-".$v['relation_game_id']] = !$is_inside?$v['sum_money']:0; @@ -793,6 +803,11 @@ class TimingController extends AdminController { foreach ($statement_info as $k => $v) { $statement_begin_time = strtotime(str_replace('.','-',$v['statement_begin_time'])); $statement_end_time = strtotime(str_replace('.','-',$v['statement_end_time']))+86399; + + if (date("m",$statement_begin_time)!=date("m",$start_time) || date("m",$statement_end_time)!=date("m",$end_time)) { + continue; + } + $amount_time['tab_spend.pay_status'] = 1; $amount_time['pay_way'] = ['egt',0]; $amount_time['_string'] = "payed_time between {$statement_begin_time} and {$statement_end_time} and relation_game_id={$v['relation_game_id']}"; @@ -830,15 +845,16 @@ class TimingController extends AdminController { // $admin_id = 0,$promote_id = 0,$company_id=0,$relation_game_id=0,$date ='',$pay_amount = 0 - public function getCompanyGameRadio($admin_id = 0,$promote_id = 0,$company_id=0,$relation_game_id=0,$date ='',$pay_amount = 0) { -// $company_id=64; -// $relation_game_id=211; + public function getCompanyGameRadio($admin_id = 0,$promote_id = 0,$company_id=0,$relation_game_id=0,$begintime=0,$endtime =0,$pay_amount = 0) { +// $company_id=239; +// $relation_game_id=213; // $pay_amount = 440; // $date = "2020-08"; -// $admin_id = 34; -// $promote_id = 1726; - $begintime = strtotime(date("Y-m-1",strtotime($date))); - $endtime = strtotime(date("Y-m-t",strtotime($date)))+86399; +// $admin_id = 27; +// $promote_id = 3235; + +// $begintime = strtotime(date("Y-m-1",strtotime($date))); +// $endtime = strtotime(date("Y-m-t",strtotime($date)))+86399; $is_inside = M("PromoteCompany","tab_")->field("is_inside")->where("id='{$company_id}'")->find()['is_inside']; @@ -881,13 +897,15 @@ class TimingController extends AdminController { foreach ($company_game_ratio as $key => $value) { $turnover_ratio = json_decode($value['turnover_ratio'],true); +// dump($value); $spend = $this->getSpendData($value['begintime'],$value['endtime'],$company_id,$relation_game_id,$admin_id,$promote_id); +// dump($spend); $amount += $this->setSpendData($spend,$turnover_ratio,$value['ratio'],$pay_amount); } - +// dump($amount);die(); return $amount?$amount:0; @@ -972,8 +990,8 @@ class TimingController extends AdminController { } else { - $time_start = strtotime(date('Y-m-1',strtotime($_REQUEST['time']))); - $time_end = strtotime(date('Y-m-t',strtotime($_REQUEST['time']))); + $time_start = strtotime(date('Y-m-1',strtotime($map['pay_time']))); + $time_end = strtotime(date('Y-m-t',strtotime($map['pay_time']))); $belong_map = "((begin_time<={$time_start} and (end_time >={$time_start} or end_time=0)) or (begin_time<={$time_end} and end_time >={$time_end}) or (end_time>={$time_start} and end_time <={$time_end}))"; @@ -1012,11 +1030,11 @@ class TimingController extends AdminController { if (!$spend_map['_string']) { - $spend_map['_string'] = "(pay_time between {$value['begin_time']} and {$value['end_time']}+86399 and relation_game_id not in({$value['game_ids']}))"; + $spend_map['_string'] = "(pay_time between {$value['begin_time']} and {$value['end_time']}+86399 and relation_game_id in({$value['game_ids']}))"; } else { - $spend_map['_string'] .= " or (pay_time between {$value['begin_time']} and {$value['end_time']}+86399 and relation_game_id not in({$value['game_ids']}))"; + $spend_map['_string'] .= " or (pay_time between {$value['begin_time']} and {$value['end_time']}+86399 and relation_game_id in({$value['game_ids']}))"; } @@ -1025,7 +1043,7 @@ class TimingController extends AdminController { $spend = M("spend","tab_") ->field("sum(pay_amount) as pay_amount,FROM_UNIXTIME(pay_time,'%Y-%m') pay_time, substring_index(substring_index(tab_spend.game_name,'(',1),'(',-1) game_name,game_id,relation_game_id,tab_spend.sdk_version, - CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,1 is_settlement") + CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,0 is_settlement") ->join("left join tab_promote on tab_spend.promote_id = tab_promote.id") ->join("left join tab_game game on game.id=tab_spend.game_id") ->where(['tab_spend.pay_status'=>1,'pay_way'=>['egt',0]]) @@ -1047,7 +1065,7 @@ class TimingController extends AdminController { $unsettlement_spend = M("spend","tab_") ->field("sum(pay_amount) as pay_amount,FROM_UNIXTIME(pay_time,'%Y-%m') pay_time, substring_index(substring_index(tab_spend.game_name,'(',1),'(',-1) game_name,game_id,relation_game_id,tab_spend.sdk_version, - CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,0 is_settlement") + CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,1 is_settlement") ->join("left join tab_promote on tab_spend.promote_id = tab_promote.id") ->join("left join tab_game game on game.id=tab_spend.game_id") ->where(['tab_spend.pay_status'=>1,'pay_way'=>['egt',0]]) @@ -1135,10 +1153,14 @@ class TimingController extends AdminController { ->join("left join tab_promote_company company on promote.company_id = company.id") ->join("left join ({$data}) auth on auth.uid=market_admin_id") ->where(['develop_type'=>['egt',1],'group_id'=>['in',['11','12','21']]]) +// ->where(['company_id'=>64,'spend.promote_id'=>1726,'relation_game_id'=>219]) +// ->order("is_settlement ASC") ->select(); $specialPayAmount = []; + $unsettlement_amount = []; + foreach ($promote_data as $key => $value) { $cp_radio = getGameCpRadio($value['game_id'],$value['pay_amount'],true); @@ -1153,8 +1175,123 @@ class TimingController extends AdminController { // $promote_radio = getGamePromoteCompanyRadio($value['company_id'],$value['relation_game_id'],time(),$value['pay_amount'],false,$value['company_belong']); // } + $begin_pay_time = strtotime(date("Y-m-1",strtotime($value['pay_time']))); + $end_pay_time = strtotime(date("Y-m-t",strtotime($value['pay_time'])))+86399; + + $company_belong_game = M("company_belong_game","tab_") + ->field("game_ids,begin_time,end_time") + ->where("begin_time <={$end_pay_time} AND ( end_time = 0 OR end_time >= {$begin_pay_time})") +// ->where("((begin_time<={$begin_pay_time} and (end_time >={$begin_pay_time} or end_time=0)) or (begin_time<={$end_pay_time} and end_time >={$end_pay_time}) or (end_time>={$begin_pay_time} and end_time <={$end_pay_time}))") + ->order("begin_time ASC") + ->select(); + + $promote_data[$key]['promote_amount'] = 0; + + foreach ($company_belong_game as $ck => $cv) { + + $ungame_ids = explode(',',$cv['game_ids']); + + $use_begin = 0; + $use_end = 0; + if ($value['is_settlement'] == '0') { + + if ($begin_pay_time > $cv['begin_time']) { + $use_begin = $begin_pay_time; + if ($end_pay_time > $cv['end_time']+86399) { + $use_end = $cv['end_time']+86399; + } else { + $use_end = $end_pay_time; + } + } else { + + $use_begin = $cv['begin_time']; + if ($end_pay_time > $cv['end_time']) { + $use_end = $cv['end_time']+86399; + } else { + $use_end = $end_pay_time; + } + + } + + //下游流水 + $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$use_begin,$use_end,$value['pay_amount']); + + } elseif($value['is_settlement'] == '1') { + + if ($ck == 0) { + + if ($cv['begin_time'] >= $begin_pay_time) { + + $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$begin_pay_time,$cv['begin_time']-1,$value['pay_amount']); + + } + + } + + if (!$company_belong_game[$ck+1]) { + + if ($end_pay_time > $cv['end_time']) { + + $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$cv['end_time']+86400,$end_pay_time,$value['pay_amount']); + } + + } + + if ($ck > 1) { + + if (($cv['begin_time'] - $company_belong_game[$ck-1]['end_time'] + 86399) > 1) { + + $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$company_belong_game[$ck-1]['end_time'] + 86400,$cv['begin_time']-1,$value['pay_amount']); + } + } + + if (!in_array($value['relation_game_id'],$ungame_ids)) { + + if (($cv['end_time']+86399) > $end_pay_time) { + $cv['end_time'] = $end_pay_time; + } else { + $cv['end_time'] = $cv['end_time']+86399; + } + + $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$cv['begin_time'],$cv['end_time'],$value['pay_amount']); + } + + } + +// if (!in_array($value['relation_game_id'],$ungame_ids)) { +// +// if ($begin_pay_time > $cv['begin_time']) { +// $use_begin = $begin_pay_time; +// if ($end_pay_time > $cv['end_time']+86399) { +// $use_end = $cv['end_time']+86399; +// } else { +// $use_end = $end_pay_time; +// } +// } else { +// +// $use_begin = $cv['begin_time']; +// if ($end_pay_time > $cv['end_time']) { +// $use_end = $cv['end_time']+86399; +// } else { +// $use_end = $end_pay_time; +// } +// +// } +// +// //下游流水 +// $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$use_begin,$use_end,$value['pay_amount']); +// } + + } + + if (!$company_belong_game) { + $promote_data[$key]['promote_amount'] += $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$begin_pay_time,$end_pay_time,$value['pay_amount']); + } + + + //下游流水 - $promote_data[$key]['promote_amount'] = $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$value['pay_time'],$value['pay_amount']); +// $promote_data[$key]['promote_amount'] = $this->getCompanyGameRadio($value['admin_id'],$value['promote_id'],$value['company_id'],$value['relation_game_id'],$value['pay_time'],$value['pay_amount'],$value['is_settlement']); //下游流水 // $promote_data[$key]['promote_amount'] = $value['pay_amount'] * ($promote_radio * 0.01); diff --git a/Application/Admin/View/MarketPercentage/indexuncaculate.html b/Application/Admin/View/MarketPercentage/indexuncaculate.html index 77e841140..9fa438257 100644 --- a/Application/Admin/View/MarketPercentage/indexuncaculate.html +++ b/Application/Admin/View/MarketPercentage/indexuncaculate.html @@ -105,7 +105,7 @@
- 搜索 + 搜索