From 0bc4ced051c10b1eeb2641aa60b0fab290c815da Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Sun, 28 Jun 2020 17:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=AA=8C=E8=AF=81=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E5=BF=97=E6=84=BF=E8=80=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiActUserRelationController.java | 40 +----------- .../feign/AppActUserRelationFeignClient.java | 25 +++++--- ...AppActUserRelationFeignClientFallback.java | 5 ++ .../epdc/service/ActUserRelationService.java | 5 +- .../impl/ActUserRelationServiceImpl.java | 61 ++++++++++++++++++- 5 files changed, 87 insertions(+), 49 deletions(-) diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/ApiActUserRelationController.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/ApiActUserRelationController.java index 0ccfad8..a5dbbc4 100644 --- a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/controller/ApiActUserRelationController.java +++ b/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 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); } diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/AppActUserRelationFeignClient.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/AppActUserRelationFeignClient.java index 00f257f..45ccc75 100644 --- a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/AppActUserRelationFeignClient.java +++ b/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; /** - * * 活动报名管理 * * @Author:wanggongfeng @@ -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 clockAddressDetail(@PathVariable("actId") String actId); + + /** + * 获取活动志愿者标识 + * + * @param actId + * @return + */ + @GetMapping("heart/appactinfo/getVolunteerFlag/{actId}") + Result getVolunteerFlag(@PathVariable("actId") String actId); + } diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/fallback/AppActUserRelationFeignClientFallback.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/fallback/AppActUserRelationFeignClientFallback.java index 3954ce3..b355a1d 100644 --- a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/feign/fallback/AppActUserRelationFeignClientFallback.java +++ b/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 getVolunteerFlag(String actId) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_HEART_SERVER, "getVolunteerFlag", actId); + } } diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/ActUserRelationService.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/ActUserRelationService.java index d85f6ba..850c1ae 100644 --- a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/ActUserRelationService.java +++ b/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); /** * 取消活动报名 diff --git a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/ActUserRelationServiceImpl.java b/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/ActUserRelationServiceImpl.java index 26d89d2..a617565 100644 --- a/epdc-cloud-api/src/main/java/com/elink/esua/epdc/service/impl/ActUserRelationServiceImpl.java +++ b/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 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 dataResult = actInfoFeignClient.activitySignUp(actUserRelationDTO); return dataResult; }