|
|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.geo.Point;
|
|
|
@@ -70,10 +71,13 @@ import java.util.stream.Collectors;
|
|
|
* @author ssk
|
|
|
* @since 2024-12-05
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
@Transactional
|
|
|
public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo> implements StoreInfoService {
|
|
|
+ private static final int DEFAULT_DISTANCE_METER = 1000;
|
|
|
+
|
|
|
|
|
|
private final String DEFAULT_PASSWORD = "123456";
|
|
|
|
|
|
@@ -145,6 +149,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
|
+ private final StoreImgService storeImgService;
|
|
|
+
|
|
|
+
|
|
|
/** 商户证照历史记录数据访问对象 */
|
|
|
private final StoreLicenseHistoryMapper licenseHistoryMapper;
|
|
|
|
|
|
@@ -210,9 +217,16 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
List<StoreImg> albumUrlList = storeImgMapper.selectList(albumUrlQueryWrapper);
|
|
|
storeMainInfoVo.setAlbumUrl(albumUrlList.stream().sorted(Comparator.comparing(StoreImg::getImgSort)).map(StoreImg::getImgUrl).collect(Collectors.toList()));
|
|
|
//推荐菜
|
|
|
- storeMainInfoVo.setRecommendUrl(storeMenuMapper.getStoreMenuList(id, 1).stream().sorted(Comparator.comparing(StoreMenuVo::getImgSort)).collect(Collectors.toList()));
|
|
|
+ storeMainInfoVo.setRecommendUrl(storeMenuMapper.getStoreMenuList(id, 1,1).stream().sorted(Comparator.comparing(StoreMenuVo::getImgSort)).collect(Collectors.toList()));
|
|
|
//菜单
|
|
|
- storeMainInfoVo.setMenuUrl(storeMenuMapper.getStoreMenuList(id, 0).stream().sorted(Comparator.comparing(StoreMenuVo::getImgSort)).collect(Collectors.toList()));
|
|
|
+ storeMainInfoVo.setMenuUrl(storeMenuMapper.getStoreMenuList(id, 0,1).stream().sorted(Comparator.comparing(StoreMenuVo::getImgSort)).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ // todo 需要根据门店类型来判断
|
|
|
+ // 推荐酒水
|
|
|
+ storeMainInfoVo.setRecommendBeverageUrl(storeMenuMapper.getStoreMenuList(id, 1,1).stream().sorted(Comparator.comparing(StoreMenuVo::getImgSort)).collect(Collectors.toList()));
|
|
|
+ //酒单
|
|
|
+ storeMainInfoVo.setBeverageUrl(storeMenuMapper.getStoreMenuList(id, 0,1).stream().sorted(Comparator.comparing(StoreMenuVo::getImgSort)).collect(Collectors.toList()));
|
|
|
+
|
|
|
//门店标签
|
|
|
storeMainInfoVo.setStoreLabel(storeLabelMapper.selectOne(new LambdaQueryWrapper<StoreLabel>().eq(StoreLabel::getStoreId, id)));
|
|
|
//营业时间
|
|
|
@@ -3966,5 +3980,442 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * web-分页查询店铺信息
|
|
|
+ *
|
|
|
+
|
|
|
+ * @return IPage<StoreInfoVo>
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<StoreInfoVo> getMoreRecommendedStores(Double lon , Double lat, String businessSection, String businessTypes, String businessClassify) {
|
|
|
+ // 参数校验
|
|
|
+ if (lon == null || lat == null) {
|
|
|
+ log.warn("获取更多推荐店铺失败,经纬度为空");
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<StoreInfoVo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("a.delete_flag", 0).eq("b.delete_flag", 0);
|
|
|
+ //如果查询未过期
|
|
|
+ // 获取当前时刻
|
|
|
+ Date currentDate = new Date();
|
|
|
+ // 获取当前日期和时间
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ // 将时间设置为 0 点
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ calendar.set(Calendar.MINUTE, 0);
|
|
|
+ calendar.set(Calendar.SECOND, 0);
|
|
|
+ calendar.set(Calendar.MILLISECOND, 0);
|
|
|
+ // 加上 30 天
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, 30);
|
|
|
+ // 如果 expiration_time 为空则不做过期判断;如果不为空则要求大于当前时间
|
|
|
+ queryWrapper.and(w -> w.isNull("a.expiration_time")
|
|
|
+ .or()
|
|
|
+ .gt("a.expiration_time", currentDate));
|
|
|
+
|
|
|
+ // 如果 food_licence_expiration_time 为空则不做过期判断;如果不为空则要求大于当前时间
|
|
|
+ queryWrapper.and(w -> w.isNull("a.food_licence_expiration_time")
|
|
|
+ .or()
|
|
|
+ .gt("a.food_licence_expiration_time", currentDate));
|
|
|
+
|
|
|
+ // 构建一级分类
|
|
|
+ if(StringUtils.isNotEmpty(businessSection)){
|
|
|
+ queryWrapper.eq("a.business_section", businessSection);
|
|
|
+ // 构建二级分类
|
|
|
+ if(StringUtils.isNotEmpty(businessTypes)){
|
|
|
+ queryWrapper.eq("a.business_types", businessTypes);
|
|
|
+ // 构建三级分类
|
|
|
+ if(StringUtils.isNotEmpty(businessClassify)){
|
|
|
+ // 解析businessClassify参数(格式:1,2,3)
|
|
|
+ String[] classifyArray = businessClassify.split(",");
|
|
|
+ // 使用FIND_IN_SET函数检查数据库字段是否包含参数中的任何一个值
|
|
|
+ queryWrapper.and(wrapper -> {
|
|
|
+ for (int i = 0; i < classifyArray.length; i++) {
|
|
|
+ String classify = classifyArray[i].trim();
|
|
|
+ if (StringUtils.isNotEmpty(classify)) {
|
|
|
+ if (i == 0) {
|
|
|
+ wrapper.apply("FIND_IN_SET({0}, a.business_classify) > 0", classify);
|
|
|
+ } else {
|
|
|
+ wrapper.or().apply("FIND_IN_SET({0}, a.business_classify) > 0", classify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建position参数(格式:经度,纬度)
|
|
|
+ String position = lon + "," + lat;
|
|
|
+ List<StoreInfoVo> storeInfoVoList = storeInfoMapper.getMoreRecommendedStores(queryWrapper, position);
|
|
|
+ if (CollectionUtils.isEmpty(storeInfoVoList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ // 提前查询所有需要的字典数据
|
|
|
+ List<StoreInfoVo> collect = storeInfoVoList.stream().filter(record -> StringUtils.isNotEmpty(record.getStoreType())).collect(Collectors.toList());
|
|
|
+ Set<String> allTypes = collect.stream().map(StoreInfoVo::getStoreType).flatMap(type -> Arrays.stream(type.split(","))).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ List<StoreDictionary> storeDictionaries = storeDictionaryMapper.selectList(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getTypeName, "storeType").isNull(StoreDictionary::getParentId).in(!allTypes.isEmpty(), StoreDictionary::getDictId, allTypes));
|
|
|
+ Map<String, String> typeMap = storeDictionaries.stream().collect(Collectors.toMap(StoreDictionary::getDictId, StoreDictionary::getDictDetail));
|
|
|
+
|
|
|
+
|
|
|
+ // 计算平均分和评价
|
|
|
+ Map<String, List<Map<String, Object>>> avgScoreMap = new HashMap<>();
|
|
|
+ Map<Integer, List<StoreComment>> commentMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 注意:需要将store_id转换为String类型,与后续containsKey判断保持一致
|
|
|
+ avgScoreMap = storeEvaluationMapper.allStoreAvgScore().stream().collect(Collectors.groupingBy(o -> o.get("store_id").toString()));
|
|
|
+ commentMap = storeCommentMapper.selectList(new QueryWrapper<StoreComment>().eq("business_type", "5").eq("delete_flag", 0)).stream().collect(Collectors.groupingBy(StoreComment::getStoreId));
|
|
|
+
|
|
|
+
|
|
|
+ // 查询入口头图
|
|
|
+ List<Integer> storeIds = storeInfoVoList.stream()
|
|
|
+ .map(StoreInfoVo::getId) // 假设 StoreImg 有 getStoreUrl() 方法
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<StoreImg> storeImgList = storeImgMapper.selectList(new QueryWrapper<StoreImg>().in("store_id", storeIds).eq("img_type", 1));
|
|
|
+ Map<Integer, List<StoreImg>> storeCollect = storeImgList.stream()
|
|
|
+ .collect(Collectors.groupingBy(StoreImg::getStoreId));
|
|
|
+
|
|
|
+
|
|
|
+ for (StoreInfoVo record : storeInfoVoList) {
|
|
|
+ //处理类型
|
|
|
+ if (StringUtils.isNotEmpty(record.getStoreType())) {
|
|
|
+ String[] types = record.getStoreType().split(",");
|
|
|
+ List<String> typeDetails = Arrays.stream(types).map(typeMap::get).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ record.setStoreTypeStr(String.join(",", typeDetails));
|
|
|
+ record.setStoreTypeList(Arrays.asList(types));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 加入头图
|
|
|
+ if(!CollectionUtils.isEmpty(storeCollect) && storeCollect.containsKey(record.getId())){
|
|
|
+ List<StoreImg> storeImgs = storeCollect.get(record.getId());
|
|
|
+ if(!CollectionUtils.isEmpty(storeImgs)){
|
|
|
+ record.setEntranceImage(storeImgs.get(0).getImgUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //写经纬度
|
|
|
+ String[] split = record.getStorePosition().split(",");
|
|
|
+ record.setStorePositionLongitude(split[0]);
|
|
|
+ record.setStorePositionLatitude(split[1]);
|
|
|
+ // 格式化距离,移除无意义的小数位
|
|
|
+ if (!StringUtils.isEmpty(record.getDistance3())) {
|
|
|
+ try {
|
|
|
+ BigDecimal distanceValue = new BigDecimal(record.getDistance3());
|
|
|
+ record.setDistance3(distanceValue.stripTrailingZeros().toPlainString());
|
|
|
+ } catch (NumberFormatException ex) {
|
|
|
+ log.warn("店铺距离格式化失败, storeId: {}, distance3: {}", record.getId(), record.getDistance3(), ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //处理一下到期状态
|
|
|
+ Date expirationTime = record.getExpirationTime();
|
|
|
+ if (expirationTime != null) {
|
|
|
+ // 获取当前时间
|
|
|
+ Calendar now = Calendar.getInstance();
|
|
|
+ Date nowCurrentDate = now.getTime();
|
|
|
+ // 计算 30 天后的时间
|
|
|
+ now.add(Calendar.DAY_OF_YEAR, 30);
|
|
|
+ Date thirtyDaysLater = now.getTime();
|
|
|
+ // 比较两个日期
|
|
|
+ if (expirationTime.after(currentDate)) {
|
|
|
+ record.setExpiredState("0");
|
|
|
+ if ((expirationTime.after(nowCurrentDate) || expirationTime.equals(nowCurrentDate)) && expirationTime.before(thirtyDaysLater)) {
|
|
|
+ record.setExpiredState("1");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ record.setExpiredState("2");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前时间
|
|
|
+ LocalDate nowLocal = LocalDate.now();
|
|
|
+ // 将 expirationTime 转换为 LocalDate
|
|
|
+ LocalDate expDate = expirationTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ // 计算距离到期的天数
|
|
|
+ long daysToExpire = ChronoUnit.DAYS.between(nowLocal, expDate);
|
|
|
+ record.setDaysToExpire(daysToExpire);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置店铺得分,设置店铺人均消费,设置总评论数
|
|
|
+ if (avgScoreMap.containsKey(String.valueOf(record.getId()))) {
|
|
|
+ record.setAvgScore(String.valueOf(avgScoreMap.get(String.valueOf(record.getId())).get(0).get("avg_score")));
|
|
|
+ }
|
|
|
+ // 设置店铺得分,设置店铺人均消费,设置总评论数
|
|
|
+ if (commentMap.containsKey(record.getId())) {
|
|
|
+ record.setTotalNum(String.valueOf(commentMap.get(record.getId()).size()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // SQL已经实现了距离过滤和排序,直接返回结果
|
|
|
+ return storeInfoVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @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");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取店铺相册
|
|
|
+ List<StoreImg> storeAlbumList = new ArrayList<>();
|
|
|
+ if(storeInfo.getImgMode() != null && storeInfo.getImgMode() == 0){
|
|
|
+ storeAlbumList = storeImgService.getStoreImg(Integer.parseInt(storeId), 20);
|
|
|
+ } else {
|
|
|
+ storeAlbumList = storeImgService.getStoreImg(Integer.parseInt(storeId), 21);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(storeAlbumList)){
|
|
|
+ List<String> storeAlbumUrlList = storeAlbumList.stream().map(StoreImg::getImgUrl) // 假设 StoreImg 有 getStoreUrl() 方法
|
|
|
+ .filter(url -> url != null && !url.trim().isEmpty()) // 过滤空值
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ result.setStoreAlbumUrlList(storeAlbumUrlList);
|
|
|
+ } else {
|
|
|
+ result.setStoreAlbumUrlList(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置经纬度
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 该用户的打卡记录
|
|
|
+ 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<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);
|
|
|
+//
|
|
|
+// 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.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;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|