| | |
| | | import com.dsh.communityWorldCup.mapper.WorldCupMapper; |
| | | import com.dsh.communityWorldCup.model.*; |
| | | import com.dsh.communityWorldCup.service.*; |
| | | import com.dsh.communityWorldCup.util.GeodesyUtil; |
| | | import com.dsh.communityWorldCup.util.PayMoneyUtil; |
| | | import com.dsh.communityWorldCup.util.ResultUtil; |
| | | import com.dsh.communityWorldCup.util.UUIDUtil; |
| | | import com.dsh.communityWorldCup.util.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | */ |
| | | @Override |
| | | public List<WorldCupListVo> getWorldCupList(WorldCupList worldCupList) { |
| | | if(null == worldCupList.getSort()){ |
| | | worldCupList.setSort(1); |
| | | } |
| | | //没有筛选门店,默认使用当前门店 |
| | | if(null == worldCupList.getStoreId()){ |
| | | worldCupList.setStoreId(worldCupList.getStoreId()); |
| | |
| | | heat += count; |
| | | } |
| | | worldCupListVo.setHeat(heat); |
| | | String lat = worldCupListVo.getLat(); |
| | | String lon = worldCupListVo.getLon(); |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, worldCupList.getLon() + "," + worldCupList.getLat()); |
| | | worldCupListVo.setDistance(distance.get("WGS84")); |
| | | } |
| | | |
| | | Collections.sort(worldCupList1, new Comparator<WorldCupListVo>() { |
| | | @Override |
| | | public int compare(WorldCupListVo o1, WorldCupListVo o2) { |
| | | if(worldCupList.getSort() == 1){ |
| | | return o1.getHeat().compareTo(o2.getHeat()); |
| | | |
| | | if(null != worldCupList.getSort()){ |
| | | Collections.sort(worldCupList1, new Comparator<WorldCupListVo>() { |
| | | @Override |
| | | public int compare(WorldCupListVo o1, WorldCupListVo o2) { |
| | | if(worldCupList.getSort() == 1){ |
| | | return o1.getHeat().compareTo(o2.getHeat()); |
| | | } |
| | | if(worldCupList.getSort() == 2){ |
| | | return o1.getHeat().compareTo(o2.getHeat()) * -1; |
| | | } |
| | | return 0; |
| | | } |
| | | if(worldCupList.getSort() == 2){ |
| | | return o1.getHeat().compareTo(o2.getHeat()) * -1; |
| | | }); |
| | | }else{ |
| | | Collections.sort(worldCupList1, new Comparator<WorldCupListVo>() { |
| | | @Override |
| | | public int compare(WorldCupListVo o1, WorldCupListVo o2) { |
| | | return o1.getDistance().compareTo(o2.getDistance()) * -1; |
| | | } |
| | | return 0; |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | return worldCupList1; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public WorldCupInfo getWorldCupInfo(Integer id) { |
| | | public WorldCupInfo getWorldCupInfo(Integer id, String lon, String lat) { |
| | | WorldCupInfo worldCupInfo = this.baseMapper.getWorldCupInfo(id); |
| | | List<WorldCupStore> worldCupStores = worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("worldCupId", id)); |
| | | JSONArray jsonArray = new JSONArray(); |
| | |
| | | heat += count; |
| | | } |
| | | worldCupInfo.setHeat(heat); |
| | | ArrayList<Map<String, Object>> objects = new ArrayList<>(); |
| | | for (WorldCupStore worldCupStore : worldCupStores) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | Store store = storeClient.queryStoreById(worldCupStore.getStoreId()); |
| | | map.put("name", store.getName()); |
| | | |
| | | |
| | | String str = store.getAddress(); |
| | | str = str.substring(str.indexOf("省") + 1); |
| | | |
| | | // 去掉第一个“市”及之前的字符串 |
| | | str = str.substring(str.indexOf("市") + 1); |
| | | |
| | | // 去掉第一个“区”及之前的字符串 |
| | | str = str.substring(str.indexOf("区") + 1); |
| | | |
| | | map.put("address", str); |
| | | map.put("storeLon", store.getLon()); |
| | | map.put("storeLat", store.getLat()); |
| | | map.put("storeCoverDrawing", store.getCoverDrawing()); |
| | | if (ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)) { |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | map.put("distance", wgs84); |
| | | } |
| | | objects.add(map); |
| | | } |
| | | worldCupInfo.setStoreInfos(objects); |
| | | return worldCupInfo; |
| | | } |
| | | |