|
@@ -40,6 +40,8 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
public class LifeStoreService {
|
|
public class LifeStoreService {
|
|
|
|
|
|
|
|
|
|
+ private static final String LOGOUT_DISPLAY_NAME = "已注销";
|
|
|
|
|
+
|
|
|
private final LifeCollectMapper lifeCollectMapper;
|
|
private final LifeCollectMapper lifeCollectMapper;
|
|
|
|
|
|
|
|
private final LifeUserMapper lifeUserMapper;
|
|
private final LifeUserMapper lifeUserMapper;
|
|
@@ -105,6 +107,7 @@ public class LifeStoreService {
|
|
|
}
|
|
}
|
|
|
boolean onlyStoreFollowed = (type != null && type == 1) && fansId != null && fansId.startsWith("store_");
|
|
boolean onlyStoreFollowed = (type != null && type == 1) && fansId != null && fansId.startsWith("store_");
|
|
|
IPage<LifeFansVo> myFollowed = queryMyFollowed(new Page<>(page, size), fansId, relationFansId, blockerType, blockerId, onlyStoreFollowed, wrapper);
|
|
IPage<LifeFansVo> myFollowed = queryMyFollowed(new Page<>(page, size), fansId, relationFansId, blockerType, blockerId, onlyStoreFollowed, wrapper);
|
|
|
|
|
+ applyLoggedOutUsername(myFollowed.getRecords());
|
|
|
// 过滤掉我拉黑的
|
|
// 过滤掉我拉黑的
|
|
|
List<LifeFansVo> collect = myFollowed.getRecords().stream().filter(x -> null == x.getBlackListid()).collect(Collectors.toList());
|
|
List<LifeFansVo> collect = myFollowed.getRecords().stream().filter(x -> null == x.getBlackListid()).collect(Collectors.toList());
|
|
|
myFollowed.setRecords(collect);
|
|
myFollowed.setRecords(collect);
|
|
@@ -112,6 +115,88 @@ public class LifeStoreService {
|
|
|
return myFollowed;
|
|
return myFollowed;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** 关注/互关等列表回显:被关注方 logout_flag=1 时 username 展示为「已注销」 */
|
|
|
|
|
+ private void applyLoggedOutUsername(List<LifeFansVo> records) {
|
|
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (LifeFansVo vo : records) {
|
|
|
|
|
+ if (isFollowedAccountLoggedOut(vo)) {
|
|
|
|
|
+ vo.setUsername(LOGOUT_DISPLAY_NAME);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean isFollowedAccountLoggedOut(LifeFansVo vo) {
|
|
|
|
|
+ if (vo == null) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 互关/关注列表:商户 id 为 store_info.id,按 store_id 查 store_user.logout_flag
|
|
|
|
|
+ if (isStoreFansVo(vo) && StringUtils.isNotEmpty(vo.getId())) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (storeUserService.count(new LambdaQueryWrapper<StoreUser>()
|
|
|
|
|
+ .eq(StoreUser::getStoreId, Integer.valueOf(vo.getId()))
|
|
|
|
|
+ .eq(StoreUser::getDeleteFlag, 0)
|
|
|
|
|
+ .eq(StoreUser::getLogoutFlag, StoreUser.LOGOUT_FLAG_DONE)) > 0) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (NumberFormatException ignored) {
|
|
|
|
|
+ // ignore
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // C 端用户:列表 id 为 life_user.id
|
|
|
|
|
+ if (isLifeUserFansVo(vo) && StringUtils.isNotEmpty(vo.getId())) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ LifeUser user = lifeUserMapper.selectById(Integer.valueOf(vo.getId()));
|
|
|
|
|
+ if (user != null && (user.getDeleteFlag() == null || user.getDeleteFlag() == 0)
|
|
|
|
|
+ && user.getLogoutFlag() != null
|
|
|
|
|
+ && LifeUser.LOGOUT_FLAG_DONE == user.getLogoutFlag()) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (NumberFormatException ignored) {
|
|
|
|
|
+ // ignore
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(vo.getPhoneId())) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ String[] parts = vo.getPhoneId().split("_", 2);
|
|
|
|
|
+ if (parts.length < 2 || StringUtils.isEmpty(parts[1])) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("user".equals(parts[0])) {
|
|
|
|
|
+ LifeUser user = lifeUserMapper.selectOne(new LambdaQueryWrapper<LifeUser>()
|
|
|
|
|
+ .eq(LifeUser::getUserPhone, parts[1])
|
|
|
|
|
+ .eq(LifeUser::getDeleteFlag, 0)
|
|
|
|
|
+ .orderByDesc(LifeUser::getCreatedTime)
|
|
|
|
|
+ .orderByDesc(LifeUser::getId)
|
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
|
+ return user != null && user.getLogoutFlag() != null
|
|
|
|
|
+ && LifeUser.LOGOUT_FLAG_DONE == user.getLogoutFlag();
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("store".equals(parts[0])) {
|
|
|
|
|
+ StoreUser user = storeUserService.getOne(new LambdaQueryWrapper<StoreUser>()
|
|
|
|
|
+ .eq(StoreUser::getPhone, parts[1])
|
|
|
|
|
+ .eq(StoreUser::getDeleteFlag, 0)
|
|
|
|
|
+ .orderByDesc(StoreUser::getCreatedTime)
|
|
|
|
|
+ .orderByDesc(StoreUser::getId)
|
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
|
|
+ return user != null && user.getLogoutFlag() != null
|
|
|
|
|
+ && StoreUser.LOGOUT_FLAG_DONE == user.getLogoutFlag();
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static boolean isStoreFansVo(LifeFansVo vo) {
|
|
|
|
|
+ return "1".equals(vo.getIsMerchant())
|
|
|
|
|
+ || (vo.getPhoneId() != null && vo.getPhoneId().startsWith("store_"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static boolean isLifeUserFansVo(LifeFansVo vo) {
|
|
|
|
|
+ return !"1".equals(vo.getIsMerchant())
|
|
|
|
|
+ && (vo.getPhoneId() == null || vo.getPhoneId().startsWith("user_"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 我的关注所有
|
|
* 我的关注所有
|
|
|
*/
|
|
*/
|
|
@@ -213,6 +298,7 @@ public class LifeStoreService {
|
|
|
LifeFansIdentityQuery.Scope scope = LifeFansIdentityQuery.resolve(fansId, typeUtil);
|
|
LifeFansIdentityQuery.Scope scope = LifeFansIdentityQuery.resolve(fansId, typeUtil);
|
|
|
IPage<LifeFansVo> mutualAttention = lifeFansMapper.getMutualAttention(new Page<>(page, size), fansId,
|
|
IPage<LifeFansVo> mutualAttention = lifeFansMapper.getMutualAttention(new Page<>(page, size), fansId,
|
|
|
scope.getUserType(), scope.getRefId(), blockerType, blockerId, wrapper);
|
|
scope.getUserType(), scope.getRefId(), blockerType, blockerId, wrapper);
|
|
|
|
|
+ applyLoggedOutUsername(mutualAttention.getRecords());
|
|
|
List<LifeFansVo> collect = mutualAttention.getRecords().stream().filter(x -> null == x.getBlackListid()).collect(Collectors.toList());
|
|
List<LifeFansVo> collect = mutualAttention.getRecords().stream().filter(x -> null == x.getBlackListid()).collect(Collectors.toList());
|
|
|
mutualAttention.setRecords(collect);
|
|
mutualAttention.setRecords(collect);
|
|
|
mutualAttention.setTotal(collect.size());
|
|
mutualAttention.setTotal(collect.size());
|
|
@@ -229,6 +315,7 @@ public class LifeStoreService {
|
|
|
LifeFansIdentityQuery.Scope scope = LifeFansIdentityQuery.resolve(fansId, typeUtil);
|
|
LifeFansIdentityQuery.Scope scope = LifeFansIdentityQuery.resolve(fansId, typeUtil);
|
|
|
IPage<LifeFansVo> mutualAttention = lifeFansMapper.getMutualAttentionUser(new Page<>(page, size), fansId,
|
|
IPage<LifeFansVo> mutualAttention = lifeFansMapper.getMutualAttentionUser(new Page<>(page, size), fansId,
|
|
|
scope.getUserType(), scope.getRefId(), wrapper);
|
|
scope.getUserType(), scope.getRefId(), wrapper);
|
|
|
|
|
+ applyLoggedOutUsername(mutualAttention.getRecords());
|
|
|
filterBlocked(fansId, mutualAttention);
|
|
filterBlocked(fansId, mutualAttention);
|
|
|
List<LifeFansVo> collect = mutualAttention.getRecords().stream().filter(x -> x.getIsBlocked().equals("0")).collect(Collectors.toList());
|
|
List<LifeFansVo> collect = mutualAttention.getRecords().stream().filter(x -> x.getIsBlocked().equals("0")).collect(Collectors.toList());
|
|
|
mutualAttention.setRecords(collect);
|
|
mutualAttention.setRecords(collect);
|