|
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
20
|
20
|
import org.springframework.web.bind.annotation.*;
|
21
|
21
|
|
22
|
22
|
import com.huiju.estateagents.base.BaseController;
|
|
23
|
+import org.springframework.web.client.RestTemplate;
|
23
|
24
|
|
24
|
25
|
import javax.servlet.http.HttpServletRequest;
|
25
|
26
|
import java.time.LocalDateTime;
|
|
@@ -517,7 +518,35 @@ public class TaPersonController extends BaseController {
|
517
|
518
|
}
|
518
|
519
|
return responseBean;
|
519
|
520
|
}
|
520
|
|
-
|
521
|
|
-
|
522
|
|
-
|
|
521
|
+
|
|
522
|
+ /**
|
|
523
|
+ * 微信添加人员添加城市
|
|
524
|
+ * @param location
|
|
525
|
+ * @param request
|
|
526
|
+ * @return
|
|
527
|
+ */
|
|
528
|
+ @PutMapping("/wx/person/city")
|
|
529
|
+ public ResponseBean updatePersonCity(@RequestBody String location, HttpServletRequest request) {
|
|
530
|
+ ResponseBean responseBean = new ResponseBean();
|
|
531
|
+ String openid = JWTUtils.getSubject(request);
|
|
532
|
+ List<TaPerson> taPersons = taPersonService.getPersonsByOpenId(openid);
|
|
533
|
+ if (null == taPersons || taPersons.size() != 1) {
|
|
534
|
+ return ResponseBean.error("验证人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
535
|
+ }
|
|
536
|
+ TaPerson person = taPersons.get(0);
|
|
537
|
+ JSONObject jsonObject = JSONObject.parseObject(location);
|
|
538
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
539
|
+ String result = restTemplate.getForObject("https://restapi.amap.com/v3/geocode/regeo?key="+ CommConstant.GD_KEY + "&location=" + jsonObject.getString("location") + "&output=json", String.class);
|
|
540
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
541
|
+ if (!resultJson.getString("status").equals(CommConstant.STATUS_NORMAL)){
|
|
542
|
+ String adcode = resultJson.getJSONObject("regeocode").getJSONObject("addressComponent").getString("adcode");
|
|
543
|
+ adcode = adcode.substring(0,adcode.length()-2) + "00";
|
|
544
|
+ person.setCity(adcode);
|
|
545
|
+ taPersonService.updateById(person);
|
|
546
|
+ responseBean.addSuccess("保存城市成功");
|
|
547
|
+ return responseBean;
|
|
548
|
+ }
|
|
549
|
+ responseBean.addError("未找到城市");
|
|
550
|
+ return responseBean;
|
|
551
|
+ }
|
523
|
552
|
}
|