7天签到新增发放抽奖券逻辑
This commit is contained in:
parent
2aa5da1546
commit
069291571c
@ -209,6 +209,8 @@ public enum OtherErrorCode implements IResponseErrorCode {
|
||||
* 签到操作频繁
|
||||
*/
|
||||
SIGN_IN_OPERATION_TOO_FREQUENT(3286, "Sign-in operation too frequent, please try again later"),
|
||||
|
||||
CONSECUTIVE_REWARD(3287, "Consecutive Check-in Reward!"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
|
||||
@ -16,6 +16,7 @@ import com.red.circle.other.infra.database.rds.entity.UserSignInRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRewardConfigService;
|
||||
import com.red.circle.other.inner.asserts.OtherErrorCode;
|
||||
import com.red.circle.other.inner.endpoint.activity.LotteryTicketClient;
|
||||
import com.red.circle.other.inner.model.cmd.material.PrizeDescribe;
|
||||
import com.red.circle.other.inner.model.cmd.material.PrizeDescribeRewardCmd;
|
||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||
@ -30,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@ -43,6 +45,9 @@ public class SignCheckInExe {
|
||||
private final WalletGoldClient walletGoldClient;
|
||||
private final PropsSendCommon propsSendCommon;
|
||||
private final PropsActivityRewardConfigService propsActivityRewardConfigService;
|
||||
private final LotteryTicketClient lotteryTicketClient;
|
||||
|
||||
private final static Long FIXED_ACTIVITY_ID = 2004471533988167125L;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CheckInResultCO execute(CheckInCmd cmd) {
|
||||
@ -70,7 +75,7 @@ public class SignCheckInExe {
|
||||
.eq(UserSignInRecord::getWeekStartDate, weekStartDate)
|
||||
.eq(UserSignInRecord::getDayIndex, i)
|
||||
);
|
||||
ResponseAssert.isTrue(OtherErrorCode.SIGN_IN_NEED_PREVIOUS, count > 0);
|
||||
ResponseAssert.isTrue(OtherErrorCode.CONSECUTIVE_REWARD, count > 0);
|
||||
}
|
||||
|
||||
SignInDailyConfig config = dailyConfigDAO.selectList(
|
||||
@ -101,6 +106,9 @@ public class SignCheckInExe {
|
||||
|
||||
sendReward(userId, config);
|
||||
|
||||
// 发放抽奖券
|
||||
sendLotteryTickets(userId, config, record.getId());
|
||||
|
||||
CheckInResultCO resultCO = new CheckInResultCO();
|
||||
resultCO.setSuccess(true);
|
||||
resultCO.setMessage("Sign-in successful");
|
||||
@ -148,4 +156,30 @@ public class SignCheckInExe {
|
||||
.setQuantity(config.getQuantity())))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放抽奖券
|
||||
*/
|
||||
private void sendLotteryTickets(Long userId, SignInDailyConfig config, Long trackId) {
|
||||
if (config.getLotteryTicketCount() == null || config.getLotteryTicketCount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (int i = 0; i < config.getLotteryTicketCount(); i++) {
|
||||
Long ticketId = lotteryTicketClient.addTicket(
|
||||
userId,
|
||||
FIXED_ACTIVITY_ID,
|
||||
1,
|
||||
"SIGN_IN",
|
||||
"SIGN_IN_DAY_" + config.getDayIndex()
|
||||
).getBody();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("发放签到抽奖券失败, userId={}, dayIndex={}, count={}",
|
||||
userId, config.getDayIndex(), config.getLotteryTicketCount(), e);
|
||||
throw new RuntimeException("Failed to send lottery tickets");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import com.red.circle.other.infra.database.rds.entity.UserSignInRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRewardConfigService;
|
||||
import com.red.circle.other.inner.asserts.OtherErrorCode;
|
||||
import com.red.circle.other.inner.endpoint.activity.LotteryTicketClient;
|
||||
import com.red.circle.other.inner.model.cmd.material.PrizeDescribe;
|
||||
import com.red.circle.other.inner.model.cmd.material.PrizeDescribeRewardCmd;
|
||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||
@ -42,6 +43,9 @@ public class SupplementCheckInExe {
|
||||
private final WalletGoldClient walletGoldClient;
|
||||
private final PropsSendCommon propsSendCommon;
|
||||
private final PropsActivityRewardConfigService propsActivityRewardConfigService;
|
||||
private final LotteryTicketClient lotteryTicketClient;
|
||||
|
||||
private final static Long FIXED_ACTIVITY_ID = 2004471533988167125L;
|
||||
|
||||
private static final int BASE_SUPPLEMENT_COST = 500;
|
||||
|
||||
@ -105,6 +109,9 @@ public class SupplementCheckInExe {
|
||||
|
||||
sendReward(userId, config);
|
||||
|
||||
// 发放抽奖券
|
||||
sendLotteryTickets(userId, config, record.getId());
|
||||
|
||||
CheckInResultCO resultCO = new CheckInResultCO();
|
||||
resultCO.setSuccess(true);
|
||||
resultCO.setMessage("Make-up successful");
|
||||
@ -153,4 +160,31 @@ public class SupplementCheckInExe {
|
||||
.setQuantity(config.getQuantity())))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发放抽奖券
|
||||
*/
|
||||
private void sendLotteryTickets(Long userId, SignInDailyConfig config, Long trackId) {
|
||||
if (config.getLotteryTicketCount() == null || config.getLotteryTicketCount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (int i = 0; i < config.getLotteryTicketCount(); i++) {
|
||||
Long ticketId = lotteryTicketClient.addTicket(
|
||||
userId,
|
||||
FIXED_ACTIVITY_ID,
|
||||
1,
|
||||
"SIGN_IN",
|
||||
"SIGN_IN_DAY_" + config.getDayIndex()
|
||||
).getBody();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("发放签到抽奖券失败, userId={}, dayIndex={}, count={}",
|
||||
userId, config.getDayIndex(), config.getLotteryTicketCount(), e);
|
||||
throw new RuntimeException("Failed to send lottery tickets");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,6 +23,11 @@ public class SignInDailyConfig {
|
||||
|
||||
private Integer paidCost;
|
||||
|
||||
/**
|
||||
* 抽奖券数量
|
||||
*/
|
||||
private Integer lotteryTicketCount;
|
||||
|
||||
private Long resourceGroupId;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user