From 29e8421266269d7225016e83576f461a4df891d1 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 28 Dec 2020 13:54:25 +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 --- ...ompanyStatementOfflineController.class.php | 81 ++- .../CompanyStatementPoolController.class.php | 64 ++- .../Controller/PaymentController.class.php | 366 ++++++++++-- Application/Payment/View/Payment/lists.html | 522 ++++++++++++------ 4 files changed, 794 insertions(+), 239 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementOfflineController.class.php b/Application/Admin/Controller/CompanyStatementOfflineController.class.php index 791d6519a..842d9653d 100644 --- a/Application/Admin/Controller/CompanyStatementOfflineController.class.php +++ b/Application/Admin/Controller/CompanyStatementOfflineController.class.php @@ -89,6 +89,12 @@ class CompanyStatementOfflineController extends ThinkController $v["payment"] = $v["pay_status_str"]; } + if ($v['pay_check'] == 0) { + $v['pay_check_str'] = "未确认"; + } else { + $v['pay_check_str'] = "已确认"; + } + $v['oplist'] = $this->OpAuth($v); } @@ -107,6 +113,78 @@ class CompanyStatementOfflineController extends ThinkController $this->display(); } + + //打款设置 + public function setPayment(){ + if(!isset($_REQUEST['id'])) $this->error("参数错误"); + $id = $_REQUEST['id']; + $CompanyInfo = M("company_statement_info","tab_") + ->alias('i') + ->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,i.remark,i.pay_status,i.verify_status,p.statement_num,i.statement_money") + ->join("tab_company_statement_pool p ON p.id = i.pool_id") + ->where("i.id in({$id})") + ->select(); + + $all_money = 0; + foreach($CompanyInfo as $k=>&$v){ + if($v['verify_status'] == 2){ + $v['is_payment'] = 2; + }else{ + $v['is_payment'] = 1; + } + + $v['company_info'] = json_decode($v['company_info'],true); + $v['company_info']['ali_user'] ?? ''; + $v['company_info']['ali_account'] ?? ''; + + $all_money += $v['statement_money']; + + } + + $this->assign('all_money',$all_money); + $this->assign("CompanyInfo",$CompanyInfo); + $this->assign("id",$id); + $this->display(); + } + + //修改打款设置 + public function editPayment(){ + if(!isset($_REQUEST['info'])) $this->error("参数错误"); + $info = $_REQUEST['info']; + +// dump($info);die(); + + $CompanyInfo = M("company_statement_info","tab_"); + //循环保存 + foreach($info as $k=>$v){ + $ydata = $CompanyInfo->where("id= '{$k}'")->find(); + $company_info = json_decode($ydata['company_info'],true); + if($ydata['verify_status'] == 2){ + $company_info['payee_name'] = $v['payee_name']; + $company_info['bank_account'] = $v['bank_account']; + $company_info['opening_bank'] = $v['opening_bank']; + }else{ + $company_info['ali_user'] = $v['ali_user']; + $company_info['ali_account'] = $v['ali_account']; + } + $savedata = [ + "company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE), + "remark"=>$v['remark'], + "pay_check"=>1, + "id"=>$k + ]; + + $CompanyInfo->save($savedata); + + } + + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"打款信息编辑成功" + )); + + } + public function doPayment() { if(!isset($_REQUEST['ids']) || !isset($_REQUEST['payment_time'])) $this->error("参数错误"); @@ -236,8 +314,9 @@ class CompanyStatementOfflineController extends ThinkController public function menuAuth() { $mentBtn = [ + "setPayment"=>"打款信息确认", "doPayment"=>"打款确认", - "export"=>"批量导出" + "export"=>"批量导出", ]; $resarr = []; foreach ($mentBtn as $k => $v) { diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index 9638f2444..d8dae4cca 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -1151,7 +1151,7 @@ class CompanyStatementPoolController extends ThinkController } } //线上打款审核状态撤回 - M("company_statement_info","tab_")->where("pool_id={$id}")->save(['pay_verify_status'=>0,'verify_time'=>'','verify_member_id'=>0]); + M("company_statement_info","tab_")->where("pool_id={$id}")->save(['pay_verify_status'=>0,'verify_time'=>'','verify_member_id'=>0,'pay_check'=>0,'remark'=>'']); //线上打款支付宝状态撤回 M("company_statement_info","tab_")->where("pool_id={$id} and verify_status != 2")->save(['verify_status'=>0]); @@ -1206,6 +1206,9 @@ class CompanyStatementPoolController extends ThinkController if($ajaxreturn){ if ($change_status == 2) { + + $this->autoSetPayment($ids); + $this->splitForPayStatementInfo(); } @@ -1233,6 +1236,62 @@ class CompanyStatementPoolController extends ThinkController )); } + public function autoSetPayment($pool_id) { + + $CompanyInfo = M("company_statement_info","tab_"); + + $pool_id = explode(',',$pool_id); + + foreach ($pool_id as $pkey => $pvalue) { + + $data = $CompanyInfo->where(['pool_id'=>['in',$pvalue]])->select(); + + foreach ($data as $key => $value) { + if($value['verify_status'] != 2) { + $CompanyInfo->where(['id'=>$value['id']])->save(['verify_status'=>1]); + } + } + + } + + //循环保存 +// foreach($info as $k=>$v){ +// $ydata = $CompanyInfo->where("id= '{$k}'")->find(); +// $company_info = json_decode($ydata['company_info'],true); +// if($ydata['verify_status'] == 2){ +// $company_info['payee_name'] = $v['payee_name']; +// $company_info['bank_account'] = $v['bank_account']; +// $company_info['opening_bank'] = $v['opening_bank']; +// }else{ +// $company_info['ali_user'] = $v['ali_user']; +// $company_info['ali_account'] = $v['ali_account']; +// } +// $savedata = [ +// "company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE), +// "remark"=>$v['remark'], +// "id"=>$k +// ]; +// if($ydata['verify_status'] != 2){ +// if(empty($v['ali_user']) || empty($v['ali_account'])){ +// $savedata['verify_status'] = -1; +// }else{ +// $savedata['verify_status'] = 1; +// } +// } +// $CompanyInfo->save($savedata); +// } +// $verify_status = $this->DBModel->field("verify_status")->where("id = {$pool_id}")->find()['verify_status']; +// if( $verify_status == 6){ +// $this->setOneVerifyStatus(1,"payment",$_REQUEST['pool_id'],$mgs = "打款信息确认"); +// }else{ +// $this->ajaxReturn(array( +// 'status' => 1, +// "info"=>"打款信息编辑成功" +// )); +// } + + } + //打款设置 public function setPayment(){ if(!isset($_REQUEST['id'])) $this->error("参数错误"); @@ -1721,7 +1780,8 @@ class CompanyStatementPoolController extends ThinkController $optist = ["viewPool","addRemark","viewRemark","editRemark","reCount","cancelPool"]; break; case '6': - $optist = ["viewPool","addRemark","viewRemark","editRemark","reCount","cancelPool","setPayment"]; + $optist = ["viewPool","addRemark","viewRemark","editRemark","reCount","cancelPool"]; +// ,"setPayment"]; break; default: break; diff --git a/Application/Payment/Controller/PaymentController.class.php b/Application/Payment/Controller/PaymentController.class.php index 7d41b83df..86b67acfd 100644 --- a/Application/Payment/Controller/PaymentController.class.php +++ b/Application/Payment/Controller/PaymentController.class.php @@ -93,6 +93,17 @@ class PaymentController extends BaseController } // dump($map);die(); + $sum = M("pay_statement_info","tab_") + ->alias('c') + ->field("sum(if(c.pay_status=0,c.statement_money,0)) unpay_amount,sum(if(c.pay_status>0,c.statement_money,0)) pay_amount,sum(if(c.pay_status<0,c.statement_money,0)) faild_pay_amount") + ->join("left join tab_company_statement_info s on c.statement_info_id = s.id") + ->where($map) + ->find(); + + $this->assign('sum',$sum); +// dump($sum);die(); + + $CompanyInfo = M("company_statement_info","tab_") ->alias('s') ->field("s.*,p.statement_num statement_pool_num") @@ -118,17 +129,29 @@ class PaymentController extends BaseController $v['verify_status_str'] .= ("/". $v['pay_type']); } } + $companypay_info = json_decode($v['company_info'],true); + if (empty($companypay_info['ali_user']) || empty($companypay_info['ali_account'])) { + $v['verify_status'] = -1; + $v['verify_status_str']="信息配置不全"; + $v['can_pay'] = 0; + } - if($v['pay_verify_status'] == 0){ - $v['verify'] = "--"; + if($v['pay_check'] == 0){ + $v['pay_check_detail'] = "--"; }else { $member = M("payment_member") ->field("name") - ->where(['id'=>$v['verify_member_id']]) + ->where(['id'=>$v['pay_check_member_id']]) ->find(); - $v['verify'] = (($v['pay_verify_status'] == 1)?'审核通过':'审核拒绝')."({$member['name']})
".date('Y-m-d H:i:s', $v['verify_time']);; + $v['pay_check_detail'] = $member['name'].(($v['pay_check'] == 1)?'已确认':'未确认')."
".date('Y-m-d H:i:s', $v['pay_check_time']);; } +// if ($v['pay_check'] == 0) { +// $v['pay_check_str'] = "未确认"; +// } else { +// $v['pay_check_str'] = "已确认"; +// } + $v['company_type'] = $this->CompanyType[$v['company_type']]; $v['statement_begin_time'] = date('Y-m-d',$v['statement_begin_time']); $v['statement_end_time'] = date('Y-m-d',$v['statement_end_time']); @@ -194,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) { @@ -207,6 +229,75 @@ class PaymentController extends BaseController $this->assign("PayStatus", $this->PayStatus); $this->display(); } + + //导出 + public function export() { + + if(!isset($_REQUEST['id'])){ + $this->error('参数错误'); + } + $id = $_REQUEST['id']; + $data = M("company_statement_info","tab_") + ->alias('s') + ->field("s.*,p.statement_num statement_pool_num") + ->join("left join tab_company_statement_pool p ON p.id = s.pool_id") + ->where(['s.id'=>['in',$id]]) + ->order("FIELD(s.pay_status,0,-1,1),s.verify_status desc") + ->select(); + + foreach ($data as $key => $value) { + $company_info = json_decode($value['company_info'],true); + $data[$key]['ali_user'] = $company_info['ali_user']; + $data[$key]['ali_account'] = $company_info['ali_account']; + $data[$key]['statement_time'] = date("Y-m-d H:i:s",$value['statement_begin_time']).'-'.date("Y-m-d H:i:s",$value['statement_end_time']); + + if($value['pay_check'] == 0){ + $v['pay_check_detail'] = "--"; + }else { + $member = M("payment_member") + ->field("name") + ->where(['id'=>$value['pay_check_member_id']]) + ->find(); + $data[$key]['pay_check_detail'] = $member['name'].(($value['pay_check'] == 1)?'已确认':'未确认').date('Y-m-d H:i:s', $value['pay_check_time']);; + } + + $data[$key]['pay_status_str'] = $value['pay_status']==1?"已打款":($value['pay_status']==-1?'打款失败':'未打款'); + $data[$key]['pay_time'] = $value['pay_time']?date("Y-m-d H:i:s",$value['pay_time']):'未支付'; + } + + $title = [ + 'company_name' => '公司名称', + 'statement_time' => '结算时间', + 'statement_money' => '结算金额', + 'ali_user' => '支付宝真实姓名', + 'ali_account'=>'支付宝账号', + 'remark'=>'备注', + 'statement_pool_num'=>'汇总单号', + 'pay_check_detail'=>'打款信息确认', + 'pay_status_str'=>'打款状态', + 'pay_time'=>'打款时间',]; + + $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'=>'导出成功']); + + } + //查看 public function viewPool() { @@ -329,52 +420,55 @@ class PaymentController extends BaseController } - foreach($handle_data as $hk => $hv) { - $substract = 1; - if ($is_export) { - - for (;;) { - - if (!$handle_data[$hk+$substract]['time']&&$handle_data[$hk+$substract]['account']) { -// if ( -// $hv['account'] == 'zj9587' || -// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') { -// dump($handle_data[$hk]['time']); -// } - - $week_line++; - $substract++; - } else { - break; - } - - } - - if (count($hv['game_list'])>1) { - $week_line += count($hv['game_list'])-1; - } - - $handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line})+SUM(P{$old_line}:P{$week_line})-SUM(Q{$old_line}:Q{$week_line})-SUM(R{$old_line}:R{$week_line}),2)"; - - - if (count($hv['game_list'])>1) { - - $old_line += count($hv['game_list']); - - } else { - $old_line++; - } - - if(count($hv['game_list'])>1) { - - $week_line = $old_line ; - } else { - $week_line = $old_line; - } - - } - - } +// foreach($handle_data as $hk => $hv) { +// $substract = 1; +// if ($is_export) { +// +// for (;;) { +// +// if (!$handle_data[$hk+$substract]['time']&&$handle_data[$hk+$substract]['account']) { +//// if ( +//// $hv['account'] == 'zj9587' || +//// $hv['account'] == 'ruiyou' || $hv['account'] == 'weicheng') { +//// dump($handle_data[$hk]['time']); +//// } +// +// $week_line++; +// $substract++; +// } else { +// break; +// } +// +// } +// +// if (count($hv['game_list'])>1) { +// $week_line += count($hv['game_list'])-1; +// } +// +// $handle_data[$hk]['week_amount'] = "=ROUND(SUM(O{$old_line}:O{$week_line})+SUM(P{$old_line}:P{$week_line})-SUM(Q{$old_line}:Q{$week_line})-SUM(R{$old_line}:R{$week_line}),2)"; +// +// if ($hk > 0) { +// $handle_data[0]['week_amount'] = str_replace($old_line,$week_line,$handle_data[0]['week_amount']); +// } +// +// if (count($hv['game_list'])>1) { +// +// $old_line += count($hv['game_list']); +// +// } else { +// $old_line++; +// } +// +// if(count($hv['game_list'])>1) { +// +// $week_line = $old_line ; +// } else { +// $week_line = $old_line; +// } +// +// } +// +// } return $handle_data?$handle_data:[]; } @@ -619,6 +713,168 @@ class PaymentController extends BaseController $this->display("viewCpPool"); } + //打款设置 + public function setPayment(){ + if(!isset($_REQUEST['id'])) $this->error("参数错误"); + $id = $_REQUEST['id']; + $CompanyInfo = M("company_statement_info","tab_") + ->alias('i') + ->field("i.id,i.pool_id,i.company_name,i.company_info,i.statement_money,i.remark,i.pay_status,i.verify_status,p.statement_num,i.statement_money") + ->join("tab_company_statement_pool p ON p.id = i.pool_id") + ->where("i.id in({$id})") + ->select(); + + $all_money = 0; + foreach($CompanyInfo as $k=>&$v){ + if($v['verify_status'] == 2){ + $v['is_payment'] = 2; + }else{ + $v['is_payment'] = 1; + } + + $v['company_info'] = json_decode($v['company_info'],true); + $v['company_info']['ali_user'] ?? ''; + $v['company_info']['ali_account'] ?? ''; + + $all_money += $v['statement_money']; + + } + + $this->assign('all_money',$all_money); + $this->assign("CompanyInfo",$CompanyInfo); + $this->assign("id",$id); + $this->display(); + } + + public function returnSetPayment() { + + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + + $ids = explode(',',$ids); + + $CompanyInfo = M("company_statement_info","tab_"); + + $CompanyInfo + ->where(['id'=>['in',$ids]]) + ->save([ + 'pay_check'=>0, + 'pay_check_member_id'=>0, + 'pay_check_time'=>0 + ]); + + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"打款信息编辑成功" + )); + + } + + //修改打款设置 + 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){ + $company_info['payee_name'] = $v['payee_name']; + $company_info['bank_account'] = $v['bank_account']; + $company_info['opening_bank'] = $v['opening_bank']; + }else{ + $company_info['ali_user'] = $v['ali_user']; + $company_info['ali_account'] = $v['ali_account']; + } + $savedata = [ + "company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE), + "remark"=>$v['remark'], + "pay_check"=>1, + "pay_check_member_id"=>$member_id = $_SESSION['onethink_admin']['payment_user']['id'], + "id"=>$k, + "pay_check_time"=>time() + ]; + + M("pay_statement_info","tab_")->where(['statement_info_id'=>$k])->save(["company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE)]); + $CompanyInfo->save($savedata); + + } + + $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"=>"打款信息编辑成功" + )); + + } + public function transfer_set() { $this->getAccountMoney(); @@ -900,10 +1156,16 @@ class PaymentController extends BaseController $fund = new \Fund(C("ALI_PAYMENT")); $dbres = M("pay_statement_info", "tab_")->where("id='{$id}'")->find(); + $company_statement = M("company_statement_info", "tab_")->field("pay_check")->where(['id'=>$dbres['statement_info_id']])->find(); + + if ($company_statement['pay_check']!=1) { + $this->ajaxReturn(["success"=>"打款信息未确认,打款失败","data"=>["status"=>0]]); + } + $company_info = json_decode($dbres['company_info'], true); if ($dbres['pay_status'] != 1 && $dbres['verify_status'] == 1) { //执行打款 - $title = "信息服务费"; + $title = $remark; $amount = $dbres['final_statement_money']; $payres = $fund->transfer($company_info['ali_account'], $company_info['ali_user'], $dbres['statement_num'], $amount, $title); diff --git a/Application/Payment/View/Payment/lists.html b/Application/Payment/View/Payment/lists.html index 219422b9a..275ff26a6 100644 --- a/Application/Payment/View/Payment/lists.html +++ b/Application/Payment/View/Payment/lists.html @@ -214,9 +214,12 @@ 打款 - 审核通过 - 审核拒绝 - 审核撤回 + + + + 打款信息确认 + 打款信息确认撤回 + 导出 @@ -233,7 +236,8 @@ 结算时间 关联汇总单号 结算金额 - 审批状态 + 打款信息确认状态 + 打款状态 支付时间 @@ -252,30 +256,32 @@ - + {$data.company_name} - {$data.company_type} - {$data.valid} - - {$data.statement_pool_num} - - {$data.statement_money} - {$data.verify|default='--'} - - - {$data.verify_status_str} - - {$data.verify_status_str} + {$data.company_type} + {$data.valid} + {$data.statement_pool_num} + + {$data.statement_money} + {$data.pay_check_detail} + + + + {$data.verify_status_str} + {$data.verify_status_str} + + + {$data.pay_time} + {$data.remark} + + 查看 + + 打款详情 - - {$data.pay_time} - {$data.remark} - - 查看 - - 打款详情 - - + + + + @@ -289,7 +295,8 @@ {$s_data.statement_pool_num} {$s_data.statement_money} - {$data.verify|default='--'} + {$data.pay_check_detail} + {$s_data.verify_status_str} @@ -309,7 +316,7 @@ - 合计待打款金额: {$money.statement_money} + 合计待打款金额: {$sum['unpay_amount']|default='0.00'}  打款成功: {$sum['pay_amount']|default='0.00'} 打款失败: {$sum['faild_pay_amount']|default='0.00'} @@ -430,158 +437,189 @@ $(function(){ - $(".return_verify").click(function () { - - var status = $(this).data('value'); - var verifytip = 0; - var paytip = 0; - var canpay = 0; - + // $(".return_verify").click(function () { + // + // var status = $(this).data('value'); + // var verifytip = 0; + // var paytip = 0; + // var canpay = 0; + // + // var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + // + // var verifystatus = $(elem).data('verifystatus'); + // var pay_status = $(elem).data('paystatus'); + // + // if (verifystatus == 0) { + // verifytip = 1; + // return ; + // } + // + // if (pay_status != 0) { + // paytip = 1; + // return ; + // } + // + // return $(elem).data('verify_id'); + // + // }).get(); + // + // if (verifytip == 1) { + // layer.msg("" + '请选择已审核的打款单' + ""); + // return; + // } + // + // if (paytip == 1) { + // layer.msg("" + '请选择未打款的打款单' + ""); + // return; + // } + // + // if(text.length < 1){ + // layer.msg("" + '请先选择要操作的打款单' + ""); + // return; + // } + // + // layer.confirm('【提示】是否取消审核'+((status==1)?'通过':'拒绝'), { + // btn: ['确认','取消'], + // title:false + // }, function(){ + // $.ajax({ + // type:'post', + // dataType:'json', + // data: {'id':text,'status':status}, + // url:"{:U('verify')}", + // success:function(data) { + // + // if (data.status ==1) { + // //弹框 + // layer.msg("审批撤回成功"); + // setTimeout(function(){ + // window.location.reload(); + // },1500); + // } else { + // layer.msg("审批撤回失败"); + // } + // }, + // error:function() { + // alert('服务器开小差了,请稍后再试。'); + // // checkcode(mobile); + // } + // }); + // + // }); + // + // }); + // + // + // $(".verify").click(function () { + // + // var status = $(this).data('value'); + // var verifytip = 0; + // var paytip = 0; + // var canpay = 0; + // var paychecktip = 0; + // + // var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + // + // var verifystatus = $(elem).data('verifystatus'); + // var pay_status = $(elem).data('paystatus'); + // + // if (verifystatus > 0) { + // verifytip = 1; + // return ; + // } + // + // if (pay_status != 0) { + // paytip = 1; + // return ; + // } + // + // if($(elem).data("pay") != 1) { + // canpay = 1; + // return; + // } + // + // if($(elem).data("pay_check") == 0) { + // paychecktip = 1; + // return; + // } + // + // return $(elem).data('verify_id'); + // + // }).get(); + // + // if (paychecktip == 1) { + // layer.msg("" + '请选择打款信息已确认的打款单' + ""); + // return; + // } + // + // if (verifytip == 1) { + // layer.msg("" + '请选择未审核的打款单' + ""); + // return; + // } + // + // if (paytip == 1) { + // layer.msg("" + '请选择未打款的打款单' + ""); + // return; + // } + // + // if (canpay == 1) { + // layer.msg("" + '请选择信息配置完全的打款单' + ""); + // return; + // } + // + // if(text.length < 1){ + // layer.msg("" + '请先选择要操作的打款单' + ""); + // return; + // } + // + // layer.confirm('【提示】是否确认审核'+((status==1)?'通过':'拒绝'), { + // btn: ['确认','取消'], + // title:false + // }, function(){ + // $.ajax({ + // type:'post', + // dataType:'json', + // data: {'id':text,'status':status}, + // url:"{:U('verify')}", + // success:function(data) { + // layer.msg("" + data.msg + ""); + // if (data.status ==1) { + // //弹框 + // setTimeout(function(){ + // window.location.reload(); + // },1500); + // } + // }, + // error:function() { + // alert('服务器开小差了,请稍后再试。'); + // // checkcode(mobile); + // } + // }); + // + // }); + // + // }); + + $("#export").click(function () { + var flag = false; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - - var verifystatus = $(elem).data('verifystatus'); - var pay_status = $(elem).data('paystatus'); - - if (verifystatus == 0) { - verifytip = 1; - return ; - } - - if (pay_status != 0) { - paytip = 1; - return ; - } - - return $(elem).data('verify_id'); - + return $(elem).data("verify_id"); }).get(); - if (verifytip == 1) { - layer.msg("" + '请选择已审核的打款单' + ""); - return; - } - - if (paytip == 1) { - layer.msg("" + '请选择未打款的打款单' + ""); - return; - } - if(text.length < 1){ - layer.msg("" + '请先选择要操作的打款单' + ""); + layer.msg("" + '请先选择要导出的打款单' + ""); return; } - - layer.confirm('【提示】是否取消审核'+((status==1)?'通过':'拒绝'), { - btn: ['确认','取消'], - title:false - }, function(){ - $.ajax({ - type:'post', - dataType:'json', - data: {'id':text,'status':status}, - url:"{:U('verify')}", - success:function(data) { - - if (data.status ==1) { - //弹框 - layer.msg("审批撤回成功"); - setTimeout(function(){ - window.location.reload(); - },1500); - } else { - layer.msg("审批撤回失败"); - } - }, - error:function() { - alert('服务器开小差了,请稍后再试。'); - // checkcode(mobile); - } - }); - - }); - + _export(); + function _export(){ + layer.alert(""+"指令执行成功,等待浏览器响应中..在未确认下载完成前请勿关闭此页面.."+ ""); + var id = text.join(","); + var url ="{:U('export')}"+"&id="+id; + var iframeExcel = ""//添加下载的地址到iframe,这里是公司信息,我用**表示了。 + $("body").append(iframeExcel); + } }); - - $(".verify").click(function () { - - var status = $(this).data('value'); - var verifytip = 0; - var paytip = 0; - var canpay = 0; - - var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - - var verifystatus = $(elem).data('verifystatus'); - var pay_status = $(elem).data('paystatus'); - - if (verifystatus > 0) { - verifytip = 1; - return ; - } - - if (pay_status != 0) { - paytip = 1; - return ; - } - - if($(elem).data("pay") != 1) { - canpay = 1; - return; - } - - return $(elem).data('verify_id'); - - }).get(); - - if (verifytip == 1) { - layer.msg("" + '请选择未审核的打款单' + ""); - return; - } - - if (paytip == 1) { - layer.msg("" + '请选择未打款的打款单' + ""); - return; - } - - if (canpay == 1) { - layer.msg("" + '请选择信息配置完全的打款单' + ""); - return; - } - - if(text.length < 1){ - layer.msg("" + '请先选择要操作的打款单' + ""); - return; - } - - layer.confirm('【提示】是否确认审核'+((status==1)?'通过':'拒绝'), { - btn: ['确认','取消'], - title:false - }, function(){ - $.ajax({ - type:'post', - dataType:'json', - data: {'id':text,'status':status}, - url:"{:U('verify')}", - success:function(data) { - layer.msg("" + data.msg + ""); - if (data.status ==1) { - //弹框 - setTimeout(function(){ - window.location.reload(); - },1500); - } - }, - error:function() { - alert('服务器开小差了,请稍后再试。'); - // checkcode(mobile); - } - }); - - }); - - }); - var company_id = "{$_GET['company_id']??0}"; $("#company_type").on("change",function(){ var val = $(this).find("option:selected").val(); @@ -605,7 +643,7 @@ $("#company_id").html(companystr); $("#company_id").select2(); }) - }) + }); $("#company_type").change(); $(".viewPool").click(function () { @@ -638,8 +676,8 @@ var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - var verifystatus = $(elem).data('verifystatus'); - if($(elem).data("pay") == 1 && verifystatus == 1){ + // var verifystatus = $(elem).data('verifystatus'); + if($(elem).data("pay") == 1 ){ return $(elem).data("verify_id"); } @@ -685,13 +723,12 @@ var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { var verifystatus = $(elem).data('verifystatus'); - if($(elem).data("pay") == 1 && verifystatus == 1 && $(elem).val()!=''){ + if($(elem).data("pay") == 1 && $(elem).val()!=''){ return $(elem).val(); } }).get(); - console.log(text) text = text.join(","); if (!text) { @@ -712,26 +749,143 @@ $("#commit").on("click",function () { doPayment(); + }); + + $(".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) && $(elem).data("paystatus") != 1){ + return $(elem).data("verify_id"); + } + if ($(elem).data("pay_check") != 1) { + tip = 1; + } + + if ($(elem).data("paystatus") == 1) { + paystatustip = 1; + } + + }).get(); + + if(tip == 1) { + layer.msg("请选择打款信息未确认的单子"); + return; + } + + if(paystatustip == 1) { + layer.msg("请选择未打款的单子"); + return; + } + + text = text.join(","); + + if (!text) { + layer.msg("没有符合打款确认的打款单,请重新选择"); + return; + } + + var url = "{:U('setPayment')}"+"&id="+text + layer.open({ + type: 2, + title: "海南万盟天下科技有限公司", + shadeClose: true, + shade: 0.8, + area: ['100%', '100%'], + content: url + }); + }); + + $("#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 && $(elem).data("paystatus") != 1){ + return $(elem).data("verify_id"); + } + + if ($(elem).data("pay_check") != 1) { + tip = 1; + } + + if ($(elem).data("paystatus") == 1) { + paystatustip = 1; + } + + }).get(); + + if(tip == 1) { + layer.msg("请选择打款信息已确认的单子"); + return; + } + + if(paystatustip == 1) { + layer.msg("请选择未打款的单子"); + return; + } + + text = text.join(","); + + layer.confirm('【提示】是否确认打款信息撤回', { + btn: ['确认','取消'], + title:false + }, function(){ + $.ajax({ + type:'post', + dataType:'json', + data: {'ids':text}, + url:"{:U('returnSetPayment')}", + success:function(data) { + if (data.status == 1) { + layer.msg("打款信息确认撤回成功"); + window.location.reload(); + return; + } + }, + error:function() { + alert('服务器开小差了,请稍后再试。'); + } + }) + }); + + }); $("#doPayment").on("click",function(){ var verifytip = 0; + var pay_checktip = 0; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - var verifystatus = $(elem).data('verifystatus'); - if($(elem).data("pay") == 1 && verifystatus == 1){ + // var verifystatus = $(elem).data('verifystatus'); + var pay_check = $(elem).data('pay_check'); + if($(elem).data("pay") == 1 && pay_check == 1){ return $(elem).val(); } - if (verifystatus != 1) { - verifytip = 1; + // if (verifystatus != 1) { + // verifytip = 1; + // } + + if (pay_check != 1) { + pay_checktip = 1; } }).get(); - if (verifytip == 1) { - layer.msg("审核通过方能打款"); - return; + if (pay_checktip == 1) { + layer.msg("打款确认后方能打款"); + return; } + // if (verifytip == 1) { + // layer.msg("审核通过方能打款"); + // return; + // } + if(text.length < 1){ layer.msg("请先选择需要打款的结算单"); return;