|
|
|
@ -259,18 +259,15 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
// 活动报名的按钮,报名后。在取消 报名活动的所有时间段之前,不支持再次报名!
|
|
|
|
|
|
|
|
List<ActPeriodDTO> periods = actUserRelationDTO.getPeriods(); |
|
|
|
if (CollectionUtil.isEmpty(periods)) { |
|
|
|
// 兼容之前,不存在 活动时间段 的老数据
|
|
|
|
ActInfoDTO actInfoDTO = actInfoDao.queryActSignupNum(actUserRelationDTO.getActId()); |
|
|
|
if (NumConstant.ZERO != actInfoDTO.getActQuotaCategory() && actInfoDTO.getActQuota().equals(actInfoDTO.getSignupNum())) { |
|
|
|
return new Result().error("活动已报满"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 校验当前报名的 活动时间段,是否已报满
|
|
|
|
List<ActPeriodDTO> periodsByActId = actPeriodService.listOfActPeriodsByActId(actUserRelationDTO.getActId()); |
|
|
|
// 校验当前报名的 活动时间段,是否已报满
|
|
|
|
List<ActPeriodDTO> periodsByActId = actPeriodService.listOfActPeriodsByActId(actUserRelationDTO.getActId()); |
|
|
|
for (ActPeriodDTO period : periods) { |
|
|
|
for (ActPeriodDTO dto : periodsByActId) { |
|
|
|
if (NumConstant.ZERO != dto.getActPeriodQuotaCategory() && dto.getActPeriodQuota().equals(dto.getActPeriodSignUpNum())) { |
|
|
|
return new Result().error("该" + dto.getActPeriodStartTime() + "-" + dto.getActPeriodEndTime() + "时间段的活动已报满! 请选择其他时间段"); |
|
|
|
if (period.getId().equals(dto.getId())) { |
|
|
|
if (NumConstant.ZERO != dto.getActPeriodQuotaCategory() && |
|
|
|
dto.getActPeriodQuota().equals(dto.getActPeriodSignUpNum())) { |
|
|
|
return new Result().error("该时间段活动已报满! 请选择其他时间段"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -313,40 +310,50 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
return new Result().ok("报名成功"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result activityCancelSignUp(AppActUserCancelsignupDTO appActUserCancelsignupDTO) { |
|
|
|
// 用户取消报名,先对已报名的 所有时间段进行处理
|
|
|
|
if (NumConstant.ZERO < appActUserCancelsignupDTO.getActPeriodId().size()) { |
|
|
|
// 查询用户关联表主键
|
|
|
|
ActUserRelationEntity actUserRelationEntity = baseDao.selectOneByUserIdAndActId(appActUserCancelsignupDTO.getUserId(), appActUserCancelsignupDTO.getActId()); |
|
|
|
// 根据活动id,查询该活动是否属于老数据(即,epdc_act_period 表中,不存在的活动)
|
|
|
|
Integer number = actPeriodService.getPeriodNumberByActId(appActUserCancelsignupDTO.getActId()); |
|
|
|
|
|
|
|
// 0 != number 该活动属于新数据,先进行 活动时间段逻辑处理
|
|
|
|
if (NumConstant.ZERO != number) { |
|
|
|
// 用户取消报名,先对已报名的 所有时间段进行处理
|
|
|
|
if (NumConstant.ZERO < appActUserCancelsignupDTO.getActPeriodId().size()) { |
|
|
|
// 查询用户关联表主键
|
|
|
|
ActUserRelationEntity actUserRelationEntity = baseDao.selectOneByUserIdAndActId(appActUserCancelsignupDTO.getUserId(), appActUserCancelsignupDTO.getActId()); |
|
|
|
|
|
|
|
List<ActPeriodUserDTO> periodUserDtoList = new ArrayList<>(); |
|
|
|
for (String actPeriodId : appActUserCancelsignupDTO.getActPeriodId()) { |
|
|
|
ActPeriodUserDTO periodUserDTO = new ActPeriodUserDTO(); |
|
|
|
periodUserDTO.setActPeriodId(actPeriodId); |
|
|
|
periodUserDTO.setActUserRelationId(actUserRelationEntity.getId()); |
|
|
|
periodUserDTO.setFailureReason(appActUserCancelsignupDTO.getFailureReason()); |
|
|
|
periodUserDTO.setPeriodStatus(ActUserRelationStatusConstant.CANCEL_SIGN_UP); |
|
|
|
periodUserDtoList.add(periodUserDTO); |
|
|
|
} |
|
|
|
// 批量修改
|
|
|
|
actPeriodUserService.updateBatch(periodUserDtoList); |
|
|
|
|
|
|
|
List<ActPeriodUserDTO> periodUserDtoList = new ArrayList<>(); |
|
|
|
for (String actPeriodId : appActUserCancelsignupDTO.getActPeriodId()) { |
|
|
|
ActPeriodUserDTO periodUserDTO = new ActPeriodUserDTO(); |
|
|
|
periodUserDTO.setActPeriodId(actPeriodId); |
|
|
|
periodUserDTO.setActUserRelationId(actUserRelationEntity.getId()); |
|
|
|
periodUserDTO.setFailureReason(appActUserCancelsignupDTO.getFailureReason()); |
|
|
|
periodUserDTO.setPeriodStatus(ActUserRelationStatusConstant.CANCEL_SIGN_UP); |
|
|
|
periodUserDtoList.add(periodUserDTO); |
|
|
|
} |
|
|
|
// 批量修改
|
|
|
|
actPeriodUserService.updateBatch(periodUserDtoList); |
|
|
|
// 查询状态为:已报名的所有时间段
|
|
|
|
List<ActPeriodDTO> periodTime = actPeriodUserService.listOfNormalSignInActPeriodsByActUserRelationId1(actUserRelationEntity.getId()); |
|
|
|
if (null == periodTime) { |
|
|
|
periodTime = new ArrayList<>(); |
|
|
|
} |
|
|
|
// 是否已经取消了,报名的所有活动时间段
|
|
|
|
if (NumConstant.ZERO < periodTime.size()) { |
|
|
|
// 否,退出。不再进行下一步操作
|
|
|
|
return new Result().ok("取消报名成功"); |
|
|
|
} |
|
|
|
// 是,用户取消报名(已报名的所有时间段),处理完报名的所有时间段之后,再走原先的 取消报名逻辑
|
|
|
|
|
|
|
|
// 查询状态为:已报名的所有时间段
|
|
|
|
List<ActPeriodDTO> periodTime = actPeriodUserService.listOfNormalSignInActPeriodsByActUserRelationId1(actUserRelationEntity.getId()); |
|
|
|
if (null == periodTime) { |
|
|
|
periodTime = new ArrayList<>(); |
|
|
|
} |
|
|
|
// 是否已经取消了,报名的所有活动时间段
|
|
|
|
if (NumConstant.ZERO < periodTime.size()) { |
|
|
|
// 否,不再进行下一步操作
|
|
|
|
return new Result().ok("取消报名成功"); |
|
|
|
} else { |
|
|
|
// 该活动存在 时间段,但用户取消报名时,未勾选。此时,返回提示:请选择要取消的时间段
|
|
|
|
return new Result().error("请选择要取消的时间段"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 用户取消报名(已报名的所有时间段),处理完报名的所有时间段之后,再走原先的 取消报名逻辑
|
|
|
|
|
|
|
|
//查询是否已报名
|
|
|
|
List<String> statusList = new ArrayList<>(); |
|
|
|
statusList.add(ActUserRelationStatusConstant.SIGN_UP); |
|
|
|
|