Browse Source

志愿者认证接口

feature/dangjian
wanggongfeng 6 years ago
parent
commit
d4b0addad7
  1. 35
      esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/IdentityNoAnalysisUtil.java
  2. 10
      esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java
  3. 8
      esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcCompleteVolunteerInfoFormDTO.java
  4. 32
      esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java

35
esua-epdc/epdc-commons/epdc-common-clienttoken/src/main/java/com/elink/esua/epdc/common/token/util/IdentityNoAnalysisUtil.java

@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
@ -23,6 +24,17 @@ public class IdentityNoAnalysisUtil {
private static final Integer EIGHTEEN_ID_CARD=18;
private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
/**
* 从身份证号码中获取生日
* @param idno
* @return null表示idno错误未获取到生日
*/
public static Date getBirthDay(String idno){
if(!isValid(idno)){
return null;
}
return toBirthDay(idno.substring(6, 14));
}
/**
* 根据身份证号获取性别
@ -140,4 +152,27 @@ public class IdentityNoAnalysisUtil {
}
return true;
}
/**
* 转换成日期
* @param birthday
* @return
*/
private static Date toBirthDay(String birthday){
try{
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, Integer.parseInt(birthday.substring(0, 4)));
calendar.set(Calendar.MONTH, Integer.parseInt(birthday.substring(4, 6)) - 1);//月份从0开始,所以减1
calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(birthday.substring(6, 8)));
//以下设置意义不大
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}catch (Exception e){
return null;
}
}
}

10
esua-epdc/epdc-module/epdc-api/epdc-api-server/src/main/java/com/elink/esua/epdc/service/impl/AppUserServiceImpl.java

@ -1060,21 +1060,23 @@ public class AppUserServiceImpl implements AppUserService {
*/
@Override
public Result volunteerAuthenticate(TokenDto tokenDto, EpdcCompleteVolunteerInfoFormDTO formDto) {
String sex = IdentityNoAnalysisUtil.getSex(formDto.getIdentityNo()); // 身份证解析性别
Date birthday = IdentityNoAnalysisUtil.getBirthDay(formDto.getIdentityNo()); // 身份证解析生日
formDto.setSex(sex); // 性别
formDto.setBirthday(birthday); // 生日
formDto.setUserId(tokenDto.getUserId()); // 用户ID
//验证是否为志愿者
Result<Integer> volunteerCountResult = userFeignClient.getVolunteerCountById(tokenDto.getUserId());
if (!volunteerCountResult.success() || null == volunteerCountResult.getData()) {
return new Result().error("志愿者认证失败");
}else if(volunteerCountResult.getData() == 0){
//添加志愿者
formDto.setUserId(tokenDto.getUserId());
Result<Integer> insertCountResult = userFeignClient.insertVolunteerInfo(formDto);
}
//调用用户完善个人信息-保存
EpdcCompleteUserInfoFormDTO epdcCompleteUserInfoFormDTO = ConvertUtils.sourceToTarget(formDto, EpdcCompleteUserInfoFormDTO.class);
String sex = IdentityNoAnalysisUtil.getSex(formDto.getIdentityNo());//身份证解析性别
epdcCompleteUserInfoFormDTO.setSex(sex);//性别
epdcCompleteUserInfoFormDTO.setPartyFlag(tokenDto.getPartyFlag());//党员标志
epdcCompleteUserInfoFormDTO.setPartyFlag(tokenDto.getPartyFlag());// 党员标志
Result<EpdcAppAuthorizationDTO> result = completeUserInfoNoVerifyCode(tokenDto, epdcCompleteUserInfoFormDTO);
return result;

8
esua-epdc/epdc-module/epdc-user/epdc-user-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/EpdcCompleteVolunteerInfoFormDTO.java

@ -4,6 +4,7 @@ import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
/**
* 移动端完善用户信息
@ -83,6 +84,13 @@ public class EpdcCompleteVolunteerInfoFormDTO implements Serializable {
*/
private String introduce;
/*----------------------志愿者新增所需字段---------------------------*/
/**
* 出生日期
*/
private Date birthday;
/*----------------------用户认证所需字段-----------------------------*/

32
esua-epdc/epdc-module/epdc-user/epdc-user-server/src/main/java/com/elink/esua/epdc/service/impl/VolunteerInfoServiceImpl.java

@ -27,6 +27,7 @@ import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.constant.VolunteerInfoConsant;
import com.elink.esua.epdc.dao.VolunteerInfoDao;
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO;
import com.elink.esua.epdc.dto.UserTagDTO;
import com.elink.esua.epdc.dto.VolunteerInfoDTO;
import com.elink.esua.epdc.dto.epdc.form.EpdcCompleteVolunteerInfoFormDTO;
@ -34,6 +35,7 @@ import com.elink.esua.epdc.dto.epdc.form.EpdcInformationFormDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcAdjustVolunteerPointsDTO;
import com.elink.esua.epdc.dto.epdc.result.EpdcGetVolunteerRankDTO;
import com.elink.esua.epdc.entity.VolunteerInfoEntity;
import com.elink.esua.epdc.feign.AdminFeignClient;
import com.elink.esua.epdc.redis.VolunteerInfoRedis;
import com.elink.esua.epdc.service.UserService;
import com.elink.esua.epdc.service.VolunteerInfoService;
@ -43,6 +45,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -67,6 +70,9 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
@Autowired
private NewsTask newsTask;
@Autowired
private AdminFeignClient adminFeignClient;
/**
* 根据查询条件返回首页 志愿者信息列表
* @param params
@ -219,10 +225,36 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
return new Result<Integer>().ok(baseDao.getVolunteerCountById(userId));
}
/**
* 新增志愿者
* @param epdcCompleteVolunteerInfoFormDTO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Integer> insertVolunteerInfo(EpdcCompleteVolunteerInfoFormDTO epdcCompleteVolunteerInfoFormDTO) {
VolunteerInfoEntity volunteerEntity = ConvertUtils.sourceToTarget(epdcCompleteVolunteerInfoFormDTO, VolunteerInfoEntity.class);
// 补全其他字段
volunteerEntity.setRegistTime(new Date());// 注册时间
volunteerEntity.setAuditStatus("1"); // 审核状态 默认审核通过
volunteerEntity.setAuditTime(new Date()); // 审核时间
volunteerEntity.setKindnessTime(0); // 爱心时长(单位:分钟)
volunteerEntity.setParticipationNum(0); // 参加活动次数
String address = volunteerEntity.getRoad()
.concat(StringUtils.isNotBlank(volunteerEntity.getVillageName()) ? volunteerEntity.getVillageName() : "")
.concat(StringUtils.isNotBlank(volunteerEntity.getDwellingPlace()) ? volunteerEntity.getDwellingPlace() : "");
volunteerEntity.setAddress(address); // 居住地址
// 获取部门信息
Result<ParentAndAllDeptDTO> dtoResult = adminFeignClient.getParentAndAllDept(volunteerEntity.getGirdId()+"");
ParentAndAllDeptDTO parentAndAllDeptDTO = dtoResult.getData();
volunteerEntity.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds()); // 父所有部门ID
volunteerEntity.setParentDeptNames(parentAndAllDeptDTO.getParentDeptNames());// 父所有部门
volunteerEntity.setAllDeptIds(parentAndAllDeptDTO.getAllDeptIds()); // 所有部门ID
volunteerEntity.setAllDeptNames(parentAndAllDeptDTO.getAllDeptNames()); // 所有部门
insert(volunteerEntity);
return new Result<Integer>().ok(1);
}

Loading…
Cancel
Save