Commit 3efe4eda by xieshixiang

校验电话号码唯一

parent 3d5e5f78
......@@ -74,13 +74,19 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override
public Response bind(ParkBindInfo info) {
//判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆
QueryWrapper boundQuery = new QueryWrapper();
QueryWrapper<ParkBindInfo> boundQuery = new QueryWrapper();
boundQuery.eq("user_id", info.getUserId());
boundQuery.eq("status", "1");
Integer bound = mapper.selectCount(boundQuery);
if (bound >= 3) {
List<ParkBindInfo> list = mapper.selectList(boundQuery);
if (list != null && list.size() >= 3) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR);
}
if (list != null && list.size() > 0) {
boolean equals = list.get(0).getPhone().equals(info.getPhone());
if (!equals) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR, "当前客户手机号与历史绑定手机号不一致");
}
}
//规则2:客户手机号与车辆对应的车主手机号一致
PlateNumQueryReq req = new PlateNumQueryReq();
......@@ -113,7 +119,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
info.setUnqId(unqIdUtil.getUnqId());
info.setGmtBindTime(new Date());
mapper.insert(info);
bindCache.insert(info);
return ResponseGenerator.success(new BindInfoRes(info.getUnqId()));
}
......
......@@ -23,6 +23,14 @@ public class BindCache {
private BindInfoMapper mapper;
@Caching(evict = {
@CacheEvict(value = "bindinfo", key = "'userId:'+#info.userId", condition = "#info!=null")
})
public boolean insert(ParkBindInfo info) {
return mapper.insert(info) > 0;
}
/**
* 获取绑定信息
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment