Authored by wangshusheng

身份证

package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareUserIdentityCard;
import org.apache.ibatis.annotations.Param;
import java.util.List;
... ... @@ -9,11 +10,9 @@ public interface UnionShareUserIdentityCardMapper {
int insert(UnionShareUserIdentityCard record);
int insertSelective(UnionShareUserIdentityCard record);
UnionShareUserIdentityCard selectByPrimaryKey(Integer id);
List<UnionShareUserIdentityCard> selectByUid(UnionShareUserIdentityCard bo);
UnionShareUserIdentityCard selectByUid(@Param("uid") Integer uid);
int updateByPrimaryKeySelective(UnionShareUserIdentityCard record);
... ...
... ... @@ -22,12 +22,13 @@
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByUid" resultMap="BaseResultMap" parameterType="com.yoho.unions.dal.model.UnionShareUserIdentityCard">
<select id="selectByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from union_share_user_identity_card
where uid = #{uid,jdbcType=INTEGER}
and status=1
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.5.5-SNAPSHOT</version>
<version>1.5.9-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
... ... @@ -829,6 +829,34 @@ public class UnionShareRest {
}
/**
* 新增身份证照片
* @return
*/
@RequestMapping("/bindIdentityCard")
@ResponseBody
public UnionResponse bindIdentityCard(@RequestBody UnionShareUserIdentityCardBo bo){
log.info("UnionShareRest.bindIdentityCard req is {}", bo);
int result = unionShareService.insertUserIdentityCard(bo);
if (result > 0) {
return new UnionResponse(200, "bindIdentityCard success",bo);
}
throw new ServiceException(ServiceError.UNION_IDENTITYCARD_BIND_ERROR);
}
/**
* 查询绑定的身份证
* @param uid
* @return
*/
@RequestMapping("/getIdentityCard")
@ResponseBody
public UnionResponse getIdentityCard(@RequestBody int uid){
log.info("UnionShareRest.getIdentityCard uid is {}", uid);
UnionShareUserIdentityCardBo result = unionShareService.getUserIdentityCard(uid);
return new UnionResponse(200, "getBankCard success",result);
}
private UserInfoBO getFromredis(String pid) {
if (StringUtils.isBlank(pid)) {
return null;
... ...
... ... @@ -313,4 +313,14 @@ public interface IUnionShareService {
* @return
*/
UnionShareMessageBo getMessageById(Integer id);
/**
* 新增身份证信息
*/
int insertUserIdentityCard(UnionShareUserIdentityCardBo bo);
/**
* 查询身份证信息
*/
UnionShareUserIdentityCardBo getUserIdentityCard(Integer uid);
}
... ...
... ... @@ -93,6 +93,8 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
@Autowired
UnionShareUserBankMapper unionShareUserBankMapper;
@Autowired
UnionShareUserIdentityCardMapper unionShareUserIdentityCardMapper;
@Autowired
UnionShareUserApplyMapper unionShareUserApplyMapper;
@Autowired
UnionShareOrdersActivityLogsMapper unionShareOrdersActivityLogsMapper;
... ... @@ -169,6 +171,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
private String USER_SETTLEMENT_HASSETTLEMENT = "hasSettlement";
private String USER_SETTLEMENT_BANKCARD = "bankCard";
private String USER_SETTLEMENT_BANKCARD_UFO = "bankCardUfo";
private String USER_SETTLEMENT_IDENTITYCARD = "identityCard";
//马甲随机增预操作key
private static String VIRTUAL_ADD_KEY = "yh:union:share:virtual:add";
... ... @@ -1315,6 +1318,25 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return bo;
}
public void checkUserIdentityCard(UnionShareUserIdentityCardBo bo) {
// 校验姓名
if (!ChineseNameUtils.checkName(bo.getName())) {
throw new ServiceException(ServiceError.UNION_CHINESE_NAME_ERROR);
}
// 校验身份证
if (!checkIdCard(bo.getIdCardNo())) {
throw new ServiceException(ServiceError.UNION_IDCARD_ERROR);
}
// 校验身份证图片
if (!checkBankCard(bo.getCardFrontUrl())) {
throw new ServiceException(ServiceError.UNION_IDENTITYCARD_FRONT_IMAGE_ERROR);
}
// 校验身份证图片
if (!checkBankCard(bo.getCardBackUrl())) {
throw new ServiceException(ServiceError.UNION_IDENTITYCARD_BACK_IMAGE_ERROR);
}
}
private boolean checkIdCard(String idcard) {
return IDCardUtil.isIDCard(idcard);
}
... ... @@ -3681,4 +3703,51 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
logger.info("setVirtualAddToRedis.add to redis,addBo is {}",addBo);
redisValueCache.set(VIRTUAL_ADD_KEY,addBo,50,TimeUnit.HOURS);
}
/**
* 新增身份证信息
*/
@Override
public int insertUserIdentityCard(UnionShareUserIdentityCardBo bo){
logger.info("insertUserIdentityCard, bo is {}",bo);
if (null == bo||bo.getUid()<0) {
return 0;
}
//信息格式校验
checkUserIdentityCard(bo);
UnionShareUserIdentityCard identityCard = new UnionShareUserIdentityCard();
BeanUtils.copyProperties(bo, identityCard);
identityCard.setStatus((byte)1);
identityCard.setCreateTime(DateUtil.getCurrentTimeSecond());
identityCard.setUpdateTime(identityCard.getCreateTime());
int result = unionShareUserIdentityCardMapper.insert(identityCard);
redisHashCache.delete(ShareOrdersKeyEnum.USER_SETTLEMENT.getPreKey(), bo.getUid());
return result;
}
@Override
public UnionShareUserIdentityCardBo getUserIdentityCard(Integer uid){
logger.info("getUserIdentityCard, uid is {}", uid);
if (uid==null || uid < 1) {
return null;
}
String hashkey = USER_SETTLEMENT_IDENTITYCARD;
UnionShareUserIdentityCardBo cacheResult = getFromRedis(ShareOrdersKeyEnum.USER_SETTLEMENT, uid, UnionShareUserIdentityCardBo.class, hashkey);
if (cacheResult != null) {
logger.info("getUserIdentityCard end, get redis cache ,uid is {},cacheResult is {}",uid,cacheResult);
return cacheResult;
}
UnionShareUserBank req = new UnionShareUserBank();
req.setUid(uid);
req.setStatus((byte)1);
UnionShareUserIdentityCard identityCard = unionShareUserIdentityCardMapper.selectByUid(uid);
if (identityCard==null) {
return null;
}
UnionShareUserIdentityCardBo result = new UnionShareUserIdentityCardBo();
BeanUtils.copyProperties(identityCard, result);
addToRedis(ShareOrdersKeyEnum.USER_SETTLEMENT, uid, result, hashkey);
logger.info("getBankCard end,set redis cache ,uid is {},hashkey is {},IdentityCard is {}",uid,hashkey,result);
return result;
}
}
... ...