6
0
Fork 0

批零提现状态枚举

release
李静 2022-04-13 10:52:15 +08:00
parent 5beec69c39
commit d98d31487b
5 changed files with 81 additions and 41 deletions

View File

@ -6,6 +6,7 @@ use App\Admin\Actions\Grid\Exports\DealerWalletWithdraw;
use App\Admin\Actions\Show\DealerWalletPay;
use App\Admin\Actions\Show\DealerWalletRefuse;
use App\Admin\Repositories\DealerWalletToBankLog;
use App\Enums\DealerWalletToBankLogStatus;
use App\Models\DealerWalletToBankLog as DealerWalletToBankLogModel;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
use Dcat\Admin\Admin;
@ -14,6 +15,7 @@ use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Show;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
class DealerWalletToBankLogController extends AdminController
{
@ -35,19 +37,16 @@ class DealerWalletToBankLogController extends AdminController
$grid->column('rate')->append('%');
$grid->column('service_amount')->prepend('¥');
$grid->column('account_amount')->prepend('¥');
$grid->column('status')->using([
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
])->dot([
0=>'primary',
1=>'success',
2=>'danger',
])->filter(Grid\Column\Filter\In::make([
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
]));
$grid->column('status')->display(function ($v) {
$text = $v->text();
$background = $v->color();
return "<i class='fa fa-circle' style='font-size: 13px;color: {$background}'></i>&nbsp;&nbsp;{$text}";
})->filter(Grid\Column\Filter\In::make(Arr::except(DealerWalletToBankLogStatus::texts(), [
DealerWalletToBankLogStatus::Failed->value,
DealerWalletToBankLogStatus::Passed->value,
DealerWalletToBankLogStatus::Paying->value,
])));
$grid->column('remarks');
$grid->column('created_at')->sortable();
// $grid->column('updated_at')
@ -62,11 +61,6 @@ class DealerWalletToBankLogController extends AdminController
$grid->filter(function (Grid\Filter $filter) {
$filter->panel();
// $filter->equal('status')->select([
// DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
// DealerWalletToBankLogModel::STATUS_AGREE=>'已同意',
// DealerWalletToBankLogModel::STATUS_REFUSE=>'已拒绝',
// ])->width(3);
$filter->equal('user.phone')->width(3);
$filter->between('created_at')->dateTime()->width(7);
});
@ -90,15 +84,12 @@ class DealerWalletToBankLogController extends AdminController
$show->field('rate')->append('%');
$show->field('service_amount')->prepend('¥');
$show->field('account_amount')->prepend('¥');
$show->field('status')->using([
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
])->dot([
0=>'primary',
1=>'success',
2=>'danger',
]);
$show->field('status')->as(function ($v) {
$text = $this->status->text();
$background = $this->status->color();
return "<i class='fa fa-circle' style='font-size: 13px;color: {$background}'></i>&nbsp;&nbsp;{$text}";
});
$show->field('pay_image')->image();
$show->field('remarks');
$show->divider('收款信息-银行');
@ -214,17 +205,13 @@ class DealerWalletToBankLogController extends AdminController
break;
}
}
$statusArr = [
DealerWalletToBankLogModel::STATUS_PENDING=>'待处理',
DealerWalletToBankLogModel::STATUS_AGREE=>'同意',
DealerWalletToBankLogModel::STATUS_REFUSE=>'拒绝',
];
foreach ($query->cursor() as $log) {
$payInfo = $log->getPayInfo();
$writer->addRow(WriterEntityFactory::createRowFromArray([
$log->user->phone,
$log->account_amount,
$statusArr[$log->status],
$log->status->text(),
$payInfo ? $payInfo['bank']['user_name'] : '',
$payInfo ? $payInfo['bank']['bank_name'] : '',
$payInfo ? $payInfo['bank']['bank_number'] : '',

View File

@ -2,6 +2,7 @@
namespace App\Admin\Forms;
use App\Enums\DealerWalletToBankLogStatus;
use App\Models\DealerWalletToBankLog;
use Carbon\Carbon;
use Dcat\Admin\Contracts\LazyRenderable;
@ -40,8 +41,8 @@ class DealerWalletPay extends Form implements LazyRenderable
$log = DealerWalletToBankLog::findOrFail($id);
$log->update([
'pay_info' => $log->getPayInfo(),
'pay_image' => $input['pay_image']??null,
'status' => DealerWalletToBankLog::STATUS_AGREE,
'pay_image' => $input['pay_image'] ?? null,
'status' => DealerWalletToBankLogStatus::Success,
]);
DB::commit();
} catch (Throwable $th) {

View File

@ -3,6 +3,7 @@
namespace App\Admin\Forms;
use App\Enums\DealerWalletAction;
use App\Enums\DealerWalletToBankLogStatus;
use App\Models\DealerWalletToBankLog;
use App\Services\Dealer\WalletService;
use Dcat\Admin\Contracts\LazyRenderable;
@ -40,8 +41,8 @@ class DealerWalletRefuse extends Form implements LazyRenderable
DB::beginTransaction();
$log = DealerWalletToBankLog::findOrFail($id);
$log->update([
'remark' => $input['remark']??'',
'status' => DealerWalletToBankLog::STATUS_REFUSE,
'remark' => $input['remark'] ?? '',
'status' => DealerWalletToBankLogStatus::Refused,
]);
//打回余额
$walletService = new WalletService();

View File

@ -0,0 +1,50 @@
<?php
namespace App\Enums;
enum DealerWalletToBankLogStatus: int {
case Pending = 0;
case Success = 1;
case Refused = 2;
case Passed = 3; // 审核通过 - 等待付款
case Paying = 4; // 审核通过 - 付款中
case Failed = 9;
/**
* @return string
*/
public function color(): string
{
return match ($this) {
static::Pending => '#5b69bc',
static::Passed => '#dda451',
static::Paying => '#3085d6',
static::Success => '#21b978',
static::Failed => '#ea5455',
static::Refused => '#b3b9bf',
};
}
/**
* @return string
*/
public function text(): string
{
return static::texts()[$this->value];
}
/**
* @return array
*/
public static function texts(): array
{
return [
static::Pending->value => '待处理',
static::Passed->value => '待付款',
static::Paying->value => '付款中',
static::Success->value => '成功',
static::Failed->value => '失败',
static::Refused->value => '拒绝',
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Models;
use App\Enums\DealerWalletToBankLogStatus;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@ -11,9 +12,9 @@ class DealerWalletToBankLog extends Model
use HasFactory;
use HasDateTimeFormatter;
public const STATUS_PENDING = 0;//'待处理'
public const STATUS_AGREE = 1;//'已同意'
public const STATUS_REFUSE = 2;//'已拒绝'
protected $casts = [
'status' => DealerWalletToBankLogStatus::class,
];
/**
* @var array
@ -49,7 +50,7 @@ class DealerWalletToBankLog extends Model
*/
public function isPending()
{
return $this->status == self::STATUS_PENDING;
return $this->status === DealerWalletToBankLogStatus::Pending;
}
/**