Browse Source

新增用户端店铺详情接口

zhangchen 2 weeks ago
parent
commit
c9bfc3a226

+ 12 - 4
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -870,8 +870,16 @@ public class StoreInfoController {
         }
     }
 
-
-
-
-
+    @ApiOperation(value = "获取店铺详情(用户端)")
+    @ApiOperationSupport(order = 17)
+    @GetMapping("/getClientStoreDetail")
+    @ResponseBody
+    public R getClientStoreDetail(@RequestParam("id") String id,
+                            @RequestParam(value = "userId", required = false) String userId,
+                            @RequestParam(value = "jingdu", required = false) String jingdu,
+                            @RequestParam(value = "weidu", required = false) String weidu) {
+        log.info("StoreInfoController.getClientStoreDetail?id={},userId={},jingdu={},weidu={}", id, jingdu, weidu);
+        StoreInfoVo storeDetail = storeInfoService.getClientStoreDetail(id, userId, jingdu, weidu);
+        return R.data(storeDetail);
+    }
 }

+ 5 - 0
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -316,4 +316,9 @@ public interface StoreInfoService extends IService<StoreInfo> {
      * @return IPage<StoreInfoVo> 分页的门店信息列表
      */
     IPage<StoreInfoVo> getSpecialTypeStoresByDistance(Double lon, Double lat, Double distance, Integer sortType, Integer businessType, int pageNum, int pageSize);
+
+    /**
+     * web端查询门店明细
+     */
+    StoreInfoVo getClientStoreDetail(String storeId, String userId, String jingdu, String weidu);
 }

+ 312 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -3100,4 +3100,316 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         }
         return map;
     }
