From 58eb6a0e12664c7ae7cb60a10787a167a4dc53a6 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 6 Feb 2020 20:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ecp=E5=85=AC=E5=8F=B8=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=A5=96=E7=BD=9A=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatementController.class.php | 98 +++++++++--- .../View/Statement/createCpStatement.html | 139 +++++++++++++----- .../Admin/View/Statement/editCpStatement.html | 48 +++--- 3 files changed, 212 insertions(+), 73 deletions(-) diff --git a/Application/Admin/Controller/StatementController.class.php b/Application/Admin/Controller/StatementController.class.php index ba9fb63f8..69042b87d 100644 --- a/Application/Admin/Controller/StatementController.class.php +++ b/Application/Admin/Controller/StatementController.class.php @@ -18,8 +18,14 @@ class StatementController extends ThinkController $first_party_info = json_decode($dbres['first_party_info'],true); $second_party_info = json_decode($dbres['second_party_info'],true); $statement_info = json_decode($dbres['statement_info'],true); - $fine = array_pop($statement_info); + if($dbres['company_name'] == $first_party_info['partner']){ + $first_partner_type=0; + }else{ + $first_partner_type=1; + } + // $fine = array_pop($statement_info); $senddata = array( + "first_partner_type"=>$first_partner_type, "first_part_company"=>$first_party_info['partner'], "second_part_company"=>$second_party_info['partner'], "statement_type"=>$_REQUEST['pay_type'] == 0 ? 1 :0, @@ -27,13 +33,13 @@ class StatementController extends ThinkController "second_party_info"=>$second_party_info, "statement_info"=>$statement_info, "statement_count"=>array("sum_money"=>$dbres['statement_money'],"pay_amount"=>$dbres['pay_amount']), - "fine"=>$fine['sum_money'], + "fine"=>0, "statement_begin_time"=>date("Y-m-d",$dbres['statement_begin_time']), "statement_end_time"=>date("Y-m-d",$dbres['statement_end_time']) ); $this->assign("data",$senddata); if($_REQUEST['pay_type'] == 0){ - $this->assign("company",$dbres['company_name']); + $this->assign("company",$second_party_info['partner']); }else{ $this->assign("company",$first_party_info['partner']); } @@ -56,15 +62,20 @@ class StatementController extends ThinkController $this->ajaxReturn(array("error"=>"database error","code"=>2000)); } } + public function getCompanyList() + { + $data = array(); + $data['ptCompany']= M("CompanyInfo","tab_")->field('id,partner')->select(); + $data['cpCompany']= getPartner(); + $this->ajaxReturn(array("success"=>$data,"code"=>2000)); + } //获取推广公司基础信息 public function getCpCompanyInfo() { $CompanyId = $_REQUEST['company_id']; - if($CompanyId == 0){ - $mycompany = M("tool","tab_")->field("config")->where("name='company_info'")->find(); - $info = json_decode($mycompany['config'],true); - $info['id'] = 0; - unset($info['status']); + $company_type = $_REQUEST['company_type']; + if($company_type == 'pt'){ + $info = M("CompanyInfo","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("id = '{$CompanyId}'")->find(); }else{ $info = M("partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("id = '{$CompanyId}'")->find(); } @@ -81,7 +92,8 @@ class StatementController extends ThinkController $map["pay_status"] = 1; $CompanyId = $_REQUEST['company_id']; //对账公司id - $statement_type = $_REQUEST['statement_type']; + $statement_type = $_REQUEST['statement_type'];//付款方 + $first_partner_type = $_REQUEST['first_partner_type'];//甲方类型:0cp,1pt $is_month = false;//是否是月结判断,非月结无需梯度计算 if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { @@ -164,8 +176,14 @@ class StatementController extends ThinkController // $redio = $ratiores[0]['ratio']; // } $redio = getGameCpRadio($v['game_id'],$v['pay_amount'],$is_month);//获取分成比例 - $v['second_ratio'] = $redio; - $v['first_ratio'] = (100-$redio); + if($first_partner_type==0){ + //甲方cp + $v['first_ratio'] = round($redio,2); + $v['second_ratio'] = round((100-$redio),2); + }else{ + $v['second_ratio'] = round($redio,2); + $v['first_ratio'] = round((100-$redio),2); + } if($statement_type == 0){ $v['sum_money'] = round($v['pay_amount']*$v['first_ratio']/100,2); }else{ @@ -180,6 +198,41 @@ class StatementController extends ThinkController $v['statement_end_time']=$_REQUEST['time_end']; $v['statement_type']=0; } + //获取奖罚 + $rrmap = array( + "reward_time" => ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]], + ); + $rfres = M("RewardRecord","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 + ") + ->where($rrmap)->find(); + if($rfres['reward_count'] > 0){ + $list[] = array( + "statement_begin_time"=>$_REQUEST['time_start'], + "statement_end_time"=>$_REQUEST['time_end'], + 'statement_type'=>2, + "game_name"=>"奖励", + 'pay_amount'=>$rfres['reward_count'], + 'sum_money'=>$rfres['reward_count'], + ); + $countarr['pay_amount'] +=$rfres['reward_count']; + $countarr['sum_money']+=$rfres['reward_count']; + } + if($rfres['fine_count'] > 0){ + $list[] = array( + "statement_begin_time"=>$_REQUEST['time_start'], + "statement_end_time"=>$_REQUEST['time_end'], + 'statement_type'=>1, + "game_name"=>"罚款", + 'pay_amount'=>$rfres['fine_count'], + 'sum_money'=>$rfres['fine_count'], + ); + $countarr['pay_amount'] -= $rfres['fine_count']; + $countarr['sum_money'] -= $rfres['fine_count']; + } + $countarr['pay_amount'] = round($countarr['pay_amount'],2); $countarr['sum_money'] = round($countarr['sum_money'],2); @@ -188,19 +241,26 @@ class StatementController extends ThinkController } //添加数据 public function doAddCpStatement($id = 0){ + $first_partner_type = $_REQUEST['first_partner_type']; + if($first_partner_type == 0){ + //甲方cp + $company = $_REQUEST['first_party_info']; + }else{ + $company =$_REQUEST['second_party_info']; + } $second_party_info = $_REQUEST['second_party_info']; $statement_info = $_REQUEST['statement_info']; - $statement_info[] = array( - "sum_money"=>$_REQUEST['fine'], - "type_name"=>"罚款", - "statement_type"=>1 - ); + // $statement_info[] = array( + // "sum_money"=>$_REQUEST['fine'], + // "type_name"=>"罚款", + // "statement_type"=>1 + // ); //拼凑数据 $adddata = array( "statement_type"=>0, - "company_id"=>$second_party_info['id'], - "company_name"=>$second_party_info['partner'], - "link_phone"=>$second_party_info['link_phone'], + "company_id"=>$company['id'], + "company_name"=>$company['partner'], + "link_phone"=>$company['link_phone'], "statement_begin_time"=>strtotime($_REQUEST['statement_begin_time']), "statement_end_time"=>strtotime($_REQUEST['statement_end_time']), 'create_time'=>time(), diff --git a/Application/Admin/View/Statement/createCpStatement.html b/Application/Admin/View/Statement/createCpStatement.html index 07efd2329..ed7f3cc8c 100644 --- a/Application/Admin/View/Statement/createCpStatement.html +++ b/Application/Admin/View/Statement/createCpStatement.html @@ -89,16 +89,24 @@
+ + + + @@ -107,25 +115,25 @@ @@ -135,16 +143,16 @@
公司类型: +
+ +
+
甲方:
联系人: - +
联系电话: - +
邮寄地址: - +
公司税号: - +
+ + + + @@ -381,26 +389,34 @@ -
乙方: