From 671419882fb6fc48627308c7426e89d5cf2e0256 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Fri, 23 Apr 2021 10:18:24 +0800 Subject: [PATCH] =?UTF-8?q?4.23=E5=8F=B7=E5=8A=9F=E8=83=BD=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ompanyStatementOfflineController.class.php | 302 ++++++++++++++- .../View/CompanyStatementOffline/lists.html | 93 ++++- .../setPartPayment.html | 347 ++++++++++++++++++ 3 files changed, 711 insertions(+), 31 deletions(-) create mode 100644 Application/Admin/View/CompanyStatementOffline/setPartPayment.html diff --git a/Application/Admin/Controller/CompanyStatementOfflineController.class.php b/Application/Admin/Controller/CompanyStatementOfflineController.class.php index bdc553233..e5cc02add 100644 --- a/Application/Admin/Controller/CompanyStatementOfflineController.class.php +++ b/Application/Admin/Controller/CompanyStatementOfflineController.class.php @@ -19,7 +19,8 @@ class CompanyStatementOfflineController extends ThinkController public $PayStatus=[ "-1"=>"打款失败", "0"=>"未打款", - "1"=>"打款成功" + "1"=>"打款成功", + "2"=>"部分打款" ]; public function lists() { @@ -87,6 +88,16 @@ class CompanyStatementOfflineController extends ThinkController ->page($page,$row) ->order("id desc") ->select(); + + $unPayData = SM("company_statement_info_part","tab_") + ->field("sum(statement_money) statement_money,info_id") + ->group("info_id") + ->select(); + + $handleData = []; + foreach ($unPayData as $key => $value) { + $handleData[$value['info_id']] = $value['statement_money']; + } foreach($data as $k => &$v) { @@ -96,6 +107,8 @@ class CompanyStatementOfflineController extends ThinkController $v["valid"] = "{$v['statement_begin_time']}-{$v['statement_end_time']}"; $v["pay_status_str"] = $this->PayStatus[$v["pay_status"]]; + $v['surplus_amount'] = ($v["pay_check"]==2)?($handleData[$v['id']] ?? $v['statement_money']):($v["pay_status"]!=1?$v['statement_money']:"0.00"); + $v["pay_info"] = json_decode($v['pay_info'], true); if(isset($v['pay_info']['payment_user'])){ $v["payment"]= "{$v['pay_status_str']}({$v['pay_info']['payment_user']})
{$v['pay_info']['payment_time']}"; @@ -110,7 +123,15 @@ class CompanyStatementOfflineController extends ThinkController ->field("username") ->where(['id'=>$v['pay_check_member_id']]) ->find(); - $v['pay_check_str'] = $member['username'].(($v['pay_check'] == 1)?'已确认':'未确认')."
".date('Y-m-d H:i:s', $v['pay_check_time']);; + if ($v['pay_check'] == 1) { + $pay_check = '已确认'; + } elseif($v['pay_check'] == 2) { + $pay_check = '部分确认'; + } else { + $pay_check = '未确认'; + } + + $v['pay_check_str'] = $member['username'].$pay_check."
".date('Y-m-d H:i:s', $v['pay_check_time']);; // $v['pay_check_str'] = "已确认"; } @@ -143,11 +164,14 @@ class CompanyStatementOfflineController extends ThinkController $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") + ->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,i.pay_check") ->join("tab_company_statement_pool p ON p.id = i.pool_id") ->where("i.id in({$id})") ->select(); + $temp = $this->addPaymentPartInfo($CompanyInfo); + $temp?$CompanyInfo=$temp:""; + $all_money = 0; foreach($CompanyInfo as $k=>&$v){ if($v['verify_status'] == 2){ @@ -170,18 +194,177 @@ class CompanyStatementOfflineController extends ThinkController $this->display(); } + public function addPaymentPartInfo($CompanyInfo) { + + if ($CompanyInfo[0]['pay_check'] !=2) { + return []; + } + + $id = array_column($CompanyInfo,"id"); + $data = M("company_statement_info_part","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,info_id") + ->join("tab_company_statement_pool p ON p.id = i.pool_id") + ->where(['info_id'=>['in',$id]]) + ->select(); + + + foreach ($data as $key => $value) { + $data[$key]['id'] = $value['id']."-".$value['info_id']; + } + + return $data; + + } + //修改打款设置 public function editPayment(){ // dump($_SESSION);die(); if(!isset($_REQUEST['info'])) $this->error("参数错误"); $info = $_REQUEST['info']; + $keys = ''; + $saveKey = []; -// dump($info);die(); $CompanyInfo = M("company_statement_info","tab_"); //循环保存 foreach($info as $k=>$v){ + +// dump(explode('-',$k));die(); + + $exKeys = explode('-',$k); + + if (count($exKeys) > 1) { + + $keys = $exKeys; + if (!$saveKey[$keys[1]]) { + + $saveKey[$keys[1]] = 1; + $ydata = $CompanyInfo->where("id= '{$keys[1]}'")->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 = [ + "pay_check"=>1, + "pay_check_member_id"=> $_SESSION['onethink_admin']['user_auth']['uid'], + "id"=>$keys[1], + "pay_check_time"=>time() + ]; + + $CompanyInfo->save($savedata); + } + + $ydata = M("company_statement_info_part","tab_")->where("id= '{$keys[0]}'")->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"=> $_SESSION['onethink_admin']['user_auth']['uid'], + "id"=>$keys[0], + "pay_check_time"=>time() + ]; + + M("company_statement_info_part","tab_")->save($savedata); + + } else { + $ydata = $CompanyInfo->where("id= '{$keys[1]}'")->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"=> $_SESSION['onethink_admin']['user_auth']['uid'], + "id"=>$k, + "pay_check_time"=>time() + ]; + + $CompanyInfo->save($savedata); + } + + } + + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"打款信息编辑成功" + )); + + } + + //打款设置 + public function setPartPayment(){ + 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 editPartPayment(){ + + + if (count($_REQUEST['info']) < 2) { + $this->error("未添加剩余打款金额"); + } + + if(!isset($_REQUEST['info'])) $this->error("参数错误"); + $info = $_REQUEST['info']; + $ydata = []; + $company_info = []; + + $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']; @@ -194,14 +377,45 @@ class CompanyStatementOfflineController extends ThinkController $savedata = [ "company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE), "remark"=>$v['remark'], - "pay_check"=>1, + "pay_check"=>2, "pay_check_member_id"=> $_SESSION['onethink_admin']['user_auth']['uid'], "id"=>$k, "pay_check_time"=>time() ]; $CompanyInfo->save($savedata); + unset($info[$k]); + break; + + } + +// array_pop($info); + + $id = $ydata["id"]; + unset($ydata["id"]); + + $sumUnPayAmount = array_sum(array_column($info,'unpay_amount')); + + if ($sumUnPayAmount > $ydata['statement_money'] ) { + $this->error("剩余打款金额超过结算金额"); + } + + foreach ($info as $k=>$v) { + 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']; + } + $ydata['company_info'] = json_encode($company_info,JSON_UNESCAPED_UNICODE); + $ydata['statement_money'] = $v['unpay_amount']; + $ydata['pay_amount'] = $v['unpay_amount']; + $ydata['remark'] = $v['remark']; + $ydata['info_id'] = $id; + M("company_statement_info_part","tab_")->add($ydata); } $this->ajaxReturn(array( @@ -220,13 +434,33 @@ class CompanyStatementOfflineController extends ThinkController $CompanyInfo = M("company_statement_info","tab_"); - $CompanyInfo - ->where(['id'=>['in',$ids]]) - ->save([ - 'pay_check'=>0, - 'pay_check_member_id'=>0, - 'pay_check_time'=>0 - ]); + $data = $CompanyInfo->where(['id'=>['in',$ids]])->select(); + foreach ($data as $key => $value) { + + if ($value['pay_check'] == 2||($value['pay_check'] == 1&&$value['pay_status'] == 0)) { + $CompanyInfo + ->where(['id'=>$value['id']]) + ->save([ + 'pay_check'=>0, + 'pay_check_member_id'=>0, + 'pay_check_time'=>0 + ]); + + M("company_statement_info_part","tab_")->where(['info_id'=>$value['id']])->delete(); + + } elseif($value['pay_check'] == 1&&$value['pay_status'] == 2) { + $CompanyInfo + ->where(['id'=>$value['id']]) + ->save([ + 'pay_check'=>2, + 'pay_check_member_id'=>$_SESSION['onethink_admin']['user_auth']['uid'], + 'pay_check_time'=>time() + ]); + } + + } + + $this->ajaxReturn(array( 'status' => 1, @@ -251,15 +485,51 @@ class CompanyStatementOfflineController extends ThinkController //获取母单未支付完成订单 $poolIds = implode(",",array_keys($yPoolInfo)); - $poolInfo = $companyStatementInfo->where("pool_id in ($poolIds) and pay_status <> 1")->field("pool_id,count(id) count")->group("pool_id")->select(); - - //修改info + $poolInfo = $companyStatementInfo->where("pool_id in ($poolIds) and pay_status <> 1 and pay_check !=2")->field("pool_id,count(id) count")->group("pool_id")->select(); + + $info_id = $companyStatementInfo->field("id")->where("id in ($ids) and pay_check !=2")->select(); + $unPayInfoId = $companyStatementInfo->field("id")->where("id in ($ids) and pay_check =2")->select(); + + $info_id = array_column($info_id,"id"); + $unPayInfoId = array_column($unPayInfoId,"id"); + + //支付确认的部分 $saveData = [ "pay_type"=>3, "pay_status"=>1, "pay_info"=>json_encode(["payment_user"=>$_SESSION['onethink_admin']['user_auth']["username"],"payment_time"=>$payment_time]) ]; - $ires = $companyStatementInfo->where("id in ($ids)")->save($saveData); + if($info_id) { + $companyStatementInfo->where(['id'=>['in',$info_id]])->save($saveData); + } + + //支付未确认的部分 + $saveData = [ + "pay_type"=>3, + "pay_status"=>2, + "pay_info"=>json_encode(["payment_user"=>$_SESSION['onethink_admin']['user_auth']["username"],"payment_time"=>$payment_time]) + ]; + + $unPayData = SM("company_statement_info_part","tab_") + ->field("sum(statement_money) statement_money,info_id") + ->group("info_id") + ->select(); + + $handleData = []; + foreach ($unPayData as $key => $value) { + $handleData[$value['info_id']] = $value['statement_money']; + } + + if ($unPayInfoId) { + $unPayData = $companyStatementInfo->where(['id'=>['in',$unPayInfoId]])->select(); + foreach ($unPayData as $key => $value) { + $time = date("Y-m-d H:i:s",time()); + $unPayAmount = $value['statement_money']-$handleData[$value['id']]; + $saveData['remark'] = "{$value['remark']},{$_SESSION['onethink_admin']['user_auth']['username']}于{$time}已打款{$unPayAmount},剩余{$handleData[$value['id']]}"; + + $companyStatementInfo->where(['id'=>$value['id']])->save($saveData); + } + } //全部就打款成功,否则打款中 $companyStatementPool = SM("company_statement_pool","tab_"); diff --git a/Application/Admin/View/CompanyStatementOffline/lists.html b/Application/Admin/View/CompanyStatementOffline/lists.html index b14365a3a..66dd5e56b 100644 --- a/Application/Admin/View/CompanyStatementOffline/lists.html +++ b/Application/Admin/View/CompanyStatementOffline/lists.html @@ -168,6 +168,7 @@ 公司类型 结算时间 结算金额 + 剩余未打款金额 结算流水 打款信息确认状态 打款状态 @@ -192,6 +193,7 @@ {$data.company_type_str} {$data.valid} {$data.statement_money} + {$data.surplus_amount} {$data.platform_amount} {$data.pay_check_str} {$data.payment} @@ -277,10 +279,19 @@ $("#setPayment").on('click',function(){ var tip = 0; + var unpay = false; + var pay = false; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("pay_check") == 0){ + if ($(elem).data("pay_check") == 2) { + unpay = true; + } + if ($(elem).data("pay_check") == 0) { + pay = true; + } + + if($(elem).data("pay_check") == 0 || ($(elem).data("pay_check") == 2&&$(elem).data("paystatus")==2)){ return $(elem).val(); } else { tip = 1; @@ -293,6 +304,8 @@ return; } + var textLength = text.length; + text = text.join(","); if (!text) { @@ -300,16 +313,56 @@ return; } - var url = "{:U('setPayment')}"+"&id="+text - layer.open({ - type: 2, - title: "海南万盟天下科技有限公司", - shadeClose: true, - shade: 0.8, - area: ['100%', '100%'], - content: url - }); + if(unpay && pay) { + layer.msg("部分确认的打款单不能与确认的打款单一起确认"); + return; + } + + var url = "{:U('setPartPayment')}"+"&id="+text; + if(!unpay && pay) { + layer.confirm('【提示】是否全部打款', { + btn: ['是','否'], + title:false + }, function(){ + layer.closeAll(); + url = "{:U('setPayment')}"+"&id="+text; + layer.open({ + type: 2, + title: "海南万盟天下科技有限公司", + shadeClose: true, + shade: 0.8, + area: ['100%', '100%'], + content: url + }); + + }, function(){ + + if (textLength > 1) { + layer.msg("部分确认的单子一次不能处理超过两条"); + return; + } + + layer.open({ + type: 2, + title: "海南万盟天下科技有限公司", + shadeClose: true, + shade: 0.8, + area: ['100%', '100%'], + content: url + }); + }); + } else { + url = "{:U('setPayment')}"+"&id="+text; + layer.open({ + type: 2, + title: "海南万盟天下科技有限公司", + shadeClose: true, + shade: 0.8, + area: ['100%', '100%'], + content: url + }); + } }); $(".viewStatement").click(function () { @@ -336,7 +389,11 @@ return $(elem).val(); } - if ($(elem).data("pay_check") != 1) { + if($(elem).data("pay_check") == 2 && $(elem).data("paystatus") == 0){ + return $(elem).val(); + } + + if ($(elem).data("pay_check") == 0) { tip = 1; } @@ -345,7 +402,7 @@ } }).get(); - + console.log(text); if(tip == 1) { layer.msg("请选择打款信息已确认的单子"); return; @@ -356,6 +413,12 @@ return; } + if (text.length<1) { + layer.msg("未选择达到条件的结算单"); + return; + } + + text = text.join(","); layer.confirm('【提示】是否确认打款信息撤回', { @@ -388,16 +451,16 @@ var pay_check_tip = 0; var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - if($(elem).data("paystatus") == 0&&$(elem).data("pay_check") == 1){ + if(($(elem).data("paystatus") == 0&&$(elem).data("pay_check") == 1) || ($(elem).data("paystatus") == 0&&$(elem).data("pay_check") == 2) || ($(elem).data("paystatus") == 2&&$(elem).data("pay_check") == 1)){ return $(elem).val(); } - if ($(elem).data("pay_check") != 1) { + if ($(elem).data("pay_check") == 0) { pay_check_tip = 1; } }).get(); - + // console.log(text);return; if (pay_check_tip == 1) { layer.msg("请选择打款信息已经确认的单子"); return; diff --git a/Application/Admin/View/CompanyStatementOffline/setPartPayment.html b/Application/Admin/View/CompanyStatementOffline/setPartPayment.html new file mode 100644 index 000000000..4cd094fbf --- /dev/null +++ b/Application/Admin/View/CompanyStatementOffline/setPartPayment.html @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
序号合作公司是否支付宝打款户名帐号开户行关联结算汇总单订单号结算金额(元)备注操作
{$key-0+1}{$vo.company_name}{$vo.statement_num}{$vo.statement_money}新增
{$key-0+1}{$vo.company_name}{$vo.company_info.ali_user}{$vo.company_info.ali_account}{$vo.company_info.payee_name}{$vo.company_info.bank_account}{$vo.company_info.opening_bank}{$vo.statement_num}{$vo.statement_money}{$vo.remark}新增
合计:结算总金额:{$all_money}剩余打款金额:0
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
2{$vo.company_name}{$vo.statement_num}删除
+ +
+ + + + + \ No newline at end of file