+
+    @Override
+    public StoreInfoVo getClientStoreDetail(String storeId, String userId, String jingdu, String weidu) {
+        StoreInfoVo result = new StoreInfoVo();
+        StoreInfo storeInfo = storeInfoMapper.selectById(storeId);
+        BeanUtils.copyProperties(storeInfo, result);
+        //将经营板块和种类拆分成集合
+        String businessTypes = storeInfo.getBusinessTypes();
+        if (StringUtils.isNotEmpty(businessTypes)) {
+            String[] split = businessTypes.split(",");
+            List<String> list = Arrays.asList(split);
+            result.setBusinessTypesList(list);
+        }
+        //存入用户账户
+        StoreUser storeUser = storeUserMapper.selectOne(new LambdaQueryWrapper<StoreUser>().eq(StoreUser::getStoreId, storeId));
+        if (storeUser != null) {
+            result.setUserAccount(storeUser.getId().toString());
+            result.setStorePhone(storeUser.getPhone());
+            result.setStoreUserName(storeUser.getName());
+            result.setIdCard(storeUser.getIdCard());
+        }
+        //存入执照图片地址
+        List<StoreImg> storeImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 14));
+        List<String> storeImgPaths = new ArrayList<>();
+        for (StoreImg storeImg : storeImgs) {
+            storeImgPaths.add(storeImg.getImgUrl());
+        }
+        result.setBusinessLicenseAddress(storeImgPaths);
+        //存入合同图片地址
+        List<StoreImg> storeContractImageImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 15));
+        List<String> storeContractImagePathImgs = new ArrayList<>();
+        for (StoreImg storeImg : storeContractImageImgs) {
+            storeContractImagePathImgs.add(storeImg.getImgUrl());
+        }
+        result.setContractImageList(storeContractImagePathImgs);
+        //存入续签合同地址
+        List<StoreImg> renewContractImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 22));
+        List<String> renewContractImagePathImgs = new ArrayList<>();
+        for (StoreImg storeImg : renewContractImgs) {
+            renewContractImagePathImgs.add(storeImg.getImgUrl());
+        }
+        result.setRenewContractImageList(renewContractImagePathImgs);
+        //存入经营许可证通过地址
+        List<StoreImg> foodLicenceImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 25));
+        List<String> foodLicenceImgsPathImgs = new ArrayList<>();
+        for (StoreImg storeImg : foodLicenceImgs) {
+            foodLicenceImgsPathImgs.add(storeImg.getImgUrl());
+        }
+        result.setFoodLicenceImageList(foodLicenceImgsPathImgs);
+        //存入经营许可证未通过地址
+        List<StoreImg> notPassFoodLicenceImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 24));
+        List<String> notPassFoodLicenceList = new ArrayList<>();
+        for (StoreImg storeImg : notPassFoodLicenceImgs) {
+            notPassFoodLicenceList.add(storeImg.getImgUrl());
+        }
+        result.setNotPassFoodLicenceImageList(notPassFoodLicenceList);
+        // 存放商家入口图
+        List<StoreImg> storeEntranceImageImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 1));
+        if (!storeEntranceImageImgs.isEmpty()) {
+            result.setEntranceImage(storeEntranceImageImgs.get(0).getImgUrl());
+        } else {
+            result.setEntranceImage("null");
+        }
+        // 存放商家头像
+        List<StoreImg> storeImgs1 = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getStoreId, storeId).eq(StoreImg::getImgType, 10));
+        if (!storeImgs1.isEmpty()) {
+            result.setImgUrl(storeImgs1.get(0).getImgUrl());
+        } else {
+            result.setImgUrl("null");
+        }
+
+        // 设置经纬度
+        result.setStorePositionLongitude(result.getStorePosition().split(",")[0]);
+        result.setStorePositionLatitude(result.getStorePosition().split(",")[1]);
+        // 设置距离
+        if ((jingdu != null && !jingdu.isEmpty()) && (weidu != null && !weidu.isEmpty())) {
+            /*double storeJing = Double.parseDouble(result.getStorePosition().split(",")[0]);
+            double storeWei = Double.parseDouble(result.getStorePosition().split(",")[1]);
+            double storeDistance = DistanceUtil.haversineCalculateDistance(Double.parseDouble(jingdu), Double.parseDouble(weidu), storeJing, storeWei);*/
+
+            Double distance = storeInfoMapper.getStoreDistance(jingdu + "," + weidu,result.getId());
+
+            result.setDistance(distance);
+        }
+        // 计算店铺到最近地铁站的距离
+        JSONObject nearbySubway = gaoDeMapUtil.getNearbySubway(result.getStorePosition().split(",")[0], result.getStorePosition().split(",")[1]);
+        // 地铁名
+        String subWayName = nearbySubway.getString("name");
+        result.setSubwayName(subWayName);
+        // 地铁站经纬度
+        String subWayJing = nearbySubway.getString("location") == null ? null : nearbySubway.getString("location").split(",")[0];
+        String subWayWei = nearbySubway.getString("location") == null ? null : nearbySubway.getString("location").split(",")[1];
+        if ((subWayJing != null && !subWayJing.isEmpty()) && (subWayWei != null && !subWayWei.isEmpty())) {
+            double storeJing = Double.parseDouble(result.getStorePosition().split(",")[0]);
+            double storeWei = Double.parseDouble(result.getStorePosition().split(",")[1]);
+            double storeDistance2 = DistanceUtil.haversineCalculateDistance(Double.parseDouble(subWayJing), Double.parseDouble(subWayWei), storeJing, storeWei);
+            result.setDistance2(storeDistance2);
+        } else {
+            result.setDistance2(0);
+        }
+        // 当前登录用户是否收藏
+        LambdaUpdateWrapper<LifeCollect> shouCangWrapper = new LambdaUpdateWrapper<>();
+        shouCangWrapper.eq(LifeCollect::getUserId, userId).eq(LifeCollect::getStoreId, storeId);
+        List<LifeCollect> shouCangList = lifeCollectMapper.selectList(shouCangWrapper);
+        if (null == shouCangList || shouCangList.isEmpty()) {
+            result.setCollection(0);
+        } else {
+            result.setCollection(1);
+        }
+        // 获取店铺代金券列表
+        LambdaUpdateWrapper<LifeCoupon> quanWrapper = new LambdaUpdateWrapper<>();
+        quanWrapper.eq(LifeCoupon::getStoreId, storeId).eq(LifeCoupon::getStatus, CouponStatusEnum.ONGOING.getCode()).eq(LifeCoupon::getType, 1);
+        List<LifeCoupon> quanList = lifeCouponMapper.selectList(quanWrapper);
+        List<LifeCouponVo> quanVoList = new ArrayList<>();
+        List<String> collect = quanList.stream().map(LifeCoupon::getId).collect(Collectors.toList());
+        // 设置已售数量
+        // 定义需要的订单状态集合
+        Set<Integer> excludeStatuses = new HashSet<>(Arrays.asList(
+                OrderStatusEnum.WAIT_PAY.getStatus(),
+                OrderStatusEnum.WAIT_USE.getStatus(),
+                OrderStatusEnum.USED.getStatus()
+        ));
+        if (!collect.isEmpty()) {
+            List<LifeUserOrderVo> quanCount = lifeUserOrderMapper.getQuanCount(new QueryWrapper<LifeUserOrderVo>()
+                    .eq("luo.store_id", storeId)
+                    .eq("luo.coupon_type", CouponTypeEnum.COUPON.getCode())
+                    .eq("luo.delete_flag", 0)
+                    .in("ocm.status", excludeStatuses)
+                    .groupBy("ocm.coupon_id"));
+            quanList.forEach(a -> {
+                LifeCouponVo lifeCouponVo = new LifeCouponVo();
+                BeanUtils.copyProperties(a, lifeCouponVo);
+                quanCount.forEach(item -> {
+                    if (a.getId().equals(item.getCouponId().toString())) {
+                        lifeCouponVo.setCount(item.getCount());
+                    }
+                });
+                quanVoList.add(lifeCouponVo);
+            });
+        }
+        result.setCouponList(quanVoList);
+
+        // 获取店铺团购
+        LambdaUpdateWrapper<LifeGroupBuyMain> tuangouWrapper = new LambdaUpdateWrapper<>();
+        tuangouWrapper.eq(LifeGroupBuyMain::getStoreId, storeId).eq(LifeGroupBuyMain::getStatus, CouponStatusEnum.ONGOING.getCode()).orderByDesc(LifeGroupBuyMain::getCreatedTime);
+        List<LifeGroupBuyMain> tuangouList = lifeGroupBuyMainMapper.selectList(tuangouWrapper);
+        List<LifeGroupBuyMainVo> tuangouVOList = new ArrayList<>();
+        for (LifeGroupBuyMain lifeGroupBuyMain : tuangouList) {
+            LifeGroupBuyMainVo lifeGroupBuyMainVo = new LifeGroupBuyMainVo();
+            BeanUtils.copyProperties(lifeGroupBuyMain, lifeGroupBuyMainVo);
+            if (StringUtils.isNotEmpty(lifeGroupBuyMain.getImageId())) {
+                List<String> ids = Arrays.stream(lifeGroupBuyMain.getImageId().split(",")).map(String::trim).collect(Collectors.toList());
+                List<StoreImg> imgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().in(StoreImg::getId, ids));
+                if (imgList != null) {
+                    String imgs = imgList.stream().map(StoreImg::getImgUrl).collect(Collectors.joining(","));
+                    lifeGroupBuyMainVo.setImageId(imgs);
+                }
+            }
+            tuangouVOList.add(lifeGroupBuyMainVo);
+        }
+        result.setTuangouList(tuangouVOList);
+
+        // 获取员工列表
+        LambdaQueryWrapper<StoreStaffConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(StoreStaffConfig::getStoreId, storeId);
+        List<StoreStaffConfig> storeStaffConfigs = storeStaffConfigMapper.selectList(lambdaQueryWrapper);
+        result.setEmployeeList(storeStaffConfigs);
+
+        // 该用户的打卡记录
+        LambdaQueryWrapper<StoreClockIn> clockInWrapper = new LambdaQueryWrapper<>();
+        clockInWrapper.eq(StoreClockIn::getUserId, userId);
+        List<StoreClockIn> clockInList = storeClockInMapper.selectList(clockInWrapper);
+
+        List<StoreClockIn> clockStoreList = clockInList.stream().filter(item -> item.getStoreId() == Integer.parseInt(storeId)).collect(Collectors.toList());
+        // 该用户是否在该店铺打过卡
+        if (!clockStoreList.isEmpty()) {
+            result.setClockInStore(1);
+        } else {
+            result.setClockInStore(0);
+        }
+
+        // 今天在该店铺是否打过卡
+        int today = (int) clockStoreList.stream().filter(item -> item.getCreatedTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalDate.now())).count();
+        if (today > 0) {
+            result.setClockInStoreToday(1);
+        } else {
+            result.setClockInStoreToday(0);
+        }
+
+        // 店铺平均分
+        /*Map<Object, List<Map<String, Object>>> avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id")));
+        if (avgScoreMap.containsKey(String.valueOf(result.getId()))) {
+            result.setScore(Double.parseDouble(avgScoreMap.get(String.valueOf(result.getId())).get(0).get("avg_score").toString()));
+        }*/
+
+        Map<String, Object> commitCountAndScore = storeCommentService.getCommitCountAndScore(null, 5, Integer.parseInt(storeId), null, null);
+        result.setScore(Double.parseDouble(commitCountAndScore.get("score").toString()));
+        result.setCommitCount(commitCountAndScore.get("commitCount").toString());
+
+
+        // 在该店铺的打卡次数
+        result.setClockInStoreNum(clockStoreList.size());
+
+        // 该用户打卡的所有店铺次数(一个店铺只算一次)
+        int clockInNum = (int) clockInList.stream().map(StoreClockIn::getStoreId).distinct().count();
+        result.setClockInNum(clockInNum);
+
+        // 获取店铺动态列表
+        QueryWrapper<LifeUserDynamics> dynamicsWrapper = new QueryWrapper<>();
+        dynamicsWrapper.eq("phone_id", "store_" + result.getStorePhone()).orderByDesc("lud.created_time");
+        dynamicsWrapper.eq("lud.delete_flag", 0);
+        //List<LifeUserDynamicsVo> storeDynamicslist = lifeUserDynamicsMapper.getStoreDynamicslist(userId, dynamicsWrapper);
+
+        LambdaQueryWrapper<LifeBlacklist> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper1.eq(LifeBlacklist :: getBlockerId, userId);
+        lambdaQueryWrapper1.eq(LifeBlacklist :: getBlockedPhoneId, "store_" + result.getStorePhone());
+        LifeBlacklist blacklist = lifeBlacklistMapper.selectOne(lambdaQueryWrapper1);
+        List<LifeUserDynamicsVo> storeDynamicslist = new ArrayList<>();
+
+        //判断没有拉黑当前门店账户 查出门店动态
+        if(blacklist == null){
+            storeDynamicslist = lifeUserDynamicsMapper.getStoreDynamicslist(userId, "store_" + result.getStorePhone());
+        }
+
+        List<String> followList = new ArrayList<>();
+        List<String> fansList = new ArrayList<>();
+
+        if (StringUtils.isNotEmpty(userId)) {
+            LifeUser lifeUser = lifeUserMapper.selectById(userId);
+            if (lifeUser != null && StringUtils.isNotEmpty(lifeUser.getUserPhone())) {
+                // 查询我的关注信息,构建关注者ID列表
+                LambdaQueryWrapper<LifeFans> lifeFansWrapper = new LambdaQueryWrapper<>();
+                lifeFansWrapper.eq(LifeFans::getFansId, "user_" + result.getStorePhone());
+                List<LifeFans> lifeFansList = lifeFansMapper.selectList(lifeFansWrapper);
+                if (!CollectionUtils.isEmpty(lifeFansList)) {
+                    followList = lifeFansList.stream().map(LifeFans::getFollowedId).collect(Collectors.toList());
+                }
+
+                // 查询我的粉丝信息,构建粉丝ID列表
+                lifeFansWrapper = new LambdaQueryWrapper<>();
+                lifeFansWrapper.eq(LifeFans::getFollowedId, "user_" + result.getStorePhone());
+                lifeFansList = lifeFansMapper.selectList(lifeFansWrapper);
+                if (!CollectionUtils.isEmpty(lifeFansList)) {
+                    fansList = lifeFansList.stream().map(LifeFans::getFansId).collect(Collectors.toList());
+                }
+            }
+        }
+
+        for (LifeUserDynamicsVo vo : storeDynamicslist) {
+            if (followList.contains(vo.getPhoneId())) {
+                vo.setIsFollowThis("1");
+            } else {
+                vo.setIsFollowThis("0");
+            }
+            if (fansList.contains(vo.getPhoneId())) {
+                vo.setIsFollowMe("1");
+            } else {
+                vo.setIsFollowMe("0");
+            }
+        }
+
+        // 返回动态最新的5条
+        List<LifeUserDynamicsVo> storeDynamicslist2 = storeDynamicslist.stream()
+                .limit(5).collect(Collectors.toList());
+        result.setDynamicsList(storeDynamicslist2);
+        //设置动态条数
+        Integer dynamicsNum = storeDynamicslist2.size();
+        result.setDynamicsNum(dynamicsNum);
+
+        // 获取店铺动态总数
+        result.setTotalDynamicsNum(storeDynamicslist.size());
+
+        //营业时间
+        List<StoreBusinessInfo> storeBusinessInfos = storeBusinessInfoMapper.selectList(new LambdaQueryWrapper<StoreBusinessInfo>().eq(StoreBusinessInfo::getStoreId, storeId).eq(StoreBusinessInfo::getDeleteFlag, 0));
+        if (ObjectUtils.isNotEmpty(storeBusinessInfos)) {
+            result.setStoreBusinessInfo(storeBusinessInfos.get(0));
+            result.setStoreBusinessInfos(storeBusinessInfos);
+            //StoreBusinessInfo storeBusinessInfo = result.getStoreBusinessInfo();
+            StoreBusinessInfo storeBusinessInfo = result.getStoreBusinessInfos().stream().filter(item -> item.getBusinessType() == 1).findFirst().orElse(null);
+            if (ObjectUtils.isNotEmpty(storeBusinessInfo)) {
+
+                Calendar calendar = Calendar.getInstance(); // 获取Calendar实例
+                int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); // 获取星期几,注意Calendar中的DAY_OF_WEEK是从1(代表星期天)开始的
+                String[] days = {"7", "1", "2", "3", "4", "5", "6"};
+                String day = days[dayOfWeek - 1];
+                if (storeBusinessInfo.getBusinessDate().contains(day)) {
+                    if (StringUtils.isNotEmpty(storeBusinessInfo.getStartTime()) && StringUtils.isNotEmpty(storeBusinessInfo.getEndTime())) {
+                        LocalTime now = LocalTime.now();
+                        List<String> startList = Arrays.asList(storeBusinessInfo.getStartTime().split(":"));
+                        List<String> endList = Arrays.asList(storeBusinessInfo.getEndTime().split(":"));
+                        LocalTime start = LocalTime.of(Integer.parseInt(startList.get(0)), Integer.parseInt(startList.get(1)));
+                        LocalTime end = LocalTime.of(Integer.parseInt(endList.get(0)), Integer.parseInt(startList.get(1)));
+                        if (now.isAfter(start) && now.isBefore(end)) {
+                            result.setYyFlag(1);
+                        } else {
+                            result.setYyFlag(0);
+                        }
+                    }
+                } else {
+                    result.setYyFlag(0);
+                }
+            }
+        }
+        LambdaQueryWrapper<StoreDictionary> storeDictionaryLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        storeDictionaryLambdaQueryWrapper.eq(StoreDictionary::getTypeName, "businessStatus")
+                .eq(StringUtils.isNotEmpty(result.getBusinessStatus().toString()), StoreDictionary::getDictId, result.getBusinessStatus());
+        List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(storeDictionaryLambdaQueryWrapper);
+        if (!storeDictionaries.isEmpty()) {
+            result.setBusinessStatusStr(storeDictionaries.get(0).getDictDetail());
+        }
+        return result;
+    }
 }