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..3546bf558 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -700,7 +700,74 @@ 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(); + $company_id = []; + foreach($relation as $k=>$v){ + if($v['first_company_type'] == 0){ + $company_id[]=$v['second_company_id']; + }else{ + $company_id[]=$v['first_company_id']; + } + } + if(count($company_id) < 1){ + $this->ajaxReturn(["error"=>'无新增关系,无需重算']); + } + $senddata['company_id'] = implode(",",$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() + { + $company_id = $_REQUEST['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){ + $CompanyStatementSet->cpStatement(0,$stime,$company_id,false); + $CompanyStatementSet->promoteCompanyStatement(0,$stime,$company_id,false); + } + if($d == 1){ + $CompanyStatementSet->cpStatement(1,$stime,$company_id,false); + $CompanyStatementSet->cpStatement(2,$stime,$company_id,false); + $CompanyStatementSet->promoteCompanyStatement(1,$stime,$company_id,false); + $CompanyStatementSet->promoteCompanyStatement(2,$stime,$company_id,false); + } + + $this->ajaxReturn(array("success"=>"ok","data"=>[])); + } + public function OpAuth($info) @@ -762,7 +829,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..3d3b16a36 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}) )" ]; } //获取哪些要结算 @@ -339,12 +339,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 +401,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 +414,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}) )" ]; } //获取哪些要结算 @@ -549,7 +547,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){ //非补点计算奖罚 @@ -601,16 +598,23 @@ 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); + + + // if($company_id === false){ + // //非重算 + // $StatementDb->add($add_data); + // }else{ + // return $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 +636,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;} @@ -922,7 +926,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 +951,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 +969,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..dd34b52a4 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; + } @@ -235,6 +257,15 @@ {$_page|default=''} + @@ -256,6 +287,66 @@ Think.setValue('{$key}',"{$vo}"); $(".select_gallery").select2(); + var DATA={}; + var MSG={ + showmsg:function(str){ + $("#creat_msg").show(); + $("#tip_msg").html(str); + }, + hidemsg:function(){ + $("#creat_msg").hide(); + $("#tip_msg").html(''); + } + } + var COMPARE={ + publiucAjax:function(url,senddata,callback){ + $.ajax({ + type: 'post', + url: url, + data:senddata, + success: function(data) { + if(data.success){ + callback(data.data); + }else{ + MSG.hidemsg(); + layer.alert(data.error); + return false; + } + + }, + error:function(){ + MSG.hidemsg(); + layer.alert("网络错误或超时"); + return false; + } + }); + }, + //获取基础参数 + getNewStatement:function(callback){ + MSG.showmsg("初始化获取校验中...."); + COMPARE.publiucAjax("{:U('getNewStatement')}",{},function(data){ + DATA = data; + DATA.now = 1; + MSG.showmsg("校验通过,开始统计 [0/"+DATA.count+"] ......"); + callback(); + }); + }, + //开始统计 + updateNewStatement:function(callback){ + var senddata = {date:DATA.datelist[(DATA.now-1)],company_id:DATA.company_id}; + console.log(senddata); + COMPARE.publiucAjax("{:U('updateNewStatement')}",senddata,function(){ + MSG.showmsg("开始统计 ["+DATA.now+"/"+DATA.count+"] ......"); + DATA.now ++; + if( DATA.now > DATA.count){ + callback(); + }else{ + COMPARE.updateNewStatement(callback) + } + }); + + } + }