45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid;
|
|
|
|
use App\Models\DealerManagerSubsidy;
|
|
use App\Services\Dealer\ManagerSubsidyService;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DealerManagerSubsidyPay extends RowAction
|
|
{
|
|
protected $title = '<i class="feather grid-action-icon icon-stop-circle"></i> 付款';
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.dealer_manager_subsidies.pay');
|
|
}
|
|
|
|
// 确认弹窗信息
|
|
public function confirm()
|
|
{
|
|
return '您确定要支付选中的管理者津贴吗?';
|
|
}
|
|
|
|
// 处理请求
|
|
public function handle(Request $request)
|
|
{
|
|
DB::transaction(function () {
|
|
$id = $this->getKey();
|
|
|
|
(new ManagerSubsidyService())->pay(
|
|
DealerManagerSubsidy::lockForUpdate()->settled()->findOrFail($id)
|
|
);
|
|
});
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}
|
|
}
|