From c8914800c741aad6088cfe0b21f4bf88512fa814 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 28 Dec 2020 10:48:29 +0800 Subject: [PATCH] =?UTF-8?q?12.28=E5=8A=9F=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PaymentController.class.php | 84 ++++++++++++++++++- Application/Payment/View/Payment/lists.html | 33 ++++++-- .../Payment/View/Payment/setPayment.html | 1 - 3 files changed, 110 insertions(+), 8 deletions(-) diff --git a/Application/Payment/Controller/PaymentController.class.php b/Application/Payment/Controller/PaymentController.class.php index 789d82532..4b31870d4 100644 --- a/Application/Payment/Controller/PaymentController.class.php +++ b/Application/Payment/Controller/PaymentController.class.php @@ -217,7 +217,6 @@ class PaymentController extends BaseController $countmap['pay_status']=["neq",1]; $money = M("company_statement_info","tab_")->alias('s')->field("sum(statement_money) statement_money")->where($countmap)->find(); - $count = M("company_statement_info","tab_")->alias('s')->field("count(id) count")->where($map)->find(); $page = set_pagination($count['count'], $row); if ($page) { @@ -278,8 +277,23 @@ class PaymentController extends BaseController 'pay_status_str'=>'打款状态', 'pay_time'=>'打款时间',]; - data2csv($data,'市场业绩提成',$title); + $sum = M("pay_statement_info","tab_") + ->alias('s') + ->field("sum(if(s.pay_status=0,s.statement_money,0)) unpay_amount,sum(if(s.pay_status>0,s.statement_money,0)) pay_amount,sum(if(s.pay_status<0,s.statement_money,0)) faild_pay_amount") + ->join("left join tab_company_statement_info c on s.statement_info_id = c.id") + ->where(['statement_info_id'=>['in',$id]]) + ->find(); + + $money = M("company_statement_info","tab_")->alias('s')->field("sum(statement_money) statement_money")->where(['s.id'=>['in',$id]])->find(); + $sumData = [ + 'company_name'=>'合计', + 'statement_time' => "待打款金额: {$money['statement_money']} 打款成功: {$sum['pay_amount']} 打款失败: {$sum['faild_pay_amount']}", + ]; + + $data = array_merge($data,[$sumData]); +// dump($data);die(); + data2csv($data,'线上打款',$title); // $this->ajaxReturn(['stauts'=>1,'msg'=>'导出成功']); } @@ -760,10 +774,12 @@ class PaymentController extends BaseController public function editPayment(){ if(!isset($_REQUEST['info'])) $this->error("参数错误"); $info = $_REQUEST['info']; + $id = []; $CompanyInfo = M("company_statement_info","tab_"); //循环保存 foreach($info as $k=>$v){ + array_push($id,$k); $ydata = $CompanyInfo->where("id= '{$k}'")->find(); $company_info = json_decode($ydata['company_info'],true); if($ydata['verify_status'] == 2){ @@ -788,6 +804,70 @@ class PaymentController extends BaseController } + $companyStatementInfo = M("company_statement_info","tab_") + ->where([ + 'id'=>['in',$id] + ]) + ->select(); + + foreach ($companyStatementInfo as $key => $value) { + if ($value['statement_money'] <= 0) { + $payres["remark"] = '打款金额非正,直接打款成功'; + + $pay_info = json_encode($payres, JSON_UNESCAPED_UNICODE); + M("company_statement_info","tab_") + ->where([ + 'id'=>['in',$value['id']] + ]) + ->save(['pay_status'=>1,'pay_time'=>time(),'pay_type'=>2,'pay_info'=>$pay_info]); + M("pay_statement_info","tab_") + ->where([ + 'statement_info_id'=>['in',$value['id']] + ]) + ->save(['pay_status'=>1,'pay_time'=>time(),'pay_type'=>2,'pay_info'=>$pay_info]); + } else { + $payres["remark"] = '打款金额非正,直接打款成功'; + + $pay_info = json_encode($payres, JSON_UNESCAPED_UNICODE); + M("pay_statement_info","tab_") + ->where([ + 'statement_info_id'=>['in',$value['id']], + 'statement_money'=>['elt',0] + ]) + ->save(['pay_status'=>1,'pay_time'=>time(),'pay_type'=>2,'pay_info'=>$pay_info]); + + $pay_statement_info = M("pay_statement_info","tab_") + ->where([ + 'statement_info_id'=>['in',$value['id']] + ]) + ->order("statement_money ASC") + ->select(); + $subtraction = 0; + foreach ($pay_statement_info as $sk => $sv) { + + if ($sv['statement_money'] < 0) { + $subtraction += -($sv['statement_money']); + $sv['final_statement_money'] = 0; + } elseif($sv['statement_money'] > 0 && $subtraction > 0) { + if($sv['statement_money'] >= $subtraction) { + $sv['final_statement_money'] = $sv['statement_money']-$subtraction; + $subtraction = 0; + } else { + $sv['final_statement_money'] = 0; + $subtraction =-$sv['final_statement_money']; + } + } + + M("pay_statement_info","tab_") + ->where([ + 'id'=>$sv['id'] + ])->save($sv); + + } + + } + } + $this->ajaxReturn(array( 'status' => 1, "info"=>"打款信息编辑成功" diff --git a/Application/Payment/View/Payment/lists.html b/Application/Payment/View/Payment/lists.html index f6d1666ff..4507b3b0b 100644 --- a/Application/Payment/View/Payment/lists.html +++ b/Application/Payment/View/Payment/lists.html @@ -316,7 +316,7 @@ - 合计待打款金额: {$money.statement_money} 待打款金额: {$sum['unpay_amount']} 打款成功: {$sum['pay_amount']} 打款失败: {$sum['faild_pay_amount']} + 合计待打款金额: {$money.statement_money|default='0.00'}  打款成功: {$sum['pay_amount']|default='0.00'} 打款失败: {$sum['faild_pay_amount']|default='0.00'} @@ -754,15 +754,21 @@ $(".setPayment").on("click",function(){ // var id = $(this).data("id"); var tip = 0; + var paystatustip = 0; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("pay_check") == 0 || $(elem).data("verify_status") == -1){ + if(($(elem).data("pay_check") == 0 || $(elem).data("verify_status") == -1) && $(elem).data("paystatus") != 1){ return $(elem).data("verify_id"); - } else { + } + if ($(elem).data("pay_check") != 1) { tip = 1; } + if ($(elem).data("paystatus") == 1) { + paystatustip = 1; + } + }).get(); if(tip == 1) { @@ -770,6 +776,11 @@ return; } + if(paystatustip == 1) { + layer.msg("请选择未打款的单子"); + return; + } + text = text.join(","); if (!text) { @@ -790,16 +801,23 @@ $("#returnSetPayment").on("click",function () { + var paystatustip = 0; var tip = 0; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("pay_check") == 1){ + if($(elem).data("pay_check") == 1 && $(elem).data("paystatus") != 1){ return $(elem).data("verify_id"); - } else { + } + + if ($(elem).data("pay_check") != 1) { tip = 1; } + if ($(elem).data("paystatus") == 1) { + paystatustip = 1; + } + }).get(); if(tip == 1) { @@ -807,6 +825,11 @@ return; } + if(paystatustip == 1) { + layer.msg("请选择未打款的单子"); + return; + } + text = text.join(","); layer.confirm('【提示】是否确认打款信息撤回', { diff --git a/Application/Payment/View/Payment/setPayment.html b/Application/Payment/View/Payment/setPayment.html index 416d6125d..110c1bfda 100644 --- a/Application/Payment/View/Payment/setPayment.html +++ b/Application/Payment/View/Payment/setPayment.html @@ -147,7 +147,6 @@ 是 {$vo.company_info.ali_user} {$vo.company_info.ali_account} - 否 {$vo.company_info.payee_name}