Browse Source

[招商]adjust

release_toaliyun_real
Burce 6 years ago
parent
commit
c8aee031e5
10 changed files with 125 additions and 45 deletions
  1. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java
  2. +3
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestFollowRecordController.java
  3. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestRemindController.java
  4. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java
  5. +13
    -1
      mallinkService/src/main/java/com/iformall/domain/po/InvestFollowRecordEntity.java
  6. +4
    -1
      mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java
  7. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java
  8. +4
    -4
      mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java
  9. +90
    -39
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java
  10. +2
    -0
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java

+ 2
- 0
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestDemandController.java View File

@@ -11,6 +11,7 @@ import com.iformall.service.invest.InvestDemandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -39,6 +40,7 @@ public class InvestDemandController extends InvestBaseController {
/**
* 分页列表
*/
@RequiresPermissions("investTaskEdit")
@SystemServiceLog
@ApiOperation(value = "分页列表接口")
@GetMapping("/list")


+ 3
- 0
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestFollowRecordController.java View File

@@ -4,6 +4,7 @@ import com.iformall.common.InvestResultData;
import com.iformall.domain.po.InvestFollowRecordEntity;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.service.invest.InvestBizService;
import com.iformall.service.invest.InvestFollowRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -29,6 +30,8 @@ import java.util.Arrays;
public class InvestFollowRecordController extends InvestBaseController {
@Autowired
private InvestFollowRecordService investFollowRecordService;
@Autowired
private InvestBizService bizService ;

/**
* 分页列表


+ 2
- 0
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestRemindController.java View File

@@ -8,6 +8,7 @@ import com.iformall.service.invest.InvestRemindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -52,6 +53,7 @@ public class InvestRemindController extends InvestBaseController {
/**
* 保存
*/
@RequiresPermissions("investFollowRecordEdit")
@PostMapping("/save")
public InvestResultData save(@RequestBody InvestRemindEntity investRemind) {
return execute(investRemind, p -> investRemindService.save(p));


+ 2
- 0
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestTaskController.java View File

@@ -11,6 +11,7 @@ import com.iformall.service.invest.InvestTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@@ -57,6 +58,7 @@ public class InvestTaskController extends InvestBaseController {
/**
* 保存
*/
@RequiresPermissions("investTaskEdit")
@SystemServiceLog
@PostMapping("/save")
public InvestResultData save(@RequestBody InvestTaskEntity investTask) {


+ 13
- 1
mallinkService/src/main/java/com/iformall/domain/po/InvestFollowRecordEntity.java View File

@@ -30,7 +30,14 @@ public class InvestFollowRecordEntity extends InvestBaseEntity {
/**
* 洽谈内容
*/
@io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content")
@io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content",example = "{\n" +
" \"date\": \"2019-09-10 20:12:20\",\n" +
" \"address\": \"北京三里屯\",\n" +
" \"text\": \"今天约了王老板,目标要签订框架协议\",\n" +
" \"document\": [\"url1\",\"url2\"],\n" +
" \"member\": [id1,id2,id3],\n" +
" \"negotiationType\": 1\n" +
"}")
private String content;
/**
* 跟踪类型:0-招商任务;1-客户需求
@@ -44,4 +51,9 @@ public class InvestFollowRecordEntity extends InvestBaseEntity {
@io.swagger.annotations.ApiModelProperty(value = "跟踪类型的主键ID", name = "followId")
private Long followId;

/**
* 操作人
*/
@io.swagger.annotations.ApiModelProperty(value = "操作人", name = "followId")
private Long operator;
}

+ 4
- 1
mallinkService/src/main/java/com/iformall/domain/po/InvestTaskEntity.java View File

@@ -45,7 +45,10 @@ public class InvestTaskEntity extends InvestBaseEntity {
/**
* 任务设定条件
*/
@io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content")
@io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content",example = "{\n" +
" \"business\": 1,\n" +
" \"lastDate\": \"2018-10-01 12:18:48\"\n" +
"}")
private String content;

/**


+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandVo.java View File

@@ -2,6 +2,7 @@ package com.iformall.domain.vo.invest;

import com.iformall.domain.po.InvestCustomerEntity;
import com.iformall.domain.po.InvestDemandEntity;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.WxBrand;
import lombok.Builder;
import lombok.Data;
@@ -14,5 +15,7 @@ public class InvestDemandVo<T> extends InvestDemandEntity {

private WxBrand brand;

private MallUserInfo ownerInfo;

private T targetInfo;
}

+ 4
- 4
mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java View File

@@ -1,12 +1,10 @@
package com.iformall.service.invest;

import com.iformall.domain.po.InvestDemandEntity;
import com.iformall.domain.po.InvestFollowRecordEntity;
import com.iformall.domain.po.InvestTaskEntity;
import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.vo.invest.InvestDemandVo;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.domain.vo.invest.InvestTaskVo;
import com.iformall.domain.vo.invest.*;

import java.util.List;

@@ -16,6 +14,8 @@ public interface InvestBizService {

InvestPageResult<InvestTaskVo> queryPageTask(InvestPageQuery<InvestTaskEntity> params);

InvestPageResult<InvestFollowRecordVo> queryPageFollowRecord(InvestPageQuery<InvestFollowRecordEntity> params);

List<MallUserInfo> queryUserList() ;

boolean saveCustomerAndDemand(InvestDemandVo customerDemandVo) ;


+ 90
- 39
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java View File

@@ -1,14 +1,8 @@
package com.iformall.service.invest.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.invest.InvestDemandVo;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.domain.vo.invest.InvestTaskVo;
import com.iformall.domain.vo.invest.*;
import com.iformall.service.MallUserInfoService;
import com.iformall.service.WxBrandService;
import com.iformall.service.WxShopService;
@@ -20,8 +14,10 @@ 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.stream.Collectors;
import java.util.stream.Stream;

@Service
public class InvestBizServiceImpl implements InvestBizService {
@@ -31,6 +27,8 @@ public class InvestBizServiceImpl implements InvestBizService {
@Autowired
private InvestTaskService taskService;
@Autowired
private InvestFollowRecordService followRecordService;
@Autowired
private WxShopService shopService;
@Autowired
private InvestCustomerService customerService;
@@ -41,19 +39,12 @@ public class InvestBizServiceImpl implements InvestBizService {

@Override
public InvestPageResult<InvestDemandVo> queryPageDemand(InvestPageQuery<InvestDemandEntity> params) {
InvestHelper.allNotNull(params);
Page<InvestDemandEntity> page = InvestHelper.buildQueryPage(params);
InvestPageResult<InvestDemandEntity> demandPage = demandService.queryPage(params);
InvestPageResult<InvestDemandVo> investPage = new InvestPageResult<>();
//1、客户需求
InvestDemandEntity queryTask = params.getQueryData();
LambdaQueryWrapper<InvestDemandEntity> queryWrapper = new LambdaQueryWrapper<>(queryTask);
IPage<InvestDemandEntity> demandPage = demandService.page(page, queryWrapper);
if (CollectionUtils.isEmpty(demandPage.getRecords())) {
return investPage;
}

List<InvestDemandVo> resultList = getITargeInfoList(demandPage);

List<InvestDemandVo> resultList = getTargeInfoList(demandPage);
BeanUtils.copyProperties(demandPage, investPage);
investPage.setRecords(resultList);
return investPage;
@@ -70,25 +61,64 @@ public class InvestBizServiceImpl implements InvestBizService {
}

List<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));
//3、用户信息
Map<Long, MallUserInfo> usersMap = getUserInfoMap();

List<InvestTaskVo> resultList = new ArrayList<>();
for (InvestTaskEntity item : taskList) {
WxShop shop = shopsMap.get(item.getTargetId());
resultList.add(buildResultItem(item, shop, usersMap));
resultList.add(buildTaskItem(item, shop, usersMap));
}

BeanUtils.copyProperties(taskPage, investPage);
investPage.setRecords(resultList);
investPage.setTotal(taskPage.getTotal());
return investPage;
}

@Override
public InvestPageResult<InvestFollowRecordVo> queryPageFollowRecord(InvestPageQuery<InvestFollowRecordEntity> params) {
InvestPageResult<InvestFollowRecordEntity> recordPage = followRecordService.queryPage(params);

InvestPageResult<InvestFollowRecordVo> investPage = new InvestPageResult<>();
if (CollectionUtils.isEmpty(recordPage.getRecords())) {
return investPage;
}

List<InvestFollowRecordEntity> recordList = recordPage.getRecords();

//2、用户信息
Map<Long, MallUserInfo> usersMap = getUserInfoMap();

//3、客户
Collection<InvestCustomerEntity> customers = getCustomers(recordList.stream().map(InvestFollowRecordEntity::getCustomerId));
Map<Long, InvestCustomerEntity> customerMap = getCustomerMap(customers);
//4、 品牌
Map<Long, WxBrand> brandMap = getBrandMap(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList()));

List<InvestFollowRecordVo> resultList = new ArrayList<>();
for (InvestFollowRecordEntity item : recordList) {
InvestCustomerEntity customerEntity = customerMap.get(item.getCustomerId());
WxBrand brand = brandMap.get(customerEntity.getBrandId());
Map<String, Object> followContent = (Map<String, Object>) JSON.parseObject(item.getContent(), Map.class);
String followMember = (String) followContent.get("member");
List<MallUserInfo> ownerInfo = getMallUserInfos(followMember, usersMap);
InvestFollowRecordVo followRecordVo = InvestFollowRecordVo.builder()
.customer(customerEntity)
.memberInfo(ownerInfo)
.brand(brand).build();
followRecordVo.setOwnerInfo(usersMap.get(item.getOwner()));
BeanUtils.copyProperties(item, followRecordVo);
resultList.add(followRecordVo);
}

BeanUtils.copyProperties(recordPage, investPage);
investPage.setRecords(resultList);
investPage.setTotal(recordPage.getTotal());
return investPage;
}

@Override
public List<MallUserInfo> queryUserList() {
MallUserInfo query = new MallUserInfo();
@@ -126,7 +156,8 @@ public class InvestBizServiceImpl implements InvestBizService {
InvestCustomerEntity customerEntity = customerService.getByIdNotNull(demandEntity.getCustomerId());
WxBrand brand = brandService.getById(customerEntity.getBrandId());
WxShop shop = shopService.getById(demandEntity.getTargetId());
return buildResultItem(demandEntity, customerEntity, brand, shop);
Map<Long, MallUserInfo> usersMap = getUserInfoMap();
return buildDemindItem(demandEntity, customerEntity, brand, shop,usersMap);
}

@Override
@@ -134,14 +165,15 @@ public class InvestBizServiceImpl implements InvestBizService {
InvestTaskEntity taskEntity = taskService.getByIdNotNull(id);
WxShop shop = shopService.getById(taskEntity.getTargetId());
Map<Long, MallUserInfo> usersMap = getUserInfoMap();
return buildResultItem(taskEntity, shop, usersMap);
return buildTaskItem(taskEntity, shop, usersMap);
}

private InvestDemandVo buildResultItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop) {
private InvestDemandVo buildDemindItem(InvestDemandEntity item, InvestCustomerEntity customer, WxBrand brand, WxShop shop, Map<Long, MallUserInfo> usersMap) {
InvestDemandVo resultItemVo = InvestDemandVo.builder()
.brand(brand)
.customer(customer)
.targetInfo(shop)
.ownerInfo(usersMap.get(item.getOwner()))
.build();
BeanUtils.copyProperties(item, resultItemVo);
return resultItemVo;
@@ -152,14 +184,8 @@ public class InvestBizServiceImpl implements InvestBizService {
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));
}
}
private InvestTaskVo buildTaskItem(InvestTaskEntity item, WxShop shop, Map<Long, MallUserInfo> usersMap) {
List<MallUserInfo> ownerInfo = getMallUserInfos(item.getOwner(), usersMap);
InvestTaskVo resultItemVo = InvestTaskVo.builder()
.targetInfo(shop)
.ownerInfo(ownerInfo)
@@ -168,20 +194,31 @@ public class InvestBizServiceImpl implements InvestBizService {
return resultItemVo;
}

private List<InvestDemandVo> getITargeInfoList(IPage<InvestDemandEntity> demandPage) {
private List<MallUserInfo> getMallUserInfos(String userJson, Map<Long, MallUserInfo> usersMap) {
List<MallUserInfo> ownerInfo = Lists.newArrayList();
List<Long> ownerList = JSON.parseArray(userJson, Long.class);
if (CollectionUtils.isNotEmpty(ownerList)) {
for (Long userId : ownerList) {
ownerInfo.add(usersMap.get(userId));
}
}
return ownerInfo;
}

private List<InvestDemandVo> getTargeInfoList(InvestPageResult<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));
Collection<InvestCustomerEntity> customers = getCustomers(demandList.stream().map(InvestDemandEntity::getCustomerId));
Map<Long, InvestCustomerEntity> customersMap = getCustomerMap(customers);

//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));
//4、品牌
Map<Long, WxBrand> brandMap = getBrandMap(customers.stream().map(InvestCustomerEntity::getBrandId).collect(Collectors.toList()));
//5、用户
Map<Long, MallUserInfo> usersMap = getUserInfoMap();

List<InvestDemandVo> resultList = new ArrayList<>();
for (InvestDemandEntity item : demandList) {
@@ -191,8 +228,22 @@ public class InvestBizServiceImpl implements InvestBizService {
if (Objects.nonNull(customer)) {
brand = brandMap.get(customer.getBrandId());
}
resultList.add(buildResultItem(item, customer, brand, shop));
resultList.add(buildDemindItem(item, customer, brand, shop, usersMap));
}
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 Map<Long, InvestCustomerEntity> getCustomerMap(Collection<InvestCustomerEntity> customers) {
return customers.stream().collect(Collectors.toMap(InvestCustomerEntity::getId, customer -> customer));
}

private Collection<InvestCustomerEntity> getCustomers(Stream<Long> longStream) {
return customerService.listByIds(longStream.collect(Collectors.toList()));
}
}

+ 2
- 0
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestFollowRecordServiceImpl.java View File

@@ -3,6 +3,7 @@ package com.iformall.service.invest.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.iformall.common.ErrorCode;
import com.iformall.domain.po.InvestFollowRecordEntity;
import com.iformall.domain.vo.invest.InvestUserContext;
import com.iformall.enums.EnumFollowType;
import com.iformall.mapper.InvestFollowRecordDao;
import com.iformall.service.invest.InvestDemandService;
@@ -24,6 +25,7 @@ public class InvestFollowRecordServiceImpl extends InvestBaseServiceImpl<InvestF

@Override
public boolean save(InvestFollowRecordEntity entity) {
entity.setOperator(InvestUserContext.getUserId());
return super.saveAction(entity, this::checkBeforeSaveOrUpdate);
}



Loading…
Cancel
Save