更新代码
This commit is contained in:
73
app/Admin/Controllers/WithdrawsController.php
Normal file
73
app/Admin/Controllers/WithdrawsController.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Models\Withdraw;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class WithdrawsController extends Controller
|
||||
{
|
||||
|
||||
public function status(Request $request, Withdraw $withdraw)
|
||||
{
|
||||
return view('Admin::withdraws.status', compact('withdraw'));
|
||||
}
|
||||
|
||||
public function doStatus(Request $request, Withdraw $withdraw)
|
||||
{
|
||||
$state = $request->state;
|
||||
if(empty($state)){
|
||||
return $this->error('请选择审核结果');
|
||||
}
|
||||
|
||||
if($state == 1){
|
||||
//提现处理-提现到微信零钱
|
||||
if($withdraw->way == 'Wechat'){
|
||||
if(empty($withdraw->openid)){
|
||||
return $this->error('提现失败,未找到提现用户微信');
|
||||
}
|
||||
$app = app('wechat.payment');
|
||||
$result = $app->transfer->toBalance([
|
||||
'partner_trade_no' => 'WTN' . date('ymdHis') . sprintf("%07d", mt_rand(0, pow(10, 7) - 1)),
|
||||
'openid' => $withdraw->openid,
|
||||
'check_name' => 'NO_CHECK',
|
||||
're_user_name' => '',
|
||||
'amount' => $withdraw->take * 100,
|
||||
'desc' => '余额提现到微信零钱',
|
||||
]);
|
||||
if($result['result_code'] == 'SUCCESS'){
|
||||
$withdraw->update(['state' => 1]);
|
||||
return $this->success('操作成功','close');
|
||||
}else{
|
||||
return $this->error($result['err_code_des']);
|
||||
}
|
||||
|
||||
}else{
|
||||
if($withdraw->update(['state' => 1])){
|
||||
return $this->success('操作成功','close');
|
||||
}else{
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($state == 2) {
|
||||
//驳回处理
|
||||
$remark = $request->remark;
|
||||
if (empty($remark)) {
|
||||
return $this->error('请填写驳回原因');
|
||||
}
|
||||
try {
|
||||
DB::transaction(function () use ($remark,$withdraw){
|
||||
$withdraw->user->rule('withdraw_reject', $withdraw->amount, false, 'withdraw'.$withdraw->id);
|
||||
$withdraw->update(['state' => 2, 'remark' => $remark]);
|
||||
});
|
||||
return $this->success('操作成功','close');
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('操作失败' . $e->getmessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user