| | |
| | | Store s = null; |
| | | Double d = 0D; |
| | | for (Store store : stores) { |
| | | if (store == null || !isValidCoordinate(store.getLon(), store.getLat())) { |
| | | continue; |
| | | } |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | Double wgs84 = distance.get("WGS84"); |
| | | if (s == null || d > wgs84) { |
| | |
| | | d = wgs84; |
| | | } |
| | | } |
| | | joinPlayPaiVo.setName(s.getName()); |
| | | joinPlayPaiVo.setLon(s.getLon()); |
| | | joinPlayPaiVo.setLat(s.getLat()); |
| | | joinPlayPaiVo.setStoreId(s.getId()); |
| | | joinPlayPaiVo.setPhone(s.getPhone()); |
| | | joinPlayPaiVo.setProvince(s.getProvince()); |
| | | joinPlayPaiVo.setProvinceCode(s.getProvinceCode()); |
| | | joinPlayPaiVo.setCity(s.getCity()); |
| | | joinPlayPaiVo.setCityCode(s.getCityCode()); |
| | | if (s != null) { |
| | | joinPlayPaiVo.setName(s.getName()); |
| | | joinPlayPaiVo.setLon(s.getLon()); |
| | | joinPlayPaiVo.setLat(s.getLat()); |
| | | joinPlayPaiVo.setStoreId(s.getId()); |
| | | joinPlayPaiVo.setPhone(s.getPhone()); |
| | | joinPlayPaiVo.setProvince(s.getProvince()); |
| | | joinPlayPaiVo.setProvinceCode(s.getProvinceCode()); |
| | | joinPlayPaiVo.setCity(s.getCity()); |
| | | joinPlayPaiVo.setCityCode(s.getCityCode()); |
| | | } |
| | | } |
| | | return joinPlayPaiVo; |
| | | } |
| | | |
| | | private boolean isValidCoordinate(String lon, String lat) { |
| | | if (ToolUtil.isEmpty(lon) || ToolUtil.isEmpty(lat)) { |
| | | return false; |
| | | } |
| | | try { |
| | | double longitude = Double.parseDouble(lon.trim()); |
| | | double latitude = Double.parseDouble(lat.trim()); |
| | | return Double.isFinite(longitude) && Double.isFinite(latitude) |
| | | && longitude >= -180 && longitude <= 180 |
| | | && latitude >= -90 && latitude <= 90; |
| | | } catch (NumberFormatException e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public IndexOfUserBenefirVo queryBenefitDetails(Integer appUserId, String lon, String lat) { |
| | | IndexOfUserBenefirVo benefirVo = new IndexOfUserBenefirVo(); |