|
|
@@ -64,7 +64,6 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
public InvestPageResult<InvestTaskVo> queryPageTask(InvestPageQuery<InvestTaskEntity> params) { |
|
|
public InvestPageResult<InvestTaskVo> queryPageTask(InvestPageQuery<InvestTaskEntity> params) { |
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(params); |
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(params); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>(); |
|
|
InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>(); |
|
|
if (CollectionUtils.isEmpty(taskPage.getRecords())) { |
|
|
if (CollectionUtils.isEmpty(taskPage.getRecords())) { |
|
|
return investPage; |
|
|
return investPage; |
|
|
@@ -75,10 +74,9 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
//2、目标信息 |
|
|
//2、目标信息 |
|
|
Collection<WxShop> shops = shopService.getByIds(taskList.stream().map(InvestTaskEntity::getTargetId).collect(Collectors.toList())); |
|
|
Collection<WxShop> shops = shopService.getByIds(taskList.stream().map(InvestTaskEntity::getTargetId).collect(Collectors.toList())); |
|
|
Map<Long, WxShop> shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); |
|
|
Map<Long, WxShop> shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); |
|
|
|
|
|
|
|
|
//3、用户信息 |
|
|
//3、用户信息 |
|
|
Collection<MallUserInfo> users = userInfoService.findList(null); |
|
|
|
|
|
Map<Long, MallUserInfo> usersMap = users.parallelStream().collect(Collectors.toMap(MallUserInfo::getId, MallUserInfo -> MallUserInfo)); |
|
|
|
|
|
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
|
|
|
|
|
List<InvestTaskVo> resultList = new ArrayList<>(); |
|
|
List<InvestTaskVo> resultList = new ArrayList<>(); |
|
|
for (InvestTaskEntity item : taskList) { |
|
|
for (InvestTaskEntity item : taskList) { |
|
|
WxShop shop = shopsMap.get(item.getTargetId()); |
|
|
WxShop shop = shopsMap.get(item.getTargetId()); |
|
|
@@ -91,48 +89,11 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
return investPage; |
|
|
return investPage; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private InvestTaskVo buildResultItem(InvestTaskEntity item, WxShop shop, Map<Long, MallUserInfo> usersMap) { |
|
|
|
|
|
List<MallUserInfo> ownerInfo = Lists.newArrayList(); |
|
|
|
|
|
List<Long> ownerList = JSON.parseArray(item.getOwner(), Long.class); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(ownerList)) { |
|
|
|
|
|
for (Long userId : ownerList) { |
|
|
|
|
|
ownerInfo.add(usersMap.get(userId)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
InvestTaskVo resultItemVo = InvestTaskVo.builder() |
|
|
|
|
|
.targetInfo(shop) |
|
|
|
|
|
.ownerInfo(ownerInfo) |
|
|
|
|
|
.build(); |
|
|
|
|
|
BeanUtils.copyProperties(item, resultItemVo); |
|
|
|
|
|
return resultItemVo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<InvestDemandVo> getITargeInfoList(IPage<InvestDemandEntity> demandPage) { |
|
|
|
|
|
List<InvestDemandEntity> demandList = demandPage.getRecords(); |
|
|
|
|
|
//2、客户信息 |
|
|
|
|
|
Collection<InvestCustomerEntity> customers = customerService.listByIds(demandList |
|
|
|
|
|
.stream().map(InvestDemandEntity::getCustomerId).collect(Collectors.toList())); |
|
|
|
|
|
Map<Long, InvestCustomerEntity> customersMap = customers.stream().collect(Collectors.toMap(InvestCustomerEntity::getId, customer -> customer)); |
|
|
|
|
|
|
|
|
|
|
|
//3、目标信息 |
|
|
|
|
|
Collection<WxShop> shops = shopService.getByIds(demandList.stream().map(InvestDemandEntity::getTargetId).collect(Collectors.toList())); |
|
|
|
|
|
Map<Long, WxShop> shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); |
|
|
|
|
|
|
|
|
|
|
|
//4 品牌 |
|
|
|
|
|
Collection<WxBrand> brands = brandService.getByIds(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); |
|
|
|
|
|
Map<Long, WxBrand> brandMap = brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); |
|
|
|
|
|
|
|
|
|
|
|
List<InvestDemandVo> resultList = new ArrayList<>(); |
|
|
|
|
|
for (InvestDemandEntity item : demandList) { |
|
|
|
|
|
InvestCustomerEntity customer = customersMap.get(item.getCustomerId()); |
|
|
|
|
|
WxShop shop = shopsMap.get(item.getTargetId()); |
|
|
|
|
|
WxBrand brand = null; |
|
|
|
|
|
if (Objects.nonNull(customer)) { |
|
|
|
|
|
brand = brandMap.get(customer.getBrandId()); |
|
|
|
|
|
} |
|
|
|
|
|
resultList.add(buildResultItem(item, customer, brand, shop)); |
|
|
|
|
|
} |
|
|
|
|
|
return resultList; |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<MallUserInfo> queryUserList() { |
|
|
|
|
|
MallUserInfo query = new MallUserInfo(); |
|
|
|
|
|
query.setIsAdmin(0); |
|
|
|
|
|
return userInfoService.findList(query); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@@ -160,8 +121,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public InvestDemandVo findById(Long id) { |
|
|
|
|
|
InvestHelper.allNotNull(id); |
|
|
|
|
|
|
|
|
public InvestDemandVo findDemandById(Long id) { |
|
|
InvestDemandEntity demandEntity = demandService.getByIdNotNull(id); |
|
|
InvestDemandEntity demandEntity = demandService.getByIdNotNull(id); |
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); |
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); |
|
|
WxBrand brand = brandService.getById(customerEntity.getBrandId()); |
|
|
WxBrand brand = brandService.getById(customerEntity.getBrandId()); |
|
|
@@ -169,6 +129,14 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
return buildResultItem(demandEntity, customerEntity, brand, shop); |
|
|
return buildResultItem(demandEntity, customerEntity, brand, shop); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public InvestTaskVo findTaskById(Long id) { |
|
|
|
|
|
InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); |
|
|
|
|
|
WxShop shop = shopService.getById(taskEntity.getTargetId()); |
|
|
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
|
|
return buildResultItem(taskEntity, shop, usersMap); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private InvestDemandVo buildResultItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop) { |
|
|
private InvestDemandVo buildResultItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop) { |
|
|
InvestDemandVo resultItemVo = InvestDemandVo.builder() |
|
|
InvestDemandVo resultItemVo = InvestDemandVo.builder() |
|
|
.brand(brand) |
|
|
.brand(brand) |
|
|
@@ -178,4 +146,53 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
BeanUtils.copyProperties(item, resultItemVo); |
|
|
BeanUtils.copyProperties(item, resultItemVo); |
|
|
return resultItemVo; |
|
|
return resultItemVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Map<Long, MallUserInfo> getUserInfoMap() { |
|
|
|
|
|
Collection<MallUserInfo> users = userInfoService.findList(null); |
|
|
|
|
|
return users.parallelStream().collect(Collectors.toMap(MallUserInfo::getId, MallUserInfo -> MallUserInfo)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private InvestTaskVo buildResultItem(InvestTaskEntity item, WxShop shop, Map<Long, MallUserInfo> usersMap) { |
|
|
|
|
|
List<MallUserInfo> ownerInfo = Lists.newArrayList(); |
|
|
|
|
|
List<Long> ownerList = JSON.parseArray(item.getOwner(), Long.class); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(ownerList)) { |
|
|
|
|
|
for (Long userId : ownerList) { |
|
|
|
|
|
ownerInfo.add(usersMap.get(userId)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
InvestTaskVo resultItemVo = InvestTaskVo.builder() |
|
|
|
|
|
.targetInfo(shop) |
|
|
|
|
|
.ownerInfo(ownerInfo) |
|
|
|
|
|
.build(); |
|
|
|
|
|
BeanUtils.copyProperties(item, resultItemVo); |
|
|
|
|
|
return resultItemVo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<InvestDemandVo> getITargeInfoList(IPage<InvestDemandEntity> demandPage) { |
|
|
|
|
|
List<InvestDemandEntity> demandList = demandPage.getRecords(); |
|
|
|
|
|
//2、客户信息 |
|
|
|
|
|
Collection<InvestCustomerEntity> customers = customerService.listByIds(demandList |
|
|
|
|
|
.stream().map(InvestDemandEntity::getCustomerId).collect(Collectors.toList())); |
|
|
|
|
|
Map<Long, InvestCustomerEntity> customersMap = customers.stream().collect(Collectors.toMap(InvestCustomerEntity::getId, customer -> customer)); |
|
|
|
|
|
|
|
|
|
|
|
//3、目标信息 |
|
|
|
|
|
Collection<WxShop> shops = shopService.getByIds(demandList.stream().map(InvestDemandEntity::getTargetId).collect(Collectors.toList())); |
|
|
|
|
|
Map<Long, WxShop> shopsMap = shops.stream().collect(Collectors.toMap(WxShop::getId, shop -> shop)); |
|
|
|
|
|
|
|
|
|
|
|
//4 品牌 |
|
|
|
|
|
Collection<WxBrand> brands = brandService.getByIds(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); |
|
|
|
|
|
Map<Long, WxBrand> brandMap = brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); |
|
|
|
|
|
|
|
|
|
|
|
List<InvestDemandVo> resultList = new ArrayList<>(); |
|
|
|
|
|
for (InvestDemandEntity item : demandList) { |
|
|
|
|
|
InvestCustomerEntity customer = customersMap.get(item.getCustomerId()); |
|
|
|
|
|
WxShop shop = shopsMap.get(item.getTargetId()); |
|
|
|
|
|
WxBrand brand = null; |
|
|
|
|
|
if (Objects.nonNull(customer)) { |
|
|
|
|
|
brand = brandMap.get(customer.getBrandId()); |
|
|
|
|
|
} |
|
|
|
|
|
resultList.add(buildResultItem(item, customer, brand, shop)); |
|
|
|
|
|
} |
|
|
|
|
|
return resultList; |
|
|
|
|
|
} |
|
|
} |
|
|
} |