diff --git a/Application/Admin/Controller/CompanyGameRatioController.class.php b/Application/Admin/Controller/CompanyGameRatioController.class.php index 79522f680..968f39e3d 100644 --- a/Application/Admin/Controller/CompanyGameRatioController.class.php +++ b/Application/Admin/Controller/CompanyGameRatioController.class.php @@ -111,7 +111,6 @@ class CompanyGameRatioController extends AdminController $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign("gameList",D("Game")->getRelationGameLits()); $this->display(); - dd( $dbres); } public function lists() diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 4783c147d..d734f1c6e 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -117,7 +117,7 @@ class CompanyStatementController extends ThinkController $data = M("company_statement","tab_") ->field("id,withdraw_type,company_name,company_belong,statement_begin_time,statement_end_time,statement_money,platform_amount,verify_status,verify_log,op_time,remark") ->where($map) - ->order("op_time Desc")->page($page,$row)->select(); + ->order("FIELD(verify_status,0,1,-1,2,3,-2,4,5),id desc")->page($page,$row)->select(); foreach($data as $k => &$v) { $v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']); @@ -700,7 +700,95 @@ class CompanyStatementController extends ThinkController $savedata['statement_end_time'] = $v['statement_end_time']; } } - //设定并保存数据 + //新增结算 + //获取要结算的公司及日期 + public function getNewStatement() + { + $senddata = []; + //1.获取要计算的公司 + $statement = M("company_statement","tab_")->field("count(id) count,company_id")->group("company_id")->select(); + $has_company_id =implode(",",array_column($statement, 'company_id')); + if(empty($has_company_id)){ + $where = "1=1"; + }else{ + $where = "(first_company_type > 0 AND first_company_id NOT IN ({$has_company_id}) ) OR ( second_company_type > 0 AND second_company_id NOT IN ({$has_company_id}) )"; + } + + $relation = M("company_relation","tab_")->field("first_company_id,first_company_type,second_company_id,second_company_type")->where($where)->select(); + $up_company_id = []; + $dowm_company_id= []; + foreach($relation as $k=>$v){ + if($v['first_company_type'] == 0){ + if($v['second_company_type'] == 1){ + $up_company_id[] = $v['second_company_id']; + }else{ + $dowm_company_id[] = $v['second_company_id']; + } + }else{ + if($v['first_company_type'] == 1){ + $up_company_id[] = $v['first_company_id']; + }else{ + $dowm_company_id[]=$v['first_company_id']; + } + } + } + if(count($up_company_id) < 1 && count($dowm_company_id) < 1){ + $this->ajaxReturn(["error"=>'无新增关系,无需重算']); + } + + $senddata['up_company_id'] = implode(",",$up_company_id); + $senddata['dowm_company_id'] = implode(",",$dowm_company_id); + + //获取要结算的日期 + $start = strtotime('-1 month'); + $end = time(); + + $temp_datelist = get_date_list($start,$end,1); + $datelist = []; + foreach($temp_datelist as $k=>$v){ + $w = (int)date("w",strtotime($v)); + $d = (int)date("d",strtotime($v)); + if($w == 1 || $d == 1){ + $datelist[] = $v; + } + } + $senddata['datelist'] = $datelist; + $senddata['count'] = count($datelist); + + $this->ajaxReturn(["success"=>'ok',"data"=>$senddata]); + } + public function updateNewStatement() + { + $up_company_id = $_REQUEST['up_company_id']; + $dowm_company_id = $_REQUEST['dowm_company_id']; + $date = $_REQUEST['date']; + $CompanyStatementSet = A("CompanyStatementSet"); + // dd($CompanyStatementSet); + $stime = strtotime($date); + $w = (int)date("w",strtotime($date)); + $d = (int)date("d",strtotime($date)); + // if($w == 1){ + // if(!empty($up_company_id)){ + // $CompanyStatementSet->cpStatement(0,$stime,$up_company_id,false); + // } + // if(!empty($dowm_company_id)){ + // $CompanyStatementSet->promoteCompanyStatement(0,$stime,$dowm_company_id,false); + // } + // } + if($d == 1){ + if(!empty($up_company_id)){ + $CompanyStatementSet->cpStatement(1,$stime,$up_company_id,false); + $CompanyStatementSet->cpStatement(2,$stime,$up_company_id,false); + } + if(!empty($dowm_company_id)){ + $CompanyStatementSet->promoteCompanyStatement(1,$stime,$dowm_company_id,false); + // $CompanyStatementSet->promoteCompanyStatement(2,$stime,$dowm_company_id,false); + } + } + + $this->ajaxReturn(array("success"=>"ok","data"=>[])); + } + public function OpAuth($info) @@ -762,7 +850,8 @@ class CompanyStatementController extends ThinkController "launch"=>"对外发起", "pool"=>"发起汇总", "updateStatement"=>"重算金额", - "export"=>"批量导出" + "export"=>"批量导出", + "updateNewStatement"=>"新增结算", ]; $resarr = []; foreach ($mentBtn as $k => $v) { diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index ec60a0635..6c520083e 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -97,7 +97,7 @@ class CompanyStatementSetController extends Controller { * 上游结算 * @param [string] $type 0:周结 1:月结 2:周结补点 */ - public function cpStatement($type,$stime,$company_id=false) + public function cpStatement($type,$stime,$company_id=false,$recount=true) { $t = $this->setBeginAndEndTime($type,$stime);; $begintime = $t[0]; @@ -109,7 +109,7 @@ class CompanyStatementSetController extends Controller { ]; }else{ $where = [ - "_string"=>"(first_company_type = '1' AND first_company_id = '{$company_id}') OR (second_company_type = '1' AND second_company_id = '{$company_id}')" + "_string"=>"(first_company_type = '1' AND first_company_id in ({$company_id}) ) OR (second_company_type = '1' AND second_company_id in ({$company_id}) )" ]; } //获取哪些要结算 @@ -241,6 +241,7 @@ class CompanyStatementSetController extends Controller { $promote_ratio = $cp[$add_data['company_id']]['channel_rate'] ?? 0; $fax_ratio = $cp[$add_data['company_id']]['invoice_rate'] ?? 0; //游戏统计 + if(!isset($v['list'])){continue;} foreach($v['list'] as $ke=>$va){ $game =[]; $game['pay_amount'] =$va['pay_money']; @@ -339,12 +340,11 @@ class CompanyStatementSetController extends Controller { return; } //添加 - if($company_id === false){ + if($recount && $company_id !== false){ //非重算 - $StatementDb->add($add_data); - }else{ return $add_data; } + $StatementDb->add($add_data); } } @@ -402,9 +402,8 @@ class CompanyStatementSetController extends Controller { /** * 下游结算 */ - public function promoteCompanyStatement($type,$stime,$company_id=false) + public function promoteCompanyStatement($type,$stime,$company_id=false,$recount=true) { - $t = $this->setBeginAndEndTime($type,$stime); $begintime = $t[0]; $endtime = $t[1]; @@ -416,7 +415,7 @@ class CompanyStatementSetController extends Controller { ]; }else{ $where = [ - "_string"=>"(first_company_type = '2' AND first_company_id = '{$company_id}') OR (second_company_type = '2' AND second_company_id = '{$company_id}')" + "_string"=>"(first_company_type = '2' AND first_company_id in ({$company_id}) ) OR (second_company_type = '2' AND second_company_id in ({$company_id}) )" ]; } //获取哪些要结算 @@ -427,7 +426,6 @@ class CompanyStatementSetController extends Controller { $where['settlement_type']=1; $pcDbRes = M("CompanyRelation","tab_")->where($where)->select(); } - $pcList=[]; $js_id = [];//己方公司 foreach ($pcDbRes as $k => $v) { @@ -454,6 +452,7 @@ class CompanyStatementSetController extends Controller { foreach ($tmpp as $v) { $pc[$v['id']]=$v; } + unset($tmpp); //获取己方公司 $our = []; @@ -471,7 +470,9 @@ class CompanyStatementSetController extends Controller { $statement_begin_time = date("Y-m-d",$begintime); $statement_end_time = date("Y-m-d",$endtime); $RewardRecord = M("RewardRecord","tab_"); + foreach($pcList as $k=>$v){ + if(!isset($pc[$k])){continue;}//不存在的公司不结算 $add_data=[]; @@ -511,8 +512,7 @@ class CompanyStatementSetController extends Controller { $company_belong = $pc[$add_data['company_id']]['company_belong']; $add_data['company_belong']=$company_belong; $add_data['company_type']=$pc[$add_data['company_id']]['company_type']; - - + if(!isset($v['list'])){continue;} //游戏统计 foreach($v['list'] as $ke=>$va){ $game =[]; @@ -549,7 +549,6 @@ class CompanyStatementSetController extends Controller { $game['statement_type']=0; $add_data['statement_info'][] = $game; } - $add_data['platform_amount'] = $add_data['pay_amount']; if($type < 2){ //非补点计算奖罚 @@ -600,17 +599,17 @@ class CompanyStatementSetController extends Controller { if($add_data['platform_amount'] <= 0){ return; } + // dd($add_data); //添加 - if($company_id === false){ + if($recount && $company_id !== false){ //非重算 - $StatementDb->add($add_data); - }else{ return $add_data; } + $StatementDb->add($add_data); } } //设定开始结束时间 - protected function setBeginAndEndTime($type,$stime){ + public function setBeginAndEndTime($type,$stime){ if($type == 0){ $begintime = mktime(0,0,0,date('m',$stime),date('d',$stime)-7,date('Y',$stime)); $endtime = mktime(0,0,0,date('m',$stime),date('d',$stime),date('Y',$stime))-1; @@ -632,7 +631,7 @@ class CompanyStatementSetController extends Controller { return [$begintime,$endtime]; } //获取推广公司推广金额 - protected function getPromoteCompanySpend(&$pcList,$idarr,$begintime,$endtime){ + public function getPromoteCompanySpend(&$pcList,$idarr,$begintime,$endtime){ $res = []; //获取推广员 if(count($idarr) == 0){return $res;} @@ -759,6 +758,7 @@ class CompanyStatementSetController extends Controller { $v['fine'] = 0; $v['reward'] = 0; $v['platform_amount'] = 0; + if(!isset($v['list'])){continue;} foreach($v['list'] as $ke=>$va){ $game =[]; $game['pay_amount'] =$va['pay_amount']; @@ -922,7 +922,7 @@ class CompanyStatementSetController extends Controller { /** * 保存信息汇总信息 */ - protected function savePromotateUserPool($data){ + public function savePromotateUserPool($data){ if(empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ return;} if($data['statement_money'] == 0 && $type ==2){ return;} if($data['statement_money'] == 0){ @@ -947,7 +947,7 @@ class CompanyStatementSetController extends Controller { /** * 获取公司额为信息 */ - protected function getCompanyOtherInfo($company_info,$company_id) + public function getCompanyOtherInfo($company_info,$company_id) { $pl = M("promote_company","tab_") ->alias('pc') @@ -965,7 +965,7 @@ class CompanyStatementSetController extends Controller { /** * 获取游戏分类名称 */ - protected function getGameTypeName($relation_game_id){ + public function getGameTypeName($relation_game_id){ return M("Game","tab_")->field("game_type_name")->where("relation_game_id = '{$relation_game_id}'")->find()['game_type_name']; } diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html index db5e44e09..52b7d75be 100644 --- a/Application/Admin/View/CompanyStatement/lists.html +++ b/Application/Admin/View/CompanyStatement/lists.html @@ -56,11 +56,33 @@ font-weight: 400; font-size: 14px; } + .main-place .question_content:before{ + right: 20px; + left: auto; + }