This commit is contained in:
Seth Call 2020-12-05 14:45:44 -06:00
parent ca933f6445
commit c572b0ac27
5 changed files with 59 additions and 4 deletions

View File

@ -51,6 +51,29 @@ module JamRuby
end
end
def notify_admin_plan(user)
if user.admin_override_plan_code.nil?
puts "INVALID NOTIFY ADMIN SUBSCRIPTION FOR USER #{user.email}"
return nil
end
@user = user
@subscription_rules = SubscriptionDefinitions.rules(user.subscription_plan_code)
@plan_end_at = user.admin_override_ends_at.strftime("%B %-d, %Y")
sendgrid_category "Subscription"
sendgrid_unique_args :type => "admin_subscription"
sendgrid_recipients([user.email])
sendgrid_substitute('@USERID', [user.id])
sendgrid_substitute(EmailBatchProgression::VAR_FIRST_NAME, [user.first_name])
mail(:to => user.email, :cc => APP_CONFIG.email_support_alias, :subject => "Enjoy your free #{@subscription_rules[:name]} plan until #{@plan_end_at}") do |format|
format.text
format.html
end
end
def take_paid_lesson(user)
@user = user
@lesson = user.taken_lessons.order(:created_at).last

View File

@ -0,0 +1,14 @@
<% provide(:title, @subject) %>
<% if !@user.anonymous? %>
<p>Hi <%= @user.first_name %>,
</p>
<% end %>
<p>
JamKazam has given you a <%= @subscription_rules[:name] %> plan for free until <%= @plan_end_at %>! After that date, your plan will automatically switch back to the Free plan.
</p>
<p>Best Regards,<br/>
Team JamKazam</p>

View File

@ -0,0 +1,11 @@
<% provide(:title, @subject) %>
<% if !@user.anonymous? %>
Hi <%= @user.first_name %>,
<% end %>
JamKazam has given you the <%= @subscription_rules[:name] %> for free until <%= @plan_end_at %>. When the plan ends, your plan will automatically switch back to the Free plan.
Best Regards,
Team JamKazam

View File

@ -2883,8 +2883,11 @@ module JamRuby
self.subscription_plan_code_set_at = DateTime.now
if plan_code.nil?
self.admin_override_ends_at = nil
else
UserMailer.notify_admin_plan(self).deliver_now
end
self.save(validate: false)
end

View File

@ -36,7 +36,8 @@ module JamRuby
can_broadcast: false,
broadcasting_type: 3,
max_players: 4,
pro_audio: false
pro_audio: false,
name: 'Free'
}
@ -52,7 +53,8 @@ module JamRuby
can_broadcast: true,
broadcasting_type: 3,
max_players: 6,
pro_audio: false
pro_audio: false,
name: 'Silver'
}
GOLD_PLAN = {
@ -67,7 +69,8 @@ module JamRuby
can_broadcast: true,
broadcasting_type: 3,
max_players: nil,
pro_audio: true
pro_audio: true,
name: 'Gold'
}
PLATINUM_PLAN = {
@ -82,7 +85,8 @@ module JamRuby
can_broadcast: true,
broadcasting_type: 3,
max_players: nil,
pro_audio: true
pro_audio: true,
name: 'Platinum'
}
def self.rules(plan_code)