diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/VolunteerInfoDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/VolunteerInfoDTO.java index b309d9a7d5..35d451f2a0 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/VolunteerInfoDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/VolunteerInfoDTO.java @@ -17,9 +17,10 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -97,4 +98,12 @@ public class VolunteerInfoDTO implements Serializable { * 志愿者注册,所在网格名称 */ private String gridName; + /** + * 网格所属的组织id + */ + private String pid; + /** + * 网格的所有上级 + */ + private String pids; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java index 0a42ede194..877abcb74c 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java @@ -17,80 +17,67 @@ import java.io.Serializable; public class ResiVolunteerAuthenticateFormDTO implements Serializable { private static final long serialVersionUID = 1L; - - //>>>>>>>>>>>>>>>>>校验分组开始>>>>>>>>>>>>>>>>>>>>> - /** - * 添加用户操作的内部异常分组 - * 出现错误会提示给前端7000错误码,返回信息为:服务器开小差... - */ public interface AddUserInternalGroup {} - - /** - * 添加用户操作的用户可见异常分组 - * 该分组用于校验需要返回给前端错误信息提示的列,需要继承CustomerClientShowGroup - * 返回错误码为8999,提示信息为DTO中具体的列的校验注解message的内容 - */ public interface AddUserShowGroup extends CustomerClientShowGroup {} - // <<<<<<<<<<<<<<<<<<<校验分组结束<<<<<<<<<<<<<<<<<<<<<<<< - /** * 用户id */ + @NotBlank(message = "tokenDto中获取userId为空", groups = {AddUserInternalGroup.class }) private String userId; /** * 客户id */ - @NotBlank(message = "客户id不能为空", groups = {AddUserShowGroup.class }) + @NotBlank(message = "tokenDto中获取customerId为空", groups = {AddUserInternalGroup.class }) private String customerId; /** * 姓 */ - @NotBlank(message = "姓不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "姓不能为空", groups = {AddUserShowGroup.class }) private String surname; /** * 名 */ - @NotBlank(message = "名不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "名不能为空", groups = {AddUserShowGroup.class }) private String name; /** * 性别(1男2女0未知) */ - @NotBlank(message = "性别不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "性别不能为空", groups = {AddUserShowGroup.class }) private String gender; /** * 手机号 */ - @NotBlank(message = "手机号不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "手机号不能为空", groups = {AddUserShowGroup.class }) private String mobile; /** * 身份证号码 */ - @NotBlank(message = "身份证号码不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "身份证号码不能为空", groups = {AddUserShowGroup.class }) private String idNum; /** * 街道 */ - @NotBlank(message = "街道不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "居住地址:街道不能为空", groups = {AddUserShowGroup.class }) private String street; /** * 小区名 */ - @NotBlank(message = "小区名不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "居住地址:小区名不能为空", groups = {AddUserShowGroup.class }) private String district; /** * 楼栋单元 */ - @NotBlank(message = "楼栋单元不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "居住地址:楼栋单元不能为空", groups = {AddUserShowGroup.class }) private String buildingAddress; /** @@ -101,13 +88,13 @@ public class ResiVolunteerAuthenticateFormDTO implements Serializable { /** * 昵称 */ - @NotBlank(message = "昵称不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "昵称不能为空", groups = {AddUserInternalGroup.class}) private String nickname; /** * 头像 */ - @NotBlank(message = "头像不能为空", groups = {AddUserInternalGroup.class, AddUserShowGroup.class }) + @NotBlank(message = "头像不能为空", groups = {AddUserInternalGroup.class}) private String avatarUrl; /** diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java index 749f8dfc3f..1f4d242f33 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java @@ -60,8 +60,11 @@ public class ResiVolunteerController { **/ @PostMapping("authenticate") public Result authenticate(@LoginUser TokenDto tokenDto, @RequestBody ResiVolunteerAuthenticateFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO, ResiVolunteerAuthenticateFormDTO.AddUserInternalGroup.class, ResiVolunteerAuthenticateFormDTO.AddUserShowGroup.class); - return volunteerInfoService.authenticate(tokenDto, formDTO); + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setCustomerId(tokenDto.getCustomerId()); + ValidatorUtils.validateEntity(formDTO, ResiVolunteerAuthenticateFormDTO.AddUserShowGroup.class, ResiVolunteerAuthenticateFormDTO.AddUserInternalGroup.class); + volunteerInfoService.authenticate(formDTO); + return new Result(); } /** diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java index 0e1e309594..2db40a7f5b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java @@ -42,13 +42,12 @@ public interface VolunteerInfoService extends BaseService { /** * 志愿者认证 * - * @param tokenDto * @param formDTO * @return com.epmet.commons.tools.utils.Result * @Author zhangyong * @Date 10:09 2020-07-23 **/ - Result authenticate(TokenDto tokenDto, ResiVolunteerAuthenticateFormDTO formDTO); + void authenticate(ResiVolunteerAuthenticateFormDTO formDTO); /** * 志愿者认证界面,获取用户基础信息+志愿者信息 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index ef5af0c4f4..3c76366865 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -39,10 +39,13 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.SendMqMsgUtils; import com.epmet.constant.SmsTemplateConstant; import com.epmet.dao.VolunteerInfoDao; +import com.epmet.dto.CustomerGridDTO; import com.epmet.dto.HeartUserInfoDTO; import com.epmet.dto.VolunteerInfoDTO; import com.epmet.dto.form.CommonCustomerFormDTO; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; +import com.epmet.dto.form.VolunteerRegResiFormDTO; import com.epmet.dto.form.resi.ResiSendSmsCodeFormDTO; import com.epmet.dto.form.resi.ResiVolunteerAuthenticateFormDTO; import com.epmet.dto.result.ResiUserBaseInfoResultDTO; @@ -54,6 +57,7 @@ import com.epmet.dto.result.resi.ResiVolunteerInfoResultDTO; import com.epmet.entity.VolunteerInfoEntity; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.HeartUserInfoService; import com.epmet.service.VolunteerInfoService; import com.github.pagehelper.PageHelper; @@ -94,8 +98,11 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl gridInfoRes = govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO); + if (!gridInfoRes.success() || null == gridInfoRes.getData()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "查询网格信息失败"); + } + insertVolunteer.setGridName(gridInfoRes.getData().getGridName()); + insertVolunteer.setPid(gridInfoRes.getData().getPid()); + insertVolunteer.setPids(gridInfoRes.getData().getPids()); + baseDao.insert(insertVolunteer); + + // 2.2 更新用户信息表的 是否是志愿者标识 + HeartUserInfoDTO userInfoDTO = new HeartUserInfoDTO(); + userInfoDTO.setUserId(formDTO.getUserId()); + userInfoDTO.setVolunteerFlag(true); + heartUserInfoService.updateHeartUserInfoByUserId(userInfoDTO); + + // 2.3发送消息 由积分系统消费消息(需要使用规则) + this.grantActPoints(formDTO); + } + //3、志愿者认证,更新用户基础信息user_base_info+自动注册居民 + VolunteerRegResiFormDTO param = ConvertUtils.sourceToTarget(formDTO, VolunteerRegResiFormDTO.class); + Result regResi=epmetUserOpenFeignClient.volunteerAutoRegResi(param); + if(!regResi.success()){ + logger.warn(String.format("userId:%s,认证志愿者时,自动注册居民失败,返参:%s",formDTO.getUserId(), JSON.toJSONString(regResi))); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), regResi.getMsg()); + } } private void grantActPoints(ResiVolunteerAuthenticateFormDTO formDTO){ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml index 4dc80881f2..a518eeed47 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml @@ -55,12 +55,7 @@