|
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
21
|
21
|
import org.springframework.web.bind.annotation.*;
|
22
|
22
|
|
23
|
23
|
import com.huiju.estateagents.base.BaseController;
|
|
24
|
+import org.springframework.web.client.RestTemplate;
|
24
|
25
|
|
25
|
26
|
import javax.servlet.http.HttpServletRequest;
|
26
|
27
|
import java.time.LocalDateTime;
|
|
@@ -562,5 +563,35 @@ public class TaPersonController extends BaseController {
|
562
|
563
|
|
563
|
564
|
return ResponseBean.success(taPerson);
|
564
|
565
|
}
|
565
|
|
-
|
|
566
|
+
|
|
567
|
+ /**
|
|
568
|
+ * 微信添加人员添加城市
|
|
569
|
+ * @param location
|
|
570
|
+ * @param request
|
|
571
|
+ * @return
|
|
572
|
+ */
|
|
573
|
+ @PutMapping("/wx/person/city")
|
|
574
|
+ public ResponseBean updatePersonCity(@RequestBody String location, HttpServletRequest request) {
|
|
575
|
+ ResponseBean responseBean = new ResponseBean();
|
|
576
|
+ String openid = JWTUtils.getSubject(request);
|
|
577
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
578
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
579
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
580
|
+ }
|
|
581
|
+ TaPerson person = taPersons.get(0);
|
|
582
|
+ JSONObject jsonObject = JSONObject.parseObject(location);
|
|
583
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
584
|
+ String result = restTemplate.getForObject("https://restapi.amap.com/v3/geocode/regeo?key="+ CommConstant.GD_KEY + "&location=" + jsonObject.getString("location") + "&output=json", String.class);
|
|
585
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
586
|
+ if (!resultJson.getString("status").equals(CommConstant.STATUS_NORMAL)){
|
|
587
|
+ String adcode = resultJson.getJSONObject("regeocode").getJSONObject("addressComponent").getString("adcode");
|
|
588
|
+ adcode = adcode.substring(0,adcode.length()-2) + "00";
|
|
589
|
+ person.setCity(adcode);
|
|
590
|
+ taPersonService.updateById(person);
|
|
591
|
+ responseBean.addSuccess("保存城市成功");
|
|
592
|
+ return responseBean;
|
|
593
|
+ }
|
|
594
|
+ responseBean.addError("未找到城市");
|
|
595
|
+ return responseBean;
|
|
596
|
+ }
|
566
|
597
|
}
|