diff --git a/internal/marketing/internal/integration/module_test.go b/internal/marketing/internal/integration/module_test.go index 2368a592..2389f485 100644 --- a/internal/marketing/internal/integration/module_test.go +++ b/internal/marketing/internal/integration/module_test.go @@ -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() @@ -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: "注册福利", @@ -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() @@ -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: "注册福利", @@ -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() @@ -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: "注册福利", diff --git a/internal/marketing/internal/service/activity/user/executor.go b/internal/marketing/internal/service/activity/user/executor.go index f0a0caba..cdd3d01e 100644 --- a/internal/marketing/internal/service/activity/user/executor.go +++ b/internal/marketing/internal/service/activity/user/executor.go @@ -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" @@ -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: "注册福利",