From 83cc2aa6ec72df1d5be38073ab57111ddae49b67 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Fri, 23 Apr 2021 17:14:09 +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 | 86 +++++++++++++++---- .../View/CompanyStatementOffline/lists.html | 15 +++- .../setPartPayment.html | 5 +- Data/update.sql | 5 +- 4 files changed, 88 insertions(+), 23 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementOfflineController.class.php b/Application/Admin/Controller/CompanyStatementOfflineController.class.php index 93c9d45df..475748270 100644 --- a/Application/Admin/Controller/CompanyStatementOfflineController.class.php +++ b/Application/Admin/Controller/CompanyStatementOfflineController.class.php @@ -91,6 +91,7 @@ class CompanyStatementOfflineController extends ThinkController $unPayData = SM("company_statement_info_part","tab_") ->field("sum(statement_money) statement_money,info_id") + ->where(["pay_status"=>1]) ->group("info_id") ->select(); @@ -107,7 +108,7 @@ 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["pay_status"]==2?$handleData[$v['id']]:$v['statement_money']):"0.00"); + $v['surplus_amount'] = ($v["pay_check"]==2)?($handleData[$v['id']] ? ($v['statement_money']-$handleData[$v['id']]):$v['statement_money'] ):($v["pay_status"]!=1?($v["pay_status"]==2?($v['statement_money']-$handleData[$v['id']]):$v['statement_money']):"0.00"); $v["pay_info"] = json_decode($v['pay_info'], true); if(isset($v['pay_info']['payment_user'])){ @@ -135,6 +136,16 @@ class CompanyStatementOfflineController extends ThinkController // $v['pay_check_str'] = "已确认"; } + $isUnPay = SM("company_statement_info_part","tab_") + ->field("info_id") + ->where(["pay_status"=>0,'info_id'=>$v['id']]) + ->group("info_id") + ->find(); + + if ($isUnPay) { + $v['pay_status'] = 0; + } + $v['oplist'] = $this->OpAuth($v); } //pay_status @@ -169,8 +180,8 @@ class CompanyStatementOfflineController extends ThinkController ->where("i.id in({$id})") ->select(); - $temp = $this->addPaymentPartInfo($CompanyInfo); - $temp?$CompanyInfo=$temp:""; +// $temp = $this->addPaymentPartInfo($CompanyInfo); +// $temp?$CompanyInfo=$temp:""; $all_money = 0; foreach($CompanyInfo as $k=>&$v){ @@ -205,7 +216,7 @@ class CompanyStatementOfflineController extends ThinkController ->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]]) + ->where(['info_id'=>['in',$id],"pay_status"=>0]) ->select(); @@ -324,6 +335,18 @@ class CompanyStatementOfflineController extends ThinkController ->where("i.id in({$id})") ->select(); + $unPayData = SM("company_statement_info_part","tab_") + ->field("sum(statement_money) statement_money,info_id") + ->where(["pay_status"=>1]) + ->group("info_id") + ->select(); + + $handleData = []; + foreach ($unPayData as $key => $value) { + $handleData[$value['info_id']] = $value['statement_money']; + } + + $surplurAmount = 0; $all_money = 0; foreach($CompanyInfo as $k=>&$v){ if($v['verify_status'] == 2){ @@ -337,9 +360,11 @@ class CompanyStatementOfflineController extends ThinkController $v['company_info']['ali_account'] ?? ''; $all_money += $v['statement_money']; + $surplurAmount += $handleData[$v['id']]; } + $this->assign('surplur_amount',$all_money-$surplurAmount); $this->assign('all_money',$all_money); $this->assign("CompanyInfo",$CompanyInfo); $this->assign("id",$id); @@ -414,6 +439,8 @@ class CompanyStatementOfflineController extends ThinkController $ydata['pay_amount'] = $v['unpay_amount']; $ydata['remark'] = $v['remark']; $ydata['info_id'] = $id; + $ydata['pay_check'] = 0; + $ydata['pay_status'] = 0; M("company_statement_info_part","tab_")->add($ydata); } @@ -437,7 +464,7 @@ class CompanyStatementOfflineController extends ThinkController $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)) { + if ($value['pay_check'] == 1&&$value['pay_status'] == 0) { $CompanyInfo ->where(['id'=>$value['id']]) ->save([ @@ -446,16 +473,21 @@ class CompanyStatementOfflineController extends ThinkController 'pay_check_time'=>0 ]); - M("company_statement_info_part","tab_")->where(['info_id'=>$value['id']])->delete(); + } + + if ($value['pay_check'] == 2) { - } 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() - ]); + if($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'],'pay_status'=>['neq',1]])->delete(); } } @@ -485,7 +517,7 @@ class CompanyStatementOfflineController extends ThinkController //获取母单未支付完成订单 $poolIds = implode(",",array_keys($yPoolInfo)); - $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(); +// $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(); @@ -525,12 +557,32 @@ class CompanyStatementOfflineController extends ThinkController 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']]}"; + $saveData['remark'] = "{$value['remark']} {$_SESSION['onethink_admin']['user_auth']['username']}于{$time}已打款{$handleData[$value['id']]},剩余{$unPayAmount}"; + + SM("company_statement_info_part","tab_") + ->where(['info_id'=>$value['id']]) + ->save(["pay_status"=>1]); + + if($value['statement_money'] - $handleData[$value['id']] <=0) { + //打款成功 + $companyStatementInfo->where(['id'=>$value['id']])->save([ + "pay_check"=>1, + "pay_type"=>3, + "pay_status"=>1, + "pay_info"=>json_encode(["payment_user"=>$_SESSION['onethink_admin']['user_auth']["username"],"payment_time"=>$payment_time]), + "remark"=>$saveData['remark'] + ]); + } else { + $companyStatementInfo->where(['id'=>$value['id']])->save($saveData); + } - $companyStatementInfo->where(['id'=>$value['id']])->save($saveData); } } + $poolInfo = $companyStatementInfo->where("pool_id in ($poolIds) and pay_status <> 1")->field("pool_id,count(id) count")->group("pool_id")->select(); + +// dump($yPoolInfo); +// dump($poolInfo);die(); //全部就打款成功,否则打款中 $companyStatementPool = SM("company_statement_pool","tab_"); foreach ($poolInfo as $k => $v) { diff --git a/Application/Admin/View/CompanyStatementOffline/lists.html b/Application/Admin/View/CompanyStatementOffline/lists.html index 573d15182..833ec0807 100644 --- a/Application/Admin/View/CompanyStatementOffline/lists.html +++ b/Application/Admin/View/CompanyStatementOffline/lists.html @@ -354,8 +354,13 @@ content: url }); }); - } else { - url = "{:U('setPayment')}"+"&id="+text; + } else if(unpay) { + // url = "{:U('setPayment')}"+"&id="+text; + if (textLength > 1) { + layer.msg("部分确认的单子一次不能处理超过两条"); + return; + } + layer.open({ type: 2, title: "海南万盟天下科技有限公司", @@ -453,7 +458,11 @@ 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) || ($(elem).data("paystatus") == 0&&$(elem).data("pay_check") == 2) || ($(elem).data("paystatus") == 2&&$(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) + || ($(elem).data("paystatus") == 2&&$(elem).data("pay_check") == 2) + ){ return $(elem).val(); } diff --git a/Application/Admin/View/CompanyStatementOffline/setPartPayment.html b/Application/Admin/View/CompanyStatementOffline/setPartPayment.html index 264b1688d..7a9dbc17a 100644 --- a/Application/Admin/View/CompanyStatementOffline/setPartPayment.html +++ b/Application/Admin/View/CompanyStatementOffline/setPartPayment.html @@ -166,7 +166,7 @@ 合计: - 结算总金额:{$all_money}剩余打款金额:0 + 结算总金额:{$all_money}剩余打款金额:{$surplur_amount} @@ -321,6 +321,7 @@ }); } + var surplur_amount = "{$surplur_amount}"; function unPayAmountDetail() { var value = 0; @@ -330,7 +331,7 @@ }).get(); - $(".surplusAmount").text(value); + $(".surplusAmount").text((surplur_amount - value).toFixed(2)); } function cancelPoolAjax(opurl,senddata){ diff --git a/Data/update.sql b/Data/update.sql index 785a3a4c1..e26d53ea5 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2823,4 +2823,7 @@ CREATE TABLE `tab_business_affairs_award_pool` ( `verify_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '审核状态 0 未审核 1 审核通过 2 审核拒绝', `verify_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; \ No newline at end of file +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic; + +ALTER TABLE `tab_company_statement_info` +MODIFY COLUMN `remark` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL COMMENT '备注' AFTER `pay_info`; \ No newline at end of file