jingcai-php/app/Admin/Forms/ShopWithdrawForm.php

81 lines
2.6 KiB
PHP

<?php
namespace App\Admin\Forms;
use App\Enums\WithdrawState;
use App\Enums\WithdrawType;
use App\Model\Seller\ShopWithdraw;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;
use Illuminate\Support\Arr;
use Log;
class ShopWithdrawForm extends Form implements LazyRenderable
{
use LazyWidget;
public function handle(array $input)
{
$id = Arr::get($input, 'id');
if (!$id) {
return $this->response()->alert()->error('参数有误');
}
$shopWithdraw = ShopWithdraw::find($id);
if (!$shopWithdraw) {
return $this->response()->alert()->error('数据不存在!');
}
$state = Arr::get($input, 'state');
if (!WithdrawState::hasValue($state, false)) {
return $this->response()->alert()->error('状态有误!');
}
$admin_remark = Arr::get($input, 'admin_remark');
$shopWithdraw->state = $state;
$shopWithdraw->admin_remark = strval($admin_remark);
$shopWithdraw->remark_at = date('Y-m-d H:i:s');
$shopWithdraw->save();
return $this->response()->success("设置成功")->refresh();
}
public function form()
{
$id = $this->payload['id'];
$shopWithdraw = ShopWithdraw::find($id);
if (!$shopWithdraw) {
return $this->response()->alert()->error('数据不存在!');
}
$this->display('shop_name','店铺名称')->with(function ($item)use($shopWithdraw){
return $shopWithdraw->shop->name;
});
$types = WithdrawType::typeAsArray();
$this->text('type', '提现方式')
->value(Arr::get($types, $shopWithdraw->type))->readOnly();
if ($shopWithdraw->type == WithdrawType::ALI) {
$this->text('ali_account', '支付宝账号')
->value($shopWithdraw->ali_account)
->readOnly();
} else {
$this->text('bank_master', '开户行')
->value($shopWithdraw->bank_master)
->readOnly();
$this->text('bank_branch', '支行')
->value($shopWithdraw->bank_branch)
->readOnly();
$this->text('bank_no', '银行卡号')
->value($shopWithdraw->bank_no)
->readOnly();
}
$this->select('state','提现审核状态')
->options(WithdrawState::stateAsArray())
->value($shopWithdraw->state)
->help('请谨慎设置提现状态');
$this->text('admin_remark', '提现审核信息')->value($shopWithdraw->admin_remark);
$this->hidden('id')->value($id);
}
}