can('dcat.admin.after_sales.verify'); } /** * Handle the form request. * * @param array $input * * @return mixed */ public function handle(array $input) { $afterSaleService = new AfterSaleService(); try { DB::beginTransaction(); $afterSale = AfterSale::where('state', AfterSale::STATE_VERIFY)->findOrFail($this->payload['id']); if ($input['state'] == 3) {//审核通过 $afterSaleService->verify($afterSale, $input['remarks3']); } elseif ($input['state'] == 1) {//需要补充资料 $afterSaleService->backApply($afterSale, $input['remarks1']); } DB::commit(); } catch (Throwable $th) { DB::rollBack(); report($th); return $this->response()->error('操作失败:'.$th->getMessage()); } return $this->response() ->success(__('admin.update_succeeded')) ->refresh(); } /** * Build a form here. */ public function form() { $id = $this->payload['id'] ?? 0; $afterSale = AfterSale::findOrFail($id); if (!in_array($afterSale->type, [3, 4])) { $this->currency('amount')->symbol('¥')->value($afterSale->amount); } $this->radio('state') ->when(3, function (Form $form) use ($afterSale) { $defaultRemarks = ''; switch ($afterSale->type) { case 1: $defaultRemarks = '同意退款退货';//需要用户确认并填入回寄单号 break; case 2: $defaultRemarks = '同意退款,等待财务打款审核。'; break; case 3: $defaultRemarks = '同意换货';//需要用户确认并填入回寄单号 break; case 4: $defaultRemarks = '同意补货, 新的订单号:';//需要用户收到补货后确认,可后台关闭 } $this->text('remarks3')->value($defaultRemarks); }) ->when(1, function (Form $form) { $this->text('remarks1')->value('需要补充资料'); })->options([ 3=>'审核通过', 1=>'需要补充资料', ])->default(3); } }