|
|
|
@@ -3,14 +3,13 @@ package com.iformall.service.invest.impl; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.iformall.domain.dto.InvestDemandDto; |
|
|
|
import com.iformall.domain.dto.InvestTaskDto; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.domain.po.invest.InvestCustomerEntity; |
|
|
|
import com.iformall.domain.po.invest.InvestDemandEntity; |
|
|
|
import com.iformall.domain.po.invest.InvestFollowRecordEntity; |
|
|
|
import com.iformall.domain.po.invest.InvestTaskEntity; |
|
|
|
import com.iformall.domain.po.invest.*; |
|
|
|
import com.iformall.domain.vo.invest.*; |
|
|
|
import com.iformall.enums.EnumNegotiationType; |
|
|
|
import com.iformall.service.MallUserInfoService; |
|
|
|
import com.iformall.service.WxBrandService; |
|
|
|
import com.iformall.service.WxShopService; |
|
|
|
@@ -18,15 +17,15 @@ import com.iformall.service.invest.*; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.apache.commons.collections.MapUtils; |
|
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.io.Serializable; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
@@ -38,6 +37,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
@Autowired |
|
|
|
private InvestFollowRecordService followRecordService; |
|
|
|
@Autowired |
|
|
|
private InvestRemindService remindService; |
|
|
|
@Autowired |
|
|
|
private WxShopService shopService; |
|
|
|
@Autowired |
|
|
|
private InvestCustomerService customerService; |
|
|
|
@@ -47,49 +48,87 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
private MallUserInfoService userInfoService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestPageResult<InvestDemandVo> queryPageDemand(InvestPageQuery<InvestDemandDto> params) { |
|
|
|
InvestHelper.notNull(params); |
|
|
|
InvestDemandDto queryParams = params.getQueryData(); |
|
|
|
public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) { |
|
|
|
InvestDemandDto queryParams = convert(params, this::doConvertDemand); |
|
|
|
InvestCustomerEntity customerParams = null; |
|
|
|
InvestDemandEntity demandParams = null; |
|
|
|
if (Objects.nonNull(queryParams)) { |
|
|
|
customerParams = queryParams.getCustomer(); |
|
|
|
demandParams = queryParams.getDemand(); |
|
|
|
} |
|
|
|
|
|
|
|
InvestPageResult<InvestDemandVo> investPage = new InvestPageResult<>(); |
|
|
|
InvestPageResult<InvestCustomerEntity> customerPage = customerService.queryPage( |
|
|
|
new InvestPageQuery<>(Objects.isNull(queryParams) ? null : queryParams.getCustomer())); |
|
|
|
if (CollectionUtils.isEmpty(customerPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
|
|
|
|
LambdaQueryWrapper<InvestDemandEntity> queryWrapperDemand = null; |
|
|
|
if (Objects.nonNull(customerParams)) { |
|
|
|
Collection<InvestCustomerEntity> customers = customerService.list(new QueryWrapper<>(customerParams)); |
|
|
|
if (CollectionUtils.isEmpty(customers)) { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
queryWrapperDemand = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapperDemand.in(InvestDemandEntity::getId, getIds(customers, InvestCustomerEntity::getId)); |
|
|
|
} |
|
|
|
LambdaQueryWrapper<InvestDemandEntity> queryWrapperDemand = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapperDemand.in(InvestDemandEntity::getCustomerId, customerPage.getRecords().stream().map(InvestCustomerEntity::getId).collect(Collectors.toList())); |
|
|
|
InvestPageResult<InvestDemandEntity> demandPage = demandService.queryPage(new InvestPageQuery<>(Objects.isNull(queryParams) ? null : queryParams.getDemand()), queryWrapperDemand); |
|
|
|
|
|
|
|
InvestPageResult<InvestDemandEntity> demandPage = demandService.queryPage(buildPageQuery(params, demandParams), queryWrapperDemand); |
|
|
|
if (CollectionUtils.isEmpty(demandPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
List<InvestDemandVo> resultList = getTargeInfoList(demandPage, customerPage.getRecords()); |
|
|
|
List<InvestDemandVo> resultList = getTargeInfoList(demandPage); |
|
|
|
BeanUtils.copyProperties(demandPage, investPage); |
|
|
|
investPage.setRecords(resultList); |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
private InvestDemandDto doConvertDemand(InvestDemandQuery params) { |
|
|
|
InvestCustomerEntity customerEntity = new InvestCustomerEntity(); |
|
|
|
customerEntity.setId(params.getCustomerId()); |
|
|
|
customerEntity.setType(params.getCustomerType()); |
|
|
|
customerEntity.setBusinessId(params.getBusinessId()); |
|
|
|
|
|
|
|
InvestDemandEntity demandEntity = new InvestDemandEntity(); |
|
|
|
demandEntity.setOwner(params.getOwner()); |
|
|
|
|
|
|
|
InvestDemandDto demandDto = new InvestDemandDto(); |
|
|
|
demandDto.setCustomer(customerEntity); |
|
|
|
demandDto.setDemand(demandEntity); |
|
|
|
return demandDto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestPageResult<InvestTaskVo> queryPageTask(InvestPageQuery<InvestTaskDto> params) { |
|
|
|
InvestTaskDto queryParams = params.getQueryData(); |
|
|
|
InvestTaskEntity queryTask = null; |
|
|
|
public InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params) { |
|
|
|
InvestTaskDto queryParams = convert(params, this::doConvertTask); |
|
|
|
InvestTaskEntity taskParams = null; |
|
|
|
WxShop shopParams = null; |
|
|
|
if (Objects.nonNull(queryParams)) { |
|
|
|
queryTask = new InvestTaskEntity(); |
|
|
|
shopParams = queryParams.getShop(); |
|
|
|
taskParams = queryParams.getTask(); |
|
|
|
} |
|
|
|
|
|
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(new InvestPageQuery<>(queryTask)); |
|
|
|
|
|
|
|
LambdaQueryWrapper<InvestTaskEntity> taskQueryWrapper = null; |
|
|
|
InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>(); |
|
|
|
if (Objects.nonNull(shopParams)) { |
|
|
|
Collection<WxShop> shops = shopService.selectList(new QueryWrapper<>(shopParams)); |
|
|
|
if (CollectionUtils.isEmpty(shops)) { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
taskQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); |
|
|
|
} |
|
|
|
if (Objects.nonNull(taskQueryWrapper) && Objects.nonNull(taskParams)) { |
|
|
|
taskQueryWrapper.eq(InvestTaskEntity::getOwner, taskParams.getOwner()); |
|
|
|
taskQueryWrapper.apply(StringUtils.isNoneEmpty(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner()); |
|
|
|
} |
|
|
|
|
|
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper); |
|
|
|
if (CollectionUtils.isEmpty(taskPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
List<InvestTaskEntity> taskList = taskPage.getRecords(); |
|
|
|
Collection<InvestTaskEntity> taskList = taskPage.getRecords(); |
|
|
|
//2、目标信息 |
|
|
|
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)); |
|
|
|
Collection<WxShop> shops = shopService.getByIds(getIds(taskList, InvestTaskEntity::getTargetId)); |
|
|
|
Map<Long, WxShop> shopsMap = getMap(shops, WxShop::getId); |
|
|
|
//3、用户信息 |
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); |
|
|
|
List<InvestTaskVo> resultList = new ArrayList<>(); |
|
|
|
for (InvestTaskEntity item : taskList) { |
|
|
|
WxShop shop = shopsMap.get(item.getTargetId()); |
|
|
|
@@ -97,10 +136,26 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
} |
|
|
|
BeanUtils.copyProperties(taskPage, investPage); |
|
|
|
investPage.setRecords(resultList); |
|
|
|
investPage.setTotal(taskPage.getTotal()); |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private InvestTaskDto doConvertTask(InvestTaskQuery params) { |
|
|
|
InvestTaskEntity task = new InvestTaskEntity(); |
|
|
|
task.setOwner(params.getTaskOwner()); |
|
|
|
task.setStatus(params.getTaskStatus()); |
|
|
|
|
|
|
|
WxShop shop = new WxShop(); |
|
|
|
shop.setShopNumber(params.getShopNumber()); |
|
|
|
shop.setStatus(params.getShopStatus()); |
|
|
|
shop.setBusinessId(params.getBusinessId()); |
|
|
|
|
|
|
|
InvestTaskDto taskDto = new InvestTaskDto(); |
|
|
|
taskDto.setShop(shop); |
|
|
|
taskDto.setTask(task); |
|
|
|
return taskDto; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestPageResult<InvestFollowRecordVo> queryPageFollowRecord(InvestPageQuery<InvestFollowRecordEntity> params) { |
|
|
|
InvestPageResult<InvestFollowRecordEntity> recordPage = followRecordService.queryPage(params); |
|
|
|
@@ -110,16 +165,16 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
List<InvestFollowRecordEntity> recordList = recordPage.getRecords(); |
|
|
|
Collection<InvestFollowRecordEntity> recordList = recordPage.getRecords(); |
|
|
|
|
|
|
|
//2、用户信息 |
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); |
|
|
|
|
|
|
|
//3、客户 |
|
|
|
Collection<InvestCustomerEntity> customers = getCustomers(recordList.stream().map(InvestFollowRecordEntity::getCustomerId)); |
|
|
|
Map<Long, InvestCustomerEntity> customerMap = getCustomerMap(customers); |
|
|
|
Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(recordList, InvestFollowRecordEntity::getCustomerId)); |
|
|
|
Map<Long, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getId); |
|
|
|
//4、 品牌 |
|
|
|
Map<Long, WxBrand> brandMap = getBrandMap(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); |
|
|
|
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); |
|
|
|
|
|
|
|
List<InvestFollowRecordVo> resultList = new ArrayList<>(); |
|
|
|
for (InvestFollowRecordEntity item : recordList) { |
|
|
|
@@ -128,15 +183,63 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
resultList.add(buildFollowRecordItem(usersMap, item, customerEntity, brand)); |
|
|
|
} |
|
|
|
|
|
|
|
BeanUtils.copyProperties(recordPage, investPage); |
|
|
|
investPage.setRecords(resultList); |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestPageResult<InvestRemindVo> queryPageRemind(InvestPageQuery<InvestRemindEntity> params) { |
|
|
|
InvestHelper.notNull(params); |
|
|
|
InvestPageResult<InvestRemindVo> investPage = new InvestPageResult<>(); |
|
|
|
InvestPageResult<InvestRemindEntity> recordPage = remindService.queryPage(params); |
|
|
|
if (CollectionUtils.isEmpty(recordPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
Collection<InvestRemindEntity> recordList = recordPage.getRecords(); |
|
|
|
Collection<InvestRemindVo> resultList = Collections.emptyList(); |
|
|
|
for (InvestRemindEntity investRemindEntity : recordList) { |
|
|
|
InvestRemindVo remindVo = new InvestRemindVo(); |
|
|
|
BeanUtils.copyProperties(investRemindEntity, remindVo); |
|
|
|
HashMap contentMap = JSON.parseObject(investRemindEntity.getContent(), HashMap.class); |
|
|
|
if (MapUtils.isNotEmpty(contentMap)) { |
|
|
|
Object customerId = contentMap.get(InvestRemindEntity.KEY_CUSTOMER); |
|
|
|
remindVo.setCustomerId(Objects.isNull(customerId) ? null : Long.parseLong((String) customerId)); |
|
|
|
Object negotiationType = contentMap.get(InvestRemindEntity.KEY_NEGOTIATIONTYPE); |
|
|
|
remindVo.setNegotiationType(EnumNegotiationType.getEnum(Integer.valueOf((String) negotiationType))); |
|
|
|
} |
|
|
|
resultList.add(remindVo); |
|
|
|
} |
|
|
|
|
|
|
|
//2、用户信息 |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestRemindEntity::getOwner)), MallUserInfo::getId); |
|
|
|
|
|
|
|
//3、客户 |
|
|
|
Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(resultList, InvestRemindVo::getCustomerId)); |
|
|
|
Map<Long, InvestCustomerEntity> customerMap = getMap(customers, InvestCustomerEntity::getId); |
|
|
|
//4、 品牌 |
|
|
|
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); |
|
|
|
|
|
|
|
for (InvestRemindVo remindVo : resultList) { |
|
|
|
InvestCustomerEntity customerEntity = customerMap.get(remindVo.getCustomerId()); |
|
|
|
if (Objects.nonNull(customerEntity)) { |
|
|
|
remindVo.setCustomer(customerEntity); |
|
|
|
remindVo.setBrand(brandMap.get(customerEntity.getBrandId())); |
|
|
|
} |
|
|
|
remindVo.setOwnerInfo(usersMap.get(remindVo.getOwner())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(recordPage, investPage); |
|
|
|
investPage.setRecords(resultList); |
|
|
|
investPage.setTotal(recordPage.getTotal()); |
|
|
|
|
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
private List<MallUserInfo> getMallUserInfos(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item) { |
|
|
|
List<MallUserInfo> ownerInfo = null ; |
|
|
|
Map contentMap = JSON.parseObject(item.getContent(),Map.class); |
|
|
|
List<MallUserInfo> ownerInfo = null; |
|
|
|
HashMap contentMap = JSON.parseObject(item.getContent(), HashMap.class); |
|
|
|
if (MapUtils.isNotEmpty(contentMap)) { |
|
|
|
Object followMember = contentMap.get(InvestFollowRecordEntity.KEY_MEMBER); |
|
|
|
ownerInfo = getMallUserInfos(followMember, usersMap); |
|
|
|
@@ -172,7 +275,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
public boolean updateCustomerAndDemand(InvestDemandDto demandDto) { |
|
|
|
InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); |
|
|
|
customerService.updateById(demandDto.getCustomer()); |
|
|
|
InvestDemandEntity demandEntity = demandDto.getDemand() ; |
|
|
|
InvestDemandEntity demandEntity = demandDto.getDemand(); |
|
|
|
demandEntity.setCustomerId(demandDto.getCustomer().getId()); |
|
|
|
return demandService.updateById(demandEntity); |
|
|
|
} |
|
|
|
@@ -183,28 +286,29 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId()); |
|
|
|
WxBrand brand = brandService.getById(customerEntity.getBrandId()); |
|
|
|
WxShop shop = shopService.getById(demandEntity.getTargetId()); |
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
return buildDemindItem(demandEntity, customerEntity, brand, shop,usersMap); |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); |
|
|
|
return buildDemindItem(demandEntity, customerEntity, brand, shop, usersMap); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestTaskVo findTaskById(Long id) { |
|
|
|
InvestTaskEntity taskEntity = taskService.getByIdNotNull(id); |
|
|
|
WxShop shop = shopService.getById(taskEntity.getTargetId()); |
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); |
|
|
|
return buildTaskItem(taskEntity, shop, usersMap); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestFollowRecordVo findFollowRecordById(Long id) { |
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); |
|
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(followRecordEntity.getCustomerId()); |
|
|
|
WxBrand brand = brandService.getById(customerEntity.getBrandId()); |
|
|
|
return buildFollowRecordItem(usersMap, followRecordEntity, customerEntity, brand); |
|
|
|
} |
|
|
|
|
|
|
|
private InvestFollowRecordVo buildFollowRecordItem(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item, InvestCustomerEntity customerEntity, WxBrand brand) { |
|
|
|
private InvestFollowRecordVo buildFollowRecordItem(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item, |
|
|
|
InvestCustomerEntity customerEntity, WxBrand brand) { |
|
|
|
List<MallUserInfo> ownerInfo = getMallUserInfos(usersMap, item); |
|
|
|
InvestFollowRecordVo followRecordVo = new InvestFollowRecordVo(); |
|
|
|
followRecordVo.setCustomer(customerEntity); |
|
|
|
@@ -215,7 +319,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return followRecordVo; |
|
|
|
} |
|
|
|
|
|
|
|
private InvestDemandVo buildDemindItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop, Map<Long, MallUserInfo> usersMap) { |
|
|
|
private InvestDemandVo buildDemindItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, |
|
|
|
WxShop shop, Map<Long, MallUserInfo> usersMap) { |
|
|
|
InvestDemandVo resultItemVo = new InvestDemandVo(); |
|
|
|
resultItemVo.setBrand(brand); |
|
|
|
resultItemVo.setCustomer(customer); |
|
|
|
@@ -225,11 +330,6 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
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 buildTaskItem(InvestTaskEntity item, WxShop shop, Map<Long, MallUserInfo> usersMap) { |
|
|
|
List<MallUserInfo> ownerInfo = getMallUserInfos(item.getOwner(), usersMap); |
|
|
|
InvestTaskVo resultItemVo = new InvestTaskVo(); |
|
|
|
@@ -242,8 +342,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
private List<MallUserInfo> getMallUserInfos(Object userJson, Map<Long, MallUserInfo> usersMap) { |
|
|
|
List<MallUserInfo> ownerInfo = Lists.newArrayList(); |
|
|
|
JSONArray ownerList; |
|
|
|
if(userJson instanceof String) { |
|
|
|
ownerList = JSONArray.parseArray((String)userJson); |
|
|
|
if (userJson instanceof String) { |
|
|
|
ownerList = JSONArray.parseArray((String) userJson); |
|
|
|
} else { |
|
|
|
ownerList = (JSONArray) userJson; |
|
|
|
} |
|
|
|
@@ -255,18 +355,19 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return ownerInfo; |
|
|
|
} |
|
|
|
|
|
|
|
private List<InvestDemandVo> getTargeInfoList(InvestPageResult<InvestDemandEntity> demandPage, List<InvestCustomerEntity> customers) { |
|
|
|
List<InvestDemandEntity> demandList = demandPage.getRecords(); |
|
|
|
Map<Long, InvestCustomerEntity> customersMap = getCustomerMap(customers); |
|
|
|
private List<InvestDemandVo> getTargeInfoList(InvestPageResult<InvestDemandEntity> demandPage) { |
|
|
|
Collection<InvestDemandEntity> demandList = demandPage.getRecords(); |
|
|
|
Collection<InvestCustomerEntity> customers = customerService.listByIds(getIds(demandList, InvestDemandEntity::getCustomerId)); |
|
|
|
Map<Long, InvestCustomerEntity> customersMap = getMap(customers, InvestCustomerEntity::getId); |
|
|
|
|
|
|
|
//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)); |
|
|
|
Collection<WxShop> shops = shopService.getByIds(getIds(demandList, InvestDemandEntity::getTargetId)); |
|
|
|
Map<Long, WxShop> shopsMap = getMap(shops, WxShop::getId); |
|
|
|
|
|
|
|
//4、品牌 |
|
|
|
Map<Long, WxBrand> brandMap = getBrandMap(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList())); |
|
|
|
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); |
|
|
|
//5、用户 |
|
|
|
Map<Long, MallUserInfo> usersMap = getUserInfoMap(); |
|
|
|
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); |
|
|
|
|
|
|
|
List<InvestDemandVo> resultList = new ArrayList<>(); |
|
|
|
for (InvestDemandEntity item : demandList) { |
|
|
|
@@ -281,17 +382,25 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long, WxBrand> getBrandMap(Collection<? extends Serializable> ids) { |
|
|
|
Collection<WxBrand> brands = brandService.getByIds(ids); |
|
|
|
return brands.stream().collect(Collectors.toMap(WxBrand::getId, brand -> brand)); |
|
|
|
private <T> InvestPageQuery<T> buildPageQuery(InvestPageQuery params, T t) { |
|
|
|
InvestPageQuery<T> pageQuery = new InvestPageQuery<>(); |
|
|
|
BeanUtils.copyProperties(params, pageQuery); |
|
|
|
if (Objects.nonNull(t)) { |
|
|
|
pageQuery.setQueryData(t); |
|
|
|
} |
|
|
|
return pageQuery; |
|
|
|
} |
|
|
|
|
|
|
|
public <R, T> R convert(T params, Function<T, R> function) { |
|
|
|
InvestHelper.notNull(params); |
|
|
|
return function.apply(params); |
|
|
|
} |
|
|
|
|
|
|
|
private Map<Long, InvestCustomerEntity> getCustomerMap(Collection<InvestCustomerEntity> customers) { |
|
|
|
return customers.stream().collect(Collectors.toMap(InvestCustomerEntity::getId, customer -> customer)); |
|
|
|
private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) { |
|
|
|
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); |
|
|
|
} |
|
|
|
|
|
|
|
private Collection<InvestCustomerEntity> getCustomers(Stream<Long> longStream) { |
|
|
|
return customerService.listByIds(longStream.collect(Collectors.toList())); |
|
|
|
private <T, R> Collection<R> getIds(Collection<T> dataList, Function<? super T, R> mapper) { |
|
|
|
return dataList.parallelStream().map(mapper).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |