diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index e6536e183..6929e92b7 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -1146,6 +1146,11 @@ class ExportController extends Controller unset($_REQUEST['is_check']); } + if (isset($_REQUEST['is_refund'])) { + $map['is_refund'] = (int)($_REQUEST['is_refund']); + unset($_REQUEST['is_refund']); + } + if ($_REQUEST['merchant_id']) { $map['merchant_id'] = $_REQUEST['merchant_id']; unset($_REQUEST['merchant_id']); @@ -1236,6 +1241,7 @@ class ExportController extends Controller 'pay_amount' => '实付金额', 'pay_way' => '充值方式', 'pay_status' => L('Order_status'), + 'is_refund' => '退款状态', 'pay_game_status' => '游戏通知状态', 'is_check' => '是否参与结算', 'promote_id' => "消费"."{$total}", @@ -1314,6 +1320,7 @@ class ExportController extends Controller $value['game_id'] = $thisGameInfo['partner_name']; $value['is_check'] = D("Spend")::IsCheckStr[$value['is_check']]; + $value['is_refund'] = D("Spend")::IsRefundStr[$value['is_refund']]; $value['company_name'] = $promoters[$value['promote_id']] == 0 ? '官方渠道' : ($companys[$promoters[$value['promote_id']]] ?? ''); unset($value['promote_id']); diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 90934283f..ec08c8661 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -29,6 +29,10 @@ class SpendController extends ThinkController $map['is_check'] = (int)($_REQUEST['is_check']); } + if (isset($_REQUEST['is_refund'])) { + $map['is_refund'] = (int)($_REQUEST['is_refund']); + } + if (isset($_REQUEST['user_account'])) { $map['user_account'] = array('like', trim($_REQUEST['user_account'])); unset($_REQUEST['user_account']); @@ -147,6 +151,7 @@ class SpendController extends ThinkController ($value['promote_account']=='官方渠道')?($value['promote_account']=C('OFFICIEL_CHANNEL')):''; $value['market_admin_username'] = $adminUsernameList[$value['market_admin_id']] ?? '无'; $value['is_check_str'] = D(self::model_name)::IsCheckStr[$value['is_check']]; + $value['is_refund_str'] = D(self::model_name)::IsRefundStr[$value['is_refund']]; //拆分游戏名称和设备类型 $game_arr = explode("(", rtrim($value['game_name'], ")")); $value['game_name'] = $game_arr[0]; @@ -178,6 +183,8 @@ class SpendController extends ThinkController $mentBtn = [ "addStatement"=>"参与结算", "removeStatement"=>"移出结算", + "addRefund"=>"登记退款", + "removeRefund"=>"取消退款", ]; $resarr = []; foreach ($mentBtn as $k => $v) { @@ -191,7 +198,7 @@ class SpendController extends ThinkController } return $resarr; } - + //是否结算 public function addStatement() { if(!isset($_REQUEST['ids'])) $this->error("参数错误"); @@ -232,4 +239,51 @@ class SpendController extends ThinkController addOperationLog(['op_type'=>1,'key'=>$key,"op_name"=>$op_name,"content"=>json_encode(["ids"=>$_REQUEST['ids'],"is_check"=>$newval])]); return true; } + //是否退款 + public function addRefund() + { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + + $this->editOrderIsrefund($ids,0,1); + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"操作成功" + )); + } + public function removeRefund() + { + if(!isset($_REQUEST['ids'])) $this->error("参数错误"); + $ids = $_REQUEST['ids']; + + $this->editOrderIsrefund($ids,1,0); + $this->ajaxReturn(array( + 'status' => 1, + "info"=>"操作成功" + )); + } + protected function editOrderIsrefund($ids,$oldval,$newval){ + $time = time(); + $dbres = D(self::model_name)->field("id as s_id,user_id,user_account,pay_amount as refund_amount,pay_time,{$time} as create_time")->where("id in ({$ids}) and is_refund = '{$oldval}' and pay_status = 1")->select(); + if(empty($dbres)) return false; + + $changeIds = implode(",",array_column($dbres,"s_id")); + //执行操作 + $res = D(self::model_name)->where("id in ({$changeIds}) and is_refund = '{$oldval}'")->save(['is_refund'=>$newval]); + if(empty($res)) return false; + //日志 + if($newval == 1){ + $op_name = "登记退款"; + $key = "addRefund"; + SM('spend_refund',"tab_")->addAll($dbres); + }else{ + $op_name = "取消退款"; + $key = "removeRefund"; + SM('spend_refund',"tab_")->where("s_id in ({$changeIds}) ")->delete(); + } + addOperationLog(['op_type'=>1,'key'=>$key,"op_name"=>$op_name,"content"=>json_encode(["ids"=>$_REQUEST['ids'],"is_refund"=>$newval])]); + return true; + } + + } diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 51fecfd41..05127744e 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -26,6 +26,10 @@ class SpendModel extends Model "1"=>"是", "2"=>"否" ]; + const IsRefundStr=[ + "0"=>"--", + "1"=>"已退款" + ]; /* 自动完成规则 */ protected $_auto = array( diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index fb8bf063a..4886c797d 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -199,6 +199,14 @@ +
+ +
+
@@ -254,6 +262,7 @@ 充值方式 订单状态 + 退款状态 游戏通知状态 是否参与结算 操作 @@ -266,7 +275,7 @@ - + {$data.pay_order_number} @@ -339,6 +348,7 @@ {:get_info_status($data['pay_status'],9)} + {$data.is_refund_str} {:get_info_status($data['pay_game_status'],14)} @@ -354,19 +364,15 @@ if (!(substr($data['pay_order_number'], 0, 3) == "PF_" && substr($data['pay_order_number'], -2) == '_1')) { ?> - + 补单 - - - 补单 -
- + 通知到账 @@ -380,7 +386,7 @@ 汇总 - + 当页充值:{:null_to_0(array_sum(array_column(array_status2value('pay_status','',$list_data),'pay_amount')))} 累计充值:{$total}(此处只汇总充值成功的订单) @@ -770,10 +776,59 @@ } }); }); + }) - - - + $("#addRefund,#removeRefund").on("click",function(){ + var id = $(this).attr("id"); + if(id == "addRefund"){ + var opname = "登记退款"; + var opurl = "{:U('addRefund')}"; + var opst ="[未退款]"; + var status = [0]; + }else if(id=="removeRefund"){ + var opname = "取消退款"; + var opurl = "{:U('removeRefund')}"; + var opst ="[已退款]"; + var status = [1]; + } + var flag = false; + var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { + const isrefund = $(elem).data("isrefund"); + if($.inArray(isrefund,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; + } + } + }); + }); }) /**