|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
package com.elink.esua.epdc.modules.activity.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.activity.*; |
|
|
@ -51,10 +52,7 @@ import com.elink.esua.epdc.dto.result.BehaviorResultDto; |
|
|
|
import com.elink.esua.epdc.modules.activity.dao.ActInfoDao; |
|
|
|
import com.elink.esua.epdc.modules.activity.dao.ActUserLogDao; |
|
|
|
import com.elink.esua.epdc.modules.activity.dao.ActUserRelationDao; |
|
|
|
import com.elink.esua.epdc.modules.activity.entity.ActInfoEntity; |
|
|
|
import com.elink.esua.epdc.modules.activity.entity.ActUserLogEntity; |
|
|
|
import com.elink.esua.epdc.modules.activity.entity.ActUserPointsLogEntity; |
|
|
|
import com.elink.esua.epdc.modules.activity.entity.ActUserRelationEntity; |
|
|
|
import com.elink.esua.epdc.modules.activity.entity.*; |
|
|
|
import com.elink.esua.epdc.modules.activity.service.*; |
|
|
|
import com.elink.esua.epdc.modules.async.NewsTask; |
|
|
|
import com.elink.esua.epdc.modules.feign.AdminFeignClient; |
|
|
@ -187,6 +185,13 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
updateById(updateEntity); |
|
|
|
if (ActStateConstant.ACT_USER_RELATION_STATUS_AUDITREJECT.equals(dto.getStatus())) { |
|
|
|
actInfoService.minusSignUpNum(entity.getActId()); |
|
|
|
|
|
|
|
// 如果活动开始未审核报名人默认状态(1-审核通过,4-审核不通过)是 4,则将 epdc_act_period 表中的,所有活动时间段状态 更改为 4
|
|
|
|
ActPeriodUserDTO periodUserDTO = new ActPeriodUserDTO(); |
|
|
|
periodUserDTO.setPeriodStatus(ActStateConstant.ACT_USER_RELATION_STATUS_AUDITREJECT); |
|
|
|
periodUserDTO.setActUserRelationId(entity.getId()); |
|
|
|
periodUserDTO.setFailureReason(dto.getFailureReason()); |
|
|
|
actPeriodUserService.updateByActUserRelationId(periodUserDTO); |
|
|
|
} |
|
|
|
//
|
|
|
|
//存储活动日志表 epdc_act_user_log
|
|
|
@ -251,11 +256,25 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result activitySignUp(ActUserRelationDTO actUserRelationDTO) { |
|
|
|
ActInfoDTO actInfoDTO = actInfoDao.queryActSignupNum(actUserRelationDTO.getActId()); |
|
|
|
//判断报名是否已满
|
|
|
|
if (actInfoDTO.getActQuotaCategory() != 0 && actInfoDTO.getActQuota().equals(actInfoDTO.getSignupNum())) { |
|
|
|
return new Result().error("活动已报满"); |
|
|
|
// 活动报名的按钮,报名后。在取消 报名活动的所有时间段之前,不支持再次报名!
|
|
|
|
|
|
|
|
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()); |
|
|
|
for (ActPeriodDTO dto : periodsByActId) { |
|
|
|
if (NumConstant.ZERO != dto.getActPeriodQuotaCategory() && dto.getActPeriodQuota().equals(dto.getActPeriodSignUpNum())) { |
|
|
|
return new Result().error("该" + dto.getActPeriodStartTime() + "-" + dto.getActPeriodEndTime() + "时间段的活动已报满! 请选择其他时间段"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//查询是否已报名
|
|
|
|
ActUserRelationEntity actUserRelationEntity = baseDao.selectOneByUserIdAndActId(actUserRelationDTO.getUserId(), actUserRelationDTO.getActId()); |
|
|
|
if (null == actUserRelationEntity || (ActUserRelationStatusConstant.CANCEL_SIGN_UP.equals(actUserRelationEntity.getStatus()) |
|
|
@ -297,6 +316,37 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result activityCancelSignUp(AppActUserCancelsignupDTO appActUserCancelsignupDTO) { |
|
|
|
// 用户取消报名,先对已报名的 所有时间段进行处理
|
|
|
|
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<ActPeriodDTO> periodTime = actPeriodUserService.listOfSignInActPeriodsByActUserRelationId(actUserRelationEntity.getId()); |
|
|
|
if (null == periodTime) { |
|
|
|
periodTime = new ArrayList<>(); |
|
|
|
} |
|
|
|
// 是否已经取消了,报名的所有活动时间段
|
|
|
|
if (NumConstant.ZERO < periodTime.size()) { |
|
|
|
// 否,不再进行下一步操作
|
|
|
|
return new Result().ok("取消报名成功"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 用户取消报名(已报名的所有时间段),处理完报名的所有时间段之后,再走原先的 取消报名逻辑
|
|
|
|
|
|
|
|
//查询是否已报名
|
|
|
|
List<String> statusList = new ArrayList<>(); |
|
|
|
statusList.add(ActUserRelationStatusConstant.SIGN_UP); |
|
|
@ -534,7 +584,14 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
// 审核不通过,活动的报名人数-1
|
|
|
|
if (!NumConstant.ONE_STR.equals(actUserDefaultState)) { |
|
|
|
actInfoService.minusSignUpNum(actInfoDTO.getId()); |
|
|
|
|
|
|
|
// 如果活动开始未审核报名人默认状态(1-审核通过,4-审核不通过)是 4,则将 epdc_act_period 表中的,所有活动时间段状态 更改为 4
|
|
|
|
ActPeriodUserDTO periodUserDTO = new ActPeriodUserDTO(); |
|
|
|
periodUserDTO.setPeriodStatus(actUserDefaultState); |
|
|
|
periodUserDTO.setActUserRelationId(entity.getId()); |
|
|
|
actPeriodUserService.updateByActUserRelationId(periodUserDTO); |
|
|
|
} |
|
|
|
|
|
|
|
//给用户发送消息通知
|
|
|
|
this.sendNotice(actUserRelationDTO, actUserDefaultState, actInfoDTO); |
|
|
|
} |
|
|
|