|
|
@ -42,7 +42,7 @@ import com.epmet.dto.result.UserRoleResultDTO; |
|
|
|
import com.epmet.entity.ActUserLogEntity; |
|
|
|
import com.epmet.entity.ActUserRelationEntity; |
|
|
|
import com.epmet.entity.HeartUserInfoEntity; |
|
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.redis.ActUserRelationRedis; |
|
|
|
import com.epmet.service.ActInfoService; |
|
|
|
import com.epmet.service.ActUserLogService; |
|
|
@ -76,7 +76,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
@Autowired |
|
|
|
private VolunteerInfoDao volunteerInfoDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private HeartUserInfoDao heartUserInfoDao; |
|
|
|
|
|
|
@ -188,7 +188,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
ActUserLogDTO userLogDTO = new ActUserLogDTO(); |
|
|
|
userLogDTO.setActId(formDTO.getActId()); |
|
|
|
userLogDTO.setUserId(tokenDto.getUserId()); |
|
|
|
userLogDTO.setOperationType(ActConstant.ACT_USER_STATUS_CANCELD); |
|
|
|
userLogDTO.setOperationType(ActConstant.ACT_USER_LOG_OPER_CANCELD); |
|
|
|
userLogDTO.setReason(formDTO.getFailureReason()); |
|
|
|
actUserLogService.save(userLogDTO); |
|
|
|
return new Result(); |
|
|
@ -201,35 +201,33 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
boolean satisfy = false; |
|
|
|
// 查询活动信息
|
|
|
|
ActInfoDTO actInfoDTO = actInfoService.get(formDTO.getActId()); |
|
|
|
// >0 当前用户是志愿者
|
|
|
|
Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getActId()); |
|
|
|
if (actInfoDTO.getVolunteerLimit()){ |
|
|
|
// 活动只能志愿者参加
|
|
|
|
Integer volunteerFlag = volunteerInfoDao.queryVolunteerFlagByUserId(formDTO.getUserId()); |
|
|
|
if (volunteerFlag > NumConstant.ZERO){ |
|
|
|
satisfy = true; |
|
|
|
// 活动只能志愿者参加, 当前用户是否满足条件
|
|
|
|
satisfy = this.volunteerParticipationAct(volunteerFlag); |
|
|
|
} else { |
|
|
|
logger.info("活动报名失败,请先认证志愿者"); |
|
|
|
throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 活动不限制志愿者身份,但要求是 居民身份
|
|
|
|
Result<List<UserRoleResultDTO>> userRoleInfo = epmetUserFeignClient.getUserRoleInfoByUserId(formDTO.getUserId()); |
|
|
|
for (UserRoleResultDTO roleResultDTO :userRoleInfo.getData()){ |
|
|
|
if (EpmetRoleKeyConstant.REGISTERED_RESI.equals(roleResultDTO.getRoleKey())){ |
|
|
|
satisfy = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!satisfy){ |
|
|
|
logger.info("活动报名失败,请完善居民信息"); |
|
|
|
throw new RenException(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); |
|
|
|
} |
|
|
|
// 活动不限制志愿者身份,但要求是 居民身份, 当前用户是否满足条件
|
|
|
|
satisfy = this.resiParticipationAct(formDTO.getUserId()); |
|
|
|
} |
|
|
|
if (satisfy){ |
|
|
|
this.actStartSignUp(actInfoDTO, formDTO); |
|
|
|
// 开始报名
|
|
|
|
this.actStartSignUp(actInfoDTO, formDTO, volunteerFlag); |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
private void actStartSignUp(ActInfoDTO actInfoDTO, ResiActRegistrationFormDTO formDTO){ |
|
|
|
/** |
|
|
|
* 开始报名活动 |
|
|
|
* |
|
|
|
* @param actInfoDTO 活动详情 |
|
|
|
* @param formDTO 接口请求入参 |
|
|
|
* @param volunteerFlag >0 当前用户是志愿者 |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 15:31 2020-07-24 |
|
|
|
**/ |
|
|
|
private void actStartSignUp(ActInfoDTO actInfoDTO, ResiActRegistrationFormDTO formDTO, Integer volunteerFlag){ |
|
|
|
boolean signUp = true; |
|
|
|
Integer auditingNum = actUserLogService.countActTimesOfParticipation(formDTO.getUserId()); |
|
|
|
if (auditingNum > NumConstant.ZERO){ |
|
|
@ -246,7 +244,7 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
HeartUserInfoEntity entity = new HeartUserInfoEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setUserId(formDTO.getUserId()); |
|
|
|
entity.setVolunteerFlag(true); |
|
|
|
entity.setVolunteerFlag(volunteerFlag > NumConstant.ZERO); |
|
|
|
entity.setKindnessTime(NumConstant.ZERO); |
|
|
|
entity.setParticipationNum(NumConstant.ZERO); |
|
|
|
entity.setObtainPointNum(NumConstant.ZERO); |
|
|
@ -264,8 +262,53 @@ public class ActUserRelationServiceImpl extends BaseServiceImpl<ActUserRelationD |
|
|
|
ActUserLogEntity userLogEntity = new ActUserLogEntity(); |
|
|
|
userLogEntity.setActId(formDTO.getActId()); |
|
|
|
userLogEntity.setUserId(formDTO.getUserId()); |
|
|
|
userLogEntity.setOperationType(ActConstant.ACT_USER_STATUS_AUDITING); |
|
|
|
userLogEntity.setOperationType(ActConstant.ACT_USER_LOG_OPER_AUDITING); |
|
|
|
actUserLogService.insert(userLogEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 活动报名,限制必须是志愿者身份。当前用户是否符合 |
|
|
|
* @param volunteerFlag |
|
|
|
* @return boolean |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 15:04 2020-07-24 |
|
|
|
**/ |
|
|
|
private boolean volunteerParticipationAct(Integer volunteerFlag){ |
|
|
|
boolean satisfy = false; |
|
|
|
// 活动只能志愿者参加
|
|
|
|
if (volunteerFlag > NumConstant.ZERO){ |
|
|
|
satisfy = true; |
|
|
|
return satisfy; |
|
|
|
} else { |
|
|
|
logger.info("活动报名失败,请先认证志愿者"); |
|
|
|
throw new RenException(EpmetErrorCode.NON_CERTIFIED_VOLUNTEER.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 活动报名,不限制志愿者身份,但要求是 居民身份。当前用户是否符合 |
|
|
|
* @param userId |
|
|
|
* @return boolean |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 15:04 2020-07-24 |
|
|
|
**/ |
|
|
|
private boolean resiParticipationAct(String userId){ |
|
|
|
boolean satisfy = false; |
|
|
|
// 活动不限制志愿者身份,但要求是 居民身份
|
|
|
|
Result<List<UserRoleResultDTO>> userRoleInfo = epmetUserOpenFeignClient.getUserRoleInfoByUserId(userId); |
|
|
|
if (userRoleInfo.success()){ |
|
|
|
for (UserRoleResultDTO roleResultDTO :userRoleInfo.getData()){ |
|
|
|
if (EpmetRoleKeyConstant.REGISTERED_RESI.equals(roleResultDTO.getRoleKey())){ |
|
|
|
satisfy = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!satisfy){ |
|
|
|
logger.info("活动报名失败,请完善居民信息"); |
|
|
|
throw new RenException(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); |
|
|
|
} else { |
|
|
|
return satisfy; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|