| | |
| | | @PostMapping("/base/pointMerchars/getCommoditys") |
| | | public PointMerchandiseVo getVicinityGoods(@RequestBody CommodityRequest request) { |
| | | |
| | | |
| | | PointMerchandiseVo pointMerchandiseVo = new PointMerchandiseVo(); |
| | | List<PointsMerchandise> list = new ArrayList<>(); |
| | | String provinceCode = ""; |
| | | String cityCode = ""; |
| | | if (ToolUtil.isEmpty(request.getLon()) && ToolUtil.isEmpty(request.getLat())) { |
| | | return pointMerchandiseVo; |
| | | }else{ |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat()); |
| | | provinceCode = geocode.get("provinceCode"); |
| | | cityCode = geocode.get("cityCode"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat()); |
| | | provinceCode = geocode.get("provinceCode"); |
| | | cityCode = geocode.get("cityCode"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | list = pmdsService.list(new QueryWrapper<PointsMerchandise>() |
| | | .eq("state", 1) |
| | |
| | | .ge("endTime", new Date()) |
| | | .eq("status", 1) |
| | | ); |
| | | if (request.getShopId()!=null){ |
| | | List<Integer> storeId = new ArrayList<>(); |
| | | storeId.add(request.getShopId()); |
| | | List<Store> stores = storeClient.queryStoreByIds(storeId); |
| | | Store store = stores.get(0); |
| | | provinceCode = store.getProvinceCode(); |
| | | cityCode = store.getCityCode(); |
| | | List<Integer> pointsMerchandiseIds = pmdstoService.lambdaQuery().eq(PointsMerchandiseStore::getStoreId, request.getShopId()).list() |
| | | .stream().map(PointsMerchandiseStore::getPointsMerchandiseId) |
| | | .collect(Collectors.toList()); |
| | | if (pointsMerchandiseIds.isEmpty()){ |
| | | pointMerchandiseVo.setMerchandises(list); |
| | | return pointMerchandiseVo; |
| | | }else{ |
| | | List<PointsMerchandise> pointsMerchandiseList = pmdsService.lambdaQuery().in(PointsMerchandise::getId, pointsMerchandiseIds).list(); |
| | | list.addAll(pointsMerchandiseList); |
| | | List<PointsMerchandise> listAll = list.stream().distinct().collect(Collectors.toList()); |
| | | list = listAll; |
| | | } |
| | | } |
| | | |
| | | if (list.size() > 0) { |
| | | Iterator<PointsMerchandise> iterator = list.iterator(); |
| | | while (iterator.hasNext()) { |