can('dcat.admin.dealer_earnings.pay'); } /** * Handle the form request. * * @param array $input * * @return mixed */ public function handle(array $input) { $id = $this->payload['id'] ?? 0; try { DB::beginTransaction(); $earning = DealerEarning::findOrFail($id); $earning->update([ 'pay_info' => $earning->getPayInfo(), 'pay_image' => $input['pay_image']??null, 'pay_at' => now(), 'status' => DealerEarningStatus::Completed, ]); //打款到余额; $walletService = new WalletService(); switch ($earning->earningable_type) { case (new DealerManagerSubsidy())->getMorphClass(): $action = DealerWalletAction::ManagerSubsidyIn; break; case (new DealerManageSubsidy())->getMorphClass(): $action = DealerWalletAction::ManageSubsidyIn; break; case (new DealerChannelSubsidyLog())->getMorphClass(): $action = DealerWalletAction::ChannelSubsidyIn; break; default: $action = DealerWalletAction::PurchaseSubsidyIn; break; } $walletService->changeBalance($earning->user, $earning->total_earnings, $action, '收入-'.$earning->type_name, $earning); 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() { $this->image('pay_image') ->move('dealer-pay/'.Carbon::now()->toDateString()) ->saveFullUrl() ->removable(false) ->autoUpload(); } }