|
@@ -7,6 +7,10 @@ import com.xuekairui.activity.mapper.CheckInConfigMapper;
|
|
|
import com.xuekairui.activity.mapper.CheckInPeriodMapper;
|
|
import com.xuekairui.activity.mapper.CheckInPeriodMapper;
|
|
|
import com.xuekairui.common.BusinessException;
|
|
import com.xuekairui.common.BusinessException;
|
|
|
import com.xuekairui.common.ErrorCode;
|
|
import com.xuekairui.common.ErrorCode;
|
|
|
|
|
+import com.xuekairui.user.enums.OperationSource;
|
|
|
|
|
+import com.xuekairui.user.enums.OperationType;
|
|
|
|
|
+import com.xuekairui.user.enums.OperatorRole;
|
|
|
|
|
+import com.xuekairui.user.service.OperationAuditLogService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -16,6 +20,7 @@ import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -39,6 +44,7 @@ public class CheckInConfigService {
|
|
|
|
|
|
|
|
private final CheckInConfigMapper checkinConfigMapper;
|
|
private final CheckInConfigMapper checkinConfigMapper;
|
|
|
private final CheckInPeriodMapper periodMapper;
|
|
private final CheckInPeriodMapper periodMapper;
|
|
|
|
|
+ private final OperationAuditLogService auditLogService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取签到配置(不存在则初始化默认值并生成周期)
|
|
* 获取签到配置(不存在则初始化默认值并生成周期)
|
|
@@ -74,6 +80,8 @@ public class CheckInConfigService {
|
|
|
public CheckInConfig updateConfig(CheckInConfigRequest request) {
|
|
public CheckInConfig updateConfig(CheckInConfigRequest request) {
|
|
|
CheckInConfig config = getConfig();
|
|
CheckInConfig config = getConfig();
|
|
|
|
|
|
|
|
|
|
+ Map<String, Object> beforeData = configSnapshot(config);
|
|
|
|
|
+
|
|
|
boolean timeChanged = !java.util.Objects.equals(config.getStartTime(), request.getStartTime())
|
|
boolean timeChanged = !java.util.Objects.equals(config.getStartTime(), request.getStartTime())
|
|
|
|| !java.util.Objects.equals(config.getEndTime(), request.getEndTime());
|
|
|| !java.util.Objects.equals(config.getEndTime(), request.getEndTime());
|
|
|
boolean modeChanged = request.getCycleMode() != null && !request.getCycleMode().equals(config.getCycleMode());
|
|
boolean modeChanged = request.getCycleMode() != null && !request.getCycleMode().equals(config.getCycleMode());
|
|
@@ -94,6 +102,14 @@ public class CheckInConfigService {
|
|
|
config.setRemark(request.getRemark());
|
|
config.setRemark(request.getRemark());
|
|
|
checkinConfigMapper.updateById(config);
|
|
checkinConfigMapper.updateById(config);
|
|
|
|
|
|
|
|
|
|
+ Map<String, Object> afterData = configSnapshot(config);
|
|
|
|
|
+ auditLogService.logSuccess(
|
|
|
|
|
+ 0L, OperatorRole.ADMIN, OperationType.ACTIVITY_CHECKIN_CONFIG_UPDATE,
|
|
|
|
|
+ "CHECKIN_CONFIG:" + CONFIG_ID, CONFIG_ID,
|
|
|
|
|
+ beforeData, afterData,
|
|
|
|
|
+ "签到送会员活动配置变更",
|
|
|
|
|
+ OperationSource.ADMIN_CREATE);
|
|
|
|
|
+
|
|
|
boolean active = request.getEnabled() != null && request.getEnabled() == 1;
|
|
boolean active = request.getEnabled() != null && request.getEnabled() == 1;
|
|
|
if (active) {
|
|
if (active) {
|
|
|
if (timeChanged || modeChanged) {
|
|
if (timeChanged || modeChanged) {
|
|
@@ -349,6 +365,21 @@ public class CheckInConfigService {
|
|
|
return "ACTIVE";
|
|
return "ACTIVE";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private Map<String, Object> configSnapshot(CheckInConfig c) {
|
|
|
|
|
+ Map<String, Object> s = new HashMap<>();
|
|
|
|
|
+ s.put("enabled", c.getEnabled());
|
|
|
|
|
+ s.put("startTime", c.getStartTime());
|
|
|
|
|
+ s.put("endTime", c.getEndTime());
|
|
|
|
|
+ s.put("cycleMode", c.getCycleMode());
|
|
|
|
|
+ s.put("requiredDays", c.getRequiredDays());
|
|
|
|
|
+ s.put("rewardMode", c.getRewardMode());
|
|
|
|
|
+ s.put("rewardDays", c.getRewardDays());
|
|
|
|
|
+ s.put("rewardLevel", c.getRewardLevel());
|
|
|
|
|
+ s.put("maxRewardCount", c.getMaxRewardCount());
|
|
|
|
|
+ s.put("remark", c.getRemark());
|
|
|
|
|
+ return s;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/** 值为 null 时返回默认值 */
|
|
/** 值为 null 时返回默认值 */
|
|
|
private static <T> T orDefault(T value, T defaultValue) {
|
|
private static <T> T orDefault(T value, T defaultValue) {
|
|
|
return value != null ? value : defaultValue;
|
|
return value != null ? value : defaultValue;
|