From c6017c3c83d2b40bcb72329f8e63ca34a0860191 Mon Sep 17 00:00:00 2001 From: Burce Date: Wed, 30 Oct 2019 12:33:10 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF]=E5=BD=95=E5=85=A5=E5=90=88=E5=90=8C?= =?UTF-8?q?=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../V201910231900__W_INVEST_CREATE.sql | 1 + .../po/invest/InvestCustomerEntity.java | 6 ++++++ .../service/invest/event/InvestListener.java | 2 +- .../invest/impl/InvestBaseServiceImpl.java | 6 +++--- .../invest/impl/InvestBizServiceImpl.java | 21 ++++++++++++++++--- .../resources/mapper/InvestCustomerMapper.xml | 1 + 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/mallinkAdmin/src/main/resources/db/migration/V201910231900__W_INVEST_CREATE.sql b/mallinkAdmin/src/main/resources/db/migration/V201910231900__W_INVEST_CREATE.sql index 2ad38c8a0..eee489e89 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V201910231900__W_INVEST_CREATE.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V201910231900__W_INVEST_CREATE.sql @@ -40,6 +40,7 @@ CREATE TABLE `invest_customer` ( `type` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败', `rating` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '客户预评级:0-无;1-主力店;2-次主力店;3-甲;4-乙;5-丙' , `invest_channel` VARCHAR(10) NOT NULL COMMENT '招商渠道:0-无;1-电视;2-广播;3-报纸;4-刊物;5-物联网;6-招商活动;7-中介机构;8-自定义渠道', + `contract_no` VARCHAR(100) NOT NULL COMMENT '合同编号', `create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java index 76c828ec0..c51b95447 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestCustomerEntity.java @@ -87,4 +87,10 @@ public class InvestCustomerEntity extends InvestBaseEntity { @Version private Date updateDate; + /** + * 合同编号 + */ + @io.swagger.annotations.ApiModelProperty(value = "合同编号", name = "contractNo") + private String contractNo; + } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java b/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java index a8bf194bf..93800740d 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/event/InvestListener.java @@ -35,7 +35,7 @@ public class InvestListener implements ApplicationListener { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); query.in(InvestTaskEntity::getTargetId, rentEventInfo.getTargetIds()); query.eq(InvestTaskEntity::getTargetType, EnumInvestType.RENT); - query.eq(InvestTaskEntity::getStatus, EnumTaskStatus.NEGOTIATING); + query.in(InvestTaskEntity::getStatus, EnumTaskStatus.NEGOTIATING, EnumTaskStatus.INTENTION); List tasks = taskService.list(query); if (CollectionUtils.isEmpty(tasks)) { log.warn("receive InvestEvent , tasks is empty : {}", tasks); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java index 9d4f7f736..c04dbd6cc 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java @@ -68,9 +68,9 @@ public class InvestBaseServiceImpl, T> extends ServiceIm @Override public T getByIdNotNull(Serializable id) { - InvestHelper.checkResult(id, "id=null"); + InvestHelper.checkResult(id, "id=" + id); T t = super.getById(id); - InvestHelper.checkResult(t, "id=null"); + InvestHelper.checkResult(t, "id=" + id); return t; } @@ -95,7 +95,7 @@ public class InvestBaseServiceImpl, T> extends ServiceIm } void checkUserAndTenant(T input, Consumer consumer) { - InvestHelper.notNull(input, "参数"); + InvestHelper.notNull(input, "参数 " + input); InvestHelper.notNull(InvestUserContext.getUser(), ErrorCode.USER_IS_EMPTY); ((InvestBaseEntity) input).setTenantId(InvestUserContext.getUser().getTenantId()); if (consumer != null) { diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java index ed74b8fbe..188260a90 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java @@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.iformall.common.ErrorCode; import com.iformall.common.Result; +import com.iformall.common.ResultData; import com.iformall.domain.dto.InvestDemandDto; import com.iformall.domain.dto.InvestTaskDto; import com.iformall.domain.po.*; @@ -772,6 +773,7 @@ public class InvestBizServiceImpl implements InvestBizService { public boolean saveCustomerAndDemand(InvestDemandDto demandDto) { InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); InvestCustomerEntity customerEntity = demandDto.getCustomer(); + checkCustomer(customerEntity); customerService.save(customerEntity); InvestDemandEntity demandEntity = demandDto.getDemand(); demandEntity.setCustomerId(customerEntity.getId()); @@ -780,16 +782,29 @@ public class InvestBizServiceImpl implements InvestBizService { return true; } + private void checkCustomer(InvestCustomerEntity customerEntity) { + if (Objects.equals(customerEntity.getType(), EnumCustomerType.COOPERATIVE)) { + InvestHelper.notNull(customerEntity.getContractNo(), "合同编号"); + WxRentContract contract = new WxRentContract(); + contract.setTenantId(InvestUserContext.getUser().getTenantId()); + contract.setContractNumber(customerEntity.getContractNo()); + ResultData resultData = rentContractService.hasContractNumber(contract); + InvestHelper.isTrue(Objects.equals(resultData.data, true),ErrorCode.INVEST_RESULT_NOT_FOUND,"合同编号"); + } + } + @Transactional(rollbackFor = Exception.class) @Override public boolean updateCustomerAndDemand(InvestDemandDto demandDto) { InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); Long customerId = demandDto.getCustomer().getId(); + InvestCustomerEntity customerEntity = demandDto.getCustomer(); if (Objects.isNull(customerId)) { customerId = demandDto.getDemand().getCustomerId(); - demandDto.getCustomer().setId(customerId); + customerEntity.setId(customerId); } - customerService.updateById(demandDto.getCustomer()); + checkCustomer(customerEntity); + customerService.updateById(customerEntity); InvestDemandEntity demandEntity = demandDto.getDemand(); if (Objects.isNull(demandEntity.getCustomerId())) { demandEntity.setCustomerId(customerId); @@ -800,7 +815,7 @@ public class InvestBizServiceImpl implements InvestBizService { } else { demandService.updateById(demandEntity); } - saveMessage(demandEntity, demandDto.getCustomer()); + saveMessage(demandEntity, customerEntity); return true; } diff --git a/mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml b/mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml index 7930e51af..78f03f492 100644 --- a/mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml +++ b/mallinkService/src/main/resources/mapper/InvestCustomerMapper.xml @@ -15,6 +15,7 @@ +