|
|
@@ -5,6 +5,7 @@ import com.finikes.oc.Passports;
|
|
|
import com.finikes.oc.base.dao.PassportDAO;
|
|
|
import com.finikes.oc.base.entity.Passport;
|
|
|
import com.finikes.oc.estate.dao.HouseDAO;
|
|
|
+import com.finikes.oc.estate.entity.House;
|
|
|
import com.finikes.oc.management.dao.HouseRelationDAO;
|
|
|
import com.finikes.oc.management.entity.HouseRelation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -29,45 +30,42 @@ public class HouseController {
|
|
|
@Autowired
|
|
|
private PassportDAO passportDAO;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HouseDAO houseDAO;
|
|
|
+
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = "/passport", method = RequestMethod.PUT)
|
|
|
public BaseDTO bind(@RequestBody Map<String, Object> map, HttpServletRequest request) {
|
|
|
String certificateNo = (String) map.get("certificateNo");
|
|
|
String certificatePhoto = (String) map.get("certificatePhoto");
|
|
|
- String houseId = (String) map.get("houseId");
|
|
|
+ int houseId = Integer.parseInt((String) map.get("houseId"));
|
|
|
String name = (String) map.get("name");
|
|
|
+ String idNumber = (String) map.get("idNumber");
|
|
|
+
|
|
|
Passport passport = Passports.getPassport(request);
|
|
|
if (passport == null) {
|
|
|
return new BaseDTO("104", "需要登录");
|
|
|
}
|
|
|
|
|
|
- HouseRelation relation = houseRelationDAO.findByPassport(passport.getId());
|
|
|
- if (relation != null) {
|
|
|
- /*if (relation.getState() == 1) {
|
|
|
+ HouseRelation relation = houseRelationDAO.findByPassportAndHouse(passport.getId(), houseId);
|
|
|
+ if (relation != null) { // 如果不为空, 说明已经有关系数据
|
|
|
+ if (relation.getState() == 1) {
|
|
|
return new BaseDTO("105", "已绑定过");
|
|
|
} else {
|
|
|
- relation.setState(2);
|
|
|
- relation.setCertificateNo(certificateNo);
|
|
|
- relation.setCertificateUrl(certificatePhoto);
|
|
|
- houseRelationDAO.update(relation);
|
|
|
- if(name != null && !"".equals(name)) {
|
|
|
- passportDAO.updateName(passport.getId(), name);
|
|
|
- }
|
|
|
- return new BaseDTO();
|
|
|
- }*/
|
|
|
- return new BaseDTO("107", "房产已有绑定");
|
|
|
+ return new BaseDTO("106", "已存在未审核的绑定关系");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
relation = new HouseRelation();
|
|
|
- relation.setHouseId(Integer.parseInt(houseId));
|
|
|
+ relation.setHouseId(houseId);
|
|
|
relation.setPassportId(passport.getId());
|
|
|
relation.setState(2);
|
|
|
relation.setCertificateNo(certificateNo);
|
|
|
relation.setCertificateUrl(certificatePhoto);
|
|
|
+ relation.setName(name);
|
|
|
+ relation.setIdNumber(idNumber);
|
|
|
houseRelationDAO.insert(relation);
|
|
|
- if(name != null && !"".equals(name)) {
|
|
|
- passportDAO.updateName(passport.getId(), name);
|
|
|
- }
|
|
|
+
|
|
|
return new BaseDTO();
|
|
|
}
|
|
|
|
|
|
@@ -101,7 +99,7 @@ public class HouseController {
|
|
|
@RequestMapping(value = "/passport/security", method = RequestMethod.POST)
|
|
|
public BaseDTO checkBind(@RequestBody Map<String, Object> map) {
|
|
|
String passportId = (String) map.get("passportId");
|
|
|
- String houseId = (String) map.get("houseId");
|
|
|
+ int houseId = Integer.parseInt((String) map.get("houseId"));
|
|
|
|
|
|
HouseRelation relation = houseRelationDAO.findByPassportAndHouse(Integer.parseInt(passportId), houseId);
|
|
|
if (relation != null) {
|
|
|
@@ -115,4 +113,40 @@ public class HouseController {
|
|
|
|
|
|
return new BaseDTO("000", "系统错误");
|
|
|
}
|
|
|
+
|
|
|
+ @ResponseBody
|
|
|
+ @RequestMapping(value = "/passport", method = RequestMethod.POST)
|
|
|
+ public BaseDTO autoBind(@RequestBody Map<String, Object> map, HttpServletRequest request) {
|
|
|
+ int houseId = Integer.parseInt((String) map.get("houseId"));
|
|
|
+ String name = (String) map.get("name");
|
|
|
+ String idNumber = (String) map.get("idNumber");
|
|
|
+ Passport passport = Passports.getPassport(request);
|
|
|
+ if (passport == null) {
|
|
|
+ return new BaseDTO("104", "需要登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ HouseRelation relation = houseRelationDAO.findByPassportAndHouse(passport.getId(), houseId);
|
|
|
+ if (relation != null) {
|
|
|
+ if (relation.getState() == 1) {
|
|
|
+ return new BaseDTO("105", "已绑定过");
|
|
|
+ } else {
|
|
|
+ return new BaseDTO("106", "已存在未审核的绑定关系");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ House house = houseDAO.findById(houseId);
|
|
|
+ if (!passport.getMobile().equals(house.getReservedMobile())) {
|
|
|
+ return new BaseDTO("107", "与房产预留电话号码不匹配");
|
|
|
+ }
|
|
|
+
|
|
|
+ relation = new HouseRelation();
|
|
|
+ relation.setHouseId(houseId);
|
|
|
+ relation.setPassportId(passport.getId());
|
|
|
+ relation.setState(1);
|
|
|
+ relation.setName(name);
|
|
|
+ relation.setIdNumber(idNumber);
|
|
|
+ houseRelationDAO.insert(relation);
|
|
|
+
|
|
|
+ return new BaseDTO();
|
|
|
+ }
|
|
|
}
|