50 lines
1.8 KiB
PHP
50 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Withdrawal;
|
|
|
|
use App\Vault;
|
|
use App\Vault2;
|
|
use App\Withdrawal;
|
|
use Encore\Admin\Actions\RowAction;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class Refuse extends RowAction
|
|
{
|
|
public $name = '拒绝';
|
|
|
|
public function handle(Model $model)
|
|
{
|
|
if ($model['status'] == 0) {
|
|
// 反平台币,提取本金
|
|
if ($model['type'] == 1 && $model['liexing'] == 2) {
|
|
DB::transaction(function () use ($model) {
|
|
Vault::where(['address' => $model['address']])->increment($model['bi_name'], $model['balance']);
|
|
Withdrawal::where(['id' => $model['id']])->update(['status' => 2, 'true_balance' => $model['balance']]);
|
|
});
|
|
}
|
|
|
|
// 反自身币,提取收益
|
|
if ($model['type'] == 2 && $model['liexing'] == 1) {
|
|
DB::transaction(function () use ($model) {
|
|
Vault2::where(['address' => $model['address']])->increment($model['bi_name'].'_T', $model['balance']);
|
|
Withdrawal::where(['id' => $model['id']])->update(['status' => 2, 'true_balance' => $model['balance']]);
|
|
});
|
|
}
|
|
|
|
// 反自身币,提取本金
|
|
if ($model['type'] == 2 && $model['liexing'] == 2) {
|
|
DB::transaction(function () use ($model) {
|
|
Vault2::where(['address' => $model['address']])->increment($model['bi_name'], $model['balance']);
|
|
Withdrawal::where(['id' => $model['id']])->update(['status' => 2, 'true_balance' => $model['balance']]);
|
|
});
|
|
}
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}else{
|
|
return $this->response()->error('不要给人家送钱')->refresh();
|
|
}
|
|
|
|
}
|
|
|
|
} |