| | |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, shopList); |
| | | } |
| | | |
| | | Double distance = null; |
| | | BigDecimal distance = null; |
| | | SysShopInfo nearestShop = null; |
| | | |
| | | AjaxResult ajaxResult = new AjaxResult("200", shopList); |
| | |
| | | for (SysShopInfo shopInfo : shopList) { |
| | | Double shopX = Double.parseDouble(shopInfo.getLongitude()); |
| | | Double shopY = Double.parseDouble(shopInfo.getLatitude()); |
| | | Double disResult = LocationUtil.getDistance(Double.parseDouble(locX), Double.parseDouble(locY), shopX, shopY); |
| | | shopInfo.setDistance(new BigDecimal(disResult).setScale(1, BigDecimal.ROUND_HALF_UP)); |
| | | if (distance == null || distance > disResult) { |
| | | BigDecimal disResult = LocationUtil.getDistance(Double.parseDouble(locX), Double.parseDouble(locY), shopX, shopY); |
| | | shopInfo.setDistance(disResult); |
| | | if (distance == null || distance.compareTo(disResult)>0) { |
| | | distance = disResult; |
| | | nearestShop = shopInfo; |
| | | } |