|
|
@@ -62,7 +62,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
Long creatorId = 1L; // 默认值,实际应从 SecurityContext 获取
|
|
|
String creatorName = "系统管理员"; // 默认值,实际应从 SecurityContext 获取
|
|
|
|
|
|
- if (dto.getActivityType() == 4) {
|
|
|
+ if (dto.getActivityType() == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
log.info("[统一活动] 路由到邀请活动服务");
|
|
|
InviteActivityCreateDTO inviteDTO = convertToInviteCreateDTO(dto);
|
|
|
InviteActivity activity = inviteActivityService.create(inviteDTO, creatorId, creatorName);
|
|
|
@@ -72,7 +72,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
dto.getInviterCouponTemplateId(), dto.getInviteeCouponTemplateId());
|
|
|
|
|
|
return activity.getId();
|
|
|
- } else if (dto.getActivityType() >= 1 && dto.getActivityType() <= 3) {
|
|
|
+ } else if (dto.getActivityType() >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && dto.getActivityType() <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
log.info("[统一活动] 路由到营销活动服务");
|
|
|
ActivityCreateDTO marketingDTO = convertToMarketingCreateDTO(dto);
|
|
|
MarketingActivity activity = marketingActivityService.create(marketingDTO, creatorId, creatorName);
|
|
|
@@ -88,7 +88,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
|
|
|
Integer type = getActivityTypeFromUpdateDTO(dto);
|
|
|
|
|
|
- if (type == 4) {
|
|
|
+ if (type == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
log.info("[统一活动] 路由到邀请活动服务进行更新");
|
|
|
|
|
|
// 【Task 8】更新前获取旧的优惠券模板ID,用于后续清理旧关联
|
|
|
@@ -111,7 +111,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
syncCouponTemplateAssociation(dto.getId(),
|
|
|
oldInviterCouponId, oldInviteeCouponId,
|
|
|
dto.getInviterCouponTemplateId(), dto.getInviteeCouponTemplateId());
|
|
|
- } else if (type >= 1 && type <= 3) {
|
|
|
+ } else if (type >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && type <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
log.info("[统一活动] 路由到营销活动服务进行更新");
|
|
|
ActivityUpdateDTO marketingDTO = convertToMarketingUpdateDTO(dto);
|
|
|
marketingActivityService.update(marketingDTO);
|
|
|
@@ -125,14 +125,14 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
log.info("[统一活动] 分页查询 - type: {}, page: {}, size: {}",
|
|
|
queryDTO.getActivityType(), queryDTO.getPage(), queryDTO.getPageSize());
|
|
|
|
|
|
- if (queryDTO.getActivityType() != null && queryDTO.getActivityType() == 4) {
|
|
|
+ if (queryDTO.getActivityType() != null && queryDTO.getActivityType() == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
// 仅查询邀请活动,并转换为统一 VO 格式
|
|
|
log.info("[统一活动] 查询邀请活动列表");
|
|
|
InviteRecordQueryDTO inviteQuery = convertToInviteQuery(queryDTO);
|
|
|
IPage<InviteActivity> page = inviteActivityService.getPage(inviteQuery);
|
|
|
return convertInvitePageToUnified(page);
|
|
|
} else if (queryDTO.getActivityType() == null ||
|
|
|
- (queryDTO.getActivityType() >= 1 && queryDTO.getActivityType() <= 3)) {
|
|
|
+ (queryDTO.getActivityType() >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && queryDTO.getActivityType() <= ActivityTypeEnum.FULL_REDUCTION.getCode())) {
|
|
|
// 查询营销活动 (type 1-3 或全部)
|
|
|
log.info("[统一活动] 查询营销活动列表");
|
|
|
ActivityQueryDTO marketingQuery = convertToMarketingQuery(queryDTO);
|
|
|
@@ -147,11 +147,11 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
public UnifiedActivityVO getDetail(Long id, Integer type) {
|
|
|
log.info("[统一活动] 查询详情 - id: {}, type: {}", id, type);
|
|
|
|
|
|
- if (type == 4) {
|
|
|
+ if (type == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
log.info("[统一活动] 从邀请活动服务获取详情");
|
|
|
InviteActivity activity = inviteActivityService.getDetail(id);
|
|
|
return convertInviteToUnifiedVO(activity);
|
|
|
- } else if (type >= 1 && type <= 3) {
|
|
|
+ } else if (type >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && type <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
log.info("[统一活动] 从营销活动服务获取详情");
|
|
|
MarketingActivity activity = marketingActivityService.getDetail(id);
|
|
|
return convertMarketingToUnifiedVO(activity);
|
|
|
@@ -166,10 +166,10 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
public void publish(Long id, Integer type) {
|
|
|
log.info("[统一活动] 发布活动 - id: {}, type: {}", id, type);
|
|
|
|
|
|
- if (type == 4) {
|
|
|
+ if (type == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
boolean result = inviteActivityService.publish(id);
|
|
|
logPublishResult(id, type, result);
|
|
|
- } else if (type >= 1 && type <= 3) {
|
|
|
+ } else if (type >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && type <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
boolean result = marketingActivityService.publish(id);
|
|
|
logPublishResult(id, type, result);
|
|
|
} else {
|
|
|
@@ -181,10 +181,10 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
public void pause(Long id, Integer type) {
|
|
|
log.info("[统一活动] 暂停活动 - id: {}, type: {}", id, type);
|
|
|
|
|
|
- if (type == 4) {
|
|
|
+ if (type == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
boolean result = inviteActivityService.pause(id);
|
|
|
logOperationResult("暂停", id, type, result);
|
|
|
- } else if (type >= 1 && type <= 3) {
|
|
|
+ } else if (type >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && type <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
boolean result = marketingActivityService.pause(id);
|
|
|
logOperationResult("暂停", id, type, result);
|
|
|
} else {
|
|
|
@@ -196,10 +196,10 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
public void resume(Long id, Integer type) {
|
|
|
log.info("[统一活动] 恢复活动 - id: {}, type: {}", id, type);
|
|
|
|
|
|
- if (type == 4) {
|
|
|
+ if (type == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
boolean result = inviteActivityService.resume(id);
|
|
|
logOperationResult("恢复", id, type, result);
|
|
|
- } else if (type >= 1 && type <= 3) {
|
|
|
+ } else if (type >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && type <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
boolean result = marketingActivityService.resume(id);
|
|
|
logOperationResult("恢复", id, type, result);
|
|
|
} else {
|
|
|
@@ -213,7 +213,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
public void delete(Long id, Integer type) {
|
|
|
log.info("[统一活动] 删除活动 - id: {}, type: {}", id, type);
|
|
|
|
|
|
- if (type == 4) {
|
|
|
+ if (type == ActivityTypeEnum.INVITE_REWARD.getCode()) {
|
|
|
// 【Task 8】删除前清理关联的优惠券模板 activityId
|
|
|
try {
|
|
|
InviteActivity existingActivity = inviteActivityService.getDetail(id);
|
|
|
@@ -228,7 +228,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
|
|
|
boolean result = inviteActivityService.deleteActivity(id);
|
|
|
logOperationResult("删除", id, type, result);
|
|
|
- } else if (type >= 1 && type <= 3) {
|
|
|
+ } else if (type >= ActivityTypeEnum.FIRST_ORDER_DISCOUNT.getCode() && type <= ActivityTypeEnum.FULL_REDUCTION.getCode()) {
|
|
|
boolean result = marketingActivityService.deleteActivity(id);
|
|
|
logOperationResult("删除", id, type, result);
|
|
|
} else {
|
|
|
@@ -463,7 +463,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
return UnifiedActivityVO.builder()
|
|
|
.id(activity.getId())
|
|
|
.activityName(activity.getActivityName())
|
|
|
- .activityType(4) // 邀请活动固定为 type 4
|
|
|
+ .activityType(ActivityTypeEnum.INVITE_REWARD.getCode())
|
|
|
.activityTypeName(ActivityTypeEnum.INVITE_REWARD.getLabel())
|
|
|
.activityDesc(activity.getActivityDesc())
|
|
|
.startTime(activity.getStartTime())
|
|
|
@@ -505,7 +505,7 @@ public class UnifiedActivityServiceImpl implements UnifiedActivityService {
|
|
|
InviteActivity inviteActivity = inviteActivityService.getById(id);
|
|
|
if (inviteActivity != null && inviteActivity.getDeleted() != null && inviteActivity.getDeleted() == 0) {
|
|
|
log.info("[统一活动] 从邀请活动表查到活动类型: id={}, type=4", id);
|
|
|
- return 4;
|
|
|
+ return ActivityTypeEnum.INVITE_REWARD.getCode();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.debug("[统一活动] 邀请活动表未找到该记录: id={}", id);
|