|
@@ -752,4 +752,63 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
|
|
|
return baseMapper.getByAllGoodsIdByShopId(shopId);
|
|
return baseMapper.getByAllGoodsIdByShopId(shopId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Result selectSupplierShop(ShopQueryDTO queryDTO) {
|
|
|
|
|
+ //如果没有经纬度,则默认为北京的经纬度
|
|
|
|
|
+ Double lat = queryDTO.getLat();
|
|
|
|
|
+ Double lng = queryDTO.getLng();
|
|
|
|
|
+ if (lng == null || lat == null || lng == 0 || lat == 0) {
|
|
|
|
|
+ lng = 121.47;
|
|
|
|
|
+ lat = 31.23;
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<GoodsShop> pages = new Page<>(queryDTO.getPage(), queryDTO.getLimit());
|
|
|
|
|
+
|
|
|
|
|
+ String city = queryDTO.getCity();
|
|
|
|
|
+ if (StrUtil.isBlank(city)) {
|
|
|
|
|
+ city = getCity(lat, lng);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IPage<GoodsShop> goodsShopIPage = goodsShopDao.selectSupplierShop(pages, queryDTO.getScreen(), queryDTO.getShopTypeId(), lng, lat, city, queryDTO.getImpotr(), queryDTO.getActivityId());
|
|
|
|
|
+ List<GoodsShop> records = goodsShopIPage.getRecords();
|
|
|
|
|
+
|
|
|
|
|
+ if (CollUtil.isNotEmpty(records)) {
|
|
|
|
|
+ CommonInfo one1 = commonInfoService.findOne(292);
|
|
|
|
|
+ CommonInfo one2 = commonInfoService.findOne(293);
|
|
|
|
|
+ List<Long> shopIdList = records.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
|
|
|
|
|
+ List<Goods> goodsList = goodsDao.selectGoodsBySalesAndGoodsNameAndShopIds(shopIdList, queryDTO.getImpotr());
|
|
|
|
|
+ Map<Long, List<Goods>> goodsMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getShopId));
|
|
|
|
|
+
|
|
|
|
|
+ List<TbCoupon> tbCoupons = tbCouponDao.selectCouponListByShopIdList(shopIdList, null);
|
|
|
|
|
+ Map<Long, List<TbCoupon>> couponMap = tbCoupons.stream().collect(Collectors.groupingBy(TbCoupon::getShopId));
|
|
|
|
|
+
|
|
|
|
|
+ // 查询店铺活动
|
|
|
|
|
+ List<ShopActivityVO> shopActivityVOS = activityShopService.getActivityByShopIds(shopIdList);
|
|
|
|
|
+ Map<Long, List<ShopActivityVO>> shopActivityMap = shopActivityVOS.stream().collect(Collectors.groupingBy(ShopActivityVO::getShopId));
|
|
|
|
|
+
|
|
|
|
|
+ for (int a = 0; a < goodsShopIPage.getRecords().size(); a++) {
|
|
|
|
|
+ GoodsShop goodsShop = goodsShopIPage.getRecords().get(a);
|
|
|
|
|
+ Long shopId = goodsShop.getShopId();
|
|
|
|
|
+ goodsShop.setCouponList(couponMap.get(shopId));
|
|
|
|
|
+
|
|
|
|
|
+ // 设置活动信息
|
|
|
|
|
+ goodsShop.setShopActivityList(shopActivityMap.get(shopId));
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(queryDTO.getImpotr())) {
|
|
|
|
|
+ goodsShop.setGoodsList(goodsMap.get(shopId));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ goodsShop.setGoodsList(new ArrayList<>());
|
|
|
|
|
+ }
|
|
|
|
|
+ Double distance = goodsShop.getDistance();
|
|
|
|
|
+ double errandTime = distance / Double.parseDouble(one1.getValue());
|
|
|
|
|
+ if (errandTime < Double.parseDouble(one2.getValue())) {
|
|
|
|
|
+ errandTime = Double.parseDouble(one2.getValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ goodsShop.setErrandTime(errandTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PageUtils pageUtils = new PageUtils(goodsShopIPage);
|
|
|
|
|
+ return Result.success().put("data", pageUtils);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|