| @@ -2,7 +2,7 @@ package com.iformall.controller.invest; | |||
| import com.iformall.annotation.SystemServiceLog; | |||
| import com.iformall.common.InvestResultData; | |||
| import com.iformall.domain.dto.InvestCustomerDto; | |||
| import com.iformall.domain.dto.InvestDemandDto; | |||
| import com.iformall.domain.vo.invest.InvestDemandVo; | |||
| import com.iformall.domain.vo.invest.InvestPageQuery; | |||
| import com.iformall.domain.vo.invest.InvestPageResult; | |||
| @@ -42,7 +42,7 @@ public class InvestDemandController extends InvestBaseController { | |||
| @SystemServiceLog | |||
| @ApiOperation(value = "分页列表接口") | |||
| @GetMapping("/list") | |||
| public InvestResultData<InvestPageResult<InvestDemandVo>> list(InvestPageQuery<InvestCustomerDto> params) { | |||
| public InvestResultData<InvestPageResult<InvestDemandVo>> list(InvestPageQuery<InvestDemandDto> params) { | |||
| return execute(params, p -> investBizService.queryPageDemand(p)); | |||
| } | |||
| @@ -61,7 +61,7 @@ public class InvestDemandController extends InvestBaseController { | |||
| */ | |||
| @SystemServiceLog | |||
| @PostMapping("/save") | |||
| public InvestResultData save(@RequestBody InvestCustomerDto investDemand) { | |||
| public InvestResultData save(@RequestBody InvestDemandDto investDemand) { | |||
| return execute(investDemand, p -> investBizService.saveCustomerAndDemand(p)); | |||
| } | |||
| @@ -70,7 +70,7 @@ public class InvestDemandController extends InvestBaseController { | |||
| */ | |||
| @SystemServiceLog | |||
| @PostMapping("/update") | |||
| public InvestResultData update(@RequestBody InvestCustomerDto customerDto) { | |||
| public InvestResultData update(@RequestBody InvestDemandDto customerDto) { | |||
| return execute(customerDto, p -> investBizService.updateCustomerAndDemand(p)); | |||
| } | |||
| @@ -1,29 +0,0 @@ | |||
| package com.iformall.domain.dto; | |||
| import com.iformall.common.LogColumn; | |||
| import com.iformall.domain.po.invest.InvestCustomerEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class InvestCustomerDto extends InvestCustomerEntity { | |||
| /** | |||
| * 负责人 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "招商负责人", name = "owner") | |||
| @LogColumn | |||
| private Long owner; | |||
| @io.swagger.annotations.ApiModelProperty(value = "demandId", name = "demandId") | |||
| private Long demandId; | |||
| /** | |||
| * 客户意向 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "客户意向", name = "intent", | |||
| example = "\"{\"rent_area\":100,\"opening_time\": \"2019-09-03\"}\"") | |||
| @LogColumn(COLUMN_TYPE) | |||
| private String intent; | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.domain.dto; | |||
| import com.iformall.domain.po.invest.InvestCustomerEntity; | |||
| import com.iformall.domain.po.invest.InvestDemandEntity; | |||
| import lombok.Data; | |||
| @Data | |||
| public class InvestDemandDto { | |||
| @io.swagger.annotations.ApiModelProperty(value = "客户信息", name = "客户信息") | |||
| private InvestCustomerEntity customer ; | |||
| @io.swagger.annotations.ApiModelProperty(value = "客户需求", name = "客户需求") | |||
| private InvestDemandEntity demand ; | |||
| } | |||
| @@ -33,14 +33,14 @@ public class InvestFollowRecordEntity extends InvestBaseEntity { | |||
| /** | |||
| * 洽谈内容 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content",example = "\"{" + | |||
| @io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content",example = "{" + | |||
| "\"date\": \"2019-09-03\"," + | |||
| " \"address\": \"北京三里屯\"," + | |||
| " \"text\": \"今天约了王老板,目标要签订框架协议\"," + | |||
| " \"document\": [\"url1\",\"url2\"]," + | |||
| " \"member\": [id1,id2,id3]," + | |||
| " \"negotiationType\": 1" + | |||
| "}\"") | |||
| "}") | |||
| private String content; | |||
| /** | |||
| * 跟踪类型:0-招商任务;1-客户需求 | |||
| @@ -46,7 +46,7 @@ public class InvestOperateRecordEntity extends InvestBaseEntity { | |||
| /** | |||
| * 更新内容 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新前", name = "content",example = "\"[{\"after\": \"13366183866\", \"before\": \"15811234999\", \"column\": \"phone\"}]\"") | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新前", name = "content",example = "[{\"after\": \"13366183866\", \"before\": \"15811234999\", \"column\": \"phone\"}]") | |||
| private String content; | |||
| @JsonIgnore | |||
| @@ -28,12 +28,12 @@ public class InvestRemindEntity extends InvestBaseEntity { | |||
| * 提醒内容 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "提醒内容", name = "content",example = "\"" + | |||
| @io.swagger.annotations.ApiModelProperty(value = "提醒内容", name = "content",example = | |||
| "{" + | |||
| "\"text\": \"今天约了王老板,要求签订框架协议\"," + | |||
| " \"customerId\": 222222," + | |||
| "\"text\": \"今天约了王老板,要求签订框架协议\"," + | |||
| " \"customerId\": 222222," + | |||
| " \"negotiationType\": 2" + | |||
| "}\"") | |||
| "}") | |||
| private String content; | |||
| /** | |||
| * 提醒时间 | |||
| @@ -49,10 +49,10 @@ public class InvestTaskEntity extends InvestBaseEntity { | |||
| /** | |||
| * 任务设定条件 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content",example = "\"{" + | |||
| @io.swagger.annotations.ApiModelProperty(value = "任务设定条件", name = "content",example = "{" + | |||
| "\"business\": 1," + | |||
| " \"lastDate\": \"2018-10-01 12:18:48\",\"contractId\":222222222222" + | |||
| "}\"") | |||
| "}") | |||
| private String content; | |||
| /** | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.service.invest; | |||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
| import com.iformall.domain.vo.invest.InvestPageQuery; | |||
| import com.iformall.domain.vo.invest.InvestPageResult; | |||
| @@ -16,6 +17,8 @@ public interface InvestBaseService<T> { | |||
| InvestPageResult<T> queryPage(InvestPageQuery<T> params) ; | |||
| InvestPageResult<T> queryPage(InvestPageQuery<T> params, LambdaQueryWrapper<T> queryWrapper) ; | |||
| T getByIdNotNull(Serializable id); | |||
| } | |||
| @@ -1,9 +1,8 @@ | |||
| package com.iformall.service.invest; | |||
| import com.iformall.domain.dto.InvestCustomerDto; | |||
| import com.iformall.domain.dto.InvestDemandDto; | |||
| import com.iformall.domain.dto.InvestTaskDto; | |||
| import com.iformall.domain.po.invest.InvestFollowRecordEntity; | |||
| import com.iformall.domain.po.invest.InvestTaskEntity; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.vo.invest.*; | |||
| @@ -11,7 +10,7 @@ import java.util.List; | |||
| public interface InvestBizService { | |||
| InvestPageResult<InvestDemandVo> queryPageDemand(InvestPageQuery<InvestCustomerDto> params); | |||
| InvestPageResult<InvestDemandVo> queryPageDemand(InvestPageQuery<InvestDemandDto> params); | |||
| InvestPageResult<InvestTaskVo> queryPageTask(InvestPageQuery<InvestTaskDto> params); | |||
| @@ -19,9 +18,9 @@ public interface InvestBizService { | |||
| List<MallUserInfo> queryUserList() ; | |||
| boolean saveCustomerAndDemand(InvestCustomerDto customerDemandDto) ; | |||
| boolean saveCustomerAndDemand(InvestDemandDto customerDemandDto) ; | |||
| boolean updateCustomerAndDemand(InvestCustomerDto customerDto) ; | |||
| boolean updateCustomerAndDemand(InvestDemandDto customerDto) ; | |||
| InvestDemandVo findDemandById(Long id) ; | |||
| @@ -3,6 +3,7 @@ package com.iformall.service.invest.impl; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import com.baomidou.mybatisplus.core.metadata.IPage; | |||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
| @@ -40,12 +41,19 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm | |||
| @Override | |||
| public InvestPageResult<T> queryPage(InvestPageQuery<T> params) { | |||
| return this.queryPage(params, null); | |||
| } | |||
| @Override | |||
| public InvestPageResult<T> queryPage(InvestPageQuery<T> params, LambdaQueryWrapper<T> queryWrapper) { | |||
| InvestHelper.notNull(params); | |||
| //1、分页信息 | |||
| Page<T> queryPage = buildQueryPage(params); | |||
| //2、查询数据 | |||
| T queryParams = params.getQueryData(); | |||
| LambdaQueryWrapper<T> queryWrapper = new LambdaQueryWrapper<>(queryParams); | |||
| if (Objects.isNull(queryWrapper)) { | |||
| queryWrapper = new LambdaQueryWrapper<>(queryParams); | |||
| } | |||
| IPage<T> resultPage = this.page(queryPage, queryWrapper); | |||
| InvestPageResult<T> investPage = new InvestPageResult<>(); | |||
| @@ -3,8 +3,7 @@ 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.InvestCustomerDto; | |||
| import com.iformall.domain.dto.InvestDemandDto; | |||
| import com.iformall.domain.dto.InvestTaskDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.invest.InvestCustomerEntity; | |||
| @@ -48,19 +47,22 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| private MallUserInfoService userInfoService; | |||
| @Override | |||
| public InvestPageResult<InvestDemandVo> queryPageDemand(InvestPageQuery<InvestCustomerDto> params) { | |||
| InvestCustomerDto queryParams = params.getQueryData(); | |||
| InvestDemandEntity queryDemand = null; | |||
| if (Objects.nonNull(queryParams)) { | |||
| queryDemand = new InvestDemandEntity(); | |||
| queryDemand.setOwner(queryParams.getOwner()); | |||
| } | |||
| InvestPageResult<InvestDemandEntity> demandPage = demandService.queryPage(new InvestPageQuery<>(queryDemand)); | |||
| public InvestPageResult<InvestDemandVo> queryPageDemand(InvestPageQuery<InvestDemandDto> params) { | |||
| InvestHelper.notNull(params); | |||
| InvestDemandDto queryParams = params.getQueryData(); | |||
| 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 = 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); | |||
| if (CollectionUtils.isEmpty(demandPage.getRecords())) { | |||
| return investPage; | |||
| } | |||
| List<InvestDemandVo> resultList = getTargeInfoList(demandPage, queryParams); | |||
| List<InvestDemandVo> resultList = getTargeInfoList(demandPage, customerPage.getRecords()); | |||
| BeanUtils.copyProperties(demandPage, investPage); | |||
| investPage.setRecords(resultList); | |||
| return investPage; | |||
| @@ -151,44 +153,30 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| @Transactional(rollbackFor = Exception.class) | |||
| @Override | |||
| public boolean saveCustomerAndDemand(InvestCustomerDto customerDto) { | |||
| InvestHelper.notNull(customerDto); | |||
| InvestCustomerEntity customerEntityDB = customerService.getById(customerDto.getId()); | |||
| public boolean saveCustomerAndDemand(InvestDemandDto demandDto) { | |||
| InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); | |||
| InvestCustomerEntity customerEntityDB = customerService.getById(demandDto.getCustomer().getId()); | |||
| if (Objects.isNull(customerEntityDB)) { | |||
| customerService.save(customerDto); | |||
| customerEntityDB = demandDto.getCustomer(); | |||
| customerService.save(customerEntityDB); | |||
| } else { | |||
| customerService.updateById(customerDto); | |||
| customerService.updateById(demandDto.getCustomer()); | |||
| } | |||
| InvestDemandEntity demandEntity = new InvestDemandEntity(); | |||
| setValDmand(customerDto, demandEntity); | |||
| InvestDemandEntity demandEntity = demandDto.getDemand(); | |||
| demandEntity.setCustomerId(customerEntityDB.getId()); | |||
| return demandService.save(demandEntity); | |||
| } | |||
| @Transactional(rollbackFor = Exception.class) | |||
| @Override | |||
| public boolean updateCustomerAndDemand(InvestCustomerDto customerDto) { | |||
| InvestHelper.notNull(customerDto, customerDto.getDemandId()); | |||
| InvestDemandEntity demandEntity = demandService.getByIdNotNull(customerDto.getDemandId()); | |||
| InvestCustomerEntity customerEntity = new InvestCustomerEntity(); | |||
| customerDto.setId(demandEntity.getCustomerId()); | |||
| BeanUtils.copyProperties(customerDto, customerEntity); | |||
| customerService.updateById(customerEntity); | |||
| setValDmand(customerDto, demandEntity); | |||
| public boolean updateCustomerAndDemand(InvestDemandDto demandDto) { | |||
| InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); | |||
| customerService.updateById(demandDto.getCustomer()); | |||
| InvestDemandEntity demandEntity = demandDto.getDemand() ; | |||
| demandEntity.setCustomerId(demandDto.getCustomer().getId()); | |||
| return demandService.updateById(demandEntity); | |||
| } | |||
| private void setValDmand(InvestCustomerDto customerDto, InvestDemandEntity demandEntity) { | |||
| if (Objects.isNull(demandEntity)) { | |||
| demandEntity = new InvestDemandEntity(); | |||
| } | |||
| demandEntity.setCustomerId(customerDto.getId()); | |||
| demandEntity.setId(customerDto.getDemandId()); | |||
| demandEntity.setIntent(customerDto.getIntent()); | |||
| if (Objects.nonNull(customerDto.getOwner())) { | |||
| demandEntity.setOwner(customerDto.getOwner()); | |||
| } | |||
| } | |||
| @Override | |||
| public InvestDemandVo findDemandById(Long id) { | |||
| InvestDemandEntity demandEntity = demandService.getByIdNotNull(id); | |||
| @@ -267,12 +255,8 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| return ownerInfo; | |||
| } | |||
| private List<InvestDemandVo> getTargeInfoList(InvestPageResult<InvestDemandEntity> demandPage, InvestCustomerEntity queryCustomer) { | |||
| private List<InvestDemandVo> getTargeInfoList(InvestPageResult<InvestDemandEntity> demandPage, List<InvestCustomerEntity> customers) { | |||
| List<InvestDemandEntity> demandList = demandPage.getRecords(); | |||
| //2、客户信息 | |||
| LambdaQueryWrapper<InvestCustomerEntity> customerWrapper = new LambdaQueryWrapper<>(queryCustomer); | |||
| customerWrapper.in(InvestCustomerEntity::getId, demandList.stream().map(InvestDemandEntity::getCustomerId)); | |||
| Collection<InvestCustomerEntity> customers = customerService.list(new QueryWrapper<>(queryCustomer)); | |||
| Map<Long, InvestCustomerEntity> customersMap = getCustomerMap(customers); | |||
| //3、目标信息 | |||