|
@@ -1,5 +1,6 @@
|
|
|
package com.sqx.modules.goods.service.impl;
|
|
package com.sqx.modules.goods.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -538,47 +539,47 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
|
|
|
|
|
|
|
|
IPage<GoodsShop> goodsShopIPage = goodsShopDao.selectShop(pages, screen, shopTypeId, lng, lat, city, impotr, activityId);
|
|
IPage<GoodsShop> goodsShopIPage = goodsShopDao.selectShop(pages, screen, shopTypeId, lng, lat, city, impotr, activityId);
|
|
|
List<GoodsShop> records = goodsShopIPage.getRecords();
|
|
List<GoodsShop> records = goodsShopIPage.getRecords();
|
|
|
- CommonInfo one1 = commonInfoService.findOne(292);
|
|
|
|
|
- CommonInfo one2 = commonInfoService.findOne(293);
|
|
|
|
|
- //改为使用stream拼接shopid 查询数据 后循环封装
|
|
|
|
|
- List<Long> shopIdList = records.stream().map(GoodsShop::getShopId).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
- List<Goods> goodsList = goodsDao.selectGoodsBySalesAndGoodsNameAndShopIds(shopIdList, impotr);
|
|
|
|
|
- Map<Long, List<Goods>> goodsMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getShopId));
|
|
|
|
|
|
|
+ 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, impotr);
|
|
|
|
|
+ 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<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));
|
|
|
|
|
|
|
+ // 查询店铺活动
|
|
|
|
|
+ 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));
|
|
|
|
|
|
|
+ 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));
|
|
|
|
|
|
|
+ // 设置活动信息
|
|
|
|
|
+ goodsShop.setShopActivityList(shopActivityMap.get(shopId));
|
|
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(impotr)) {
|
|
|
|
|
- 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());
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(impotr)) {
|
|
|
|
|
+ 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);
|
|
|
}
|
|
}
|
|
|
- goodsShop.setErrandTime(errandTime);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
PageUtils pageUtils = new PageUtils(goodsShopIPage);
|
|
PageUtils pageUtils = new PageUtils(goodsShopIPage);
|
|
|
return Result.success().put("data", pageUtils);
|
|
return Result.success().put("data", pageUtils);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Result selectSearch(Integer page, Integer limit, String impotr, Double lng, Double lat) {
|
|
public Result selectSearch(Integer page, Integer limit, String impotr, Double lng, Double lat) {
|
|
|
Page<GoodsShop> pages = new Page<>(page, limit);
|
|
Page<GoodsShop> pages = new Page<>(page, limit);
|