Просмотр исходного кода

[招商]adjust

release_toaliyun_real
Burce 6 лет назад
Родитель
Сommit
9174fe2e5e
20 измененных файлов: 319 добавлений и 46 удалений
  1. +15
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java
  2. +4
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java
  3. +22
    -0
      mallinkService/src/main/java/com/iformall/domain/po/invest/InvestMessageEntity.java
  4. +28
    -4
      mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestUserContext.java
  5. +44
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumInvestMessageType.java
  6. +33
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumInvestUserType.java
  7. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java
  8. +4
    -0
      mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java
  9. +5
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxBrandServiceImpl.java
  10. +4
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java
  11. +6
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java
  12. +15
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestBaseService.java
  13. +2
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java
  14. +12
    -1
      mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java
  15. +3
    -0
      mallinkService/src/main/java/com/iformall/service/invest/InvestMessageService.java
  16. +37
    -4
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java
  17. +38
    -19
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java
  18. +21
    -3
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java
  19. +2
    -6
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java
  20. +21
    -3
      mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java

+ 15
- 0
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java Просмотреть файл

@@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSON;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.common.InvestResultData; import com.iformall.common.InvestResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxUserDataRule;
import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.domain.vo.invest.InvestUserContext;
import com.iformall.enums.*; import com.iformall.enums.*;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.service.WxUserDataRuleService;
import com.iformall.service.invest.InvestHelper; import com.iformall.service.invest.InvestHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.InitBinder;


@@ -20,6 +23,9 @@ import java.util.function.Function;
@Slf4j @Slf4j
public class InvestBaseController extends BaseController { public class InvestBaseController extends BaseController {


@Autowired
private WxUserDataRuleService wxUserDataRuleService;

@InitBinder @InitBinder
public void InitBinder(WebDataBinder dataBinder) { public void InitBinder(WebDataBinder dataBinder) {
super.InitBinder(dataBinder); super.InitBinder(dataBinder);
@@ -51,6 +57,15 @@ public class InvestBaseController extends BaseController {
} }
} }


private void setDataRule() {
WxUserDataRule userDataRule = wxUserDataRuleService.findByUserId(getUserId());
if (userDataRule == null) {
log.info("用户的数据权限未配置");
}
EnumInvestUserType investUserType = EnumInvestUserType.getEnum(userDataRule.getType()) ;
InvestUserContext.setInvestUserType(investUserType);
}

private <T extends Enum<T>> void registerEnumEditor(WebDataBinder binder, Class<T> clz, String propertyName) { private <T extends Enum<T>> void registerEnumEditor(WebDataBinder binder, Class<T> clz, String propertyName) {
binder.registerCustomEditor(clz, propertyName, newEnumEditor(clz)); binder.registerCustomEditor(clz, propertyName, newEnumEditor(clz));
} }


+ 4
- 2
mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java Просмотреть файл

@@ -18,6 +18,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;



/** /**
* 招商模块-客户管理 * 招商模块-客户管理
@@ -44,8 +46,8 @@ public class InvestCustomerController extends InvestBaseController{
@ApiOperation("客户信息列表") @ApiOperation("客户信息列表")
@SystemControllerLog(description = "客户信息列表") @SystemControllerLog(description = "客户信息列表")
@GetMapping("/list/simple") @GetMapping("/list/simple")
public InvestResultData<InvestPageResult<InvestDemandVo>> listSimple(InvestDemandQuery params) {
return execute(params, p -> investBizService.queryPageDemand(p));
public InvestResultData<List<InvestDemandVo>> listSimple() {
return execute(null, p -> investBizService.queryCustomer());
} }


/** /**


+ 22
- 0
mallinkService/src/main/java/com/iformall/domain/po/invest/InvestMessageEntity.java Просмотреть файл

@@ -1,6 +1,8 @@
package com.iformall.domain.po.invest; package com.iformall.domain.po.invest;


import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.iformall.enums.EnumFollowType;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;


@@ -22,10 +24,30 @@ public class InvestMessageEntity extends InvestBaseEntity {
*/ */
@io.swagger.annotations.ApiModelProperty(value = "用户", name = "owner") @io.swagger.annotations.ApiModelProperty(value = "用户", name = "owner")
private Long owner; private Long owner;

/**
* 数据主键ID
*/
@JsonIgnore
//@io.swagger.annotations.ApiModelProperty(value = "数据主键ID", name = "tid")
private Long tid;

/**
* 数据类型:0-招商任务;1-客户需求
*/
@JsonIgnore
//@io.swagger.annotations.ApiModelProperty(value = "数据类型:0-招商任务;1-客户需求", name = "type")
private EnumFollowType type;
/** /**
* 消息内容 * 消息内容
*/ */
@io.swagger.annotations.ApiModelProperty(value = "消息内容", name = "message") @io.swagger.annotations.ApiModelProperty(value = "消息内容", name = "message")
private String message; private String message;


/**
* 是否删除:0-否;1-是
*/
@JsonIgnore
private Integer deleted = 0;

} }

