Bladeren bron

更新小程序优惠券

liu 9 maanden geleden
bovenliggende
commit
d87ae46e6a

+ 7 - 0
src/main/java/com/sqx/modules/goods/controller/app/AppGoodsController.java

@@ -134,4 +134,11 @@ public class AppGoodsController {
         return goodsService.goodsParticularsPictureList(page,limit,name);
     }
 
+
+    @ApiOperation("通过优惠券筛选商家")
+    @GetMapping(value = "getCouponSelectShop")
+    public Result getCouponSelectShop(Integer page,Integer limit,String usedShopId,String shopName){
+        return goodsService.getCouponSelectShop(page,limit,usedShopId,shopName);
+    }
+
 }

+ 2 - 0
src/main/java/com/sqx/modules/goods/dao/GoodsShopDao.java

@@ -108,4 +108,6 @@ public interface GoodsShopDao extends BaseMapper<GoodsShop> {
     IPage<GoodsShop> selectSupplierShop(Page<GoodsShop> pages, Integer screen, Integer shopTypeId, Double lng, Double lat, String city, String impotr,Long activityId);
 
     GoodsShop getByAdminUserId(@Param("adminUserId") Long adminUserId);
+
+    IPage<GoodsShop> getCouponSelectShop(Page<GoodsShop> pages, String usedShopId, String shopName);
 }

+ 2 - 0
src/main/java/com/sqx/modules/goods/service/GoodsService.java

@@ -75,4 +75,6 @@ public interface GoodsService extends IService<Goods> {
     Result goodsPictureList(Integer page, Integer limit, String name);
 
     Result goodsParticularsPictureList(Integer page, Integer limit, String name);
+
+    Result getCouponSelectShop(Integer page, Integer limit, String usedShopId, String shopName);
 }

+ 41 - 0
src/main/java/com/sqx/modules/goods/service/impl/GoodsServiceImpl.java

@@ -873,4 +873,45 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsDao, Goods> implements Go
         return Result.success().put("data", pageUtils);
     }
 
+    @Override
+    public Result getCouponSelectShop(Integer page, Integer limit, String usedShopId, String shopName) {
+        Page<GoodsShop> pages = new Page<>(page, limit);
+        IPage<GoodsShop> goodsShopIPage = goodsShopDao.getCouponSelectShop(pages, usedShopId,shopName);
+        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, null);
+//            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));
+
+                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);
+    }
+
 }