From 69cf42e895270a7fe6818b4d4ee0da94a6d8893f Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 25 Aug 2020 11:16:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BA=BF=E4=B8=8B=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E6=89=93=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ompanyStatementOfflineController.class.php | 88 ++++++++++++++----- .../CompanyStatementPoolController.class.php | 12 +-- .../View/CompanyStatementOffline/lists.html | 21 ++--- 3 files changed, 75 insertions(+), 46 deletions(-) diff --git a/Application/Admin/Controller/CompanyStatementOfflineController.class.php b/Application/Admin/Controller/CompanyStatementOfflineController.class.php index 25893f7f5..795822b43 100644 --- a/Application/Admin/Controller/CompanyStatementOfflineController.class.php +++ b/Application/Admin/Controller/CompanyStatementOfflineController.class.php @@ -21,11 +21,7 @@ class CompanyStatementOfflineController extends ThinkController "0"=>"未打款", "1"=>"打款成功" ]; - public $VerifyStatus=[ - "-1"=>"审批拒绝", - "0"=>"未审批", - "1"=>"审批通过", - ]; + public function lists() { $params = I('get.'); $page = $params['p'] ? intval($params['p']) : 1; @@ -37,7 +33,8 @@ class CompanyStatementOfflineController extends ThinkController $this->assign('menubtn',$this->menuAuth()); $map = [ - "c.verify_status"=>2 + "c.verify_status"=>2, + "p.verify_status"=>["GT",1] ]; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { $time_start = strtotime($_REQUEST['time_start']); @@ -58,14 +55,6 @@ class CompanyStatementOfflineController extends ThinkController if(isset($_REQUEST['company_name'])){ $map['c.company_name'] =["LIKE","%{$_REQUEST['company_name']}%"]; } - // if(isset($_REQUEST['statement_pool_num'])){ - // $map['statement_pool_num'] =["LIKE","%{$_REQUEST['statement_pool_num']}%"]; - // } - // if(isset($_REQUEST['is_payment'])){ - // $map['is_payment'] = $_REQUEST['is_payment']; - // } - - // $this->checkListOrCountAuthRestMap($map);//导出权限 //条件end $data = M("company_statement_info","tab_") @@ -73,7 +62,7 @@ class CompanyStatementOfflineController extends ThinkController ->field("c.*,p.statement_num,p.verify_status") ->where($map) - ->join("left join tab_company_statement_pool as p ON c.pool_id = p.id") + ->join("tab_company_statement_pool as p ON c.pool_id = p.id") ->page($page,$row) ->order("id desc") @@ -86,19 +75,18 @@ class CompanyStatementOfflineController extends ThinkController $v['company_type_str'] = $this->CompanyType[$v['company_type']]; $v["valid"] = "{$v['statement_begin_time']}-{$v['statement_end_time']}"; $v["pay_status_str"] = $this->PayStatus[$v["pay_status"]]; - if($v["verify_status"] < 0){ - $v["verify_status"] = -1; - } - if($v["verify_status"] > 0){ - $v["verify_status"] = 1; + + $v["pay_info"] = json_decode($v['pay_info'], true); + if(isset($v['pay_info']['payment_user'])){ + $v["payment"]= "{$v['pay_status_str']}({$v['verify_log']['payment_user']})
{$v['verify_log']['payment_time']}"; + }else{ + $v["payment"] = $v["pay_status_str"]; } - $v["verify_status_str"] = $this->VerifyStatus[$v["verify_status"]]; - $v['oplist'] = $this->OpAuth($v); } - $count = M("company_statement_info","tab_")->alias("c")->field("count(id) count,sum(statement_money) statement_money")->where($map)->find(); + $count = M("company_statement_info","tab_")->alias("c")->field("count(c.id) count,sum(c.statement_money) statement_money")->join("tab_company_statement_pool as p ON c.pool_id = p.id")->where($map)->find(); // dd($count); $params['p'] = $page; $params['row'] = $row; @@ -113,6 +101,58 @@ class CompanyStatementOfflineController extends ThinkController $this->display(); } + public function doPayment() + { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + //获取所有的母单id + $companyStatementInfo = M("company_statement_info","tab_"); + $statementPool = $companyStatementInfo->where("id in ($ids) and pay_status <> 1")->field("pool_id,count(id) count")->group("pool_id")->select(); + $poolInfo = []; + foreach ($statementPool as $k => $v) { + $poolInfo[$v['pool_id']] = $v['count']; + } + unset($statementPool); + + //修改info + $saveData = [ + "pay_type"=>3, + "pay_status"=>1, + "pay_info"=>json_encode(["payment_user"=>$_SESSION['onethink_admin']['user_auth']["username"],"payment_time"=>date("Y-m-d H:i:s")]) + ]; + $ires = $companyStatementInfo->where("id in ($ids)")->save($saveData); + + //获取母单未支付完成订单 + $poolIds = implode(",",array_keys($poolInfo)); + $poolInfo = $companyStatementInfo->where("pool_id in ($poolIds) and pay_status <> 1")->field("pool_id,count(id) count")->group("pool_id")->select(); + + //全部就打款成功,否则打款中 + $companyStatementPool = M("company_statement_pool","tab_"); + foreach ($poolInfo as $k => $v) { + if($v['count'] == $poolInfo[$v['pool_id']]){ + //打款成功 + $this->setOneVerifyStatus(4,"payment",$v['pool_id']); + }else{ + //打款中 + $this->setOneVerifyStatus(3,"payment",$v['pool_id']); + } + } + + $this->ajaxReturn(array( + 'status' =>1, + "info"=>"打款确认成功" + )); + } + protected function setOneVerifyStatus($change_status,$op_pre,$id) + { + $dbres = M("company_statement_pool","tab_")->field("id,verify_status,verify_log")->where("id = {$id}")->find(); + $dbres['verify_log'] = json_decode($dbres['verify_log'],true); + $dbres['verify_log'][$op_pre.'_user']=$_SESSION['onethink_admin']['user_auth']["username"]; + $dbres['verify_log'][$op_pre.'_time']=date("Y-m-d H:i:s"); + $dbres['verify_log'] = json_encode($dbres['verify_log']); + $dbres['verify_status']=$change_status; + M("company_statement_pool","tab_")->save($dbres); + } public function OpAuth($info) { @@ -139,7 +179,7 @@ class CompanyStatementOfflineController extends ThinkController public function menuAuth() { $mentBtn = [ - "pool"=>"发起汇总", + "doPayment"=>"打款确认", "export"=>"批量导出" ]; $resarr = []; diff --git a/Application/Admin/Controller/CompanyStatementPoolController.class.php b/Application/Admin/Controller/CompanyStatementPoolController.class.php index ccf4b5520..ad6a3bf0f 100644 --- a/Application/Admin/Controller/CompanyStatementPoolController.class.php +++ b/Application/Admin/Controller/CompanyStatementPoolController.class.php @@ -151,24 +151,16 @@ class CompanyStatementPoolController extends ThinkController if(isset($v['verify_log']['payment_user'])){ if($v['verify_status'] == -2){ $ts = "拒绝打款"; - $v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}"; }elseif($v['verify_status'] == 2){ $ts = "待打款"; - $v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}"; }elseif($v['verify_status'] == 3){ $ts = "打款中"; - $v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}"; }elseif($v['verify_status'] == 4){ - if($v['is_payment']==1){ - $ts="线上打款成功"; - }else{ - $ts="线下打款成功"; - } - $v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}"; + $ts="打款成功"; }elseif($v['verify_status'] == 5){ $ts="无需打款"; - $v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}"; } + $v["payment"]= "{$ts}({$v['verify_log']['payment_user']}){$symbol} {$v['verify_log']['payment_time']}"; }else{ $v["payment"] = '--'; } diff --git a/Application/Admin/View/CompanyStatementOffline/lists.html b/Application/Admin/View/CompanyStatementOffline/lists.html index c461dcf05..97e8017e6 100644 --- a/Application/Admin/View/CompanyStatementOffline/lists.html +++ b/Application/Admin/View/CompanyStatementOffline/lists.html @@ -162,7 +162,6 @@ 结算金额 结算流水 - 汇总单状态 打款状态 汇总单号汇总单号 @@ -180,13 +179,12 @@ - + {$data.company_name} {$data.company_type_str} {$data.valid} {$data.statement_money} {$data.platform_amount} - {$data.verify_status_str} {$data.pay_status_str} {$data.statement_num} @@ -279,24 +277,23 @@ }); }); - $("#pool").on("click",function(){ + $("#doPayment").on("click",function(){ var id = $(this).attr("id"); var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { - return $(elem).val(); + if($(elem).data("paystatus") == 0){ + return $(elem).val(); + } }).get(); - if(text.length > 40){ - layer.msg("" + '为保证效率暂不支持超过40条的批量操作' + ""); - return; - } if(text.length < 1){ - layer.msg("" + '无需要汇总的操作'+""); + layer.msg("无需要进行确认打款确认操作的数据"); return; } + text = text.join(","); if(confirm){ - layer.confirm('【警告】汇总后将不可回退,如需继续请点击确认', { + layer.confirm('【警告】确认打款后将不可回退,如需继续请点击确认', { btn: ['确认','取消'], title:false }, function(){ @@ -310,7 +307,7 @@ //执行 $.ajax({ type: "POST", - url: "{:U('pool')}", + url: "{:U('doPayment')}", dataType: 'json', async: false, data: {ids:text},