class Competitions::SavePrizeTeamAccountService < ApplicationService attr_reader :competition, :user, :params def initialize(competition, user, params) @competition = competition @user = user @params = params end def call Competitions::SavePrizeTeamAccountForm.new(params).validate! prize_leaders = competition.competition_prize_users.where(user_id: user.id, leader: true) raise Error, '审批通过后不能修改' if prize_leaders.exists?(status: :approved) prize_leaders.update_all(extra: params) end end