| @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class InvestDemandDto extends InvestDemandEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer",required = true) | |||
| private InvestCustomerEntity customer; | |||
| } | |||
| @@ -39,7 +39,7 @@ public class InvestDemandEntity extends InvestBaseEntity { | |||
| * 客户意向 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "客户意向", name = "intent", | |||
| example = "{\"rent_area\":100,\"opening_time\": 2019-09-03}") | |||
| example = "{\"rent_area\":100,\"opening_time\": \"2019-09-03\"}") | |||
| @LogColumn(COLUMN_TYPE) | |||
| private String intent; | |||
| /** | |||
| @@ -33,7 +33,7 @@ public class InvestFollowRecordEntity extends InvestBaseEntity { | |||
| * 洽谈内容 | |||
| */ | |||
| @io.swagger.annotations.ApiModelProperty(value = "洽谈内容", name = "content",example = "{\n" + | |||
| " \"date\": \"2019-09-10 20:12:20\",\n" + | |||
| " \"date\": \"2019-09-03\",\n" + | |||
| " \"address\": \"北京三里屯\",\n" + | |||
| " \"text\": \"今天约了王老板,目标要签订框架协议\",\n" + | |||
| " \"document\": [\"url1\",\"url2\"],\n" + | |||
| @@ -4,16 +4,14 @@ 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; | |||
| import lombok.EqualsAndHashCode; | |||
| @Data | |||
| @Builder | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class InvestDemandVo<T> extends InvestDemandEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer",required = true) | |||
| @io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer") | |||
| private InvestCustomerEntity customer; | |||
| @io.swagger.annotations.ApiModelProperty(value = "brand", name = "brand") | |||
| @@ -1,22 +1,24 @@ | |||
| package com.iformall.domain.vo.invest; | |||
| import com.iformall.domain.po.*; | |||
| import lombok.Builder; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.List; | |||
| @Data | |||
| @Builder | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class InvestFollowRecordVo extends InvestFollowRecordEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "customer", name = "customer") | |||
| private InvestCustomerEntity customer; | |||
| @io.swagger.annotations.ApiModelProperty(value = "brand", name = "brand") | |||
| private WxBrand brand; | |||
| @io.swagger.annotations.ApiModelProperty(value = "memberInfo", name = "memberInfo") | |||
| private List<MallUserInfo> memberInfo ; | |||
| @io.swagger.annotations.ApiModelProperty(value = "ownerInfo", name = "ownerInfo") | |||
| private MallUserInfo ownerInfo; | |||
| } | |||
| @@ -2,14 +2,12 @@ package com.iformall.domain.vo.invest; | |||
| import com.iformall.domain.po.InvestTaskEntity; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import lombok.Builder; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.List; | |||
| @Data | |||
| @Builder | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class InvestTaskVo<T> extends InvestTaskEntity { | |||
| @@ -19,5 +17,6 @@ public class InvestTaskVo<T> extends InvestTaskEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "targetInfo", name = "targetInfo") | |||
| private T targetInfo; | |||
| @io.swagger.annotations.ApiModelProperty(value = "ownerInfo", name = "ownerInfo") | |||
| private List<MallUserInfo> ownerInfo ; | |||
| } | |||
| @@ -1,12 +1,15 @@ | |||
| package com.iformall.service.invest; | |||
| import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.vo.invest.InvestPageQuery; | |||
| import com.iformall.exception.MallinkException; | |||
| import org.apache.commons.lang3.ObjectUtils; | |||
| import org.apache.commons.compress.utils.Lists; | |||
| import org.springframework.util.CollectionUtils; | |||
| import java.text.MessageFormat; | |||
| import java.util.List; | |||
| import java.util.Objects; | |||
| public class InvestHelper { | |||
| @@ -15,13 +18,41 @@ public class InvestHelper { | |||
| Page<T> page = new Page<>(); | |||
| page.setCurrent(pageQuery.getPageNum()); | |||
| page.setSize(pageQuery.getPageSize()); | |||
| page.setAscs(pageQuery.getAscs()); | |||
| page.setDescs(pageQuery.getDescs()); | |||
| page.setAscs(camelToUnderline(pageQuery.getAscs())); | |||
| page.setDescs(camelToUnderline(pageQuery.getDescs())); | |||
| page.setOptimizeCountSql(true); | |||
| page.setSearchCount(true); | |||
| return page; | |||
| } | |||
| private static List<String> camelToUnderline(List<String> orders) { | |||
| if (CollectionUtils.isEmpty(orders)) { | |||
| return orders; | |||
| } | |||
| List<String> newOrders = Lists.newArrayList(); | |||
| for (String order : orders) { | |||
| newOrders.add(StringUtils.camelToUnderline(order)); | |||
| } | |||
| return newOrders; | |||
| } | |||
| /** | |||
| * @param objects the object to check | |||
| * @throws MallinkException if the object is {@code null} | |||
| */ | |||
| public static void notNull(final Object... objects) { | |||
| if (objects == null) { | |||
| throwException(ErrorCode.INVEST_PARAMETER_NOT_FOUND, "参数"); | |||
| } | |||
| for (final Object val : objects) { | |||
| if (val == null) { | |||
| throwException(ErrorCode.INVEST_PARAMETER_NOT_FOUND, "参数"); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * @param object the object to check | |||
| * @param message the exception message to use if the assertion fails | |||
| @@ -44,15 +75,6 @@ public class InvestHelper { | |||
| } | |||
| } | |||
| /** | |||
| * @param values the objects to check | |||
| */ | |||
| public static void allNotNull(final Object... values) { | |||
| if (!ObjectUtils.allNotNull(values)) { | |||
| throwException(ErrorCode.INVEST_PARAMETER_NOT_FOUND, values.getClass().getTypeName()); | |||
| } | |||
| } | |||
| /** | |||
| * @param expression | |||
| * @param errorCode | |||
| @@ -37,7 +37,7 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm | |||
| @Override | |||
| public InvestPageResult<T> queryPage(InvestPageQuery<T> params) { | |||
| InvestHelper.allNotNull(params); | |||
| InvestHelper.notNull(params); | |||
| //1、分页信息 | |||
| Page<T> queryPage = buildQueryPage(params); | |||
| //2、查询数据 | |||
| @@ -105,10 +105,10 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| 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(); | |||
| InvestFollowRecordVo followRecordVo = new InvestFollowRecordVo(); | |||
| followRecordVo.setCustomer(customerEntity); | |||
| followRecordVo.setMemberInfo(ownerInfo); | |||
| followRecordVo.setBrand(brand); | |||
| followRecordVo.setOwnerInfo(usersMap.get(item.getOwner())); | |||
| BeanUtils.copyProperties(item, followRecordVo); | |||
| resultList.add(followRecordVo); | |||
| @@ -130,7 +130,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| @Transactional(rollbackFor = Exception.class) | |||
| @Override | |||
| public boolean saveCustomerAndDemand(InvestDemandDto demandDto) { | |||
| InvestHelper.allNotNull(demandDto); | |||
| InvestHelper.notNull(demandDto); | |||
| InvestCustomerEntity customerEntity = demandDto.getCustomer(); | |||
| InvestCustomerEntity customerEntityDB = customerService.getById(demandDto.getCustomerId()); | |||
| if (Objects.nonNull(customerEntity)) { | |||
| @@ -142,15 +142,16 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| } | |||
| InvestDemandEntity demandEntity = new InvestDemandEntity(); | |||
| BeanUtils.copyProperties(demandDto, demandEntity); | |||
| demandEntity.setCustomerId(customerEntity.getId()); | |||
| return demandService.save(demandEntity); | |||
| } | |||
| @Transactional(rollbackFor = Exception.class) | |||
| @Override | |||
| public boolean updateCustomerAndDemand(InvestDemandDto demandDto) { | |||
| InvestHelper.allNotNull(demandDto, demandDto.getCustomerId()); | |||
| InvestHelper.notNull(demandDto, demandDto.getCustomerId()); | |||
| InvestCustomerEntity customerEntity = demandDto.getCustomer(); | |||
| InvestHelper.allNotNull(customerEntity); | |||
| InvestHelper.notNull(customerEntity); | |||
| customerService.updateById(customerEntity); | |||
| InvestDemandEntity demandEntity = new InvestDemandEntity(); | |||
| BeanUtils.copyProperties(demandDto, demandEntity); | |||
| @@ -176,12 +177,11 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| } | |||
| 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(); | |||
| InvestDemandVo resultItemVo = new InvestDemandVo(); | |||
| resultItemVo.setBrand(brand); | |||
| resultItemVo.setCustomer(customer); | |||
| resultItemVo.setTargetInfo(shop); | |||
| resultItemVo.setOwnerInfo(usersMap.get(item.getOwner())); | |||
| BeanUtils.copyProperties(item, resultItemVo); | |||
| return resultItemVo; | |||
| } | |||
| @@ -193,10 +193,9 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| 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) | |||
| .build(); | |||
| InvestTaskVo resultItemVo = new InvestTaskVo(); | |||
| resultItemVo.setTargetInfo(shop); | |||
| resultItemVo.setOwnerInfo(ownerInfo); | |||
| BeanUtils.copyProperties(item, resultItemVo); | |||
| return resultItemVo; | |||
| } | |||
| @@ -30,7 +30,7 @@ public class InvestFollowRecordServiceImpl extends InvestBaseServiceImpl<InvestF | |||
| } | |||
| private void checkBeforeSaveOrUpdate(InvestFollowRecordEntity entity) { | |||
| InvestHelper.allNotNull(entity); | |||
| InvestHelper.notNull(entity); | |||
| InvestHelper.notNull(entity.getFollowId(), "followId"); | |||
| Object object = null; | |||
| if(Objects.equals(entity.getType(), EnumFollowType.DEMAND)) { | |||