'; public function title() { if ($this->title) { return $this->title.' '.__('admin_message.extensions.grid.batch.release_down'); } return __('admin_message.extensions.grid.batch.release_down'); } protected function authorize($user): bool { return $user->can('dcat.admin.product_skus.batch_release_down'); } // 确认弹窗信息 public function confirm() { return '您确定操作已选中的商品吗?'; } // 处理请求 public function handle(Request $request) { // 获取选中的skuID数组 $keys = $this->getKey(); $query = ProductSku::query()->whereIn('id', $keys)->where('verify_state', 0)->whereNotNull('release_at'); $list = $query->get(); if ($list->count() != count($keys)) { return $this->response()->error('操作失败,所选商品含有不能操作项')->refresh(); } $message = '下架成功'; try { DB::beginTransaction(); ProductSku::skuDown($keys); DB::commit(); } catch (Throwable $th) { DB::rollBack(); report($th); return $this->response()->error('操作失败,'.$th->getMessage())->refresh(); } return $this->response()->success($message)->refresh(); } }