48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid;
|
|
|
|
use App\Enums\DrawLogStatus;
|
|
use App\Models\DrawLog;
|
|
use App\Services\DrawActivityService;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class DrawLogComplete extends RowAction
|
|
{
|
|
protected $title = '<i class="feather icon-navigation grid-action-icon"></i> 发放奖品';
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.draw_activities.log_complete');
|
|
}
|
|
|
|
// 确认弹窗信息
|
|
public function confirm()
|
|
{
|
|
return '您确定要发放中奖奖品吗?';
|
|
}
|
|
|
|
// 处理请求
|
|
public function handle(Request $request)
|
|
{
|
|
$drawLog = DrawLog::findOrFail($this->getKey());
|
|
|
|
try {
|
|
DB::beginTransaction();
|
|
(new DrawActivityService())->sendPrize($drawLog);
|
|
DB::commit();
|
|
return $this->response()->success('操作成功')->refresh();
|
|
} catch (\Exception $e) {
|
|
DB::rollBack();
|
|
return $this->response()->error($e->getMessage())->refresh();
|
|
}
|
|
}
|
|
}
|