Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit8d6fc93

Browse files
committed
refactor(mailer): notify admin when some give tips
1 parentc98a4b8 commit8d6fc93

File tree

5 files changed

+837
-4
lines changed

5 files changed

+837
-4
lines changed

‎lib/groupher_server/billing/delegates/curd.ex‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ defmodule GroupherServer.Billing.Delegate.CURD do
1212
aliasGroupherServer.Billing.BillRecord
1313
aliasGroupherServer.Billing.Delegate.Actions
1414
aliasGroupherServer.Repo
15+
aliasGroupherServer.Email
1516

1617
aliasEcto.Multi
1718

@@ -87,6 +88,13 @@ defmodule GroupherServer.Billing.Delegate.CURD do
8788
|>Map.merge(~m(user_id hash_id state)a)
8889
|>map_atom_value(:string)
8990

90-
BillRecord|>ORM.create(attrs)
91+
# {:ok, record} = BillRecord |> ORM.create(attrs)
92+
# TODO:
93+
{:ok,record}=BillRecord|>ORM.create(attrs)
94+
# IO.inspect(record, label: "record ->")
95+
Email.notify_admin(record,:payment)
96+
# {:ok, record} = BillRecord |> ORM.create(attrs, {after_success: })
97+
# i email to admin
98+
{:ok,record}
9199
end
92100
end

‎lib/groupher_server/mailer/email.ex‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule GroupherServer.Email do
88
importHelper.Utils,only:[get_config:2]
99

1010
aliasGroupherServer.Accounts.User
11+
aliasGroupherServer.Billing.BillRecord
12+
1113
aliasGroupherServer.Email.Templates
1214
aliasGroupherServer.Mailer
1315

@@ -32,16 +34,22 @@ defmodule GroupherServer.Email do
3234
base_mail()
3335
|>to(@admin_email)
3436
|>subject("新用户(#{user.nickname})注册")
35-
|>html_body(Templates.AdminNewRegister.html(user))
36-
|>text_body(Templates.AdminNewRegister.text())
37+
|>html_body(Templates.NotifyAdminRegister.html(user))
38+
|>text_body(Templates.NotifyAdminRegister.text())
3739
|>Mailer.deliver_later()
3840
end
3941

4042
defnotify_admin(_user,:new_register)do
4143
{:ok,:pass}
4244
end
4345

44-
defnotify_admin(:payment,_kind)do
46+
defnotify_admin(%BillRecord{}=record,:payment)do
47+
base_mail()
48+
|>to(@admin_email)
49+
|>subject("打赏#{record.amount} 元")
50+
|>html_body(Templates.NotifyAdminPayment.html(record))
51+
|>text_body(Templates.NotifyAdminPayment.text())
52+
|>Mailer.deliver_later()
4553
end
4654

4755
# some one comment to your post ..

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp