From fbefd0e0452a3d9198fac9529aa24a3b2d5e93b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=8B=BC?= <2468023037@qq.com> Date: Thu, 20 Feb 2025 15:53:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=AE=A1=E7=90=86=E5=91=98=E5=90=8C?= =?UTF-8?q?=E6=84=8F=E6=8F=90=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/WithdrawController.php | 68 +++++++++++++++-------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/app/controller/api/WithdrawController.php b/app/controller/api/WithdrawController.php index 0d80312..0e2649d 100644 --- a/app/controller/api/WithdrawController.php +++ b/app/controller/api/WithdrawController.php @@ -10,7 +10,7 @@ use app\model\Userbank; use support\Request; use App\Utils\API\Payment; use App\Utils\API\PaymentNew; - +use App\Utils\ApiResponse; use App\Utils\ApiResponseApp; use App\dao\UserRewardDao; @@ -158,30 +158,16 @@ class WithdrawController { //金额 $amount = $request->post('amount'); - //收款户名 - $bank_username = $request->post('bank_username'); - //收款帐号 - $account = $request->post('account'); - //收款银行名称 - $bank_name = $request->post('bank_name'); //转账订单id $id = $request->post('id'); //管理员审批结果 $type = $request->post('type'); - - if ($type == 1) { - $res = PaymentNew::pushMoney($amount, $bank_username, $account, $bank_name,$id); - // var_dump($res); - // if ($res['Success'] == 200) { - // $Withdraw = Withdraw::where('id', $id)->first(); - // $Withdraw->status = 2; - // $Withdraw->status_text = '已到账'; - // $Withdraw->save(); - // return ApiResponseApp::success(null, '转账成功'); - // } else { - // return ApiResponseApp::error(null, '转账失败'); - // } - } else { + //用户id + $user_id = $request->post('user_id'); + //是否同意转账 + $type = $request->post('type'); + //不同意 + if($type==1){ $Withdraw = Withdraw::where('id', $id)->first(); $Withdraw->status = 3; $Withdraw->status_text = '已驳回'; @@ -193,8 +179,46 @@ class WithdrawController $user_id = $request->data['id']; //用户积分增加$money UserRewardDao::base($user_id, 1, $money, '提现失败返还'); - return ApiResponseApp::error(null, '操作成功'); + return ApiResponse::success(200, null,'操作成功'); } + //同意 + $userbank = Userbank::where('user_id',$user_id)->first(); + if ($userbank) { + PaymentNew::pushMoney($amount,$userbank->bank_username, $userbank->account, $userbank->bank_name,$id); + $Withdraw = Withdraw::where('id', $id)->first(); + $Withdraw->status = 2; + $Withdraw->status_text = '已到账'; + $Withdraw->save(); + return ApiResponse::success(200,null,'操作成功'); + }else{ + return ApiResponse::error(200, null, '用户银行信息存在问题'); + } + // if ($type == 1) { + // $res = PaymentNew::pushMoney($amount, $bank_username, $account, $bank_name,$id); + // var_dump($res); + // if ($res['Success'] == 200) { + // $Withdraw = Withdraw::where('id', $id)->first(); + // $Withdraw->status = 2; + // $Withdraw->status_text = '已到账'; + // $Withdraw->save(); + // return ApiResponseApp::success(null, '转账成功'); + // } else { + // return ApiResponseApp::error(null, '转账失败'); + // } + // } else { + // $Withdraw = Withdraw::where('id', $id)->first(); + // $Withdraw->status = 3; + // $Withdraw->status_text = '已驳回'; + // $Withdraw->save(); + // $rate = ExchangeRate::where('type', 'BDT')->get(); + // //计算积分 + // $money = $amount * 100 / $rate[0]['points'] + 300; + // //用户id + // $user_id = $request->data['id']; + // //用户积分增加$money + // UserRewardDao::base($user_id, 1, $money, '提现失败返还'); + // return ApiResponseApp::error(null, '操作成功'); + // } } /**