|
|
|
@@ -10,10 +10,7 @@ import com.iformall.domain.po.*; |
|
|
|
import com.iformall.domain.po.invest.*; |
|
|
|
import com.iformall.domain.vo.invest.*; |
|
|
|
import com.iformall.enums.*; |
|
|
|
import com.iformall.service.MallUserInfoService; |
|
|
|
import com.iformall.service.WxBrandService; |
|
|
|
import com.iformall.service.WxRentContractService; |
|
|
|
import com.iformall.service.WxShopService; |
|
|
|
import com.iformall.service.*; |
|
|
|
import com.iformall.service.invest.*; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
@@ -26,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
@@ -54,10 +52,15 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
@Autowired |
|
|
|
private MallUserInfoService userInfoService; |
|
|
|
@Autowired |
|
|
|
private WxBusinessService businessService; |
|
|
|
@Autowired |
|
|
|
private WxRentContractService rentContractService; |
|
|
|
@Autowired |
|
|
|
private ExcelService excelService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) { |
|
|
|
InvestPageResult<InvestDemandVo> investPage = new InvestPageResult<>(); |
|
|
|
InvestDemandDto queryParams = convert(params, this::doConvertDemand); |
|
|
|
InvestCustomerEntity customerParams = null; |
|
|
|
InvestDemandEntity demandParams = null; |
|
|
|
@@ -65,10 +68,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
customerParams = queryParams.getCustomer(); |
|
|
|
demandParams = queryParams.getDemand(); |
|
|
|
} |
|
|
|
InvestPageResult<InvestDemandVo> investPage = new InvestPageResult<>(); |
|
|
|
List<InvestDemandEntity> demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); |
|
|
|
LambdaQueryWrapper<InvestCustomerEntity> queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams); |
|
|
|
InvestPageResult<InvestCustomerEntity> customers; |
|
|
|
if (Objects.isNull(InvestUserContext.getDataUser())) { |
|
|
|
queryWrapperCustomer.in(ObjectUtils.allNotNull(params.getDemandOwner()), |
|
|
|
InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); |
|
|
|
@@ -79,7 +80,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
queryWrapperCustomer.in(InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); |
|
|
|
} |
|
|
|
} |
|
|
|
customers = customerService.queryPage(buildPageQuery(params, null), queryWrapperCustomer); |
|
|
|
queryWrapperCustomer.orderByDesc(InvestCustomerEntity::getCreateDate); |
|
|
|
InvestPageResult<InvestCustomerEntity> customers = customerService.queryPage(buildPageQuery(params, null), queryWrapperCustomer); |
|
|
|
List<InvestDemandVo> resultList = getTargeInfoList(demandList, customers.getRecords()); |
|
|
|
BeanUtils.copyProperties(customers, investPage); |
|
|
|
investPage.setRecords(resultList); |
|
|
|
@@ -90,6 +92,35 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return investPage; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportCustomer(InvestDemandQuery params, HttpServletResponse response) { |
|
|
|
InvestDemandDto queryParams = convert(params, this::doConvertDemand); |
|
|
|
InvestCustomerEntity customerParams = null; |
|
|
|
InvestDemandEntity demandParams = null; |
|
|
|
if (Objects.nonNull(queryParams)) { |
|
|
|
customerParams = queryParams.getCustomer(); |
|
|
|
demandParams = queryParams.getDemand(); |
|
|
|
} |
|
|
|
List<InvestDemandEntity> demandList = demandService.list(new LambdaQueryWrapper<>(demandParams)); |
|
|
|
LambdaQueryWrapper<InvestCustomerEntity> queryWrapperCustomer = new LambdaQueryWrapper<>(customerParams); |
|
|
|
if (Objects.isNull(InvestUserContext.getDataUser())) { |
|
|
|
queryWrapperCustomer.in(ObjectUtils.allNotNull(params.getDemandOwner()), |
|
|
|
InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); |
|
|
|
} else { |
|
|
|
if (CollectionUtils.isNotEmpty(demandList)) { |
|
|
|
return; |
|
|
|
} else { |
|
|
|
queryWrapperCustomer.in(InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); |
|
|
|
} |
|
|
|
} |
|
|
|
queryWrapperCustomer.orderByDesc(InvestCustomerEntity::getCreateDate); |
|
|
|
Collection<InvestCustomerEntity> customers = customerService.list(queryWrapperCustomer); |
|
|
|
if (CollectionUtils.isNotEmpty(customers)) { |
|
|
|
List<InvestCustomerVo> resultList = getCustomerVOList(demandList, customers); |
|
|
|
excelService.exportExcel(resultList, null, "客户信息", InvestCustomerVo.class, "客户信息.xlsx", response, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<InvestDemandVo> queryCustomer() { |
|
|
|
List<InvestCustomerEntity> customerEntities = customerService.list(); |
|
|
|
@@ -140,7 +171,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
} |
|
|
|
taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); |
|
|
|
} |
|
|
|
|
|
|
|
taskQueryWrapper.orderByDesc(InvestTaskEntity::getCreateDate); |
|
|
|
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, null), taskQueryWrapper); |
|
|
|
if (CollectionUtils.isEmpty(taskPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
@@ -220,7 +251,6 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
followRecordEntity.setFollowId(params.getFollowId()); |
|
|
|
followRecordEntity.setType(params.getType()); |
|
|
|
InvestPageQuery<InvestFollowRecordEntity> pageQuery = buildPageQuery(params, followRecordEntity); |
|
|
|
|
|
|
|
InvestPageResult<InvestFollowRecordEntity> recordPage = followRecordService.queryPage(pageQuery); |
|
|
|
|
|
|
|
InvestPageResult<InvestFollowRecordVo> investPage = new InvestPageResult<>(); |
|
|
|
@@ -270,6 +300,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
LambdaQueryWrapper<InvestRemindEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
queryWrapper.ge(Objects.nonNull(params.getRemindDate()), InvestRemindEntity::getBeginDate, getDayStart(params.getRemindDate())); |
|
|
|
queryWrapper.le(Objects.nonNull(params.getRemindDate()), InvestRemindEntity::getEndDate, getDayEnd(params.getRemindDate())); |
|
|
|
queryWrapper.orderByDesc(InvestRemindEntity::getCreateDate); |
|
|
|
InvestPageResult<InvestRemindEntity> recordPage = remindService.queryPage(remindPageQuery, queryWrapper); |
|
|
|
if (CollectionUtils.isEmpty(recordPage.getRecords())) { |
|
|
|
return investPage; |
|
|
|
@@ -320,6 +351,8 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
InvestMessageEntity messageEntity = new InvestMessageEntity(); |
|
|
|
messageEntity.setOwner(InvestUserContext.getUserId()); |
|
|
|
query.setQueryData(messageEntity); |
|
|
|
query.setSortColumn("createDate"); |
|
|
|
query.setSortOrder("desc"); |
|
|
|
return messageService.queryPage(query); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -327,6 +360,7 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
if (ObjectUtils.allNotNull(tbl, tId)) { |
|
|
|
wrapper.eq(InvestOperateRecordEntity::getTbl, tbl); |
|
|
|
wrapper.eq(InvestOperateRecordEntity::getTid, tId); |
|
|
|
wrapper.orderByDesc(InvestOperateRecordEntity::getCreateDate); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -538,6 +572,31 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
return resultItemVo; |
|
|
|
} |
|
|
|
|
|
|
|
private InvestCustomerVo buildCustomerItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, |
|
|
|
WxShop shop, WxBusiness business) { |
|
|
|
InvestCustomerVo resultItemVo = new InvestCustomerVo(); |
|
|
|
BeanUtils.copyProperties(customer, resultItemVo); |
|
|
|
if (Objects.nonNull(brand)) { |
|
|
|
resultItemVo.setBrandName(brand.getName()); |
|
|
|
} |
|
|
|
if (Objects.nonNull(shop)) { |
|
|
|
resultItemVo.setShopNumber(shop.getShopNumber()); |
|
|
|
} |
|
|
|
if (Objects.nonNull(business)) { |
|
|
|
resultItemVo.setBusiness(business.getTitle()); |
|
|
|
} |
|
|
|
if (Objects.nonNull(item)) { |
|
|
|
resultItemVo.setDemandOwner(item.getOwner()); |
|
|
|
if (StringUtils.isNotBlank(item.getIntent())) { |
|
|
|
Map intentMap = JSON.parseObject(item.getIntent(), Map.class); |
|
|
|
resultItemVo.setRentArea(String.valueOf(intentMap.get(InvestDemandEntity.KEY_RENT_AREA))); |
|
|
|
resultItemVo.setOpeningTime(String.valueOf(intentMap.get(InvestDemandEntity.KEY_OPENING_TIME))); |
|
|
|
} |
|
|
|
} |
|
|
|
//resultItemVo.setBusiness(usersMap.get(item.getOwner())); |
|
|
|
return resultItemVo; |
|
|
|
} |
|
|
|
|
|
|
|
private InvestTaskVo buildTaskItem(InvestTaskEntity item, WxShop shop, Map<Long, MallUserInfo> usersMap) { |
|
|
|
List<MallUserInfo> ownerInfo = getMallUserInfos(item.getOwner(), usersMap); |
|
|
|
InvestTaskVo resultItemVo = new InvestTaskVo(); |
|
|
|
@@ -574,13 +633,40 @@ public class InvestBizServiceImpl implements InvestBizService { |
|
|
|
if (userId instanceof Long) { |
|
|
|
ownerInfo.add(usersMap.get(userId)); |
|
|
|
} else { |
|
|
|
ownerInfo.add(usersMap.get(Long.parseLong((String) userId))); |
|
|
|
String uId = (String) userId; |
|
|
|
if (StringUtils.isNotBlank(uId)) { |
|
|
|
ownerInfo.add(usersMap.get(Long.parseLong(uId))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return ownerInfo; |
|
|
|
} |
|
|
|
|
|
|
|
private List<InvestCustomerVo> getCustomerVOList(List<InvestDemandEntity> demandList, Collection<InvestCustomerEntity> customers) { |
|
|
|
Map<Long, InvestDemandEntity> demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId); |
|
|
|
|
|
|
|
//3、目标信息 |
|
|
|
Collection<WxShop> shops = shopService.getByIds(getIds(demandList, InvestDemandEntity::getTargetId)); |
|
|
|
Map<Long, WxShop> shopsMap = getMap(shops, WxShop::getId); |
|
|
|
|
|
|
|
//4、品牌 |
|
|
|
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); |
|
|
|
//5、用户 |
|
|
|
Map<Integer, WxBusiness> bussinessMap = getMap(businessService.getByIds(getIds(customers, InvestCustomerEntity::getBusinessId)), WxBusiness::getId); |
|
|
|
List<InvestCustomerVo> resultList = new ArrayList<>(); |
|
|
|
for (InvestCustomerEntity costomerItem : customers) { |
|
|
|
InvestDemandEntity demandItem = demindsMap.get(costomerItem.getId()); |
|
|
|
WxShop shop = null; |
|
|
|
if (Objects.nonNull(demandItem)) { |
|
|
|
shop = shopsMap.get(demandItem.getTargetId()); |
|
|
|
} |
|
|
|
WxBrand brand = brandMap.get(costomerItem.getBrandId()); |
|
|
|
resultList.add(buildCustomerItem(demandItem, costomerItem, brand, shop, bussinessMap.get(costomerItem.getBusinessId()))); |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
private List<InvestDemandVo> getTargeInfoList(List<InvestDemandEntity> demandList, Collection<InvestCustomerEntity> customers) { |
|
|
|
Map<Long, InvestDemandEntity> demindsMap = getMap(demandList, InvestDemandEntity::getCustomerId); |
|
|
|
|
|
|
|
|