update:
1. fix
This commit is contained in:
@@ -35,15 +35,25 @@ public class InitUserAssetsProcessor implements BasicProcessor {
|
||||
|
||||
private final IMarketCashPerformanceService cashPerformanceService;
|
||||
|
||||
private final IMarketUserHierarchyService hierarchyService;
|
||||
|
||||
@Override
|
||||
public ProcessResult process(TaskContext taskContext) throws Exception {
|
||||
List<User> userList = userService.list(Wrappers.<User>lambdaQuery().eq(User::getUserType, 2).eq(User::getIsDeleted, 0));
|
||||
List<User> userList = userService.list(Wrappers.lambdaQuery(User.class).eq(User::getUserType, 2).eq(User::getIsDeleted, 0));
|
||||
userList.forEach(user -> {
|
||||
MarketInfoEntity marketInfo = marketInfoService.getById(user.getId());
|
||||
if (marketInfo == null) {
|
||||
marketInfo = new MarketInfoEntity();
|
||||
marketInfo.setId(user.getId());
|
||||
marketInfoService.save(marketInfo);
|
||||
} else {
|
||||
if (marketInfo.getVerified() == 1) {
|
||||
MarketUserHierarchyEntity hierarchy = hierarchyService.getById(user.getId());
|
||||
if (hierarchy == null) {
|
||||
List<Long> ids = marketInfoService.selectAncestorIds(user.getId());
|
||||
hierarchyService.init(user.getId(), ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
CommonUserPointEntity userPoint = userPointService.getById(user.getId());
|
||||
if (userPoint == null) {
|
||||
|
||||
@@ -30,6 +30,8 @@ import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.modules.market.pojo.entity.MarketUserHierarchyEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketUserHierarchyVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 用户层级表 服务类
|
||||
@@ -47,7 +49,7 @@ public interface IMarketUserHierarchyService extends BaseService<MarketUserHiera
|
||||
*/
|
||||
IPage<MarketUserHierarchyVO> selectHierarchyPage(IPage<MarketUserHierarchyVO> page, MarketUserHierarchyVO hierarchy);
|
||||
|
||||
void init(Long userId);
|
||||
void init(Long userId, List<Long> parentsIds);
|
||||
|
||||
boolean isInDirectLineage(Long userId1, Long userId2);
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.springblade.modules.market.mapper.MarketInfoMapper;
|
||||
import org.springblade.modules.market.service.*;
|
||||
import org.springblade.modules.system.pojo.entity.User;
|
||||
import org.springblade.modules.system.service.IUserService;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
@@ -89,6 +90,7 @@ public class MarketInfoServiceImpl extends BaseServiceImpl<MarketInfoMapper, Mar
|
||||
|
||||
private final IMarketCashPerformanceService cashPerformanceService;
|
||||
|
||||
private final IMarketUserHierarchyService hierarchyService;
|
||||
|
||||
@Override
|
||||
public IPage<MarketInfoVO> selectMarketInfoPage(IPage<MarketInfoVO> page, MarketInfoVO marketInfo) {
|
||||
@@ -163,11 +165,12 @@ public class MarketInfoServiceImpl extends BaseServiceImpl<MarketInfoMapper, Mar
|
||||
marketInfo.setVerifiedDate(DateUtil.now());
|
||||
marketInfo.setVerified(1);
|
||||
if (updateById(marketInfo)) {
|
||||
List<Long> ids = selectAncestorIds(userId);
|
||||
hierarchyService.init(userId, ids);
|
||||
CacheUtil.evict(MARKET_INFO_CONFIG_CACHE, REAL_NAME, marketInfo.getId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.modules.market.mapper.MarketUserHierarchyMapper;
|
||||
import org.springblade.modules.market.pojo.entity.MarketUserHierarchyEntity;
|
||||
import org.springblade.modules.market.pojo.vo.MarketUserHierarchyVO;
|
||||
import org.springblade.modules.market.service.IMarketInfoService;
|
||||
import org.springblade.modules.market.service.IMarketUserHierarchyService;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -52,27 +51,24 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
public class MarketUserHierarchyServiceImpl extends BaseServiceImpl<MarketUserHierarchyMapper, MarketUserHierarchyEntity> implements IMarketUserHierarchyService {
|
||||
|
||||
private IMarketInfoService marketInfoService;
|
||||
|
||||
@Override
|
||||
public IPage<MarketUserHierarchyVO> selectHierarchyPage(IPage<MarketUserHierarchyVO> page, MarketUserHierarchyVO hierarchy) {
|
||||
return page.setRecords(baseMapper.selectHierarchyPage(page, hierarchy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Long userId) {
|
||||
public void init(Long userId, List<Long> parentsIds) {
|
||||
if (getById(userId) != null) {
|
||||
return;
|
||||
}
|
||||
List<Long> ids = marketInfoService.selectAncestorIds(userId);
|
||||
MarketUserHierarchyEntity hierarchy = new MarketUserHierarchyEntity();
|
||||
hierarchy.setId(userId);
|
||||
hierarchy.setRootId(userId);
|
||||
hierarchy.setLevel(ids.size() + 1);
|
||||
if (!ids.isEmpty()) {
|
||||
hierarchy.setPid(ids.get(0));
|
||||
hierarchy.setRootId(ids.get(ids.size() - 1));
|
||||
hierarchy.setAncestors(ids);
|
||||
hierarchy.setLevel(parentsIds.size() + 1);
|
||||
if (!parentsIds.isEmpty()) {
|
||||
hierarchy.setPid(parentsIds.get(0));
|
||||
hierarchy.setRootId(parentsIds.get(parentsIds.size() - 1));
|
||||
hierarchy.setAncestors(parentsIds);
|
||||
}
|
||||
try {
|
||||
save(hierarchy);
|
||||
|
||||
Reference in New Issue
Block a user