+ 28
- 4
mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestUserContext.java Просмотреть файл

@@ -1,12 +1,16 @@
package com.iformall.domain.vo.invest; package com.iformall.domain.vo.invest;


import com.iformall.common.ErrorCode;
import com.iformall.domain.po.MallUserInfo; import com.iformall.domain.po.MallUserInfo;
import com.iformall.enums.EnumInvestUserType;
import com.iformall.exception.MallinkException;


import java.util.Objects; import java.util.Objects;


public class InvestUserContext { public class InvestUserContext {


public static final ThreadLocal<MallUserInfo> threadLocal = ThreadLocal.withInitial(() -> new MallUserInfo());
private static final ThreadLocal<MallUserInfo> USER_INFO_THREAD_LOCAL = ThreadLocal.withInitial(MallUserInfo::new);
private static final ThreadLocal<EnumInvestUserType> MANAGER_THREAD_LOCAL = ThreadLocal.withInitial(() -> EnumInvestUserType.MANAGER);




public static Long getUserId() { public static Long getUserId() {
@@ -15,16 +19,36 @@ public class InvestUserContext {
} }


public static MallUserInfo getUser() { public static MallUserInfo getUser() {
return threadLocal.get();
return USER_INFO_THREAD_LOCAL.get();
}

public static Long getDataUser() {
if (isManager()) {
return null;
} else {
return getUserId();
}
} }


public static void setUser(MallUserInfo user) { public static void setUser(MallUserInfo user) {
if (user != null) { if (user != null) {
threadLocal.set(user);
USER_INFO_THREAD_LOCAL.set(user);
}
}

public static void setInvestUserType(EnumInvestUserType type) {
if(Objects.isNull(type)) {
throw new MallinkException(ErrorCode.USER_NO_PERMISSION.getCode(), "用户的数据权限未配置");
} }
MANAGER_THREAD_LOCAL.set(type);
}

public static boolean isManager() {
return Objects.equals(MANAGER_THREAD_LOCAL.get(), EnumInvestUserType.MANAGER);
} }


public static void remove() { public static void remove() {
threadLocal.remove();
USER_INFO_THREAD_LOCAL.remove();
MANAGER_THREAD_LOCAL.remove();
} }
} }

+ 44
- 0
mallinkService/src/main/java/com/iformall/enums/EnumInvestMessageType.java Просмотреть файл

@@ -0,0 +1,44 @@
package com.iformall.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

public enum EnumInvestMessageType {

TASK_REMIND(0, "【%d】需在%s前完成,请及时跟进!"),
COSTOMER_REMIND(1, "【%d】已超过一周没有跟进,请及时跟进!"),
TASK_CREATE(2, "管理员向您指派了一个任务"),
CUSTOMER_CREATE(3, "管理员向您指派了一个客户"),
;

public static String message(EnumInvestMessageType type, Object... args) {
return String.format(type.info, args);
}

public static EnumInvestMessageType getEnum(Integer code) {
for (EnumInvestMessageType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

@EnumValue
private final Integer code;
private final String info;

EnumInvestMessageType(Integer code, String info) {
this.code = code;
this.info = info;
}

@JsonValue
public Integer getCode() {
return code;
}

public String getInfo() {
return info;
}
}

+ 33
- 0
mallinkService/src/main/java/com/iformall/enums/EnumInvestUserType.java Просмотреть файл

@@ -0,0 +1,33 @@
package com.iformall.enums;


public enum EnumInvestUserType {
MANAGER(301, "招商管理人员"),
USER(302, "招商人员"),
;

public static EnumInvestUserType getEnum(Integer code) {
for (EnumInvestUserType value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private final Integer code;
private final String info;

EnumInvestUserType(Integer code, String info) {
this.code = code;
this.info = info;
}

public Integer getCode() {
return code;
}

public String getInfo() {
return info;
}
}

+ 3
- 0
mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java Просмотреть файл

@@ -2,6 +2,8 @@ package com.iformall.service;


import com.iformall.domain.po.WxUserDataRule; import com.iformall.domain.po.WxUserDataRule;


import java.util.List;

/** /**
* @author gongbiao * @author gongbiao
*/ */
@@ -11,4 +13,5 @@ public interface WxUserDataRuleService {


WxUserDataRule findByUserId(Long userId); WxUserDataRule findByUserId(Long userId);


List<WxUserDataRule> list(WxUserDataRule rule) ;
} }

+ 4
- 0
mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java Просмотреть файл

@@ -19,6 +19,7 @@ import com.iformall.mapper.MallUserRoleMapper;
import com.iformall.mapper.WxMsgValidationcodeMapper; import com.iformall.mapper.WxMsgValidationcodeMapper;
import com.iformall.service.MallUserInfoService; import com.iformall.service.MallUserInfoService;
import com.iformall.service.WxMallService; import com.iformall.service.WxMallService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -67,6 +68,9 @@ public class MallUserInfoServiceImpl implements MallUserInfoService {


@Override @Override
public List<MallUserInfo> getByIds(Collection<? extends Serializable> ids) { public List<MallUserInfo> getByIds(Collection<? extends Serializable> ids) {
if(CollectionUtils.isEmpty(ids)) {
return new ArrayList<>() ;
}
return mallUserInfoMapper.selectBatchIds(ids) ; return mallUserInfoMapper.selectBatchIds(ids) ;
} }




+ 5
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxBrandServiceImpl.java Просмотреть файл

@@ -12,6 +12,7 @@ import com.iformall.enums.EnumDelFlag;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxBrandMapper; import com.iformall.mapper.WxBrandMapper;
import com.iformall.service.WxBrandService; import com.iformall.service.WxBrandService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.io.Serializable; import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;


/** /**
* @author gongbiao * @author gongbiao
@@ -46,6 +44,9 @@ public class WxBrandServiceImpl implements WxBrandService {


@Override @Override
public Collection<WxBrand> getByIds(Collection<? extends Serializable> ids) { public Collection<WxBrand> getByIds(Collection<? extends Serializable> ids) {
if(CollectionUtils.isEmpty(ids)) {
return new ArrayList<>() ;
}
return wxBrandMapper.selectBatchIds(ids); return wxBrandMapper.selectBatchIds(ids);
} }




+ 4
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java Просмотреть файл

@@ -18,6 +18,7 @@ import com.iformall.mapper.WxRentContractMapper;
import com.iformall.mapper.WxShopMapper; import com.iformall.mapper.WxShopMapper;
import com.iformall.service.ExcelService; import com.iformall.service.ExcelService;
import com.iformall.service.WxShopService; import com.iformall.service.WxShopService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -77,6 +78,9 @@ public class WxShopServiceImpl implements WxShopService {
} }


public List<WxShop> getByIds(Collection<? extends Serializable> ids) { public List<WxShop> getByIds(Collection<? extends Serializable> ids) {
if(CollectionUtils.isEmpty(ids)) {
return new ArrayList<>() ;
}
return wxShopMapper.selectBatchIds(ids) ; return wxShopMapper.selectBatchIds(ids) ;
} }




+ 6
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java Просмотреть файл

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.Date; import java.util.Date;
import java.util.List;


/** /**
* @author gongbiao * @author gongbiao
@@ -49,4 +50,9 @@ public class WxUserDataRuleServiceImpl implements WxUserDataRuleService {
wxUserDataRule.setUserId(userId); wxUserDataRule.setUserId(userId);
return wxUserDataRuleMapper.selectOne(new QueryWrapper(wxUserDataRule)); return wxUserDataRuleMapper.selectOne(new QueryWrapper(wxUserDataRule));
} }

@Override
public List<WxUserDataRule> list(WxUserDataRule rule) {
return wxUserDataRuleMapper.selectList(new QueryWrapper<>(rule)) ;
}
} }

+ 15
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestBaseService.java Просмотреть файл

@@ -3,8 +3,11 @@ package com.iformall.service.invest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.iformall.domain.vo.invest.InvestPageQuery; import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult; import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.enums.EnumFollowType;
import com.iformall.enums.EnumInvestMessageType;


import java.io.Serializable; import java.io.Serializable;
import java.util.List;


/** /**
* 招商任务 * 招商任务
@@ -20,5 +23,17 @@ public interface InvestBaseService<T> {
InvestPageResult<T> queryPage(InvestPageQuery<T> params, LambdaQueryWrapper<T> queryWrapper) ; InvestPageResult<T> queryPage(InvestPageQuery<T> params, LambdaQueryWrapper<T> queryWrapper) ;


T getByIdNotNull(Serializable id); T getByIdNotNull(Serializable id);

/**
*
* @param ownerArray
* @param message
* @param type
* @param tid
* @return
*/
default boolean saveBatchMessage(List<Long> ownerArray, EnumInvestMessageType message, EnumFollowType type, Long tid) {
return false;
}
} }



+ 2
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java Просмотреть файл

@@ -6,10 +6,12 @@ import com.iformall.domain.po.invest.InvestMessageEntity;
import com.iformall.domain.vo.invest.*; import com.iformall.domain.vo.invest.*;


import java.util.Collection; import java.util.Collection;
import java.util.List;


public interface InvestBizService { public interface InvestBizService {


InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params); InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params);
List<InvestDemandVo> queryCustomer();


InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params); InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params);




+ 12
- 1
mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java Просмотреть файл

@@ -16,7 +16,10 @@ import java.lang.reflect.Method;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;


public class InvestHelper { public class InvestHelper {


@@ -151,7 +154,7 @@ public class InvestHelper {
return (T) T.valueOf(enumType, name); return (T) T.valueOf(enumType, name);
} }


private <T, R> ImmutableListMultimap<R, T> getMultiMap(Collection<T> dataList) {
public <T, R> ImmutableListMultimap<R, T> getMultiMap(Collection<T> dataList) {
return Multimaps.index(dataList, new com.google.common.base.Function<T, R>() { return Multimaps.index(dataList, new com.google.common.base.Function<T, R>() {
@Nullable @Nullable
@Override @Override
@@ -163,4 +166,12 @@ public class InvestHelper {
} }
}); });
} }

public static <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) {
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity));
}

