From 74d9d6ed181b64f9382a3fb6b27d703bae67e0d7 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Fri, 27 Nov 2020 10:24:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=85=E5=80=BC=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 7 +- .../Controller/SpendController.class.php | 64 ++++++++----------- Application/Admin/View/Spend/lists.html | 59 ++++++++++++++++- 3 files changed, 91 insertions(+), 39 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 60c63486b..f47a6c040 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2556,14 +2556,14 @@ function getCompanyBlongOther($id = -1) * array( * op_type=>操作类型 0:新增,1:编辑 2:删除 3:下载, * op_name=>操作说明 例如:编辑,删除,锁定等, - * url=>需要跳转的url 添加去列表加唯一id,编辑直接去编辑页面,下载可以重新下载(新开页面), + * url=>U函数可以跳转 的操作地址, * key=>关键词:用户的账号,游戏的名词等, * menu=>非必须,菜单目录,不存在的话按控制器寻找。 * ) */ function addOperationLog($options) { - $checkarr = ['op_type','url','key']; + $checkarr = ['op_type','key']; foreach ($checkarr as $v) { if(!array_key_exists($v,$options)){ return false; @@ -2572,6 +2572,9 @@ function addOperationLog($options) if(!array_key_exists("op_name",$options)){ $options['op_name'] = ($options['op_type'] == 1 ? "编辑" : ($options['op_type'] == 2 ? "删除" :($options['op_type'] == 3 ? "导出" :"新增"))); } + if(!array_key_exists("url",$options)){ + $options['url'] = MODULE_NAME."/".CONTROLLER_NAME."/".ACTION_NAME; + } //获取ip $addarray = [ "op_ip"=>$_SERVER['REMOTE_ADDR'], diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 077ecf406..efec7a82b 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -198,50 +198,42 @@ class SpendController extends ThinkController public function addStatement() { - if(!isset($_REQUEST['ids']) || !isset($_REQUEST['type'])) $this->error("参数错误"); + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); $ids = $_REQUEST['ids']; - - $dbres = D(self::model_name)->where("id in ({$ids}) and type = '1'")->select(); - if(empty($dbres)){ - $this->ajaxReturn(array( - 'status' => 1, - "info"=>"加入结算成功" - )); - } - $ids = array_column($dbres,"id"); - - foreach ($dbres as $key=>$value) { - if($value['withdraw_type'] !=3) { - $this->DBModel->where("id = {$value['id']} and verify_status = 0")->delete(); - } else { - $this->DBModel->where("id = {$value['id']} and verify_status != 2")->delete(); - } - - } - addOperationLog(['op_type'=>2,'key'=>$ids,"op_name"=>"删除结算单",'url'=>U('lists')]); + $this->editOrderIscheck($ids,2,1); + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"操作成功" + )); + } + public function removeStatement() + { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + $this->editOrderIscheck($ids,1,2); $this->ajaxReturn(array( 'status' => 1, - "info"=>"删除成功" + "info"=>"操作成功" )); + } protected function editOrderIscheck($ids,$oldval,$newval){ - $dbres = D(self::model_name)->where("id in ({$ids}) and type = '{$oldval}'")->select(); + $dbres = D(self::model_name)->where("id in ({$ids}) and is_check = '{$oldval}'")->select(); if(empty($dbres)) return false; - $changeIds = array_column($dbres,"id"); + + $changeIds = implode(",",array_column($dbres,"id")); //执行操作 - $res = D(self::model_name)->where("id in ({$changeIds}) and type = '{$oldval}'")->save(['is_check'=>$newval]); + $res = D(self::model_name)->where("id in ({$changeIds}) and is_check = '{$oldval}'")->save(['is_check'=>$newval]); if(empty($res)) return false; - - return array_column($dbres,"id"); - + //日志 + if($newval == 1){ + $op_name = "加入结算"; + $key = "addStatement"; + }else{ + $op_name = "移出结算"; + $key = "removeStatement"; + } + addOperationLog(['op_type'=>1,'key'=>$key,"op_name"=>$op_name,"content"=>json_encode(["ids"=>$_REQUEST['ids'],"is_check"=>$newval])]); + return true; } - /** - * 充值补单功能 - */ - public function order_repair() { - if (IS_AJAX) { - - } - } - } diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index eb6b45ff5..ee308c9b4 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -262,7 +262,7 @@ - + {$data.pay_order_number} @@ -718,6 +718,63 @@ }); $("#game_name").change(); + $("#addStatement,#removeStatement").on("click",function(){ + var id = $(this).attr("id"); + if(id == "addStatement"){ + var opname = "参与结算"; + var opurl = "{:U('addStatement')}"; + var opst ="[不参与结算]"; + var status = [2]; + }else if(id=="removeStatement"){ + var opname = "移出结算"; + var opurl = "{:U('removeStatement')}"; + var opst ="[参与结算]"; + var status = [1]; + } + var flag = false; + var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + const ischeck = $(elem).data("ischeck"); + if($.inArray(ischeck,status) > -1){ + return $(elem).val(); + } + }).get(); + if(text.length < 1){ + layer.msg("" + '无需要'+opname+'的操作,仅'+opst+'状态可以进行'+opname+""); + return; + } + text = text.join(","); + layer.confirm('【提示】'+opname+'操作后,相应的结算单需要进行重算后生效', { + btn: ['确认','取消'], + title:false + }, function(index){ + layer.close(index); + layer.load(2); + $.ajax({ + type: "POST", + url: opurl, + dataType: 'json', + async: true, + data: {ids:text}, + success:function(data){ + layer.closeAll('loading'); + if(data.status==1){ + layer.msg("" + data.info + ""); + setTimeout(function(){ + window.location.reload(); + },1500); + }else{ + layer.msg("" + data.info + ""); + return false; + } + } + }); + }); + + + + + }) + /** * 初始化select2单选,默认带搜索功能。 */