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 @@ +