Commit ede31bd8 by xieshixiang

校验电话号码唯一

parent c2d69122
...@@ -74,14 +74,22 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -74,14 +74,22 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
@Override @Override
public Response bind(ParkBindInfo info) { public Response bind(ParkBindInfo info) {
//判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆 //判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆
QueryWrapper boundQuery = new QueryWrapper(); QueryWrapper<ParkBindInfo> boundQuery = new QueryWrapper();
boundQuery.eq("user_id", info.getUserId()); boundQuery.eq("user_id", info.getUserId());
boundQuery.eq("status", "1"); boundQuery.eq("status", "1");
Integer bound = mapper.selectCount(boundQuery); List<ParkBindInfo> list = mapper.selectList(boundQuery);
if (bound >= 3) { if (list != null && list.size() >= 3) {
return ResponseGenerator.fail(StatusCode.BUSINESS_ERROR); 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:客户手机号与车辆对应的车主手机号一致 //规则2:客户手机号与车辆对应的车主手机号一致
PlateNumQueryReq req = new PlateNumQueryReq(); PlateNumQueryReq req = new PlateNumQueryReq();
req.setPlateNum(info.getPlateNum()); req.setPlateNum(info.getPlateNum());
...@@ -113,7 +121,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i ...@@ -113,7 +121,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, ParkBindInfo> i
info.setUnqId(unqIdUtil.getUnqId()); info.setUnqId(unqIdUtil.getUnqId());
info.setGmtBindTime(new Date()); info.setGmtBindTime(new Date());
mapper.insert(info); bindCache.insert(info);
return ResponseGenerator.success(new BindInfoRes(info.getUnqId())); return ResponseGenerator.success(new BindInfoRes(info.getUnqId()));
} }
......
...@@ -23,6 +23,14 @@ public class BindCache { ...@@ -23,6 +23,14 @@ public class BindCache {
private BindInfoMapper mapper; 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;
}
/** /**
* 获取绑定信息 * 获取绑定信息
* *
...@@ -67,4 +75,6 @@ public class BindCache { ...@@ -67,4 +75,6 @@ public class BindCache {
bindInfo.setUnbindTime(new Date()); bindInfo.setUnbindTime(new Date());
return mapper.unbind(bindInfo) > 0; return mapper.unbind(bindInfo) > 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