Fix anchor activity point reset
This commit is contained in:
parent
cd904de915
commit
d17f75e42d
@ -156,8 +156,8 @@ public class GiftAnchorCountStrategy implements GiftStrategy {
|
|||||||
teamIds.add(teamMember.getTeamId());
|
teamIds.add(teamMember.getTeamId());
|
||||||
|
|
||||||
// 团队内 -> 代理主播活动(永久活动)
|
// 团队内 -> 代理主播活动(永久活动)
|
||||||
// activityAgentAnchorCount(acceptAnchorUser.getTargetAmount().longValue(),
|
activityAgentAnchorCount(acceptAnchorUser.getTargetAmount().longValue(),
|
||||||
// acceptAnchorUser.getAcceptUserId(), teamMember.getTeamId());
|
acceptAnchorUser.getAcceptUserId(), teamMember.getTeamId());
|
||||||
// 代理活动(永久活动)
|
// 代理活动(永久活动)
|
||||||
// agentActivityCount(acceptAnchorUser, teamMember.getTeamId());
|
// agentActivityCount(acceptAnchorUser, teamMember.getTeamId());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import com.red.circle.tool.core.collection.CollectionUtils;
|
|||||||
import com.red.circle.tool.core.date.TimestampUtils;
|
import com.red.circle.tool.core.date.TimestampUtils;
|
||||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||||
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
import com.red.circle.tool.core.sequence.IdWorkerUtils;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -64,6 +65,10 @@ public class ActivityAgentAnchorCountServiceImpl implements ActivityAgentAnchorC
|
|||||||
@Override
|
@Override
|
||||||
public void initZero(Long acceptUserId, Long teamId) {
|
public void initZero(Long acceptUserId, Long teamId) {
|
||||||
|
|
||||||
|
if (!isMonthEndResetDay()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 主播月收礼,永久活动
|
// 主播月收礼,永久活动
|
||||||
Long quantity1 = getCountQuantity(acceptUserId, "ACTIVE_ANCHOR_MONTH_TARGET_REWARD",
|
Long quantity1 = getCountQuantity(acceptUserId, "ACTIVE_ANCHOR_MONTH_TARGET_REWARD",
|
||||||
getThisMonthDate());
|
getThisMonthDate());
|
||||||
@ -87,6 +92,10 @@ public class ActivityAgentAnchorCountServiceImpl implements ActivityAgentAnchorC
|
|||||||
@Override
|
@Override
|
||||||
public void initZeroTeam(Long teamId) {
|
public void initZeroTeam(Long teamId) {
|
||||||
|
|
||||||
|
if (!isMonthEndResetDay()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mongoTemplate.updateFirst(Query.query(Criteria.where("businessId").is(teamId)
|
mongoTemplate.updateFirst(Query.query(Criteria.where("businessId").is(teamId)
|
||||||
.and("group").is("ACTIVE_AGENT_MONTH_TARGET_REWARD")
|
.and("group").is("ACTIVE_AGENT_MONTH_TARGET_REWARD")
|
||||||
.and("dateNumber").is(getThisMonthDate())),
|
.and("dateNumber").is(getThisMonthDate())),
|
||||||
@ -97,6 +106,10 @@ public class ActivityAgentAnchorCountServiceImpl implements ActivityAgentAnchorC
|
|||||||
@Override
|
@Override
|
||||||
public void initZeroMember(Set<Long> acceptUserIds) {
|
public void initZeroMember(Set<Long> acceptUserIds) {
|
||||||
|
|
||||||
|
if (!isMonthEndResetDay()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(acceptUserIds)) {
|
if (CollectionUtils.isEmpty(acceptUserIds)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,4 +134,10 @@ public class ActivityAgentAnchorCountServiceImpl implements ActivityAgentAnchorC
|
|||||||
return ZonedDateTimeAsiaRiyadhUtils.nowDateToInt();
|
return ZonedDateTimeAsiaRiyadhUtils.nowDateToInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isMonthEndResetDay() {
|
||||||
|
ZonedDateTime now = ZonedDateTimeAsiaRiyadhUtils.now();
|
||||||
|
return Objects.equals(ZonedDateTimeAsiaRiyadhUtils.nowDateToInt(),
|
||||||
|
ZonedDateTimeAsiaRiyadhUtils.getLastDayOfMonthToInt(now));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.red.circle.other.infra.database.mongo.service.activity.impl;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
|
|
||||||
|
class ActivityAgentAnchorCountServiceImplTest {
|
||||||
|
|
||||||
|
private MongoTemplate mongoTemplate;
|
||||||
|
private ActivityAgentAnchorCountServiceImpl service;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
mongoTemplate = mock(MongoTemplate.class);
|
||||||
|
service = new TestableActivityAgentAnchorCountService(mongoTemplate, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void initZeroSkipsBeforeMonthEnd() {
|
||||||
|
service.initZero(10001L, 20001L);
|
||||||
|
|
||||||
|
verifyNoInteractions(mongoTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void initZeroTeamSkipsBeforeMonthEnd() {
|
||||||
|
service.initZeroTeam(20001L);
|
||||||
|
|
||||||
|
verifyNoInteractions(mongoTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void initZeroMemberSkipsBeforeMonthEnd() {
|
||||||
|
service.initZeroMember(Set.of(10001L, 10002L));
|
||||||
|
|
||||||
|
verifyNoInteractions(mongoTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TestableActivityAgentAnchorCountService
|
||||||
|
extends ActivityAgentAnchorCountServiceImpl {
|
||||||
|
|
||||||
|
private final boolean monthEndResetDay;
|
||||||
|
|
||||||
|
private TestableActivityAgentAnchorCountService(MongoTemplate mongoTemplate,
|
||||||
|
boolean monthEndResetDay) {
|
||||||
|
super(mongoTemplate);
|
||||||
|
this.monthEndResetDay = monthEndResetDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isMonthEndResetDay() {
|
||||||
|
return monthEndResetDay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user