diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index cd65229db..40d5da0e9 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1901,12 +1901,18 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1)->mergeCells("J$line:K$line"); $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['statement_begin_time'] . '-' . $value['statement_end_time']); if ($value['statement_type'] > 0) {//罚款 - $product_name = $value['type_name']; + $product_name = $value['game_name']; $objPHPExcel->getActiveSheet()->setCellValue('F'.$line , '-'); $objPHPExcel->getActiveSheet()->setCellValue('G'.$line, '-'); $objPHPExcel->getActiveSheet()->setCellValue('H'.$line, '-'); $objPHPExcel->getActiveSheet()->setCellValue('I'.$line, '-'); - $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['sum_money']); + if ($value['statement_type'] == 1) { + $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, "-".$value['pay_amount']); + $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, "-".$value['sum_money']); + }else{ + $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['pay_amount']); + $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']); + } } else {//游戏 $product_name = $value['game_name']; $objPHPExcel->getActiveSheet()->setCellValue('F'.$line , $value['first_ratio'] . '%'); @@ -1914,9 +1920,10 @@ 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('D'.$line, $product_name); - $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']); + $line++; } @@ -1961,7 +1968,6 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
'); - date_default_timezone_set('Europe/London'); Vendor("PHPExcel.PHPExcel"); $objPHPExcel = new \PHPExcel(); $objReader = \PHPExcel_IOFactory::createReader('Excel5'); @@ -1971,12 +1977,12 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al $statement_begin_time = date('Y.m.d', $data['statement_begin_time']);//对账开始时间 $statement_end_time = date('Y.m.d',$data['statement_end_time']);//对账截止时间 - $objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['company_name']} 》结算单 - ({$statement_begin_time}-{$statement_end_time}"); - if ($data['second_party_info']['settlement_type'] == '补点订单') { - $objPHPExcel->getActiveSheet()->setCellValue('D2' , '补点比例'); + $objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['company_name']} 》结算单\n({$statement_begin_time}-{$statement_end_time})"); + if ($data['withdraw_type'] == '2') { + $objPHPExcel->getActiveSheet()->setCellValue('D2','补点比例'); } + $line = 3; @@ -1985,19 +1991,30 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al $objPHPExcel->getActiveSheet()->removeConditionalStyles(); $objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $value['statement_begin_time'] . '-' . $value['statement_end_time']); - if ($value['statement_type']>0) {//罚款 - $product_name = $value['type_name']; + if ($value['statement_type'] > 0) {//罚款 + $product_name = $value['game_name']; $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, '-'); $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, '-'); - $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['sum_money']); + if ($value['statement_type'] == 1) { + $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, "-".$value['pay_amount']); + $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, "-".$value['sum_money']); + }else{ + $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['pay_amount']); + $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']); + } } else {//游戏 $product_name = $value['game_name']; - $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['second_ratio'] . '%'); + if ($data['withdraw_type'] == 2) { + $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['increment_ratio'] . '%'); + }else{ + $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['ratio'] . '%'); + } $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('B'.$line, $product_name); - $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']); + $line++; } @@ -2007,23 +2024,23 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额 //甲方信息 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['first_party_info']['jfCompany']);//甲方 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['first_party_info']['jfPerson']);//联系人 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+5), $data['first_party_info']['jfTel']);//联系电话 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['second_party_info']['invoice_item']);//开票项目 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['second_party_info']['invoice_type']);//发票类型 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['pay_company']['partner']);//甲方 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['pay_company']['link_man']);//联系人 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+5), $data['pay_company']['link_phone']);//联系电话 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['receive_company']['invoice_content']);//开票项目 + $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['receive_company']['invoice_type']);//发票类型 //乙方信息 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+3), $data['second_party_info']['partner']);//乙方 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+4), $data['second_party_info']['link_man']);//联系人 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+5), $data['second_party_info']['link_phone']);//联系电话 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+6), $data['second_party_info']['address']);//邮寄地址 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+3), $data['receive_company']['partner']);//乙方 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+4), $data['receive_company']['link_man']);//联系人 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+5), $data['receive_company']['link_phone']);//联系电话 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+6), $data['receive_company']['address']);//邮寄地址 // $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $value['pay_amount']);//请汇入此账号 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['second_party_info']['bank_account_name']);//户名 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['second_party_info']['bank_account']);//银行账号 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['second_party_info']['opening_bank']);//开户行 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['receive_company']['bank_account_name']);//户名 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['receive_company']['bank_account']);//银行账号 + $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['receive_company']['opening_bank']);//开户行 - $fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['jfCompany']}-对账单{$statement_begin_time}-{$statement_end_time}"; + $fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$statement_begin_time}-{$statement_end_time}"; // dd($fileName); ob_end_clean();//清除缓冲区,避免乱码 header('pragma:public'); diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php index c936067c2..1d9d90789 100644 --- a/Application/Admin/Controller/CompanyStatementController.class.php +++ b/Application/Admin/Controller/CompanyStatementController.class.php @@ -45,7 +45,9 @@ class CompanyStatementController extends ThinkController } $this->assign('menubtn',$this->menuAuth()); - $map = []; + $map = [ + "_string"=>"1=1" + ]; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { $time_start = strtotime($_REQUEST['time_start']); $time_end = strtotime($_REQUEST['time_end'])+ 86399; @@ -296,6 +298,62 @@ class CompanyStatementController extends ThinkController "info"=>$opname."成功" )); } + //重算 + public function updateStatement() + { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $dbres = $this->DBModel->field("id,verify_status,verify_log")->where("id in ({$ids})")->select(); + foreach($dbres as $k=>&$v){ + if(in_array($v['verify_status'],[3,4])) continue; //合作方确认后不进行重算 + //重算 + $res = A("CompanyStatementSet")->updateCompanyStatementData($v['id'],$this->admininfo["username"]); + if($res === false){ + $this->ajaxReturn(array( + 'status' => 0, + "info"=>"重算金额错误" + )); + } + } + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"重算金额成功" + )); + } + //导出 + public function export() + { + if(!isset($_REQUEST['id'])) $this->error("参数错误"); + $id = $_REQUEST['id']; + + $data = M("CompanyStatement","tab_")->where(['id' => $id])->find(); + $data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方 + $data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方 + $data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录 + //收款方 + $all_sum_money = $data['pay_amount'];//合计平台总额 + $all_pay_amount = $data['statement_money'];//合计结算金额 + + $big_all_sum_money = convertAmountToCn($data['statement_money']);//大写 + + if($data['pay_type'] == 2){ + $data['receive_company'] = $data['second_party_info'];//收款方 + $data['pay_company'] = $data['first_party_info']; + }else{ + $data['receive_company'] = $data['first_party_info']; + $data['pay_company'] = $data['second_party_info']; + } + if($data['receive_company']['invoice_type'] == 1){ + $data['receive_company']['invoice_type']="专票"; + }else{ + $data['receive_company']['invoice_type']="普票"; + } + if ($data['company_belong'] == 9) {//上游 + excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); + } else {//下游 + excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); + } + } public function OpAuth($info) { diff --git a/Application/Admin/Controller/CompanyStatementSetController.class.php b/Application/Admin/Controller/CompanyStatementSetController.class.php index b5d9bd4c8..1701afe0e 100644 --- a/Application/Admin/Controller/CompanyStatementSetController.class.php +++ b/Application/Admin/Controller/CompanyStatementSetController.class.php @@ -667,6 +667,7 @@ class CompanyStatementSetController extends Controller { } //重写用户 $savedata['verify_log'] = json_encode(["create_user"=>$admin_user,"create_time"=>date("Y-m-d H:i:s")]); + $savedata['verify_status'] = 0; $savedata['id'] = $dbres['id']; return $StatementDb->save($savedata); } diff --git a/Application/Admin/Controller/VerifyBillController.class.php b/Application/Admin/Controller/VerifyBillController.class.php index 48ddb830c..62d4a925d 100644 --- a/Application/Admin/Controller/VerifyBillController.class.php +++ b/Application/Admin/Controller/VerifyBillController.class.php @@ -137,33 +137,36 @@ class VerifyBillController extends Controller { */ public function export() { - $id = I('id'); + if(!isset($_REQUEST['id'])) $this->error("参数错误"); + $id = $_REQUEST['id']; + $data = M("CompanyStatement","tab_")->where(['id' => $id])->find(); $data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方 $data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方 $data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录 //收款方 -// dd($data); $all_sum_money = $data['pay_amount'];//合计平台总额 $all_pay_amount = $data['statement_money'];//合计结算金额 $big_all_sum_money = convertAmountToCn($data['statement_money']);//大写 if($data['pay_type'] == 2){ - $data['receive_company'] = $data['second_party_info']; + $data['receive_company'] = $data['second_party_info'];//收款方 $data['pay_company'] = $data['first_party_info']; }else{ $data['receive_company'] = $data['first_party_info']; $data['pay_company'] = $data['second_party_info']; } - if ($data['statement_type'] == 1) {//下游 - excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); - } else {//上游 + if($data['receive_company']['invoice_type'] == 1){ + $data['receive_company']['invoice_type']="专票"; + }else{ + $data['receive_company']['invoice_type']="普票"; + } + if ($data['company_belong'] == 9) {//上游 excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); + } else {//下游 + excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money); } - - - } } diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html index da09e8bf0..dc6dfab2d 100644 --- a/Application/Admin/View/CompanyStatement/lists.html +++ b/Application/Admin/View/CompanyStatement/lists.html @@ -297,49 +297,72 @@ }); }); - $("#verifyAgree,#verifyRefuse,#launch,#pool,#updateStatement,#export").on("click",function(){ + $("#verifyAgree,#verifyRefuse,#launch,#pool,#updateStatement").on("click",function(){ var id = $(this).attr("id"); if(id == "verifyAgree"){ var opname = "审批通过"; var opurl = "{:U('verifyAgree')}"; var opst ="[未进行审批]"; - var status = 0; + var status = [0]; }else if(id=="verifyRefuse"){ var opname = "审批拒绝"; var opurl = "{:U('verifyRefuse')}"; var opst ="[未进行审批]"; - var status = 0; + var status = [0]; }else if(id=="launch"){ var opname = "对外发起"; var opurl = "{:U('launch')}"; var opst ="[审批通过]"; - var status = 1; + var status = [1]; }else if(id=="pool"){ var opname = "发起汇总"; var opurl = "{:U('pool')}"; var opst ="[合作方确认]"; - var status = 3; + var status = [3]; + }else if(id=="updateStatement"){ + var opname = "重算金额"; + var opurl = "{:U('updateStatement')}"; + var opst ="[汇总撤销,审批拒绝,未进行审批,审批通过,对外发起]"; + var status = [-2,-1,0,1,2]; + var confirm = true; } - + var confirm = confirm ? confirm :false; var flag = false; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("status") != status){ + if($.inArray( $(elem).data("status"),status) == -1){ flag = true; }else{ return $(elem).val(); } - }).get().join(","); - if(text == ''){ + }).get(); + + if(text.length > 20){ + layer.msg("" + '为保证效率暂不支持超过20条的批量操作' + ""); + return; + } + if(text.length < 1){ layer.msg("" + '无需要'+opname+'的申请,仅'+opst+'状态可以进行'+opname+""); return; } + text = text.join(","); + if(flag){ layer.confirm(opname+"仅会对"+opst+"的申请进行处理,选择中包含其他的状态的申请将被忽略,点击取消停止操作",{title:false}, function(index){ _doAgreeApply(); layer.close(index); }); }else{ - _doAgreeApply(); + if(confirm){ + layer.confirm('【警告】'+opname+'将不可回退,如需继续请点击确认', { + btn: ['确认','取消'], + title:false + }, function(){ + _doAgreeApply(); + }); + }else{ + _doAgreeApply(); + } + } function _doAgreeApply(){ //执行 @@ -360,6 +383,26 @@ }); } }) + $("#export").click(function () { + var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + return $(elem).val(); + }).get(); + + if(text.length > 20){ + layer.msg("" + '暂不支持超过20条的批量导出' + ""); + return; + } + if(text.length < 1){ + layer.msg("" + '请先选择要导出的结算单' + ""); + return; + } + for (var index = 0; index < text.length; index++) { + var id = text[index]; + var url ="{:U('export')}"+"&id="+id; + var iframeExcel = ""//添加下载的地址到iframe,这里是公司信息,我用**表示了。 + $("body").append(iframeExcel) + } + })