From 9c99cf039f4129b50d8fe54a7fd75defa53dd6e4 Mon Sep 17 00:00:00 2001 From: Burce Date: Thu, 24 Oct 2019 13:34:27 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=8B=9B=E5=95=86][=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=BC=96=E5=8F=B7]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/log/TableOperateAspect.java | 2 + .../V201910241400__W_INVEST_ALTER.sql | 2 + .../domain/po/invest/InvestBaseEntity.java | 6 ++ .../po/invest/InvestCustomerEntity.java | 8 ++ .../domain/vo/invest/InvestDemandQuery.java | 6 +- .../invest/impl/InvestBizServiceImpl.java | 73 ++++++++++++++++--- 6 files changed, 82 insertions(+), 15 deletions(-) create mode 100644 mallinkAdmin/src/main/resources/db/migration/V201910241400__W_INVEST_ALTER.sql diff --git a/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java b/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java index 42f1966a1..2f46ac4ed 100644 --- a/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java +++ b/mallinkAdmin/src/main/java/com/iformall/log/TableOperateAspect.java @@ -8,6 +8,7 @@ import com.google.common.collect.Maps; import com.iformall.common.LogColumn; import com.iformall.domain.po.invest.InvestBaseEntity; import com.iformall.domain.po.invest.InvestOperateRecordEntity; +import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.domain.vo.invest.TableTriple; import com.iformall.enums.EnumTableOperateType; import com.iformall.service.invest.InvestHelper; @@ -108,6 +109,7 @@ public class TableOperateAspect { InvestOperateRecordEntity recordEntity = new InvestOperateRecordEntity(); recordEntity.setContent(JSON.toJSONString(o)); recordEntity.setOperateType(operateType); + recordEntity.setOperator(InvestUserContext.getUserId()); recordEntity.setTbl(getTbl(signature)); recordEntity.setTid(tid); toSaveRecord.add(recordEntity) ; diff --git a/mallinkAdmin/src/main/resources/db/migration/V201910241400__W_INVEST_ALTER.sql b/mallinkAdmin/src/main/resources/db/migration/V201910241400__W_INVEST_ALTER.sql new file mode 100644 index 000000000..f6e8c8b82 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201910241400__W_INVEST_ALTER.sql @@ -0,0 +1,2 @@ +ALTER TABLE `invest_demand` CHANGE COLUMN `owner` `owner` bigint(20) DEFAULT 0 COMMENT '负责人'; +ALTER TABLE `invest_customer` ADD COLUMN `customer_no` varchar(20) NOT NULL DEFAULT '' COMMENT '客户编号' AFTER `tenant_id`; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java index af61780ae..4429abe9e 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestBaseEntity.java @@ -25,6 +25,12 @@ public class InvestBaseEntity implements Serializable { @TableId(type = IdType.ID_WORKER) @io.swagger.annotations.ApiModelProperty(value = "主键ID", name = "id") private Long id; + + /** + * 客户编号 + */ + @io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerNo") + private String customerNo; /** * 租户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 0848cad57..13cd0c81a 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 @@ -29,6 +29,13 @@ import java.util.Date; @EqualsAndHashCode(callSuper = true) public class InvestCustomerEntity extends InvestBaseEntity { + /** + * 品牌ID + */ + @LogColumn + @io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerNo") + private String customerNo; + /** * 客户名称 */ @@ -55,6 +62,7 @@ public class InvestCustomerEntity extends InvestBaseEntity { @LogColumn @io.swagger.annotations.ApiModelProperty(value = "品牌ID", name = "brandId") private Long brandId; + /** * 客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败 */ diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java index e6ff72e00..6951906b7 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestDemandQuery.java @@ -9,10 +9,10 @@ import lombok.EqualsAndHashCode; public class InvestDemandQuery extends InvestPageQuery { /** - * 主键ID + * 客户编号 */ - @io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerId") - private Long customerId; + @io.swagger.annotations.ApiModelProperty(value = "客户编号", name = "customerNo") + private String customerNo; /** * 客户分类:0-潜在客户;1-意向客户;2-合作客户;3-谈判失败 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 32e5f6eb1..370ec72eb 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 @@ -105,6 +105,7 @@ public class InvestBizServiceImpl implements InvestBizService { queryWrapperCustomer.in(CollectionUtils.isNotEmpty(demandList),InvestCustomerEntity::getId, getIds(demandList, InvestDemandEntity::getCustomerId)); } } + queryWrapperCustomer.like(StringUtils.isNotBlank(params.getCustomerNo()), InvestCustomerEntity::getCustomerNo, params.getCustomerNo()); queryWrapperCustomer.orderByDesc(InvestCustomerEntity::getCreateDate); InvestPageResult customers = customerService.queryPage(buildPageQuery(params, null), queryWrapperCustomer); List resultList = getTargeInfoList(demandList, customers.getRecords()); @@ -279,12 +280,10 @@ public class InvestBizServiceImpl implements InvestBizService { return; } //品牌信息 - List brands = brandService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); - Map brandMap = getMap(brands, WxBrand::getName); + Map brandMap = getBrandMap(); //业态信息 - List businesses = businessService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); - Map businesseMap = getMap(businesses, WxBusiness::getTitle); + Map businesseMap = getBusinessMap(); //商铺信息 List shops = shopService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); @@ -337,6 +336,16 @@ public class InvestBizServiceImpl implements InvestBizService { } } + private Map getBusinessMap() { + List businesses = businessService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); + return getMap(businesses, WxBusiness::getTitle); + } + + private Map getBrandMap() { + List brands = brandService.listAsPage(null, 1, Integer.MAX_VALUE).getList(); + return getMap(brands, WxBrand::getName); + } + private InvestDemandDto convetCustomer(InvestCustomerVoT customerVoT, Map brandMap, Map businesseMap, Map shopMap, Map customerMap) { InvestCustomerEntity customerEntity = new InvestCustomerEntity(); if (Objects.isNull(brandMap.get(customerVoT.getBrandName()))) { @@ -412,9 +421,9 @@ public class InvestBizServiceImpl implements InvestBizService { private InvestDemandDto doConvertDemand(InvestDemandQuery params) { InvestCustomerEntity customerEntity = null; - if (ObjectUtils.anyNotNull(params.getCustomerId(), params.getCustomerType(), params.getBusinessId())) { + if (ObjectUtils.anyNotNull(params.getCustomerNo(), params.getCustomerType(), params.getBusinessId())) { customerEntity = new InvestCustomerEntity(); - customerEntity.setId(params.getCustomerId()); + customerEntity.setCustomerNo(params.getCustomerNo()); customerEntity.setType(params.getCustomerType()); customerEntity.setBusinessId(params.getBusinessId()); } @@ -705,12 +714,12 @@ public class InvestBizServiceImpl implements InvestBizService { return true; } - private void saveMessage(InvestDemandEntity entity, InvestCustomerEntity customerEntity) { - if (Objects.isNull(entity)) { + private void saveMessage(InvestDemandEntity demandEntity, InvestCustomerEntity customerEntity) { + if (Objects.isNull(demandEntity)) { return; } - Long owner = entity.getOwner(); - if (Objects.nonNull(owner)) { + Long owner = demandEntity.getOwner(); + if (Objects.nonNull(owner) && !Objects.equals(owner, 0L)) { List ownerArray = Arrays.asList(owner); demandService.saveBatchMessage(ownerArray, EnumInvestMessageType.CUSTOMER_CREATE.getInfo(), EnumInvestMessageTag.CUSTOMER_CREATE, EnumFollowType.DEMAND, customerEntity.getId()); } @@ -819,6 +828,12 @@ public class InvestBizServiceImpl implements InvestBizService { Collection recordList = entityPageList.getRecords(); Map usersMap = getMap(userInfoService.getByIds(getIds(recordList, InvestOperateRecordEntity::getOperator)), MallUserInfo::getId); + //品牌信息 + Map brandMap = getBrandMap(); + + //业态信息 + Map businesseMap = getBusinessMap(); + List resultList = new ArrayList<>(); for (InvestOperateRecordEntity recordEntity : recordList) { InvestOperateRecordVo itemVo = new InvestOperateRecordVo(); @@ -828,7 +843,38 @@ public class InvestBizServiceImpl implements InvestBizService { itemVo.setOperatorName(userInfo.getName()); } TableTriple content = JSON.parseObject(recordEntity.getContent(), TableTriple.class); - itemVo.setRecord(content); + itemVo.setRecord(convert(content, tableTriple -> { + Object column = tableTriple.getColumn(); + if (Objects.equals(column, "businessId")) { + WxBusiness businessBefore = businesseMap.get(tableTriple.getBefore()) ; + WxBusiness businessAfter = businesseMap.get(tableTriple.getAfter()) ; + if (Objects.nonNull(businessBefore)) { + tableTriple.setBefore(businessBefore.getTitle()); + } + if (Objects.nonNull(businessAfter)) { + tableTriple.setBefore(businessAfter.getTitle()); + } + } else if (Objects.equals(column, "brandId")) { + WxBrand brandBefore = brandMap.get(tableTriple.getBefore()) ; + WxBrand brandAfter = brandMap.get(tableTriple.getAfter()) ; + if (Objects.nonNull(brandBefore)) { + tableTriple.setBefore(brandBefore.getName()); + } + if (Objects.nonNull(brandAfter)) { + tableTriple.setBefore(brandAfter.getName()); + } + } else if (Objects.equals(column, "owner")) { + MallUserInfo userBefore = usersMap.get(tableTriple.getBefore()); + MallUserInfo userAfter = usersMap.get(tableTriple.getAfter()); + if (Objects.nonNull(userBefore)) { + tableTriple.setBefore(userBefore.getName()); + } + if (Objects.nonNull(userAfter)) { + tableTriple.setBefore(userAfter.getName()); + } + } + return tableTriple; + })); resultList.add(itemVo); } BeanUtils.copyProperties(entityPageList, investPage); @@ -908,13 +954,16 @@ public class InvestBizServiceImpl implements InvestBizService { InvestDemandVo resultItemVo = new InvestDemandVo(); BeanUtils.copyProperties(customer, resultItemVo); resultItemVo.setBrand(brand); - resultItemVo.setDemand(item); resultItemVo.setTargetInfo(shop); if (Objects.nonNull(item)) { + if (Objects.equals(item.getOwner(), 0L)) { + item.setOwner(null); + } if (Objects.nonNull(usersMap.get(item.getOwner()))) { resultItemVo.setOwnerInfo(usersMap.get(item.getOwner())); } } + resultItemVo.setDemand(item); return resultItemVo; }