|
|
@@ -5736,6 +5736,44 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
|
|
|
result.setCollection(1);
|
|
|
}
|
|
|
|
|
|
+ // 当前登录用户是否关注该店铺
|
|
|
+ if (StringUtils.isNotEmpty(userId) && storeUser != null && StringUtils.isNotEmpty(storeUser.getPhone())) {
|
|
|
+ try {
|
|
|
+ // userId是用户ID(数字),查询用户信息获取手机号
|
|
|
+ Integer userIdInt = Integer.parseInt(userId);
|
|
|
+ LifeUser lifeUser = lifeUserMapper.selectById(userIdInt);
|
|
|
+
|
|
|
+ if (lifeUser != null && StringUtils.isNotEmpty(lifeUser.getUserPhone())) {
|
|
|
+ // 构造关注关系:followed_id = "store_" + 店铺手机号,fans_id = "user_" + 用户手机号
|
|
|
+ String followedId = "store_" + storeUser.getPhone();
|
|
|
+ String fansId = "user_" + lifeUser.getUserPhone();
|
|
|
+
|
|
|
+ // 查询关注关系
|
|
|
+ LambdaQueryWrapper<LifeFans> fansWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fansWrapper.eq(LifeFans::getFollowedId, followedId)
|
|
|
+ .eq(LifeFans::getFansId, fansId)
|
|
|
+ .eq(LifeFans::getDeleteFlag, 0);
|
|
|
+ LifeFans lifeFans = lifeFansMapper.selectOne(fansWrapper);
|
|
|
+
|
|
|
+ if (lifeFans != null) {
|
|
|
+ result.setIsFollowed(1); // 已关注
|
|
|
+ } else {
|
|
|
+ result.setIsFollowed(0); // 未关注
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.setIsFollowed(0); // 无法获取用户手机号,默认未关注
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error("用户ID格式错误 - userId: {}, storeId: {}, error: {}", userId, storeId, e.getMessage());
|
|
|
+ result.setIsFollowed(0); // 用户ID格式错误,默认未关注
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询用户关注状态失败 - userId: {}, storeId: {}, error: {}", userId, storeId, e.getMessage(), e);
|
|
|
+ result.setIsFollowed(0); // 查询失败,默认未关注
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.setIsFollowed(0); // 用户ID或店铺信息为空,默认未关注
|
|
|
+ }
|
|
|
+
|
|
|
// 该用户的打卡记录
|
|
|
LambdaQueryWrapper<StoreClockIn> clockInWrapper = new LambdaQueryWrapper<>();
|
|
|
clockInWrapper.eq(StoreClockIn::getUserId, userId);
|