| | |
| | | package com.dsh.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.other.entity.Store; |
| | | import com.dsh.other.feignclient.model.*; |
| | |
| | | |
| | | @PostMapping("/base/protocol/storeDetail/nearbyStore") |
| | | public List<StoreInfo> getAllNearbyStoreList(@RequestBody GetAllNearbyStoreList list ){ |
| | | String current = list.getLongitude()+","+list.getLatitude(); |
| | | List<StoreInfo> storeInfos = new ArrayList<>(); |
| | | if (ToolUtil.isEmpty(list.getLongitude()) && ToolUtil.isEmpty(list.getLatitude())){ |
| | | return storeInfos; |
| | | } |
| | | String current = list.getLongitude()+","+list.getLatitude(); |
| | | String cityCode = ""; |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(list.getLongitude(), list.getLatitude()); |
| | |
| | | String storeLat = store.getLat(); |
| | | String result = storeLon+","+storeLat; |
| | | String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | long l = 0; |
| | | try { |
| | | l = Long.parseLong(distanceTOKilometer); |
| | | }catch (Exception e){ |
| | | l = 0; |
| | | } |
| | | StoreInfo info = new StoreInfo(); |
| | | info.setStoreId(store.getId()); |
| | | info.setStoreName(store.getName()); |
| | | info.setStoreImg(store.getRealPicture()); |
| | | info.setDistance(Long.parseLong(distanceTOKilometer)); |
| | | info.setDistance(l); |
| | | info.setStoreAddr(store.getAddress()); |
| | | info.setLatitude(storeLat); |
| | | info.setLongitude(storeLon); |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/protocol/storeDetail/distanceCal") |
| | | public long calculateDistance(@RequestBody GetDistanceVo distanceVo){ |
| | | public String calculateDistance(@RequestBody GetDistanceVo distanceVo){ |
| | | String current = distanceVo.getLongitude()+","+distanceVo.getLatitude(); |
| | | Store store = storeService.getById(distanceVo.getStoreId()); |
| | | String result = store.getLon()+","+store.getLat(); |
| | | String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | return Long.parseLong(distanceTOKilometer); |
| | | return gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | } |
| | | |
| | | |
| | |
| | | .eq("state",1 ) |
| | | .eq("cityCode",citycodeResp.getCityCode())); |
| | | if (list.size() > 0 ){ |
| | | if (ToolUtil.isEmpty(citycodeResp.getLongitude()) && ToolUtil.isEmpty(citycodeResp.getLatitude())){ |
| | | return detailLists; |
| | | } |
| | | for (Store store : list) { |
| | | String current = citycodeResp.getLongitude() +","+citycodeResp.getLatitude(); |
| | | String result = store.getLon()+","+store.getLat(); |
| | | String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | long l = Long.parseLong(distanceTOKilometer); |
| | | if (ToolUtil.isNotEmpty(citycodeResp.getSpace()) && l > citycodeResp.getSpace()){ |
| | | // 取5公里范围内的门店 |
| | | if ( l > 5){ |
| | | continue; |
| | | } |
| | | StoreDetailList detailList = new StoreDetailList(); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取门店列表 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/store/queryStoreByIds") |
| | | public List<Store> queryStoreByIds(List<Integer> ids){ |
| | | try { |
| | | return storeService.list(new LambdaQueryWrapper<Store>() |
| | | .in(Store::getId,ids)); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |