From e1d624fe8b6b62cb421c2b0fddb45e3beb8308b3 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 2 Jun 2020 18:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA=E5=B9=B6?= =?UTF-8?q?=E8=81=9A=E5=90=88=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 28 ++++-- .../CompanyStatementController.class.php | 99 +++++++++++++++++++ .../CompanyStatementSetController.class.php | 6 ++ .../Admin/View/CompanyStatement/lists.html | 8 +- 4 files changed, 131 insertions(+), 10 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 40d5da0e9..5dcb80a9f 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1896,6 +1896,8 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ $objPHPExcel->getActiveSheet()->setCellValue('C7', "支付给:".$data['receive_company']['partner']); //增加支付给对应公司 $line = 10; + //记录统计项目 + $pay_amount_str = "="; //增加结算记录 foreach ($data['statement_info'] as $key => $value) { $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1)->mergeCells("J$line:K$line"); @@ -1920,8 +1922,14 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ $objPHPExcel->getActiveSheet()->setCellValue('H'.$line, $value['promote_ratio'] . '%'); $objPHPExcel->getActiveSheet()->setCellValue('I'.$line, $value['fax_ratio']. '%'); $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['pay_amount']); - $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']); + // $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']); + if ($data['pay_type'] == 2) { + $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, "=E{$line}*(1-H{$line})*G{$line}*(1-I{$line})"); + }else{ + $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, "=E{$line}*(1-H{$line})*F{$line}*(1-I{$line})"); + } } + $pay_amount_str .= "J{$line}+"; $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $product_name); $line++; @@ -1929,9 +1937,11 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ //合计 $objPHPExcel->getActiveSheet()->setCellValue("E" . ($line), $data['pay_amount']); - $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), $data['statement_money']); + // $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), $data['statement_money']); + $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), trim($pay_amount_str,"+")); - $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), $big_all_sum_money); //本月分成总金额(人民币大写) + // $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), $big_all_sum_money); //本月分成总金额(人民币大写) + $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), "=J{$line}"); //本月分成总金额(人民币大写) //收款方 $objPHPExcel->getActiveSheet()->setCellValue("D" . ($line+2), $data['receive_company']['payee_name']); @@ -1985,7 +1995,7 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al $line = 3; - + $pay_amount_str = "="; foreach ($data['statement_info'] as $key => $value) { $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1); $objPHPExcel->getActiveSheet()->removeConditionalStyles(); @@ -2011,18 +2021,20 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al } $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['fax_ratio'] . '%'); $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['pay_amount']); - $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']); + // $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']); + $objPHPExcel->getActiveSheet()->setCellValue('F'.$line,"=C{$line}*D{$line}*(1-E{$line})"); } $objPHPExcel->getActiveSheet()->setCellValue('B'.$line, $product_name); - + $pay_amount_str .= "F{$line}+"; $line++; } $objPHPExcel->getActiveSheet()->setCellValue('C'.($line), $data['pay_amount']);//合计-平台总额 - $objPHPExcel->getActiveSheet()->setCellValue('F'.($line), $data['statement_money']);//合计-结算金额 + $objPHPExcel->getActiveSheet()->setCellValue('F'.($line), trim($pay_amount_str,"+"));//合计-结算金额 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额 + // $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), "=F{$line}");//大写支付结算金额 //甲方信息 $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['pay_company']['partner']);//甲方 $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['pay_company']['link_man']);//联系人 diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index e9f9c4579..8b2eb8090 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -365,6 +365,105 @@ class CompanyStatementController extends ThinkController excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); } } + //汇总 + public function pool() + { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $dbres = $this->DBModel->field("*")->where("id in ({$ids})")->select(); + //分单 + $basedata = [ + "pay_amount"=>0, + "statement_money"=>0, + "platform_amount"=>0, + "statement_ids"=>[], + "statement_begin_time"=>0, + "statement_end_time"=>0, + "fine"=>0, + "reward"=>0, + "company_list"=>[] + ]; + // + $ups=$basedata; + $downs=$basedata; + $users=$basedata; + foreach ($dbres as $k=>$v) { + if($v['verify_status'] != 3) continue; + if($v['company_belong'] == 9){ + //上游 + $this->setDf($ups,$v); + }else{ + //下游 + if($v['company_type'] == 2){ + //个人 + $this->setDf($users,$v); + }else{ + $this->setDf($downs,$v); + } + } + } + dd($ups); + // + + } + //设定组合的子操作 + protected function setDf(&$savedata,$v) + { + $savedata['statement_ids'][] = $v['id']; + unset($v['id']); + $v['statement_info'] = json_decode( $v['statement_info'],true); + foreach($v['statement_info'] as $ka=>$va){ + if($va['statement_type'] == 2){ + //奖励 + $savedata['reward'] += $va['sum_money']; + unset($v['statement_info'][$ka]); + }else if($va['statement_type'] == 1){ + $savedata['fine'] += $va['sum_money']; + unset($v['statement_info'][$ka]); + } + } + if(isset($savedata['company_list'][$v['company_id']])){ + //存在游戏合并 + + $a = &$savedata['company_list'][$v['company_id']]; + $a['statement_info'] = array_merge($a['statement_info'],$v['statement_info']); + // dump($a['statement_info']); + $a['platform_amount'] += $v['platform_amount']; + $a['pay_amount'] += $v['pay_amount']; + $a['statement_money'] += $v['statement_money']; + }else{ + if($v['pay_type'] == 2){ + //乙方收款 + $v['company_info'] = $v['second_party_info']; + }else{ + $v['company_info'] = $v['first_party_info']; + } + $tdata = [ + "company_info"=>$v['company_info'], + "company_name"=>$v['company_name'], + "platform_amount"=>$v['platform_amount'], + "pay_amount"=>$v['pay_amount'], + "statement_money"=>$v['statement_money'], + "statement_info"=>$v['statement_info'], + ]; + $savedata['company_list'][$v['company_id']] = $tdata; + } + $savedata['pay_amount'] += $v['pay_amount']; + $savedata['statement_money'] += $v['statement_money']; + $savedata['platform_amount'] += $v['platform_amount']; + if($savedata['statement_begin_time'] == 0){ + $savedata['statement_begin_time'] = $v['statement_begin_time']; + }elseif($v['statement_begin_time'] < $savedata['statement_begin_time']){ + $savedata['statement_begin_time'] = $v['statement_begin_time']; + } + if($savedata['statement_end_time'] == 0){ + $savedata['statement_end_time'] = $v['statement_end_time']; + }elseif($v['statement_end_time'] > $savedata['statement_end_time']){ + $savedata['statement_end_time'] = $v['statement_end_time']; + } + } + //设定并保存数据 + public function OpAuth($info) { diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index 1701afe0e..c144f5714 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -326,6 +326,9 @@ class CompanyStatementSetController extends Controller { //金额为0不补点 continue; } + if($add_data['platform_amount'] <= 0){ + return; + } //添加 if($company_id === false){ //非重算 @@ -577,6 +580,9 @@ class CompanyStatementSetController extends Controller { //金额为0不补点 continue; } + if($add_data['platform_amount'] <= 0){ + return; + } //添加 if($company_id === false){ //非重算 diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html index 8285de168..11df35b7b 100644 --- a/Application/Admin/View/CompanyStatement/lists.html +++ b/Application/Admin/View/CompanyStatement/lists.html @@ -345,8 +345,8 @@ } }).get(); - if(text.length > 20){ - layer.msg("" + '为保证效率暂不支持超过20条的批量操作' + ""); + if(text.length > 40){ + layer.msg("" + '为保证效率暂不支持超过40条的批量操作' + ""); return; } if(text.length < 1){ @@ -387,11 +387,15 @@ 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) { return $(elem).val();