|
@@ -4,6 +4,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import shop.alien.entity.store.LifeDiscountCoupon;
|
|
import shop.alien.entity.store.LifeDiscountCoupon;
|
|
|
import shop.alien.entity.store.StoreImg;
|
|
import shop.alien.entity.store.StoreImg;
|
|
|
import shop.alien.entity.store.StoreInfo;
|
|
import shop.alien.entity.store.StoreInfo;
|
|
@@ -50,6 +51,12 @@ public class StoreOperationalActivityServiceImpl implements StoreOperationalActi
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public StoreOperationalActivityDetailVo getActivityDetail(Integer id, Integer userId) {
|
|
public StoreOperationalActivityDetailVo getActivityDetail(Integer id, Integer userId) {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 活动详情查询:
|
|
|
|
|
+ * 1. 校验活动ID有效性;
|
|
|
|
|
+ * 2. 组装详情数据(报名状态、报名人数、活动图片等);
|
|
|
|
|
+ * 3. 根据用户报名状态计算 detailStatus。
|
|
|
|
|
+ */
|
|
|
log.info("StoreOperationalActivityServiceImpl.getActivityDetail: id={}, userId={}", id, userId);
|
|
log.info("StoreOperationalActivityServiceImpl.getActivityDetail: id={}, userId={}", id, userId);
|
|
|
if (id == null) {
|
|
if (id == null) {
|
|
|
throw new IllegalArgumentException("活动ID不能为空");
|
|
throw new IllegalArgumentException("活动ID不能为空");
|
|
@@ -62,9 +69,12 @@ public class StoreOperationalActivityServiceImpl implements StoreOperationalActi
|
|
|
StoreOperationalActivityDetailVo vo = new StoreOperationalActivityDetailVo();
|
|
StoreOperationalActivityDetailVo vo = new StoreOperationalActivityDetailVo();
|
|
|
BeanUtils.copyProperties(activity, vo);
|
|
BeanUtils.copyProperties(activity, vo);
|
|
|
vo.setStatusName(resolveStatusName(activity.getStatus()));
|
|
vo.setStatusName(resolveStatusName(activity.getStatus()));
|
|
|
|
|
+ // 报名状态相关字段填充
|
|
|
fillSignupFlags(vo, activity, userId);
|
|
fillSignupFlags(vo, activity, userId);
|
|
|
|
|
+ // 报名人数统计
|
|
|
fillSignupCounts(vo);
|
|
fillSignupCounts(vo);
|
|
|
Integer signupStatus = resolveCurrentUserSignupStatus(activity.getId(), userId);
|
|
Integer signupStatus = resolveCurrentUserSignupStatus(activity.getId(), userId);
|
|
|
|
|
+ // 详情按钮状态计算
|
|
|
vo.setDetailStatus(resolveDetailStatus(activity, signupStatus));
|
|
vo.setDetailStatus(resolveDetailStatus(activity, signupStatus));
|
|
|
|
|
|
|
|
if (activity.getCouponId() != null) {
|
|
if (activity.getCouponId() != null) {
|
|
@@ -74,6 +84,7 @@ public class StoreOperationalActivityServiceImpl implements StoreOperationalActi
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 店铺信息与活动图片
|
|
|
attachStoreInfo(vo);
|
|
attachStoreInfo(vo);
|
|
|
fillActivityImages(vo);
|
|
fillActivityImages(vo);
|
|
|
return vo;
|
|
return vo;
|
|
@@ -136,6 +147,7 @@ public class StoreOperationalActivityServiceImpl implements StoreOperationalActi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public boolean deleteSignup(Integer activityId, Integer signupId) {
|
|
public boolean deleteSignup(Integer activityId, Integer signupId) {
|
|
|
if (activityId == null) {
|
|
if (activityId == null) {
|
|
|
throw new IllegalArgumentException("活动ID不能为空");
|
|
throw new IllegalArgumentException("活动ID不能为空");
|
|
@@ -143,12 +155,21 @@ public class StoreOperationalActivityServiceImpl implements StoreOperationalActi
|
|
|
if (signupId == null) {
|
|
if (signupId == null) {
|
|
|
throw new IllegalArgumentException("报名ID不能为空");
|
|
throw new IllegalArgumentException("报名ID不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
+ StoreOperationalActivitySignup signup = signupMapper.selectById(signupId);
|
|
|
|
|
+ if (signup == null || (signup.getDeleteFlag() != null && signup.getDeleteFlag() == 1)) {
|
|
|
|
|
+ throw new IllegalArgumentException("报名信息不存在或已删除");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!activityId.equals(signup.getActivityId())) {
|
|
|
|
|
+ throw new IllegalArgumentException("报名信息与活动不匹配");
|
|
|
|
|
+ }
|
|
|
int deletedSignup = signupMapper.delete(new LambdaQueryWrapper<StoreOperationalActivitySignup>()
|
|
int deletedSignup = signupMapper.delete(new LambdaQueryWrapper<StoreOperationalActivitySignup>()
|
|
|
.eq(StoreOperationalActivitySignup::getId, signupId)
|
|
.eq(StoreOperationalActivitySignup::getId, signupId)
|
|
|
.eq(StoreOperationalActivitySignup::getActivityId, activityId));
|
|
.eq(StoreOperationalActivitySignup::getActivityId, activityId));
|
|
|
int deletedAchievement = achievementMapper.delete(new LambdaQueryWrapper<StoreOperationalActivityAchievement>()
|
|
int deletedAchievement = achievementMapper.delete(new LambdaQueryWrapper<StoreOperationalActivityAchievement>()
|
|
|
.eq(StoreOperationalActivityAchievement::getSignupId, signupId)
|
|
.eq(StoreOperationalActivityAchievement::getSignupId, signupId)
|
|
|
.eq(StoreOperationalActivityAchievement::getActivityId, activityId));
|
|
.eq(StoreOperationalActivityAchievement::getActivityId, activityId));
|
|
|
|
|
+ log.info("deleteSignup success. activityId={}, signupId={}, deletedSignup={}, deletedAchievement={}",
|
|
|
|
|
+ activityId, signupId, deletedSignup, deletedAchievement);
|
|
|
return deletedSignup > 0 || deletedAchievement > 0;
|
|
return deletedSignup > 0 || deletedAchievement > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|