|
|
@@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.google.common.collect.ImmutableListMultimap; |
|
|
|
|
|
import com.google.common.collect.Multimaps; |
|
|
import com.iformall.domain.dto.InvestDemandDto; |
|
|
import com.iformall.domain.dto.InvestDemandDto; |
|
|
import com.iformall.domain.dto.InvestTaskDto; |
|
|
import com.iformall.domain.dto.InvestTaskDto; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.domain.po.invest.*; |
|
|
import com.iformall.domain.po.invest.*; |
|
|
import com.iformall.domain.vo.invest.*; |
|
|
import com.iformall.domain.vo.invest.*; |
|
|
|
|
|
import com.iformall.enums.EnumFollowType; |
|
|
import com.iformall.enums.EnumNegotiationType; |
|
|
import com.iformall.enums.EnumNegotiationType; |
|
|
import com.iformall.service.MallUserInfoService; |
|
|
import com.iformall.service.MallUserInfoService; |
|
|
import com.iformall.service.WxBrandService; |
|
|
import com.iformall.service.WxBrandService; |
|
|
@@ -19,6 +22,7 @@ import org.apache.commons.collections.MapUtils; |
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
@@ -38,6 +42,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private InvestFollowRecordService followRecordService; |
|
|
private InvestFollowRecordService followRecordService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private InvestOperateRecordService operateRecordService; |
|
|
|
|
|
@Autowired |
|
|
private InvestRemindService remindService; |
|
|
private InvestRemindService remindService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private WxShopService shopService; |
|
|
private WxShopService shopService; |
|
|
@@ -105,19 +111,18 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
shopParams = queryParams.getShop(); |
|
|
shopParams = queryParams.getShop(); |
|
|
taskParams = queryParams.getTask(); |
|
|
taskParams = queryParams.getTask(); |
|
|
} |
|
|
} |
|
|
LambdaQueryWrapper<InvestTaskEntity> taskQueryWrapper = null; |
|
|
|
|
|
|
|
|
LambdaQueryWrapper<InvestTaskEntity> taskQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>(); |
|
|
InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>(); |
|
|
if (Objects.nonNull(shopParams)) { |
|
|
if (Objects.nonNull(shopParams)) { |
|
|
Collection<WxShop> shops = shopService.selectList(new QueryWrapper<>(shopParams)); |
|
|
Collection<WxShop> shops = shopService.selectList(new QueryWrapper<>(shopParams)); |
|
|
if (CollectionUtils.isEmpty(shops)) { |
|
|
if (CollectionUtils.isEmpty(shops)) { |
|
|
return investPage; |
|
|
return investPage; |
|
|
} |
|
|
} |
|
|
taskQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); |
|
|
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()); |
|
|
|
|
|
|
|
|
if (Objects.nonNull(taskParams)) { |
|
|
|
|
|
taskQueryWrapper.apply(StringUtils.isNotEmpty(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner()); |
|
|
|
|
|
taskParams.setOwner(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper); |
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper); |
|
|
@@ -234,14 +239,63 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
remindVo.setOwnerInfo(usersMap.get(remindVo.getOwner())); |
|
|
remindVo.setOwnerInfo(usersMap.get(remindVo.getOwner())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(recordPage, investPage); |
|
|
BeanUtils.copyProperties(recordPage, investPage); |
|
|
investPage.setRecords(resultList); |
|
|
investPage.setRecords(resultList); |
|
|
investPage.setTotal(recordPage.getTotal()); |
|
|
|
|
|
|
|
|
|
|
|
return investPage; |
|
|
return investPage; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public InvestPageResult<InvestOperateRecordVo> queryPageOperateRecord(InvestOperateRecordQuery params) { |
|
|
|
|
|
InvestHelper.notNull(params, params.getReocrdType(), params.getTid()); |
|
|
|
|
|
LambdaQueryWrapper<InvestOperateRecordEntity> recordQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
InvestDemandEntity demandEntity = null; |
|
|
|
|
|
if (Objects.equals(params.getReocrdType(), EnumFollowType.DEMAND)) { |
|
|
|
|
|
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(params.getTid()); |
|
|
|
|
|
demandEntity = demandService.getOne(new LambdaQueryWrapper<InvestDemandEntity>().eq(InvestDemandEntity::getCustomerId, customerEntity.getId())); |
|
|
|
|
|
buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_CUSTOMER, customerEntity.getId()); |
|
|
|
|
|
} else if (Objects.equals(params.getReocrdType(), EnumFollowType.TASK)) { |
|
|
|
|
|
buildQueryWrapper(recordQueryWrapper, InvestOperateRecordEntity.TLB_TASK, params.getTid()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<InvestOperateRecordEntity> demandRecord = null; |
|
|
|
|
|
if (Objects.nonNull(demandEntity)) { |
|
|
|
|
|
LambdaQueryWrapper<InvestOperateRecordEntity> demandQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
buildQueryWrapper(demandQueryWrapper, InvestOperateRecordEntity.TLB_DEMAND, demandEntity.getId()); |
|
|
|
|
|
demandRecord = operateRecordService.list(demandQueryWrapper); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ImmutableListMultimap<Long, InvestOperateRecordEntity> demandRecordMap = getMultiMap(demandRecord); |
|
|
|
|
|
|
|
|
|
|
|
InvestPageResult<InvestOperateRecordEntity> recordPage = operateRecordService.queryPage(buildPageQuery(params, null), recordQueryWrapper); |
|
|
|
|
|
InvestPageResult<InvestOperateRecordVo> investPage = new InvestPageResult<>(); |
|
|
|
|
|
if (CollectionUtils.isNotEmpty(recordPage.getRecords())) { |
|
|
|
|
|
return investPage; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Collection<InvestOperateRecordVo> resultList = new ArrayList<>(); |
|
|
|
|
|
Collection<InvestOperateRecordEntity> primaryRecord = recordPage.getRecords(); |
|
|
|
|
|
for (InvestOperateRecordEntity recordEntity : primaryRecord) { |
|
|
|
|
|
InvestOperateRecordVo itemVo = new InvestOperateRecordVo(); |
|
|
|
|
|
BeanUtils.copyProperties(recordEntity, itemVo); |
|
|
|
|
|
List<TableTriple> record = JSONArray.parseArray(recordEntity.getContent(), TableTriple.class); |
|
|
|
|
|
//List<InvestOperateRecordEntity> innerRecord = demandRecordMap.get(recordEntity.get) ; |
|
|
|
|
|
itemVo.setRecord(record); |
|
|
|
|
|
resultList.add(itemVo) ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(recordPage, investPage); |
|
|
|
|
|
investPage.setRecords(resultList); |
|
|
|
|
|
return investPage; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void buildQueryWrapper(LambdaQueryWrapper<InvestOperateRecordEntity> wrapper, String tbl, Long tId) { |
|
|
|
|
|
if (ObjectUtils.allNotNull(tbl, tId)) { |
|
|
|
|
|
wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); |
|
|
|
|
|
wrapper.eq(InvestOperateRecordEntity::getTid, tId); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private List<MallUserInfo> getMallUserInfos(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item) { |
|
|
private List<MallUserInfo> getMallUserInfos(Map<Long, MallUserInfo> usersMap, InvestFollowRecordEntity item) { |
|
|
List<MallUserInfo> ownerInfo = null; |
|
|
List<MallUserInfo> ownerInfo = null; |
|
|
Map contentMap = JSON.parseObject(item.getContent(), Map.class); |
|
|
Map contentMap = JSON.parseObject(item.getContent(), Map.class); |
|
|
@@ -318,6 +372,12 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
return remindVo; |
|
|
return remindVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public InvestOperateRecordVo findOperateById(InvestOperateRecordQuery params) { |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public InvestFollowRecordVo findFollowRecordById(Long id) { |
|
|
public InvestFollowRecordVo findFollowRecordById(Long id) { |
|
|
InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); |
|
|
InvestFollowRecordEntity followRecordEntity = followRecordService.getByIdNotNull(id); |
|
|
@@ -430,6 +490,19 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
return function.apply(params); |
|
|
return function.apply(params); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private <T, R> ImmutableListMultimap<R, T> getMultiMap(Collection<T> dataList) { |
|
|
|
|
|
return Multimaps.index(dataList, new com.google.common.base.Function<T, R>() { |
|
|
|
|
|
@Nullable |
|
|
|
|
|
@Override |
|
|
|
|
|
public R apply(@Nullable T input) { |
|
|
|
|
|
if (input instanceof InvestBaseEntity) { |
|
|
|
|
|
return (R) ((InvestBaseEntity) input).getId(); |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) { |
|
|
private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) { |
|
|
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); |
|
|
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); |
|
|
} |
|
|
} |
|
|
|