| @@ -40,6 +40,7 @@ CREATE TABLE `invest_customer` ( | |||||
| `type` TINYINT(6) NOT NULL DEFAULT '0' COMMENT '客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败', | `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-丙' , | `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-自定义渠道', | `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 '创建时间', | `create_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||||
| `update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | `update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||||
| PRIMARY KEY (`id`), | PRIMARY KEY (`id`), | ||||
| @@ -87,4 +87,10 @@ public class InvestCustomerEntity extends InvestBaseEntity { | |||||
| @Version | @Version | ||||
| private Date updateDate; | private Date updateDate; | ||||
| /** | |||||
| * 合同编号 | |||||
| */ | |||||
| @io.swagger.annotations.ApiModelProperty(value = "合同编号", name = "contractNo") | |||||
| private String contractNo; | |||||
| } | } | ||||
| @@ -35,7 +35,7 @@ public class InvestListener implements ApplicationListener<InvestEvent> { | |||||
| LambdaQueryWrapper<InvestTaskEntity> query = new LambdaQueryWrapper<>(); | LambdaQueryWrapper<InvestTaskEntity> query = new LambdaQueryWrapper<>(); | ||||
| query.in(InvestTaskEntity::getTargetId, rentEventInfo.getTargetIds()); | query.in(InvestTaskEntity::getTargetId, rentEventInfo.getTargetIds()); | ||||
| query.eq(InvestTaskEntity::getTargetType, EnumInvestType.RENT); | query.eq(InvestTaskEntity::getTargetType, EnumInvestType.RENT); | ||||
| query.eq(InvestTaskEntity::getStatus, EnumTaskStatus.NEGOTIATING); | |||||
| query.in(InvestTaskEntity::getStatus, EnumTaskStatus.NEGOTIATING, EnumTaskStatus.INTENTION); | |||||
| List<InvestTaskEntity> tasks = taskService.list(query); | List<InvestTaskEntity> tasks = taskService.list(query); | ||||
| if (CollectionUtils.isEmpty(tasks)) { | if (CollectionUtils.isEmpty(tasks)) { | ||||
| log.warn("receive InvestEvent , tasks is empty : {}", tasks); | log.warn("receive InvestEvent , tasks is empty : {}", tasks); | ||||
| @@ -68,9 +68,9 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm | |||||
| @Override | @Override | ||||
| public T getByIdNotNull(Serializable id) { | public T getByIdNotNull(Serializable id) { | ||||
| InvestHelper.checkResult(id, "id=null"); | |||||
| InvestHelper.checkResult(id, "id=" + id); | |||||
| T t = super.getById(id); | T t = super.getById(id); | ||||
| InvestHelper.checkResult(t, "id=null"); | |||||
| InvestHelper.checkResult(t, "id=" + id); | |||||
| return t; | return t; | ||||
| } | } | ||||
| @@ -95,7 +95,7 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm | |||||
| } | } | ||||
| void checkUserAndTenant(T input, Consumer<T> consumer) { | void checkUserAndTenant(T input, Consumer<T> consumer) { | ||||
| InvestHelper.notNull(input, "参数"); | |||||
| InvestHelper.notNull(input, "参数 " + input); | |||||
| InvestHelper.notNull(InvestUserContext.getUser(), ErrorCode.USER_IS_EMPTY); | InvestHelper.notNull(InvestUserContext.getUser(), ErrorCode.USER_IS_EMPTY); | ||||
| ((InvestBaseEntity) input).setTenantId(InvestUserContext.getUser().getTenantId()); | ((InvestBaseEntity) input).setTenantId(InvestUserContext.getUser().getTenantId()); | ||||
| if (consumer != null) { | if (consumer != null) { | ||||
| @@ -11,6 +11,7 @@ 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.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | |||||
| 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.*; | ||||
| @@ -772,6 +773,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| public boolean saveCustomerAndDemand(InvestDemandDto demandDto) { | public boolean saveCustomerAndDemand(InvestDemandDto demandDto) { | ||||
| InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); | InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); | ||||
| InvestCustomerEntity customerEntity = demandDto.getCustomer(); | InvestCustomerEntity customerEntity = demandDto.getCustomer(); | ||||
| checkCustomer(customerEntity); | |||||
| customerService.save(customerEntity); | customerService.save(customerEntity); | ||||
| InvestDemandEntity demandEntity = demandDto.getDemand(); | InvestDemandEntity demandEntity = demandDto.getDemand(); | ||||
| demandEntity.setCustomerId(customerEntity.getId()); | demandEntity.setCustomerId(customerEntity.getId()); | ||||
| @@ -780,16 +782,29 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| return true; | 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) | @Transactional(rollbackFor = Exception.class) | ||||
| @Override | @Override | ||||
| public boolean updateCustomerAndDemand(InvestDemandDto demandDto) { | public boolean updateCustomerAndDemand(InvestDemandDto demandDto) { | ||||
| InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); | InvestHelper.notNull(demandDto, demandDto.getCustomer(), demandDto.getDemand()); | ||||
| Long customerId = demandDto.getCustomer().getId(); | Long customerId = demandDto.getCustomer().getId(); | ||||
| InvestCustomerEntity customerEntity = demandDto.getCustomer(); | |||||
| if (Objects.isNull(customerId)) { | if (Objects.isNull(customerId)) { | ||||
| customerId = demandDto.getDemand().getCustomerId(); | customerId = demandDto.getDemand().getCustomerId(); | ||||
| demandDto.getCustomer().setId(customerId); | |||||
| customerEntity.setId(customerId); | |||||
| } | } | ||||
| customerService.updateById(demandDto.getCustomer()); | |||||
| checkCustomer(customerEntity); | |||||
| customerService.updateById(customerEntity); | |||||
| InvestDemandEntity demandEntity = demandDto.getDemand(); | InvestDemandEntity demandEntity = demandDto.getDemand(); | ||||
| if (Objects.isNull(demandEntity.getCustomerId())) { | if (Objects.isNull(demandEntity.getCustomerId())) { | ||||
| demandEntity.setCustomerId(customerId); | demandEntity.setCustomerId(customerId); | ||||
| @@ -800,7 +815,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||||
| } else { | } else { | ||||
| demandService.updateById(demandEntity); | demandService.updateById(demandEntity); | ||||
| } | } | ||||
| saveMessage(demandEntity, demandDto.getCustomer()); | |||||
| saveMessage(demandEntity, customerEntity); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -15,6 +15,7 @@ | |||||
| <result property="type" column="type"/> | <result property="type" column="type"/> | ||||
| <result property="rating" column="rating"/> | <result property="rating" column="rating"/> | ||||
| <result property="investChannel" column="invest_channel"/> | <result property="investChannel" column="invest_channel"/> | ||||
| <result property="contractNo" column="contract_no"/> | |||||
| <result property="createDate" column="create_date"/> | <result property="createDate" column="create_date"/> | ||||
| <result property="updateDate" column="update_date"/> | <result property="updateDate" column="update_date"/> | ||||
| </resultMap> | </resultMap> | ||||