房间金币大放送领取接口处理
This commit is contained in:
parent
7e89c619a1
commit
b7ddf2d56f
@ -3,11 +3,15 @@ package com.red.circle.other.app.command.task;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskClaimCO;
|
||||
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskClaimCmd;
|
||||
import com.red.circle.other.domain.gateway.user.ability.RegisterDeviceGateway;
|
||||
import com.red.circle.other.infra.database.rds.entity.activity.LotteryDeviceRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskClaimRecord;
|
||||
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskConfig;
|
||||
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskProgress;
|
||||
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskTier;
|
||||
import com.red.circle.other.infra.database.rds.service.RoomDailyTaskDatabaseService;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryDeviceRecordService;
|
||||
import com.red.circle.other.inner.asserts.OtherErrorCode;
|
||||
import com.red.circle.other.inner.asserts.user.UserErrorCode;
|
||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||
import com.red.circle.tool.core.tuple.PennyAmount;
|
||||
@ -16,6 +20,7 @@ import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd;
|
||||
import com.red.circle.wallet.inner.model.enums.GoldOrigin;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -35,9 +40,15 @@ public class RoomDailyTaskClaimExe {
|
||||
|
||||
private final RoomDailyTaskDatabaseService taskDatabaseService;
|
||||
private final WalletGoldClient walletGoldClient;
|
||||
private final RegisterDeviceGateway registerDeviceGateway;
|
||||
private final LotteryDeviceRecordService lotteryDeviceRecordService;
|
||||
private final static long ROOM_DAILY_FIXED_ACTIVITY_ID = 10011L;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public RoomDailyTaskClaimCO execute(RoomDailyTaskClaimCmd cmd) {
|
||||
|
||||
checkDeviceUnique(ROOM_DAILY_FIXED_ACTIVITY_ID, cmd.getReqUserId());
|
||||
|
||||
Long userId = cmd.getReqUserId();
|
||||
String taskCode = cmd.getTaskCode();
|
||||
LocalDate today = ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
|
||||
@ -112,6 +123,40 @@ public class RoomDailyTaskClaimExe {
|
||||
co.setClaimedCount(records.size());
|
||||
co.setTotalRewardValue(totalReward);
|
||||
co.setClaimTime(LocalDateTime.now());
|
||||
|
||||
recordDeviceAfter(ROOM_DAILY_FIXED_ACTIVITY_ID, userId);
|
||||
return co;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验设备唯一性
|
||||
*/
|
||||
private void checkDeviceUnique(Long activityId, Long userId) {
|
||||
String fingerprint = registerDeviceGateway.getEnhancedDeviceFingerprintByUserId(userId);
|
||||
if (StringUtils.isBlank(fingerprint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LotteryDeviceRecord existingRecord = lotteryDeviceRecordService.getByActivityAndFingerprint(activityId, fingerprint);
|
||||
if (existingRecord != null && !existingRecord.getUserId().equals(userId)) {
|
||||
ResponseAssert.isTrue(OtherErrorCode.DEVICE_ALREADY_USED, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录设备信息
|
||||
*/
|
||||
private void recordDeviceAfter(Long activityId, Long userId) {
|
||||
try {
|
||||
String fingerprint = registerDeviceGateway.getEnhancedDeviceFingerprintByUserId(userId);
|
||||
if (StringUtils.isNotBlank(fingerprint)) {
|
||||
lotteryDeviceRecordService.recordDevice(activityId, userId, fingerprint);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to record device, activityId: {}, userId: {}", activityId, userId, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ public class LatestMobileDeviceServiceImpl extends
|
||||
|
||||
/**
|
||||
* 构建增强版设备指纹
|
||||
* 组成:手机型号 + 系统版本 + IP段 + 编译版本
|
||||
* 组成:手机型号 + 系统版本 + IP段
|
||||
*/
|
||||
private String buildEnhancedDeviceFingerprint(LatestMobileDevice device) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user