1
This commit is contained in:
@@ -45,7 +45,7 @@ public class MarketUserController {
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "查直推")
|
||||
public R<List<MarketDirectInfoVO>> myTeam() {
|
||||
return R.data(marketUserManager.findUserPackList( AuthUtil.getUserId()));
|
||||
return R.data(marketUserManager.findUserPackList());
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MarketUserController {
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "查推荐人信息")
|
||||
public R<MarketDirectInfoVO> myInvitor() {
|
||||
return R.data(marketUserManager.findMarketParent( AuthUtil.getUserId()));
|
||||
return R.data(marketUserManager.findMarketParent());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ package org.springblade.modules.api.vo;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -40,6 +41,7 @@ import java.util.Date;
|
||||
* @since 2026-02-05
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class MarketDirectInfoVO implements Serializable {
|
||||
private String phone;
|
||||
private String name;
|
||||
|
||||
@@ -3,6 +3,9 @@ package org.springblade.modules.market.manager;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.sensitive.SensitiveType;
|
||||
import org.springblade.core.tool.sensitive.SensitiveUtil;
|
||||
import org.springblade.modules.market.convert.MarketUserMarketInfoConvert;
|
||||
import org.springblade.modules.api.vo.MarketDirectInfoVO;
|
||||
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||
@@ -14,6 +17,8 @@ import org.springframework.util.Assert;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@@ -23,16 +28,23 @@ public class MarketUserManager {
|
||||
private final IMarketInfoService marketInfoService;
|
||||
private final IUserService userService;
|
||||
|
||||
public List<MarketDirectInfoVO> findUserPackList(Long userId) {
|
||||
|
||||
public List<MarketDirectInfoVO> findUserPackList() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
|
||||
Assert.notNull(marketInfoEntity, "用户不存在");
|
||||
|
||||
List<MarketDirectInfoVO> marketDirectInfoVOList = new LinkedList<>();
|
||||
|
||||
List<Long> marketInfoIdList = marketInfoService.list(
|
||||
List<MarketInfoEntity> marketInfoEntityList = marketInfoService.list(
|
||||
Wrappers.lambdaQuery(MarketInfoEntity.class)
|
||||
.eq(MarketInfoEntity::getPid, marketInfoEntity.getId())
|
||||
).stream().map(MarketInfoEntity::getId).toList();
|
||||
);
|
||||
|
||||
Map<Long, MarketInfoEntity> marketInfoEntityMap = marketInfoEntityList.stream()
|
||||
.collect(Collectors.toMap(MarketInfoEntity::getId, entity -> entity));
|
||||
|
||||
|
||||
List<Long> marketInfoIdList = marketInfoEntityList.stream().map(MarketInfoEntity::getId).toList();
|
||||
|
||||
if (marketInfoIdList.isEmpty()){
|
||||
return new LinkedList<>();
|
||||
@@ -43,11 +55,36 @@ public class MarketUserManager {
|
||||
.in(User::getId, marketInfoIdList)
|
||||
);
|
||||
|
||||
return MarketUserMarketInfoConvert.INSTANCE.convertMarketUserMarketInfoVOList(userList);
|
||||
|
||||
userList.forEach(user -> {
|
||||
if (marketInfoEntityMap.containsKey(user.getId())){
|
||||
MarketInfoEntity marketInfo = marketInfoEntityMap.get(user.getId());
|
||||
if (marketInfo.getVerified() == 1){
|
||||
marketDirectInfoVOList.add(
|
||||
new MarketDirectInfoVO()
|
||||
.setPhone(SensitiveUtil.process(user.getPhone()))
|
||||
.setName(desensitizationByPhone(marketInfo.getRealName()))
|
||||
.setRegisterTime(user.getCreateTime())
|
||||
);
|
||||
}else {
|
||||
marketDirectInfoVOList.add(
|
||||
new MarketDirectInfoVO()
|
||||
.setPhone(SensitiveUtil.process(user.getPhone()))
|
||||
.setName(desensitizationByPhone(user.getName()))
|
||||
.setRegisterTime(user.getCreateTime())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
return marketDirectInfoVOList;
|
||||
|
||||
}
|
||||
|
||||
public MarketDirectInfoVO findMarketParent(Long userId) {
|
||||
public MarketDirectInfoVO findMarketParent() {
|
||||
Long userId = AuthUtil.getUserId();
|
||||
MarketInfoEntity marketInfoEntity = marketInfoService.getById(userId);
|
||||
Assert.notNull(marketInfoEntity, "用户不存在");
|
||||
if (marketInfoEntity.getPid() == null || marketInfoEntity.getPid() <= 0){
|
||||
@@ -57,7 +94,26 @@ public class MarketUserManager {
|
||||
if (user == null){
|
||||
return new MarketDirectInfoVO();
|
||||
}
|
||||
return MarketUserMarketInfoConvert.INSTANCE.convertMarketUserMarketInfoVO(user);
|
||||
|
||||
MarketDirectInfoVO marketDirectInfoVO = new MarketDirectInfoVO()
|
||||
.setPhone(SensitiveUtil.process(user.getPhone()))
|
||||
.setName(desensitizationByPhone(user.getName()))
|
||||
.setRegisterTime(user.getCreateTime());
|
||||
|
||||
|
||||
MarketInfoEntity parentMarketInfoEntity = marketInfoService.getById(marketInfoEntity.getPid());
|
||||
|
||||
if(parentMarketInfoEntity != null && parentMarketInfoEntity.getVerified() == 1){
|
||||
marketDirectInfoVO.setName(desensitizationByPhone(parentMarketInfoEntity.getRealName()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
return marketDirectInfoVO;
|
||||
|
||||
}
|
||||
|
||||
private String desensitizationByPhone (String name){
|
||||
return name.replaceAll("^(.).*$", "$1" + "*".repeat(name.length() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user