public static <T, R> Collection<R> getIds(Collection<T> dataList, Function<? super T, R> mapper) {
return dataList.parallelStream().map(mapper).collect(Collectors.toList());
}
} }

+ 3
- 0
mallinkService/src/main/java/com/iformall/service/invest/InvestMessageService.java Просмотреть файл

@@ -2,6 +2,9 @@ package com.iformall.service.invest;


import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.iformall.domain.po.invest.InvestMessageEntity; import com.iformall.domain.po.invest.InvestMessageEntity;
import com.iformall.enums.EnumInvestMessageType;

import java.util.List;


/** /**
* 招商任务 * 招商任务


+ 37
- 4
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBaseServiceImpl.java Просмотреть файл

@@ -9,13 +9,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iformall.common.ErrorCode; import com.iformall.common.ErrorCode;
import com.iformall.domain.po.*; import com.iformall.domain.po.*;
import com.iformall.domain.po.invest.InvestBaseEntity;
import com.iformall.domain.po.invest.InvestCustomerEntity;
import com.iformall.domain.po.invest.InvestDemandEntity;
import com.iformall.domain.po.invest.InvestTaskEntity;
import com.iformall.domain.po.invest.*;
import com.iformall.domain.vo.invest.InvestPageQuery; import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult; import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.domain.vo.invest.InvestUserContext;
import com.iformall.enums.EnumFollowType;
import com.iformall.enums.EnumInvestMessageType;
import com.iformall.enums.EnumInvestType; import com.iformall.enums.EnumInvestType;
import com.iformall.enums.EnumShopStatus; import com.iformall.enums.EnumShopStatus;
import com.iformall.exception.MallinkException; import com.iformall.exception.MallinkException;
@@ -26,18 +25,25 @@ import com.iformall.service.WxShopService;
import com.iformall.service.invest.InvestBaseService; import com.iformall.service.invest.InvestBaseService;
import com.iformall.service.invest.InvestCustomerService; import com.iformall.service.invest.InvestCustomerService;
import com.iformall.service.invest.InvestHelper; import com.iformall.service.invest.InvestHelper;
import com.iformall.service.invest.InvestMessageService;
import com.iformall.utils.JsonUtil; import com.iformall.utils.JsonUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;


import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;


public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements InvestBaseService<T> { public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements InvestBaseService<T> {


@Autowired
private InvestMessageService messageService;

@Override @Override
public InvestPageResult<T> queryPage(InvestPageQuery<T> params) { public InvestPageResult<T> queryPage(InvestPageQuery<T> params) {
return this.queryPage(params, null); return this.queryPage(params, null);
@@ -98,6 +104,33 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm
consumer.accept(input); consumer.accept(input);
} }


@Override
public boolean saveBatchMessage(List<Long> ownerArray, EnumInvestMessageType message, EnumFollowType type, Long tid) {
if (CollectionUtils.isEmpty(ownerArray)) {
return false;
}
LambdaQueryWrapper<InvestMessageEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InvestMessageEntity::getType, type);
queryWrapper.eq(InvestMessageEntity::getTid, tid);
queryWrapper.in(InvestMessageEntity::getOwner, ownerArray);
List<InvestMessageEntity> before = messageService.list();
Map<Long,InvestMessageEntity> map = InvestHelper.getMap(before,InvestMessageEntity::getOwner) ;
List<InvestMessageEntity> messageEntityList = new ArrayList<>();
for (Long aLong : ownerArray) {
if(Objects.nonNull(map.get(aLong))) {
continue;
}
InvestMessageEntity messageEntity = new InvestMessageEntity();
messageEntity.setOwner(aLong);
messageEntity.setTid(tid);
messageEntity.setType(type);
messageEntity.setTenantId(InvestUserContext.getUser().getTenantId());
messageEntity.setMessage(EnumInvestMessageType.message(message));
messageEntityList.add(messageEntity);
}
return messageService.saveBatch(messageEntityList);
}

/** /**
* 校验商铺 * 校验商铺
* *


+ 38
- 19
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestBizServiceImpl.java Просмотреть файл

@@ -10,10 +10,12 @@ import com.iformall.domain.po.*;
import com.iformall.domain.po.invest.*; import com.iformall.domain.po.invest.*;
import com.iformall.domain.vo.invest.*; import com.iformall.domain.vo.invest.*;
import com.iformall.enums.EnumFollowType; import com.iformall.enums.EnumFollowType;
import com.iformall.enums.EnumInvestUserType;
import com.iformall.enums.EnumNegotiationType; import com.iformall.enums.EnumNegotiationType;
import com.iformall.service.MallUserInfoService; import com.iformall.service.MallUserInfoService;
import com.iformall.service.WxBrandService; import com.iformall.service.WxBrandService;
import com.iformall.service.WxShopService; import com.iformall.service.WxShopService;
import com.iformall.service.WxUserDataRuleService;
import com.iformall.service.invest.*; import com.iformall.service.invest.*;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
@@ -52,6 +54,8 @@ public class InvestBizServiceImpl implements InvestBizService {
private WxBrandService brandService; private WxBrandService brandService;
@Autowired @Autowired
private MallUserInfoService userInfoService; private MallUserInfoService userInfoService;
@Autowired
private WxUserDataRuleService wxUserDataRuleService;


@Override @Override
public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) { public InvestPageResult<InvestDemandVo> queryPageDemand(InvestDemandQuery params) {
@@ -80,6 +84,12 @@ public class InvestBizServiceImpl implements InvestBizService {
return investPage; return investPage;
} }


@Override
public List<InvestDemandVo> queryCustomer() {
List<InvestCustomerEntity> customerEntities = customerService.list();
return getTargeInfoList(new ArrayList<>(), customerEntities);
}

private InvestDemandDto doConvertDemand(InvestDemandQuery params) { private InvestDemandDto doConvertDemand(InvestDemandQuery params) {
InvestCustomerEntity customerEntity = null; InvestCustomerEntity customerEntity = null;
if (ObjectUtils.anyNotNull(params.getCustomerId(), params.getCustomerType(), params.getBusinessId())) { if (ObjectUtils.anyNotNull(params.getCustomerId(), params.getCustomerType(), params.getBusinessId())) {
@@ -89,10 +99,11 @@ public class InvestBizServiceImpl implements InvestBizService {
customerEntity.setBusinessId(params.getBusinessId()); customerEntity.setBusinessId(params.getBusinessId());
} }


InvestDemandEntity demandEntity = null;
InvestDemandEntity demandEntity = new InvestDemandEntity();
if (ObjectUtils.anyNotNull(params.getDemandOwner())) { if (ObjectUtils.anyNotNull(params.getDemandOwner())) {
demandEntity = new InvestDemandEntity();
demandEntity.setOwner(params.getDemandOwner()); demandEntity.setOwner(params.getDemandOwner());
} else {
demandEntity.setOwner(InvestUserContext.getDataUser());
} }


InvestDemandDto demandDto = new InvestDemandDto(); InvestDemandDto demandDto = new InvestDemandDto();
@@ -112,11 +123,9 @@ public class InvestBizServiceImpl implements InvestBizService {
} }
LambdaQueryWrapper<InvestTaskEntity> taskQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InvestTaskEntity> taskQueryWrapper = new LambdaQueryWrapper<>();
InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>(); InvestPageResult<InvestTaskVo> investPage = new InvestPageResult<>();
if (Objects.nonNull(taskParams)) {
taskQueryWrapper.apply(StringUtils.isNotEmpty(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner());
taskParams.setOwner(null);
taskQueryWrapper.setEntity(taskParams);
}
taskQueryWrapper.apply(StringUtils.isNotEmpty(taskParams.getOwner()), "`owner` REGEXP {0}", taskParams.getOwner());
taskParams.setOwner(null);
taskQueryWrapper.setEntity(taskParams);


if (Objects.nonNull(shopParams)) { if (Objects.nonNull(shopParams)) {
Collection<WxShop> shops = shopService.selectList(new QueryWrapper<>(shopParams)); Collection<WxShop> shops = shopService.selectList(new QueryWrapper<>(shopParams));
@@ -126,7 +135,7 @@ public class InvestBizServiceImpl implements InvestBizService {
taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId));
} }


InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper);
InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, null), taskQueryWrapper);
if (CollectionUtils.isEmpty(taskPage.getRecords())) { if (CollectionUtils.isEmpty(taskPage.getRecords())) {
return investPage; return investPage;
} }
@@ -149,12 +158,13 @@ public class InvestBizServiceImpl implements InvestBizService {




private InvestTaskDto doConvertTask(InvestTaskQuery params) { private InvestTaskDto doConvertTask(InvestTaskQuery params) {
InvestTaskEntity task = null;
if (ObjectUtils.anyNotNull(params.getTaskOwner(), params.getTaskStatus())) {
task = new InvestTaskEntity();
InvestTaskEntity task = new InvestTaskEntity();
if (Objects.nonNull(params.getTaskOwner())) {
task.setOwner(params.getTaskOwner()); task.setOwner(params.getTaskOwner());
task.setStatus(params.getTaskStatus());
} else {
task.setOwner(Objects.isNull(InvestUserContext.getDataUser()) ? "" : String.valueOf(InvestUserContext.getDataUser()));
} }
task.setStatus(params.getTaskStatus());


WxShop shop = null; WxShop shop = null;
if (ObjectUtils.anyNotNull(params.getShopNumber(), params.getShopStatus(), params.getBusinessId())) { if (ObjectUtils.anyNotNull(params.getShopNumber(), params.getShopStatus(), params.getBusinessId())) {
@@ -215,7 +225,11 @@ public class InvestBizServiceImpl implements InvestBizService {
InvestPageQuery<InvestRemindEntity> remindPageQuery = new InvestPageQuery<>(); InvestPageQuery<InvestRemindEntity> remindPageQuery = new InvestPageQuery<>();
BeanUtils.copyProperties(params, remindPageQuery); BeanUtils.copyProperties(params, remindPageQuery);
InvestRemindEntity remindQuery = new InvestRemindEntity(); InvestRemindEntity remindQuery = new InvestRemindEntity();
remindQuery.setOwner(params.getOwnerId());
if (Objects.isNull(params.getOwnerId())) {
remindQuery.setOwner(InvestUserContext.getDataUser());
} else {
remindQuery.setOwner(params.getOwnerId());
}
remindPageQuery.setQueryData(remindQuery); remindPageQuery.setQueryData(remindQuery);
InvestPageResult<InvestRemindEntity> recordPage = remindService.queryPage(remindPageQuery); InvestPageResult<InvestRemindEntity> recordPage = remindService.queryPage(remindPageQuery);
if (CollectionUtils.isEmpty(recordPage.getRecords())) { if (CollectionUtils.isEmpty(recordPage.getRecords())) {
@@ -281,9 +295,11 @@ public class InvestBizServiceImpl implements InvestBizService {


@Override @Override
public List<MallUserInfo> queryUserList() { public List<MallUserInfo> queryUserList() {
MallUserInfo query = new MallUserInfo();
query.setIsAdmin(0);
return userInfoService.findList(query);
WxUserDataRule query = new WxUserDataRule();
query.setTenantId(InvestUserContext.getUser().getTenantId());
query.setType(EnumInvestUserType.USER.getCode());
List<WxUserDataRule> ruleList = wxUserDataRuleService.list(query);
return userInfoService.getByIds(getIds(ruleList, WxUserDataRule::getUserId));
} }


@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -497,7 +513,7 @@ public class InvestBizServiceImpl implements InvestBizService {
//4、品牌 //4、品牌
Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId);
//5、用户 //5、用户
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId);
Map<Long, MallUserInfo> usersMap = getMap(userInfoService.getByIds(getIds(demandList,InvestDemandEntity::getOwner)), MallUserInfo::getId);


List<InvestDemandVo> resultList = new ArrayList<>(); List<InvestDemandVo> resultList = new ArrayList<>();
for (InvestCustomerEntity costomerItem : customers) { for (InvestCustomerEntity costomerItem : customers) {
@@ -527,10 +543,13 @@ public class InvestBizServiceImpl implements InvestBizService {
} }


private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) { private <T, R> Map<R, T> getMap(Collection<T> dataList, Function<T, R> keyMapper) {
return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity));
if(CollectionUtils.isEmpty(dataList)) {
return new HashMap<>() ;
}
return InvestHelper.getMap(dataList, keyMapper);
} }


private <T, R> Collection<R> getIds(Collection<T> dataList, Function<? super T, R> mapper) { private <T, R> Collection<R> getIds(Collection<T> dataList, Function<? super T, R> mapper) {
return dataList.parallelStream().map(mapper).collect(Collectors.toList());
return InvestHelper.getIds(dataList, mapper);
} }
} }

+ 21
- 3
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java Просмотреть файл

@@ -3,6 +3,8 @@ package com.iformall.service.invest.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.iformall.common.TableLog; import com.iformall.common.TableLog;
import com.iformall.domain.po.invest.InvestDemandEntity; import com.iformall.domain.po.invest.InvestDemandEntity;
import com.iformall.enums.EnumFollowType;
import com.iformall.enums.EnumInvestMessageType;
import com.iformall.mapper.InvestDemandDao; import com.iformall.mapper.InvestDemandDao;
import com.iformall.service.MallUserInfoService; import com.iformall.service.MallUserInfoService;
import com.iformall.service.WxShopService; import com.iformall.service.WxShopService;
@@ -11,6 +13,8 @@ import com.iformall.service.invest.InvestDemandService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.util.Arrays;
import java.util.List;
import java.util.Objects; import java.util.Objects;




@@ -27,19 +31,33 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl<InvestDemandD
@TableLog @TableLog
@Override @Override
public boolean save(InvestDemandEntity entity) { public boolean save(InvestDemandEntity entity) {
return super.saveAction(entity, this::checkBeforeSaveOrUpdate);
super.saveAction(entity, this::checkBeforeSaveOrUpdate);
saveMessage(entity);
return true;
} }


@TableLog @TableLog
@Override @Override
public boolean update(InvestDemandEntity entity, Wrapper<InvestDemandEntity> updateWrapper) { public boolean update(InvestDemandEntity entity, Wrapper<InvestDemandEntity> updateWrapper) {
return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate);
super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate);
saveMessage(entity);
return true;
} }


@TableLog @TableLog
@Override @Override
public boolean updateById(InvestDemandEntity entity) { public boolean updateById(InvestDemandEntity entity) {
return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate);
super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate);
saveMessage(entity);
return true;
}

private void saveMessage(InvestDemandEntity entity) {
Long owner = entity.getOwner();
if (Objects.nonNull(owner)) {
List<Long> ownerArray = Arrays.asList(owner);
this.saveBatchMessage(ownerArray, EnumInvestMessageType.CUSTOMER_CREATE, EnumFollowType.DEMAND, entity.getId());
}
} }


private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) { private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) {


+ 2
- 6
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java Просмотреть файл

@@ -2,7 +2,6 @@ package com.iformall.service.invest.impl;


import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.iformall.common.TableLog;
import com.iformall.domain.po.invest.InvestMessageEntity; import com.iformall.domain.po.invest.InvestMessageEntity;
import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.domain.vo.invest.InvestUserContext;
import com.iformall.mapper.InvestMessageDao; import com.iformall.mapper.InvestMessageDao;
@@ -11,23 +10,19 @@ import com.iformall.service.invest.InvestMessageService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;





@Service @Service
public class InvestMessageServiceImpl extends InvestBaseServiceImpl<InvestMessageDao, InvestMessageEntity> implements InvestMessageService { public class InvestMessageServiceImpl extends InvestBaseServiceImpl<InvestMessageDao, InvestMessageEntity> implements InvestMessageService {


@TableLog
@Override @Override
public boolean save(InvestMessageEntity entity) { public boolean save(InvestMessageEntity entity) {
return super.saveAction(entity, this::checkBeforeSaveOrUpdate); return super.saveAction(entity, this::checkBeforeSaveOrUpdate);
} }


@TableLog
@Override @Override
public boolean update(InvestMessageEntity entity, Wrapper<InvestMessageEntity> updateWrapper) { public boolean update(InvestMessageEntity entity, Wrapper<InvestMessageEntity> updateWrapper) {
return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate);
} }


@TableLog
@Override @Override
public boolean updateById(InvestMessageEntity entity) { public boolean updateById(InvestMessageEntity entity) {
return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate); return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate);
@@ -56,6 +51,7 @@ public class InvestMessageServiceImpl extends InvestBaseServiceImpl<InvestMessag
LambdaUpdateWrapper<InvestMessageEntity> wrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<InvestMessageEntity> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(InvestMessageEntity::getTenantId, InvestUserContext.getUser().getTenantId()); wrapper.eq(InvestMessageEntity::getTenantId, InvestUserContext.getUser().getTenantId());
wrapper.eq(InvestMessageEntity::getOwner, InvestUserContext.getUserId()); wrapper.eq(InvestMessageEntity::getOwner, InvestUserContext.getUserId());
return super.remove(wrapper);
wrapper.set(InvestMessageEntity::getDeleted, 1);
return super.update(wrapper);
} }
} }

+ 21
- 3
mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java Просмотреть файл

@@ -1,12 +1,16 @@
package com.iformall.service.invest.impl; package com.iformall.service.invest.impl;


import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.iformall.common.TableLog; import com.iformall.common.TableLog;
import com.iformall.domain.po.invest.InvestTaskEntity; import com.iformall.domain.po.invest.InvestTaskEntity;
import com.iformall.enums.EnumFollowType;
import com.iformall.enums.EnumInvestMessageType;
import com.iformall.mapper.InvestTaskDao; import com.iformall.mapper.InvestTaskDao;
import com.iformall.service.MallUserInfoService; import com.iformall.service.MallUserInfoService;
import com.iformall.service.WxShopService; import com.iformall.service.WxShopService;
import com.iformall.service.invest.InvestTaskService; import com.iformall.service.invest.InvestTaskService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


@@ -24,19 +28,33 @@ public class InvestTaskServiceImpl extends InvestBaseServiceImpl<InvestTaskDao,
@TableLog @TableLog
@Override @Override
public boolean save(InvestTaskEntity entity) { public boolean save(InvestTaskEntity entity) {
return super.saveAction(entity, this::checkBeforeSaveOrUpdate);
super.saveAction(entity, this::checkBeforeSaveOrUpdate);
saveMessage(entity);
return true;
} }


@TableLog @TableLog
@Override @Override
public boolean update(InvestTaskEntity entity, Wrapper<InvestTaskEntity> updateWrapper) { public boolean update(InvestTaskEntity entity, Wrapper<InvestTaskEntity> updateWrapper) {
return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate);
super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate);
saveMessage(entity);
return true;
} }


@TableLog @TableLog
@Override @Override
public boolean updateById(InvestTaskEntity entity) { public boolean updateById(InvestTaskEntity entity) {
return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate);
super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate);
saveMessage(entity);
return true;
}

private void saveMessage(InvestTaskEntity entity) {
String owner = entity.getOwner();
if (StringUtils.isNotEmpty(owner)) {
List<Long> ownerArray = JSONArray.parseArray(owner, Long.class);
this.saveBatchMessage(ownerArray, EnumInvestMessageType.TASK_CREATE, EnumFollowType.TASK, entity.getId());
}
} }


private void checkBeforeSaveOrUpdate(InvestTaskEntity entity) { private void checkBeforeSaveOrUpdate(InvestTaskEntity entity) {


Загрузка…
Отмена
Сохранить