Skip to content

Commit

Permalink
refactor(marketing): 将新用户的注册福利调整为开通7天会员
Browse files Browse the repository at this point in the history
  • Loading branch information
longyue0521 committed Jul 18, 2024
1 parent 2c1e6ad commit 4d9ec43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
15 changes: 6 additions & 9 deletions internal/marketing/internal/integration/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ func (s *ModuleTestSuite) TestConsumer_ConsumeUserRegistrationEvent() {
after func(t *testing.T, evt event.UserRegistrationEvent)
}{
{
name: "消费注册消息成功_为注册者开通会员",
name: "消费注册消息成功_为注册者开通7天会员",
newMQFunc: func(t *testing.T, ctrl *gomock.Controller, evt event.UserRegistrationEvent) mq.MQ {
t.Helper()

Expand All @@ -1100,11 +1100,10 @@ func (s *ModuleTestSuite) TestConsumer_ConsumeUserRegistrationEvent() {
mockConsumer.EXPECT().Consume(gomock.Any()).Return(s.newUserRegistrationEventMessage(t, evt), nil).Times(2)

mockProducer := mocks.NewMockProducer(ctrl)
endAtDate := time.Date(2024, 9, 30, 23, 59, 59, 0, time.UTC)
memberEvent := s.newMemberEventMessage(t, event.MemberEvent{
Key: fmt.Sprintf("user-registration-%d", evt.Uid),
Uid: evt.Uid,
Days: uint64(time.Until(endAtDate) / (24 * time.Hour)),
Days: 7,
Biz: "user",
BizId: evt.Uid,
Action: "注册福利",
Expand Down Expand Up @@ -1132,7 +1131,7 @@ func (s *ModuleTestSuite) TestConsumer_ConsumeUserRegistrationEvent() {
after: func(t *testing.T, evt event.UserRegistrationEvent) {},
},
{
name: "消费注册消息成功_为注册者开通会员_为邀请者增加积分",
name: "消费注册消息成功_为注册者开通7天会员_为邀请者增加积分",
newMQFunc: func(t *testing.T, ctrl *gomock.Controller, evt event.UserRegistrationEvent) mq.MQ {
t.Helper()

Expand All @@ -1141,11 +1140,10 @@ func (s *ModuleTestSuite) TestConsumer_ConsumeUserRegistrationEvent() {
mockConsumer.EXPECT().Consume(gomock.Any()).Return(s.newUserRegistrationEventMessage(t, evt), nil).Times(2)

mockProducer := mocks.NewMockProducer(ctrl)
endAtDate := time.Date(2024, 9, 30, 23, 59, 59, 0, time.UTC)
memberEvent := s.newMemberEventMessage(t, event.MemberEvent{
Key: fmt.Sprintf("user-registration-%d", evt.Uid),
Uid: evt.Uid,
Days: uint64(time.Until(endAtDate) / (24 * time.Hour)),
Days: 7,
Biz: "user",
BizId: evt.Uid,
Action: "注册福利",
Expand Down Expand Up @@ -1215,7 +1213,7 @@ func (s *ModuleTestSuite) TestConsumer_ConsumeUserRegistrationEvent() {
},
},
{
name: "消费注册消息成功_为注册者开通会员_邀请码找不则忽略",
name: "消费注册消息成功_为注册者开通7天会员_邀请码找不则忽略",
newMQFunc: func(t *testing.T, ctrl *gomock.Controller, evt event.UserRegistrationEvent) mq.MQ {
t.Helper()

Expand All @@ -1224,11 +1222,10 @@ func (s *ModuleTestSuite) TestConsumer_ConsumeUserRegistrationEvent() {
mockConsumer.EXPECT().Consume(gomock.Any()).Return(s.newUserRegistrationEventMessage(t, evt), nil).Times(2)

mockProducer := mocks.NewMockProducer(ctrl)
endAtDate := time.Date(2024, 9, 30, 23, 59, 59, 0, time.UTC)
memberEvent := s.newMemberEventMessage(t, event.MemberEvent{
Key: fmt.Sprintf("user-registration-%d", evt.Uid),
Uid: evt.Uid,
Days: uint64(time.Until(endAtDate) / (24 * time.Hour)),
Days: 7,
Biz: "user",
BizId: evt.Uid,
Action: "注册福利",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"errors"
"fmt"
"time"

"github.com/ecodeclub/webook/internal/marketing/internal/domain"
"github.com/ecodeclub/webook/internal/marketing/internal/event"
Expand Down Expand Up @@ -58,14 +57,10 @@ func (s *ActivityExecutor) Execute(ctx context.Context, act domain.UserRegistrat
}

func (s *ActivityExecutor) awardRegistrationBonus(ctx context.Context, act domain.UserRegistrationActivity) error {
endAtDate := time.Date(2024, 9, 30, 23, 59, 59, 0, time.UTC)
if endAtDate.Before(time.Now()) {
return nil
}
err := s.memberEventProducer.Produce(ctx, event.MemberEvent{
Key: fmt.Sprintf("user-registration-%d", act.Uid),
Uid: act.Uid,
Days: uint64(time.Until(endAtDate) / (24 * time.Hour)),
Days: 7,
Biz: "user",
BizId: act.Uid,
Action: "注册福利",
Expand Down

0 comments on commit 4d9ec43

Please sign in to comment.