From d05d6e2159757805ab44ed02bff8e1f75507ad30 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Fri, 12 Jun 2020 20:27:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyStatementLackController.class.php | 5 +- .../CompanyStatementPoolController.class.php | 131 +++++++----------- .../View/CompanyStatementLack/lists.html | 2 +- .../View/CompanyStatementPool/lists.html | 29 ++++ .../View/CompanyStatementPool/viewCpPool.html | 2 +- .../View/CompanyStatementPool/viewPcPool.html | 2 +- .../View/CompanyStatementPool/viewPuPool.html | 2 +- 7 files changed, 90 insertions(+), 83 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementLackController.class.php b/Application/Admin/Controller/CompanyStatementLackController.class.php index f03a2d5ba..d590e0fd5 100644 --- a/Application/Admin/Controller/CompanyStatementLackController.class.php +++ b/Application/Admin/Controller/CompanyStatementLackController.class.php @@ -110,10 +110,13 @@ class CompanyStatementLackController extends ThinkController } //获取基本信息 $dbres = $this->DBModel->where("id='{$id}'")->select(); + $title = $dbres[0]['company_name']; + $this->assign("title",$title); + if($dbres[0]['company_type'] == 3){ //上游 A("CompanyStatementPool")->viewCpPool($dbres,$is_export); - }elseif($infolist[0]['company_type'] == 1){ + }elseif($dbres[0]['company_type'] == 1){ //下游公司 A("CompanyStatementPool")->viewPcPool($dbres,$is_export); }else{ diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index 60a3f893f..fc26d7129 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -181,6 +181,9 @@ class CompanyStatementPoolController extends ThinkController } //获取基本信息 $infolist = M("company_statement_info","tab_")->where("pool_id = '{$id}'")->select(); + //获取母单 + $statement_num = M("company_statement_pool","tab_")->field('statement_num')->where("id={$id}")->find()['statement_num']; + $this->assign("title",$statement_num); if($infolist[0]['company_type'] == 3){ //上游 @@ -501,88 +504,60 @@ class CompanyStatementPoolController extends ThinkController } //撤销汇总 - public function cancelPool() - { - //开启事务 - if(!isset($_REQUEST['ids'])) $this->error("参数错误"); - $ids = $_REQUEST['ids']; - $dbres = $this->DBModel->field("id,statement_ids,verify_status")->where("id in ({$ids})")->select(); - $sids = []; - foreach($dbres as $k=>$v){ - if(in_array($v['verify_status'],[3,4])) continue; //有打款就不允许回退 - $statement_ids = explode(",",$v['statement_ids']); - $sids = array_merge($sids,$statement_ids); - } - $sids = implode(",",$sids); - M()->startTrans();//事务 - //删除info - $infores = M("company_statement_info","tab_")->where("pool_id in ($ids)")->delete(); - if($infores === false){ - M()->rollback(); - $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); - } - //删除自己 - $poolres = $this->DBModel->where("id in ({$ids})")->delete(); - if($poolres === false){ - M()->rollback(); - $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); - } - //修改结算单信息 - $st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select(); - foreach($st_res as $k=>&$v){ - $v['verify_log'] = json_decode($v['verify_log'],true); - $v['verify_log'][$op_pre.'_user']=$this->admininfo["username"]; - $v['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s"); - $v['verify_log'] = json_encode($v['verify_log']); - $v['verify_status']=-2; - $stres = M("company_statement","tab_")->save($v); - if($stres === false){ - M()->rollback(); - $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); - } - } - M()->commit(); - $this->ajaxReturn(array( - 'status' => 1, - "info"=>"重算金额成功" - )); - } - - - //导出 - public function export() - { + public function cancelPool(){ if(!isset($_REQUEST['id'])) $this->error("参数错误"); $id = $_REQUEST['id']; + //获取基础信息 + + } + // public function cancelPool() + // { + // //开启事务 + // if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + // $ids = $_REQUEST['ids']; + // $dbres = $this->DBModel->field("id,statement_ids,verify_status")->where("id in ({$ids})")->select(); + // $sids = []; + // foreach($dbres as $k=>$v){ + // if(in_array($v['verify_status'],[3,4])) continue; //有打款就不允许回退 + // $statement_ids = explode(",",$v['statement_ids']); + // $sids = array_merge($sids,$statement_ids); + // } + // $sids = implode(",",$sids); + // M()->startTrans();//事务 + // //删除info + // $infores = M("company_statement_info","tab_")->where("pool_id in ($ids)")->delete(); + // if($infores === false){ + // M()->rollback(); + // $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); + // } + // //删除自己 + // $poolres = $this->DBModel->where("id in ({$ids})")->delete(); + // if($poolres === false){ + // M()->rollback(); + // $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); + // } + // //修改结算单信息 + // $st_res = M("company_statement","tab_")->field("id,verify_status,verify_log")->where("id in ({$sids})")->select(); + // foreach($st_res as $k=>&$v){ + // $v['verify_log'] = json_decode($v['verify_log'],true); + // $v['verify_log'][$op_pre.'_user']=$this->admininfo["username"]; + // $v['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s"); + // $v['verify_log'] = json_encode($v['verify_log']); + // $v['verify_status']=-2; + // $stres = M("company_statement","tab_")->save($v); + // if($stres === false){ + // M()->rollback(); + // $this->ajaxReturn(array('status' => 0,"info"=>"撤销汇总失败")); + // } + // } + // M()->commit(); + // $this->ajaxReturn(array( + // 'status' => 1, + // "info"=>"重算金额成功" + // )); + // } - $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/View/CompanyStatementLack/lists.html b/Application/Admin/View/CompanyStatementLack/lists.html index 641cd384f..d6de377ff 100644 --- a/Application/Admin/View/CompanyStatementLack/lists.html +++ b/Application/Admin/View/CompanyStatementLack/lists.html @@ -344,7 +344,7 @@ } for (var index = 0; index < text.length; index++) { var id = text[index]; - var url ="{:U('export')}"+"&id="+id; + var url ="{:U('viewStatement')}"+"&id="+id+"&export=1"; var iframeExcel = ""//添加下载的地址到iframe,这里是公司信息,我用**表示了。 $("body").append(iframeExcel) } diff --git a/Application/Admin/View/CompanyStatementPool/lists.html b/Application/Admin/View/CompanyStatementPool/lists.html index 882d6beee..50f4c3e9c 100644 --- a/Application/Admin/View/CompanyStatementPool/lists.html +++ b/Application/Admin/View/CompanyStatementPool/lists.html @@ -396,6 +396,35 @@ } } }) + + //撤销汇总 + $(".cancelPool").on("click",function(){ + var id = $(this).data('id'); + var url = "{:U('cancelPool')}"; + cancelPoolAjax(url,{id:id}); + }) + function cancelPoolAjax(opurl,senddata){ + //执行 + $.ajax({ + type: "POST", + url: opurl, + dataType: 'json', + async: false, + data: senddata, + success:function(data){ + if(data.status==1){ + layer.msg("" + data.info + ""); + setTimeout(function(){ + window.location.reload(); + },1500); + }else{ + layer.msg("" + data.info + ""); + return false; + } + } + }); + } + //新增批注 $(".addRemark").click(function(){ var id = $(this).data("id"); diff --git a/Application/Admin/View/CompanyStatementPool/viewCpPool.html b/Application/Admin/View/CompanyStatementPool/viewCpPool.html index 913926d6c..2f0f88287 100644 --- a/Application/Admin/View/CompanyStatementPool/viewCpPool.html +++ b/Application/Admin/View/CompanyStatementPool/viewCpPool.html @@ -185,7 +185,7 @@ $(function(){ $("#exporttable").table2excel({ - filename: "上游结算汇总.xls", // do include extension + filename: "{$title}.xls", // do include extension preserveColors: false // set to true if you want background colors and font colors preserved }); }); diff --git a/Application/Admin/View/CompanyStatementPool/viewPcPool.html b/Application/Admin/View/CompanyStatementPool/viewPcPool.html index 0a8f834f5..b8d1c2e5a 100644 --- a/Application/Admin/View/CompanyStatementPool/viewPcPool.html +++ b/Application/Admin/View/CompanyStatementPool/viewPcPool.html @@ -168,7 +168,7 @@ $(function(){ $("#exporttable").table2excel({ - filename: "下游公司汇总.xls", // do include extension + filename: "{$title}.xls", // do include extension preserveColors: false // set to true if you want background colors and font colors preserved }); }); diff --git a/Application/Admin/View/CompanyStatementPool/viewPuPool.html b/Application/Admin/View/CompanyStatementPool/viewPuPool.html index bae3145f7..bc15698e0 100644 --- a/Application/Admin/View/CompanyStatementPool/viewPuPool.html +++ b/Application/Admin/View/CompanyStatementPool/viewPuPool.html @@ -189,7 +189,7 @@ $(function(){ $("#exporttable").table2excel({ - filename: "下游公司汇总.xls", // do include extension + filename: "{$title}.xls", // do include extension preserveColors: false // set to true if you want background colors and font colors preserved }); });