diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 75e184324..0c872f7d6 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -762,33 +762,72 @@ class TimingController extends AdminController { * @param int $end_time * @return array */ - public function getSpecialComplement($start_time=0,$end_time =0) { + 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 and company_type=2")->select(); + $data = M("company_statement","tab_")->where("statement_begin_time<={$start_time} and statement_end_time<={$end_time} and withdraw_type=3")->select(); $return = []; foreach ($data as $key => $value) { - $statement_info = json_decode($value['statement_info'],true); - foreach ($statement_info as $skey => $sval) { - $info = $sval['game_list']; - foreach ($info as $k => $v) { - // - if (isset($return[$statement_info['promote_id'].$v['relation_game_id']])) { - $return[$value['company_id']."-".$sval['promote_id']."-".$v['relation_game_id']] = $v['sum_money']; - } else { - $return[$value['company_id']."-".$sval['promote_id']."-".$v['relation_game_id']] += $v['sum_money']; + + if ($value['company_type'] == 2) { + + foreach ($statement_info as $skey => $sval) { + $info = $sval['game_list']; + foreach ($info as $k => $v) { + // + if (isset($return[$statement_info['promote_id'].$v['relation_game_id']])) { + $return[$value['company_id']."-".$sval['promote_id']."-".$v['relation_game_id']] = $v['sum_money']; + } else { + $return[$value['company_id']."-".$sval['promote_id']."-".$v['relation_game_id']] += $v['sum_money']; + } + } } + } else { + //判断公司比例是不是隶属于这个会长 + $compamy_info = M("promote","tab_")->where(['id'=>$promote_id,'company_id'=>$value['company_id']])->find(); + if ($compamy_info) { + foreach ($statement_info as $k => $v) { + $statement_begin_time = strtotime($v['statement_begin_time']); + $statement_end_time = strtotime($v['statement_end_time'])+86399; + $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']}"; + + $dataAmount = M("spend","tab_") + ->field("pay_amount,relation_game_id,relation_game_name,payed_time,game_type_name,substring_index(substring_index(promote.`chain`,'/',2),'/',-1) promote_id,chain,admin_id") + ->join("left join tab_promote promote on tab_spend.promote_id=promote.id") + ->join("left join tab_game game on tab_spend.game_id=game.id") + ->where($amount_time) + ->select(false); + + $dataAmount = M()->table("({$dataAmount})a") + ->field("a.*,sum(pay_amount) pay_amount,promote.account,member.real_name") + ->join("left join tab_promote promote on promote_id=promote.id") + ->join("left join sys_member member on promote.admin_id=member.uid ") + ->where(['promote_id'=>$promote_id]) + ->group("promote_id") + ->find(); + + $return[$value['company_id']."-".$promote_id."-".$v['relation_game_id']] += ($dataAmount['pay_amount']*$v['increment_ratio'])/100; + } + } } + } return $return; } + public function test() { + $this->getSpecialComplement(strtotime(date("Y-m-1",strtotime("2020-07"))),strtotime(date("Y-m-t",strtotime("2020-07")))+86399,2259); + } + + // $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=273; @@ -1094,11 +1133,9 @@ class TimingController extends AdminController { //特殊补点 - if (!$specialPayAmount[$value['pay_time']]) { - $specialPayAmount[$value['pay_time']] = $this->getSpecialComplement(strtotime(date("Y-m-1",strtotime($value['pay_time']))),strtotime(date("Y-m-t",strtotime($value['pay_time'])))+86399); - } + $specialPayAmount[$value['pay_time']] = $this->getSpecialComplement(strtotime(date("Y-m-1",strtotime($value['pay_time']))),strtotime(date("Y-m-t",strtotime($value['pay_time'])))+86399,$value['promote_id']); - $specialAmount = $specialPayAmount[$value['pay_time']][$value['company_id']."-".$value['promote_id']."-".$value['relation_game_id']]?$specialPayAmount[$value['pay_time']][$value['promote_id']."-".$value['relation_game_id']]:0; + $specialAmount = $specialPayAmount[$value['pay_time']][$value['company_id']."-".$value['promote_id']."-".$value['relation_game_id']]?$specialPayAmount[$value['pay_time']][$value['company_id']."-".$value['promote_id']."-".$value['relation_game_id']]:0; //渠道费用