Browse Source

修改验证是否为志愿者功能

feature/yujt_analysisHomeChange
zhangyuan 5 years ago
parent
commit
0bc4ced051
  1. 40
      epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/ApiActUserRelationController.java
  2. 25
      epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/AppActUserRelationFeignClient.java
  3. 5
      epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/fallback/AppActUserRelationFeignClientFallback.java
  4. 5
      epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/ActUserRelationService.java
  5. 61
      epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/ActUserRelationServiceImpl.java

40
epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/ApiActUserRelationController.java

@ -39,9 +39,6 @@ public class ApiActUserRelationController {
@Autowired
private ActUserRelationService actUserRelationService;
@Autowired
private AppUserService appUserService;
/**
* 活动报名
*
@ -56,42 +53,7 @@ public class ApiActUserRelationController {
if (StringUtils.isBlank(actId)) {
return new Result().error("活动id不能为空");
}
//验证是否为志愿者
Result isVolunteer = appUserService.getVolunteerCountById(tokenDto);
int code = isVolunteer.getCode();
if (code != 0) {
//不是志愿者
return isVolunteer;
}
Result<EpdcUserInfoResultDTO> userInfo = appUserService.getInfoById(tokenDto);
EpdcUserInfoResultDTO epdcUserInfoResultDTO = userInfo.getData();
ActUserRelationDTO actUserRelationDTO = new ActUserRelationDTO();
actUserRelationDTO.setActId(actId);
actUserRelationDTO.setUserId(tokenDto.getUserId());
actUserRelationDTO.setNickname(tokenDto.getNickname());
actUserRelationDTO.setFaceImg(tokenDto.getFaceImg());
if (UserTagUtils.containIdentity(tokenDto.getUserTagInfos(), UserTagEnum.PARTY_MEMBER)) {
actUserRelationDTO.setPartyFlag(YesOrNoEnum.YES.value());
} else {
actUserRelationDTO.setPartyFlag(YesOrNoEnum.NO.value());
}
String identityNo = epdcUserInfoResultDTO.getIdentityNo();
String identityNoVerification = IdentityNoUtils.IdentityNoVerification(identityNo);
if (StringUtils.isNotBlank(identityNoVerification)) {
return new Result().error(identityNoVerification);
}
actUserRelationDTO.setRealName(tokenDto.getRealName());
String sex = IdentityNoUtils.getSex(identityNo); // 身份证解析性别
actUserRelationDTO.setSex(sex);
actUserRelationDTO.setAge(IdentityNoUtils.getAge(identityNo));
actUserRelationDTO.setMobile(tokenDto.getMobile());
actUserRelationDTO.setIdentityNo(identityNo);
actUserRelationDTO.setStatus("0");
actUserRelationDTO.setSignupTime(new Date());
return actUserRelationService.activitySignUp(actUserRelationDTO);
return actUserRelationService.activitySignUp(tokenDto, actId);
}

25
epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/AppActUserRelationFeignClient.java

@ -1,9 +1,6 @@
package com.elink.esua.epdc.feign;
import com.elink.esua.epdc.activity.ActUserRelationDTO;
import com.elink.esua.epdc.activity.AppActUserCancelsignupDTO;
import com.elink.esua.epdc.activity.AppActUserClockLogDTO;
import com.elink.esua.epdc.activity.AppClockListDTO;
import com.elink.esua.epdc.activity.*;
import com.elink.esua.epdc.activity.result.AppActInfoDTO;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
@ -14,7 +11,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
*
* 活动报名管理
*
* @Authorwanggongfeng
@ -25,14 +21,16 @@ public interface AppActUserRelationFeignClient {
/**
* 活动报名
*
* @param actUserRelationDTO
* @return
*/
@GetMapping(value = "heart/appactuserrelation/activitySignUp",consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "heart/appactuserrelation/activitySignUp", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result activitySignUp(ActUserRelationDTO actUserRelationDTO);
/**
* 取消活动报名
*
* @param epdcAppActUserCancelsignupDTO
* @return
*/
@ -41,14 +39,16 @@ public interface AppActUserRelationFeignClient {
/**
* 活动打卡
*
* @param appActUserClockLogDTO
* @return
*/
@GetMapping(value = "heart/appactuserclocklog/activityClock",consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@GetMapping(value = "heart/appactuserclocklog/activityClock", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Result activityClock(AppActUserClockLogDTO appActUserClockLogDTO);
/**
* 通过活动ID查询打卡列表
*
* @param actId
* @return
*/
@ -57,10 +57,21 @@ public interface AppActUserRelationFeignClient {
/**
* 获取活动打卡地点详情
*
* @param actId
* @return
*/
@GetMapping("heart/appactinfo/clockAddressDetail/{actId}")
Result<AppActInfoDTO> clockAddressDetail(@PathVariable("actId") String actId);
/**
* 获取活动志愿者标识
*
* @param actId
* @return
*/
@GetMapping("heart/appactinfo/getVolunteerFlag/{actId}")
Result<ActInfoDTO> getVolunteerFlag(@PathVariable("actId") String actId);
}

5
epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/fallback/AppActUserRelationFeignClientFallback.java

@ -1,5 +1,6 @@
package com.elink.esua.epdc.feign.fallback;
import com.elink.esua.epdc.activity.ActInfoDTO;
import com.elink.esua.epdc.activity.ActUserRelationDTO;
import com.elink.esua.epdc.activity.AppActUserCancelsignupDTO;
import com.elink.esua.epdc.activity.AppActUserClockLogDTO;
@ -41,4 +42,8 @@ public class AppActUserRelationFeignClientFallback implements AppActUserRelation
return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "clockAddressDetail", actId);
}
@Override
public Result<ActInfoDTO> getVolunteerFlag(String actId) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getVolunteerFlag", actId);
}
}

5
epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/ActUserRelationService.java

@ -5,6 +5,7 @@ import com.elink.esua.epdc.activity.AppActUserCancelsignupDTO;
import com.elink.esua.epdc.activity.AppActUserClockLogDTO;
import com.elink.esua.epdc.activity.AppClockListDTO;
import com.elink.esua.epdc.activity.result.AppActInfoDTO;
import com.elink.esua.epdc.common.token.dto.TokenDto;
import com.elink.esua.epdc.commons.tools.utils.Result;
/**
@ -15,11 +16,11 @@ public interface ActUserRelationService {
/**
* 活动报名
* @param actUserRelationDTO
* @param userDetail,actId
* @Author wanggongfeng
* @return
*/
Result activitySignUp(ActUserRelationDTO actUserRelationDTO);
Result activitySignUp(TokenDto userDetail, String actId);
/**
* 取消活动报名

61
epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/ActUserRelationServiceImpl.java

@ -5,13 +5,25 @@ import com.elink.esua.epdc.activity.AppActUserCancelsignupDTO;
import com.elink.esua.epdc.activity.AppActUserClockLogDTO;
import com.elink.esua.epdc.activity.AppClockListDTO;
import com.elink.esua.epdc.activity.result.AppActInfoDTO;
import com.elink.esua.epdc.common.token.dto.TokenDto;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.enums.UserTagEnum;
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum;
import com.elink.esua.epdc.commons.tools.utils.IdentityNoUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.epdc.result.EpdcUserInfoResultDTO;
import com.elink.esua.epdc.feign.AppActUserRelationFeignClient;
import com.elink.esua.epdc.service.ActUserRelationService;
import com.elink.esua.epdc.service.AppUserService;
import com.elink.esua.epdc.utils.UserTagUtils;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author wanggongfeng
@ -24,8 +36,55 @@ public class ActUserRelationServiceImpl implements ActUserRelationService {
@Autowired
private AppActUserRelationFeignClient actInfoFeignClient;
@Autowired
private AppUserService appUserService;
@Override
public Result activitySignUp(ActUserRelationDTO actUserRelationDTO) {
public Result activitySignUp(TokenDto tokenDto, String actId) {
// 判断活动是否指定志愿者,正常情况下对象必定存在,直接获取
String volunteerFlag = actInfoFeignClient.getVolunteerFlag(actId).getData().getVolunteerFlag();
// 1:指定志愿者参加
if (NumConstant.ONE_STR.equals(volunteerFlag)) {
//验证是否为志愿者
Result isVolunteer = appUserService.getVolunteerCountById(tokenDto);
int code = isVolunteer.getCode();
if (code != 0) {
//不是志愿者
return isVolunteer;
}
}
Result<EpdcUserInfoResultDTO> userInfo = appUserService.getInfoById(tokenDto);
EpdcUserInfoResultDTO epdcUserInfoResultDTO = userInfo.getData();
ActUserRelationDTO actUserRelationDTO = new ActUserRelationDTO();
actUserRelationDTO.setActId(actId);
actUserRelationDTO.setUserId(tokenDto.getUserId());
actUserRelationDTO.setNickname(tokenDto.getNickname());
actUserRelationDTO.setFaceImg(tokenDto.getFaceImg());
if (UserTagUtils.containIdentity(tokenDto.getUserTagInfos(), UserTagEnum.PARTY_MEMBER)) {
actUserRelationDTO.setPartyFlag(YesOrNoEnum.YES.value());
} else {
actUserRelationDTO.setPartyFlag(YesOrNoEnum.NO.value());
}
// 获取身份证相关的字段,但参加者不一定是有身份证,有的时候在进行处理
String identityNo = epdcUserInfoResultDTO.getIdentityNo();
if (!StringUtil.isNullOrEmpty(identityNo)) {
String identityNoVerification = IdentityNoUtils.IdentityNoVerification(identityNo);
if (StringUtils.isNotBlank(identityNoVerification)) {
return new Result().error(identityNoVerification);
}
actUserRelationDTO.setSex(IdentityNoUtils.getSex(identityNo));
actUserRelationDTO.setAge(IdentityNoUtils.getAge(identityNo));
actUserRelationDTO.setIdentityNo(identityNo);
}
actUserRelationDTO.setRealName(tokenDto.getRealName());
actUserRelationDTO.setMobile(tokenDto.getMobile());
actUserRelationDTO.setStatus("0");
actUserRelationDTO.setSignupTime(new Date());
Result<Integer> dataResult = actInfoFeignClient.activitySignUp(actUserRelationDTO);
return dataResult;
}

Loading…
Cancel
Save