From 51c4b07eeaa358c780f46b3421db76bd2fdec2c5 Mon Sep 17 00:00:00 2001 From: chenzhi <294767167@11qq.com> Date: Sat, 25 Jul 2020 09:05:11 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E6=B8=B8?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/CompanyStatementSetController.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 05ae0c7ee..d0c97716d 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -361,7 +361,7 @@ class CompanyStatementSetController extends Controller { { $game_where = "partner_id in ({$cp_id})"; $game = M('game','tab_'); - $gameDbRes = $game->field("id,relation_game_name as game_name,partner_id as cp_id,original_package_name")->where($game_where)->select(); + $gameDbRes = $game->field("id,relation_game_name as game_name,partner_id as cp_id,original_package_name,select_package_name")->where($game_where)->select(); $gameList=[]; foreach ($gameDbRes as $k => $v) { $gameList[$v['id']] =$v; @@ -392,7 +392,11 @@ class CompanyStatementSetController extends Controller { if(empty($v['original_package_name'])){ $game_name = $v['game_name']; }else{ - $game_name = $v['original_package_name']; + if($v['select_package_name'] == 1){ + $game_name = $v['original_package_name']; + }else{ + $game_name = $v['game_name']; + } } $cp_id = $v['cp_id']; unset($v['cp_id']); From 16a3bea1720aa3393d475d0fc2e133dc5e0af5b1 Mon Sep 17 00:00:00 2001 From: chenzhi <294767167@11qq.com> Date: Sat, 25 Jul 2020 09:21:01 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E6=B8=B8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9C=8D=E5=8A=A1=E5=99=A8=E8=B4=B9=E7=94=A8?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8C=85=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index d0c97716d..1fabbaef7 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -143,7 +143,7 @@ class CompanyStatementSetController extends Controller { $cp_id = implode(",",array_flip(array_flip(array_keys($cpList)))); $js_id = implode(",",array_unique($js_id)); //获取cp公司 - $tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,company_type,ali_user,ali_account")->where(["id"=>['in',$cp_id]])->select(); + $tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,company_type,ali_user,ali_account,has_advance_charge,has_server_fee")->where(["id"=>['in',$cp_id]])->select(); $cp =[]; foreach ($tmpp as $v) { $cp[$v['id']]=$v; @@ -298,14 +298,15 @@ class CompanyStatementSetController extends Controller { if($type < 2){ //非补点奖罚 $rrmap = array( - "reward_time" => ['between', [$begintime,$endtime]], + "confirm_time" => ['between', [$begintime,$endtime]], "company_type"=>1, - "company_id"=>$add_data['company_id'] + "company_id"=>$add_data['company_id'], + "settlement_type"=>2, ); - $rfres = M("RewardRecord","tab_") + $rfres = M("RewardDetail","tab_") ->field(" - IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count, - IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count + IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward_count, + IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine_count ") ->where($rrmap)->find(); if($rfres['reward_count'] > 0){ @@ -333,7 +334,21 @@ class CompanyStatementSetController extends Controller { ); $add_data['statement_money'] -= $fine_count; $add_data['pay_amount'] -= $fine_count;; - } + } + //获取服务器费用 + if($v['has_server_fee'] == 1 && $v['server_fee'] >0){ + $server_count = $v['server_fee']; + $add_data['statement_info'][] = array( + "statement_begin_time"=>$statement_begin_time, + "statement_end_time"=>$statement_end_time, + 'statement_type'=>1, + "game_name"=>"服务器费用", + 'pay_amount'=>$server_count, + 'sum_money'=>$server_count, + ); + $add_data['statement_money'] -= $server_count; + $add_data['pay_amount'] -= $server_count;; + } } $add_data['statement_info'] = json_encode($add_data['statement_info'],JSON_UNESCAPED_UNICODE); From 8e77f3ed4dac3329878ad46ca5de651c607e638e Mon Sep 17 00:00:00 2001 From: chenzhi <294767167@11qq.com> Date: Sat, 25 Jul 2020 09:44:53 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E6=B8=B8?= =?UTF-8?q?=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/CompanyStatementSetController.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 1fabbaef7..91e72a61b 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -143,7 +143,7 @@ class CompanyStatementSetController extends Controller { $cp_id = implode(",",array_flip(array_flip(array_keys($cpList)))); $js_id = implode(",",array_unique($js_id)); //获取cp公司 - $tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,company_type,ali_user,ali_account,has_advance_charge,has_server_fee")->where(["id"=>['in',$cp_id]])->select(); + $tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,company_type,ali_user,ali_account,has_advance_charge,has_server_fee,server_fee")->where(["id"=>['in',$cp_id]])->select(); $cp =[]; foreach ($tmpp as $v) { $cp[$v['id']]=$v; @@ -336,8 +336,9 @@ class CompanyStatementSetController extends Controller { $add_data['pay_amount'] -= $fine_count;; } //获取服务器费用 - if($v['has_server_fee'] == 1 && $v['server_fee'] >0){ - $server_count = $v['server_fee']; + $tmp_company_info= $cp[$add_data['company_id']]; + if($tmp_company_info['has_server_fee'] == 1 && $tmp_company_info['server_fee'] >0){ + $server_count = $tmp_company_info['server_fee']; $add_data['statement_info'][] = array( "statement_begin_time"=>$statement_begin_time, "statement_end_time"=>$statement_end_time, From d946a4c91c9beaff87e26585aa9e19b116fd37f4 Mon Sep 17 00:00:00 2001 From: chenzhi <294767167@11qq.com> Date: Sat, 25 Jul 2020 10:55:47 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E6=B8=B8?= =?UTF-8?q?=E5=85=AC=E5=8F=B8=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 95 +++++++++++++++---- 1 file changed, 78 insertions(+), 17 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 91e72a61b..136094717 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -470,11 +470,25 @@ class CompanyStatementSetController extends Controller { return ; } //获取pc公司 - $tmpp = M("PromoteCompany","tab_")->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,company_belong,company_type,ali_user,ali_account") + $tmpp = M("PromoteCompany","tab_")->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,taxation_rate,company_belong,company_type,ali_user,ali_account,has_server_fee,server_fee,has_ratio,turnover_ratio") ->where(["id"=>['in',$pc_id],"company_type"=>1]) ->select(); - $pc =[]; + $pc =[]; + $Promote = M("Promote","tab_"); foreach ($tmpp as $v) { + //获取会长的支付宝账号 + $p_map = [ + "company_id"=>$v['id'], + "withdraw_done"=>1 + ]; + $pres = $Promote->field("alipay_account,alipay_real_name")->where($p_map)->find(); + if(!empty($pres) && !empty($pres['alipay_account']) && !empty($pres['alipay_real_name'])){ + $v['ali_user'] = $pres['alipay_real_name']; + $v['ali_account'] = $pres['alipay_account']; + } + if($v['has_ratio']){ + $v['turnover_ratio'] = json_decode($v['turnover_ratio'],true); + } $pc[$v['id']]=$v; } @@ -486,8 +500,10 @@ class CompanyStatementSetController extends Controller { $our[$v['id']]=$v; } unset($tmpp); - unset($js_id); - $this->getPromoteCompanySpend($pcList,array_unique(array_keys($pcList)),$begintime,$endtime); + unset($js_id); + $this->getPromoteCompanySpend($pcList,array_unique(array_keys($pcList)),$begintime,$endtime); + + //数据整合 $verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]); $StatementDb = M("CompanyStatement","tab_"); @@ -498,8 +514,13 @@ class CompanyStatementSetController extends Controller { foreach($pcList as $k=>$v){ - if(!isset($pc[$k])){continue;}//不存在的公司不结算 - + if(!isset($pc[$k])){continue;}//不存在的公司不结算 + if($pc[$k]['has_ratio'] == 1){ + $company_ratio = $this->getCompanyRatio($v['paymount'],$pc[$k]['turnover_ratio']); + }else{ + $company_ratio = 0; + } + $add_data=[]; //1.获取甲乙方信息 if($v['first_company_type'] > 0){ @@ -533,7 +554,7 @@ class CompanyStatementSetController extends Controller { $add_data['statement_info'] =[]; //获取渠道及发票税率 - $fax_ratio = $pc[$add_data['company_id']]['fax_ratio'] ?? 0; + $fax_ratio = $pc[$add_data['company_id']]['taxation_rate'] ?? 0; //税费费率 $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']; @@ -546,14 +567,15 @@ class CompanyStatementSetController extends Controller { //获取比例 $game['relation_game_id']=$va['relation_game_id']; if($type == 1){ - $tratio = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong); + $tratio = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong); + $tratio += $company_ratio; }elseif($type == 0){ $tratio = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong); }else{ //补点 $tratio1 = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);; $tratio2 = getGamePromoteCompanyRadio($add_data['company_id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong); - $tratio = $tratio1-$tratio2; + $tratio = $tratio1-$tratio2+$company_ratio; if($tratio <= 0){ continue;} } @@ -564,7 +586,7 @@ class CompanyStatementSetController extends Controller { } $add_data['pay_amount'] += $va['pay_amount']; - $game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*(1-渠道费)*分成比例*(1-税费费率) + $game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*(分成比例+补点比例)*(1-税费费率) $add_data['statement_money'] += $game['sum_money']; $game['fax_ratio']=$fax_ratio; @@ -580,12 +602,13 @@ class CompanyStatementSetController extends Controller { $rrmap = array( "reward_time" => ['between', [$begintime,$endtime]], "company_type"=>2, - "company_id"=>$add_data['company_id'] + "company_id"=>$add_data['company_id'], + "settlement_type"=>2, ); - $rfres = M("RewardRecord","tab_") + $rfres = M("RewardDetail","tab_") ->field(" - IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count, - IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count + IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward_count, + IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine_count ") ->where($rrmap)->find(); if($rfres['reward_count'] > 0){ @@ -613,7 +636,22 @@ class CompanyStatementSetController extends Controller { ); $add_data['statement_money'] -= $fine_count; $add_data['pay_amount'] -= $fine_count;; - } + } + //获取服务器费用 + $tmp_company_info= $pc[$add_data['company_id']]; + if($tmp_company_info['has_server_fee'] == 1 && $tmp_company_info['server_fee'] >0){ + $server_count = $tmp_company_info['server_fee']; + $add_data['statement_info'][] = array( + "statement_begin_time"=>$statement_begin_time, + "statement_end_time"=>$statement_end_time, + 'statement_type'=>1, + "game_name"=>"服务器费用", + 'pay_amount'=>$server_count, + 'sum_money'=>$server_count, + ); + $add_data['statement_money'] -= $server_count; + $add_data['pay_amount'] -= $server_count;; + } } $add_data['statement_info'] = json_encode($add_data['statement_info'],JSON_UNESCAPED_UNICODE); @@ -667,7 +705,6 @@ class CompanyStatementSetController extends Controller { "s.pay_time"=>['between', [$begintime,$endtime]], ]; for ($i=0; $i field("group_concat(id) ids,count(id) count")->where("company_id = '{$company_id}'")->group("company_id")->find(); if($pres['count'] ==0 ){continue;} $spenMap['s.promote_id']=["in",$pres['ids']]; @@ -677,6 +714,11 @@ class CompanyStatementSetController extends Controller { ->select(); if(empty($list)){continue;} foreach($list as $k=>$v){ + try { + $res[$company_id]["pay_amount"] += $v['pay_amount']; + } catch (\Throwable $th) { + $res[$company_id]["pay_amount"] = $v['pay_amount']; + } if(isset($res[$company_id][$v['relation_game_id']])){ // $res[$company_id][$v['relation_game_id']]['pay_amount'] += $v['pay_amount']; @@ -687,7 +729,10 @@ class CompanyStatementSetController extends Controller { } } foreach($res as $k=>$v){ + $pcList[$k]["pay_amount"] = $v['pay_amount']; + unset($v['pay_amount']); $pcList[$k]['list'] = $v; + } } public function promoteUserPool($type,$stime,$recount = false){ @@ -1007,7 +1052,23 @@ class CompanyStatementSetController extends Controller { */ 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']; - } + } + protected function getCompanyRatio($paymount,$turnover_ratio) + { + $ratio = 0; + foreach($turnover_ratio as $k=>$v){ + if($v['instanceof'] == 1){ + if($paymount >= $v['turnover']){ + $ratio = $v['ratio']; + } + }else{ + if($paymount > $v['turnover']){ + $ratio = $v['ratio']; + } + } + } + return $ratio; + } /** * 重算接口 From f91b2a5dcef922bc70f128b2684c1a50c7a8c77a Mon Sep 17 00:00:00 2001 From: chenzhi <294767167@11qq.com> Date: Sat, 25 Jul 2020 11:31:23 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8B=E6=B8=B8?= =?UTF-8?q?=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 136094717..a1c0f4d8d 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -69,30 +69,30 @@ class CompanyStatementSetController extends Controller { echo $nowdate.":".PHP_EOL; echo "--周结begin".PHP_EOL; - $this->cpStatement(0,$stime); - echo "∟----CP周结统计ok".PHP_EOL; + // $this->cpStatement(0,$stime); + // echo "∟----CP周结统计ok".PHP_EOL; - $this->promoteCompanyStatement(0,$stime); - echo "∟----推广公司周结统计ok".PHP_EOL; + // $this->promoteCompanyStatement(0,$stime); + // echo "∟----推广公司周结统计ok".PHP_EOL; - $this->promoteUserPool(0,$stime); - echo "∟----推广个人周结ok".PHP_EOL; + // $this->promoteUserPool(0,$stime); + // echo "∟----推广个人周结ok".PHP_EOL; } if($d == 1){ echo $nowdate.":".PHP_EOL; echo "--月结&补点begin".PHP_EOL; - $this->cpStatement(1,$stime); - $this->cpStatement(2,$stime); - echo "∟----CP月结&补点统计ok".PHP_EOL; + // $this->cpStatement(1,$stime); + // $this->cpStatement(2,$stime); + // echo "∟----CP月结&补点统计ok".PHP_EOL; $this->promoteCompanyStatement(1,$stime); $this->promoteCompanyStatement(2,$stime); echo "∟----推广公司月结&补点统计ok".PHP_EOL; - $this->promoteUserPool(1,$stime); + // $this->promoteUserPool(1,$stime); // $this->promoteUserPool(2,$stime); - echo "∟----推广个人月结&补点统计ok".PHP_EOL; + // echo "∟----推广个人月结&补点统计ok".PHP_EOL; } }else{ echo $nowdate."非周一和月初,无需任何处理".PHP_EOL; @@ -450,7 +450,7 @@ class CompanyStatementSetController extends Controller { }else{ $where['settlement_type']=1; $pcDbRes = M("CompanyRelation","tab_")->where($where)->select(); - } + } $pcList=[]; $js_id = [];//己方公司 foreach ($pcDbRes as $k => $v) { @@ -502,8 +502,7 @@ class CompanyStatementSetController extends Controller { unset($tmpp); unset($js_id); $this->getPromoteCompanySpend($pcList,array_unique(array_keys($pcList)),$begintime,$endtime); - - + // dd($pcList); //数据整合 $verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]); $StatementDb = M("CompanyStatement","tab_"); @@ -513,14 +512,12 @@ class CompanyStatementSetController extends Controller { $RewardRecord = M("RewardRecord","tab_"); foreach($pcList as $k=>$v){ - if(!isset($pc[$k])){continue;}//不存在的公司不结算 if($pc[$k]['has_ratio'] == 1){ - $company_ratio = $this->getCompanyRatio($v['paymount'],$pc[$k]['turnover_ratio']); + $company_ratio = $this->getCompanyRatio($v['pay_amount'],$pc[$k]['turnover_ratio']); }else{ $company_ratio = 0; } - $add_data=[]; //1.获取甲乙方信息 if($v['first_company_type'] > 0){ @@ -705,6 +702,8 @@ class CompanyStatementSetController extends Controller { "s.pay_time"=>['between', [$begintime,$endtime]], ]; for ($i=0; $i field("group_concat(id) ids,count(id) count")->where("company_id = '{$company_id}'")->group("company_id")->find(); if($pres['count'] ==0 ){continue;} $spenMap['s.promote_id']=["in",$pres['ids']]; @@ -727,7 +726,7 @@ class CompanyStatementSetController extends Controller { $res[$company_id][$v['relation_game_id']]= $v; } } - } + } foreach($res as $k=>$v){ $pcList[$k]["pay_amount"] = $v['pay_amount']; unset($v['pay_amount']); From 7f01c3ff3978b18fd5ab5d5b587edaf3ed37df02 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 25 Jul 2020 13:29:39 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=8A=E6=B8=B8?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/CompanyStatementSetController.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index a1c0f4d8d..ecde2e76e 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -143,7 +143,7 @@ class CompanyStatementSetController extends Controller { $cp_id = implode(",",array_flip(array_flip(array_keys($cpList)))); $js_id = implode(",",array_unique($js_id)); //获取cp公司 - $tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,company_type,ali_user,ali_account,has_advance_charge,has_server_fee,server_fee")->where(["id"=>['in',$cp_id]])->select(); + $tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank,channel_rate,invoice_rate,taxation_rate,company_type,ali_user,ali_account,has_advance_charge,has_server_fee,server_fee")->where(["id"=>['in',$cp_id]])->select(); $cp =[]; foreach ($tmpp as $v) { $cp[$v['id']]=$v; @@ -242,9 +242,9 @@ class CompanyStatementSetController extends Controller { $add_data['company_belong']=9;//上游 $add_data['company_type']=$cp[$add_data['company_id']]['company_type']; $add_data['is_payment']=$v['is_payment']; - //获取渠道及发票税率 + //获取渠道及税费费率 $promote_ratio = $cp[$add_data['company_id']]['channel_rate'] ?? 0; - $fax_ratio = $cp[$add_data['company_id']]['invoice_rate'] ?? 0; + $fax_ratio = $cp[$add_data['company_id']]['taxation_rate'] ?? 0; //游戏统计 if(!isset($v['list'])){continue;} foreach($v['list'] as $ke=>$va){ From f70d8cb8a7869cc6c5c508b55241f41c651b9e7e Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 25 Jul 2020 16:03:25 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 134 ++++++++++++++---- 1 file changed, 108 insertions(+), 26 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index ecde2e76e..ce425f839 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -75,8 +75,8 @@ class CompanyStatementSetController extends Controller { // $this->promoteCompanyStatement(0,$stime); // echo "∟----推广公司周结统计ok".PHP_EOL; - // $this->promoteUserPool(0,$stime); - // echo "∟----推广个人周结ok".PHP_EOL; + $this->promoteUserPool(0,$stime); + echo "∟----推广个人周结ok".PHP_EOL; } if($d == 1){ echo $nowdate.":".PHP_EOL; @@ -86,13 +86,13 @@ class CompanyStatementSetController extends Controller { // $this->cpStatement(2,$stime); // echo "∟----CP月结&补点统计ok".PHP_EOL; - $this->promoteCompanyStatement(1,$stime); - $this->promoteCompanyStatement(2,$stime); - echo "∟----推广公司月结&补点统计ok".PHP_EOL; + // $this->promoteCompanyStatement(1,$stime); + // $this->promoteCompanyStatement(2,$stime); + // echo "∟----推广公司月结&补点统计ok".PHP_EOL; - // $this->promoteUserPool(1,$stime); - // $this->promoteUserPool(2,$stime); - // echo "∟----推广个人月结&补点统计ok".PHP_EOL; + $this->promoteUserPool(1,$stime); + $this->promoteUserPool(2,$stime); + echo "∟----推广个人月结&补点统计ok".PHP_EOL; } }else{ echo $nowdate."非周一和月初,无需任何处理".PHP_EOL; @@ -509,7 +509,7 @@ class CompanyStatementSetController extends Controller { $statement_begin_time = date("Y-m-d",$begintime); $statement_end_time = date("Y-m-d",$endtime); - $RewardRecord = M("RewardRecord","tab_"); + $RewardRecord = M("RewardDetail","tab_"); foreach($pcList as $k=>$v){ if(!isset($pc[$k])){continue;}//不存在的公司不结算 @@ -597,7 +597,7 @@ class CompanyStatementSetController extends Controller { if($type < 2){ //非补点计算奖罚 $rrmap = array( - "reward_time" => ['between', [$begintime,$endtime]], + "confirm_time" => ['between', [$begintime,$endtime]], "company_type"=>2, "company_id"=>$add_data['company_id'], "settlement_type"=>2, @@ -767,13 +767,18 @@ class CompanyStatementSetController extends Controller { if($type == 0){//周结 $this->doPromoteUserPool($user,$users,$type,$stime,$recount); - }else{ + }else if($type == 1){ $users['withdraw_type'] = 1; $user['withdraw_type'] = 1; //月结&补点 $this->doPromoteUserPool($user,$users,1,$stime,$recount); + + }else{ + $users['withdraw_type'] = 1; + $user['withdraw_type'] = 1; $this->doPromoteUserPool($user,$users,2,$stime,$recount); } + $this->savePromotateUserPool($users); $this->savePromotateUserPool($user); } @@ -812,13 +817,28 @@ class CompanyStatementSetController extends Controller { } //获取pc公司 $pc_id = implode(",",array_flip(array_flip(array_keys($pcList)))); - $tmpp = M("PromoteCompany","tab_")->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,company_belong,company_type,ali_user,ali_account") + $tmpp = M("PromoteCompany","tab_") + ->field("id,uid,company_name partner,settlement_contact link_man,contact_phone link_phone,bank_name opening_bank,bank_address payee_name,bank_card bank_account,fax_ratio,taxation_rate,company_belong,company_type,ali_user,ali_account,has_server_fee,server_fee,has_ratio,turnover_ratio") ->where(["id"=>['in',$pc_id],"company_type"=>2]) ->select(); if(count($tmpp)<1){return;} $pc =[]; + $Promote = M("Promote","tab_"); foreach ($tmpp as $v) { + $p_map = [ + "company_id"=>$v['id'], + "withdraw_done"=>1 + ]; + $pres = $Promote->field("alipay_account,alipay_real_name")->where($p_map)->find(); + if(!empty($pres) && !empty($pres['alipay_account']) && !empty($pres['alipay_real_name'])){ + $v['ali_user'] = $pres['alipay_real_name']; + $v['ali_account'] = $pres['alipay_account']; + } + if($v['has_ratio']){ + $v['turnover_ratio'] = json_decode($v['turnover_ratio'],true); + } + $pc[$v['id']]=$v; $pc[$v['id']]['is_payment']=$pcList[$v['id']]['is_payment']; } @@ -828,11 +848,18 @@ class CompanyStatementSetController extends Controller { $StatementDb = M("CompanyStatement","tab_"); $statement_begin_time = date("Y-m-d",$begintime); $statement_end_time = date("Y-m-d",$endtime); - $RewardRecord = M("RewardRecord","tab_"); + // $RewardRecord = M("RewardRecord","tab_"); $LackStatement = M("company_lack_statement_info","tab_"); $StatementInfo = M("company_statement_info","tab_"); foreach($pc as $k=>&$v){ + $fax_ratio = $v['taxation_rate']; + $RewardRecordRes = $this->getPromoteUserRewardRecord($v['id'],$begintime,$endtime); + if($v['has_ratio'] == 1){ + $company_ratio = $this->getCompanyRatio($v['pay_amount'],$pc[$k]['turnover_ratio']); + }else{ + $company_ratio = 0; + } //获取其他信息 $v = $this->getCompanyOtherInfo($v,$k); if($v['is_payment'] == 1){ @@ -846,6 +873,21 @@ class CompanyStatementSetController extends Controller { $v['reward'] = 0; $v['platform_amount'] = 0; if(!isset($v['list'])){continue;} + //服务器费用 + if ($type < 2) { + if ($v['has_server_fee'] == 1 && $v['server_fee'] > 0) { + $v['statement_info'][] = [ + "game_name"=>"服务器费用", + "sum_money"=>-$v['server_fee'], + "pay_amount"=>-$v['server_fee'], + 'statement_type'=>1, + "statement_begin_time"=>$statement_begin_time, + "statement_end_time"=>$statement_end_time + ]; + $v['pay_amount'] -= $v['server_fee']; + $v['statement_money'] -= $v['server_fee']; + } + } foreach($v['list'] as $ke=>$va){ $game =[]; $game['pay_amount'] =$va['pay_amount']; @@ -856,13 +898,14 @@ class CompanyStatementSetController extends Controller { if($type == 1){ $tratio = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong); + $tratio += $company_ratio; }elseif($type == 0){ $tratio = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong); }else{ //补点 $tratio1 = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],true,$company_belong);; $tratio2 = getGamePromoteCompanyRadio($v['id'],$va['relation_game_id'],$endtime,$va['pay_amount'],false,$company_belong); - $tratio = $tratio1-$tratio2; + $tratio = $tratio1-$tratio2+$company_ratio; if($tratio <= 0){ continue; } @@ -877,22 +920,20 @@ class CompanyStatementSetController extends Controller { //判断是否是个人 if($type < 2){ //非补点 - $rrmap = array( - "reward_time" => ['between', [$begintime,$endtime]], - "company_type"=>2, - "company_id"=>$k, - "relation_game_id"=>$va['relation_game_id'] - ); - $rrfres =$RewardRecord->field("IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count,IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count")->where($rrmap)->find(); - $v['fine'] += $rrfres['fine_count']; - $v['reward'] += $rrfres['reward_count']; - + if($RewardRecordRes){ + $rrfres = $RewardRecordRes[$va['relation_game_id']]; + }else{ + $rrfres = [ + 'reward_count'=>0, + 'fine_count'=>0, + ]; + } $game['reward'] = $rrfres['reward_count']; $game['fine'] = $rrfres['fine_count']; $game['sum_money']=round($va['pay_amount']*$tratio/100,2)+$game['reward']-$game['fine']; }else{ - $game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*(1-渠道费)*分成比例*(1-税费费率) + $game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*(分成比例+补点比例)*(1-税费费率) } $v['statement_money'] += $game['sum_money']; @@ -1051,7 +1092,12 @@ class CompanyStatementSetController extends Controller { */ 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']; - } + } + /** + * 获取公司比例加成 + * @param [type] $paymount 支付金额 + * @param [type] $turnover_ratio 梯度 + */ protected function getCompanyRatio($paymount,$turnover_ratio) { $ratio = 0; @@ -1068,6 +1114,42 @@ class CompanyStatementSetController extends Controller { } return $ratio; } + /** + * 获取公司比例加成 + * @param [type] $paymount 支付金额 + * @param [type] $turnover_ratio 梯度 + */ + protected function getPromoteUserRewardRecord($cpmpamy_id,$begintime,$endtime) + { + //获取所有公司的奖罚 + $rrmap = array( + "d.confirm_time" => ['between', [$begintime,$endtime]], + "d.company_type"=>2, + "d.company_id"=>$cpmpamy_id, + "d.settlement_type"=>2, + ); + $rfres = M("RewardDetail","tab_") + ->alias("d") + ->field(" + IFNULL(SUM(CASE WHEN type = 1 THEN amount ELSE 0 END),0) as reward_count, + IFNULL(SUM(CASE WHEN type = 2 THEN amount ELSE 0 END),0) as fine_count, + r.relation_game_id + ") + ->where($rrmap) + ->join("tab_reward_record as r on d.record_id = r.id") + ->group("record_id,company_id") + ->select(); + if(empty($rfres)){ + return false; + }else{ + $s = []; + foreach($rfres as $k=>$v){ + $s[$v['relation_game_id']] = $v; + } + return $s; + } + + } /** * 重算接口 From 3cbc769bce2d241fb5c0175e6d2856895b36b4f3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 25 Jul 2020 16:12:03 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/CompanyStatementSetController.class.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index ce425f839..0f3a8b554 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -930,11 +930,8 @@ class CompanyStatementSetController extends Controller { } $game['reward'] = $rrfres['reward_count']; $game['fine'] = $rrfres['fine_count']; - - $game['sum_money']=round($va['pay_amount']*$tratio/100,2)+$game['reward']-$game['fine']; - }else{ - $game['sum_money']=round($va['pay_amount']*$tratio*(100-$fax_ratio)/(100*100),2);//结算金额=平台总额*(分成比例+补点比例)*(1-税费费率) } + $game['sum_money']=round($va['pay_amount']*$tratio/100,2)+$game['reward']-$game['fine']; //个人等于 结算金额*比例-罚款+奖励 $v['statement_money'] += $game['sum_money']; $game['fax_ratio']=$fax_ratio; From 6b9358c651a6331025ce9ea41c797f72dbfa697e Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 25 Jul 2020 16:23:06 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementSetController.class.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 0f3a8b554..e562438c2 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -69,11 +69,11 @@ class CompanyStatementSetController extends Controller { echo $nowdate.":".PHP_EOL; echo "--周结begin".PHP_EOL; - // $this->cpStatement(0,$stime); - // echo "∟----CP周结统计ok".PHP_EOL; + $this->cpStatement(0,$stime); + echo "∟----CP周结统计ok".PHP_EOL; - // $this->promoteCompanyStatement(0,$stime); - // echo "∟----推广公司周结统计ok".PHP_EOL; + $this->promoteCompanyStatement(0,$stime); + echo "∟----推广公司周结统计ok".PHP_EOL; $this->promoteUserPool(0,$stime); echo "∟----推广个人周结ok".PHP_EOL; @@ -82,13 +82,13 @@ class CompanyStatementSetController extends Controller { echo $nowdate.":".PHP_EOL; echo "--月结&补点begin".PHP_EOL; - // $this->cpStatement(1,$stime); - // $this->cpStatement(2,$stime); - // echo "∟----CP月结&补点统计ok".PHP_EOL; + $this->cpStatement(1,$stime); + $this->cpStatement(2,$stime); + echo "∟----CP月结&补点统计ok".PHP_EOL; - // $this->promoteCompanyStatement(1,$stime); - // $this->promoteCompanyStatement(2,$stime); - // echo "∟----推广公司月结&补点统计ok".PHP_EOL; + $this->promoteCompanyStatement(1,$stime); + $this->promoteCompanyStatement(2,$stime); + echo "∟----推广公司月结&补点统计ok".PHP_EOL; $this->promoteUserPool(1,$stime); $this->promoteUserPool(2,$stime); @@ -774,8 +774,8 @@ class CompanyStatementSetController extends Controller { $this->doPromoteUserPool($user,$users,1,$stime,$recount); }else{ - $users['withdraw_type'] = 1; - $user['withdraw_type'] = 1; + $users['withdraw_type'] = 2; + $user['withdraw_type'] = 2; $this->doPromoteUserPool($user,$users,2,$stime,$recount); } From 3ef8061e3e9b9924471edfb781c4ca8f5310eb4f Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 25 Jul 2020 16:34:38 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=AA=E4=BA=BA0?= =?UTF-8?q?=E5=80=BC=E9=87=8D=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/CompanyStatementSetController.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index e562438c2..d13fb3f66 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -6,6 +6,7 @@ use Think\Controller; /** * 聚合渠道结算接口对接 * @author cz + * TODO: 罚款的游戏没有流水不统计,补点为0 无法重算 */ class CompanyStatementSetController extends Controller { public $cpapihost; @@ -1046,7 +1047,9 @@ class CompanyStatementSetController extends Controller { * 保存信息汇总信息 */ public function savePromotateUserPool($data){ - if(empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ return;} + if($data['withdraw_type'] == 2 && empty($data['create_lack_ids']) && empty($data['del_lack_ids']) && empty($data['info_ids'])){ //补点为空不重算 + return ; + } if($data['statement_money'] == 0){ $data['verify_status'] = 5; $data['verify_log'] = json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s"),"verify_user"=>"system","verify_time"=>date("Y-m-d H:i:s"),"payment_user"=>"system","payment_time"=>date("Y-m-d H:i:s")]); From a69b21dd14ac018255e2b3a465a948dc6f3bdb47 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Sat, 25 Jul 2020 18:25:14 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E6=B1=87=E6=80=BB=E5=8D=95=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=91=A8=E6=9C=88=E7=BB=93=E5=AE=A1=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementController.class.php | 7 ++++++- .../CompanyStatementPoolController.class.php | 19 ++++++++++++++--- .../View/CompanyStatementPool/lists.html | 12 ++++++++++- .../View/CompanyStatementPool/viewPuPool.html | 21 ++++++++++++++----- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index 0743c12af..4bfb3d8b8 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -498,7 +498,12 @@ class CompanyStatementController extends ThinkController $v['verify_status'] = 5; $v['verify_log'] = json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s"),"verify_user"=>"system","verify_time"=>date("Y-m-d H:i:s"),"payment_user"=>"system","payment_time"=>date("Y-m-d H:i:s")]); } - + //判断周月结 + if(($v["statement_end_time"]-$v['statement_begin_time']) > 7*24*3600){ + $v["withdraw_type"] = 1; + }else{ + $v["withdraw_type"] = 0; + } $pool_id = $Pool->add($v); if($pool_id == false){ $this->ajaxReturn(array('status' => 0,"info"=>"汇总失败")); diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index 8882d4205..88a25469b 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -16,7 +16,11 @@ class CompanyStatementPoolController extends ThinkController "1"=>"是", "2"=>"否" ]; - + public $WithdrawType = [ + "0"=>"周结", + "1"=>"月结", + "2"=>"下游个人补点" + ]; public $VerifyStatus=[ "-2"=>"拒绝打款", "-1"=>"审批拒绝", @@ -94,6 +98,9 @@ class CompanyStatementPoolController extends ThinkController if(isset($_REQUEST['is_payment'])){ $map['is_payment'] = $_REQUEST['is_payment']; } + if(isset($_REQUEST['withdraw_type'])){ + $map['withdraw_type'] = $_REQUEST['withdraw_type']; + } // $this->checkListOrCountAuthRestMap($map);//导出权限 @@ -116,6 +123,7 @@ class CompanyStatementPoolController extends ThinkController $v["valid"] = "{$v['statement_begin_time']} ~ {$v['statement_end_time']}"; $v['ext_file_type'] = empty($v['ext_file']) ? "无" : "有"; + $v['withdraw_type'] = $this->WithdrawType[$v['withdraw_type']];; $v['verify_log'] = json_decode($v['verify_log'], true); if (isset($params['export'])) { @@ -177,6 +185,7 @@ class CompanyStatementPoolController extends ThinkController $this->assign('CompanyType',$this->CompanyType); $this->assign('IsPayment',$this->IsPayment); $this->assign('VerifyStatus',$this->VerifyStatus); + $this->assign('WithdrawType',$this->WithdrawType); $this->display(); } @@ -232,7 +241,11 @@ class CompanyStatementPoolController extends ThinkController if($is_export){ //J3*(K3+L3)+M3-N3 - $va['sum_money'] = "=J{$line}*(K{$line}+L{$line})+M{$line}-N{$line}"; + if($va['statement_type'] > 0){ //罚款服务器费用 + $va['sum_money'] = "=J{$line}"; + }else{ + $va['sum_money'] = "=J{$line}*(K{$line}+L{$line})+M{$line}-N{$line}"; + } $count['sum_money_exp'] .= "O{$line}+"; $count['platform_amount_exp'] .= "J{$line}+"; @@ -284,7 +297,7 @@ class CompanyStatementPoolController extends ThinkController if($is_export){ $v['statement_money_exp'] .= "H{$line}+"; - + $va['d_statement_money'] = "=D{$line}*(1-G{$line})*(E{$line}+F{$line})"; $count['platform_amount_exp'] .= "D{$line}+"; diff --git a/Application/Admin/View/CompanyStatementPool/lists.html b/Application/Admin/View/CompanyStatementPool/lists.html index d83953056..d40073fee 100644 --- a/Application/Admin/View/CompanyStatementPool/lists.html +++ b/Application/Admin/View/CompanyStatementPool/lists.html @@ -102,6 +102,15 @@ +
+ +
+
+
+ +
+
 -  @@ -186,10 +195,11 @@ 结算金额 结算流水 创建记录 + 管理员审核 审批状态 + 汇总状态 对外发起 合作确认 - 汇总状态 操作 @@ -204,7 +214,7 @@ - + {$data.company_name} {$data.company_belong} {$data.valid} @@ -215,6 +225,17 @@ {$data.create} +
+ {$data.admin} +
+ +
+ {$data.admin} +
+
+ + +
{$data.verify}
@@ -224,10 +245,8 @@
- {$data.launch} - {$data.confirm} - +
{$data.pool}
@@ -237,6 +256,8 @@
+ {$data.launch} + {$data.confirm} {$vo} @@ -244,7 +265,7 @@ - 合计结算总金额: {$count.statement_money}     结算总流水: {$count['platform_amount']} (补点不重复统计在内) + 合计结算总金额: {$count.statement_money}     结算总流水: {$count['platform_amount']} (补点不重复统计在内) @@ -386,7 +407,7 @@ //设置对账网址 var order_url = window.location.protocol+"//"+window.location.host+"/admin.php?s=/Public/cp_login.html"; - $("#order_url").html("流程说明:结算自动生成对账单--->财务审核对账单--->发起对外对账--->合作方进行确认--->进入报销流程【合作方确认地址:"+order_url+"】"); + $("#order_url").html("流程说明:结算自动生成对账单--->管理员审核--->财务审核对账单--->发起汇总 / 确认流程: 发起对外对账--->合作方进行确认【合作方确认地址:"+order_url+"】"); $("#updateNewStatement").on("click",function(){ layer.confirm("新增结算需要花费2分钟左右时间,并且只计算一个月内的新增结算,请勿在中途关闭页面,无需新增结算请取消",{title:false}, function(index){ @@ -428,33 +449,38 @@ }); }); - $("#verifyAgree,#verifyRefuse,#launch,#pool,#updateStatement").on("click",function(){ + $("#adminAgree,#adminRefuse,#verifyAgree,#verifyRefuse,#pool,#updateStatement").on("click",function(){ var id = $(this).attr("id"); - if(id == "verifyAgree"){ - var opname = "审批通过"; - var opurl = "{:U('verifyAgree')}"; + if(id == "adminAgree"){ + var opname = "管理员审批通过"; + var opurl = "{:U('adminAgree')}"; + var opst ="[未进行审批]"; + var status = [0]; + }else if(id=="adminRefuse"){ + var opname = "管理员审批拒绝"; + var opurl = "{:U('adminRefuse')}"; var opst ="[未进行审批]"; var status = [0]; + }else if(id == "verifyAgree"){ + var opname = "审批通过"; + var opurl = "{:U('verifyAgree')}"; + var opst ="[管理员审批通过]"; + var status = [1]; }else if(id=="verifyRefuse"){ var opname = "审批拒绝"; var opurl = "{:U('verifyRefuse')}"; - var opst ="[未进行审批]"; - var status = [0]; - }else if(id=="launch"){ - var opname = "对外发起"; - var opurl = "{:U('launch')}"; - var opst ="[审批通过]"; + var opst ="[管理员审批通过]"; var status = [1]; }else if(id=="pool"){ var opname = "发起汇总"; var opurl = "{:U('pool')}"; - var opst ="[合作方确认]"; - var status = [3]; + var opst ="[审批通过]"; + var status = [2]; }else if(id=="updateStatement"){ var opname = "重算金额"; var opurl = "{:U('updateStatement')}"; - var opst ="[汇总撤销,审批拒绝,未进行审批,审批通过,对外发起]"; - var status = [-2,-1,0,1,2]; + var opst ="[汇总撤销,管理员审批拒绝,审批拒绝,未进行审批,管理员审批通过,审批通过]"; + var status = [-3,-2,-1,0,1,2]; var confirm = true; } var confirm = confirm ? confirm :false; @@ -521,6 +547,49 @@ }); } }) + $("#launch").on("click",function(){ + var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + if($(elem).data("confirm") == 0){ + return $(elem).val(); + } + }).get(); + if(text.length < 1){ + layer.msg("" + '无需要进行[对外发起]的申请,仅[未发起]状态可以进行[对外发起]操作'); + return; + } + text = text.join(","); + layer.confirm('【警告】[对外发起]将不可回退,如需继续请点击确认', { + btn: ['确认','取消'], + title:false + }, function(index){ + layer.close(index); + _doAgreeApply(); + }); + function _doAgreeApply(){ + //执行 + layer.load(2); + $.ajax({ + type: "POST", + url: "{:U('launch')}", + dataType: 'json', + async: true, + data: {ids:text}, + success:function(data){ + layer.closeAll('loading'); + if(data.status==1){ + layer.msg("" + data.info + ""); + setTimeout(function(){ + window.location.reload(); + },1500); + }else{ + layer.msg("" + data.info + ""); + return false; + } + } + }); + } + + }) $("#export").click(function () { var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { diff --git a/Data/update.sql b/Data/update.sql index 9784407ca..b5a5cedf9 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2241,4 +2241,47 @@ INSERT INTO `tab_payment_member` (`id`, `real_name`, `mobile`, `last_login_time` ALTER TABLE `tab_game` ADD COLUMN `select_package_name` tinyint(2) NOT NULL DEFAULT 0 COMMENT '结算包名 0:原包名 1:现包名' AFTER `original_package_name`; +--chenzhi 新增结算发起 +CREATE TABLE `tab_company_statement` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键', + `withdraw_type` tinyint(2) DEFAULT '0' COMMENT '对账类型(0-周结 1月结 2补点)', + `company_id` int(11) DEFAULT '0' COMMENT '对账公司id', + `company_name` varchar(60) NOT NULL DEFAULT '' COMMENT '对账公司名称', + `company_belong` tinyint(1) NOT NULL DEFAULT '0' COMMENT '工会归属:0-下游内团;1-下游外团 2-下游分发联盟 3 下游无,9:上游', + `company_type` tinyint(3) NOT NULL DEFAULT '1' COMMENT '公司性质:1-公司 2-个人', + `is_payment` tinyint(3) NOT NULL DEFAULT '1' COMMENT '是否需要打款:1-是 2-否(线下)', + + `statement_begin_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账开始时间', + `statement_end_time` int(11) NOT NULL DEFAULT '0' COMMENT '对账截止时间', + + `statement_money` decimal(10,2) DEFAULT '0.00' COMMENT '对账金额', + `pay_amount` decimal(10,2) DEFAULT '0.00' COMMENT '总计', + `platform_amount` decimal(10,2) DEFAULT '0.00' COMMENT '平台流水金额', + + `verify_status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '审核状态 -2:汇总驳回 -1审批拒绝 0:系统生成 1:审核通过 2:对外发起 3:合作确认 4:汇总', + `verify_log` text NOT NULL COMMENT '审批相关信息json', + `pay_type` tinyint(2) DEFAULT '0' COMMENT '1甲方收款;2乙方收款', + `first_party_info` text NOT NULL COMMENT '甲方相关信息json', + `second_party_info` text NOT NULL COMMENT '乙方相关信息json', + `statement_info` text NOT NULL COMMENT '订单相关信息json', + `op_time` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间', + `remark` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '备注', + PRIMARY KEY (`id`), + KEY `withdraw_type` (`withdraw_type`) USING BTREE, + KEY `company_id` (`company_id`) USING BTREE, + KEY `statement_begin_time` (`statement_begin_time`) USING BTREE, + KEY `statement_end_time` (`statement_end_time`) USING BTREE, + KEY `verify_status` (`verify_status`) USING BTREE, + KEY `op_time` (`op_time`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='聚合上游联运上下游对账单'; + + + +ALTER TABLE `tab_company_statement` +ADD COLUMN `confirm_status` tinyint(2) NOT NULL DEFAULT 0 COMMENT '确认状态 0:未处理 1:发起 2审核' AFTER `verify_log`; + +ALTER TABLE `tab_company_statement` +ADD COLUMN `confirm_log` text COMMENT '确认信息' AFTER `confirm_status`; +ALTER TABLE `tab_company_statement` +MODIFY COLUMN `verify_status` tinyint(2) NOT NULL DEFAULT 0 COMMENT '审核状态 -3:汇总驳回 -2:审核拒绝 -1管理员审批拒绝 0:系统生成 1:管理员审核通过 2:审核通过 3:汇总' AFTER `platform_amount`; \ No newline at end of file