diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java index a141571a5..4cdf9b149 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestBaseController.java +++ b/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.InvestResultData; import com.iformall.controller.base.BaseController; +import com.iformall.domain.po.WxUserDataRule; import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.enums.*; import com.iformall.exception.MallinkException; +import com.iformall.service.WxUserDataRuleService; import com.iformall.service.invest.InvestHelper; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; @@ -20,6 +23,9 @@ import java.util.function.Function; @Slf4j public class InvestBaseController extends BaseController { + @Autowired + private WxUserDataRuleService wxUserDataRuleService; + @InitBinder public void InitBinder(WebDataBinder 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 > void registerEnumEditor(WebDataBinder binder, Class clz, String propertyName) { binder.registerCustomEditor(clz, propertyName, newEnumEditor(clz)); } diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java b/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java index 0def385d1..9acce2b80 100755 --- a/mallinkAdmin/src/main/java/com/iformall/controller/invest/InvestCustomerController.java +++ b/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.beans.factory.annotation.Autowired; +import java.util.List; + /** * 招商模块-客户管理 @@ -44,8 +46,8 @@ public class InvestCustomerController extends InvestBaseController{ @ApiOperation("客户信息列表") @SystemControllerLog(description = "客户信息列表") @GetMapping("/list/simple") - public InvestResultData> listSimple(InvestDemandQuery params) { - return execute(params, p -> investBizService.queryPageDemand(p)); + public InvestResultData> listSimple() { + return execute(null, p -> investBizService.queryCustomer()); } /** diff --git a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestMessageEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestMessageEntity.java index 4092e23d1..80e69a5d7 100755 --- a/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestMessageEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/invest/InvestMessageEntity.java @@ -1,6 +1,8 @@ package com.iformall.domain.po.invest; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.iformall.enums.EnumFollowType; import lombok.Data; import lombok.EqualsAndHashCode; @@ -22,10 +24,30 @@ public class InvestMessageEntity extends InvestBaseEntity { */ @io.swagger.annotations.ApiModelProperty(value = "用户", name = "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") private String message; + /** + * 是否删除:0-否;1-是 + */ + @JsonIgnore + private Integer deleted = 0; + } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestUserContext.java b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestUserContext.java index efb86e6a4..f03eebd5b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestUserContext.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/invest/InvestUserContext.java @@ -1,12 +1,16 @@ package com.iformall.domain.vo.invest; +import com.iformall.common.ErrorCode; import com.iformall.domain.po.MallUserInfo; +import com.iformall.enums.EnumInvestUserType; +import com.iformall.exception.MallinkException; import java.util.Objects; public class InvestUserContext { - public static final ThreadLocal threadLocal = ThreadLocal.withInitial(() -> new MallUserInfo()); + private static final ThreadLocal USER_INFO_THREAD_LOCAL = ThreadLocal.withInitial(MallUserInfo::new); + private static final ThreadLocal MANAGER_THREAD_LOCAL = ThreadLocal.withInitial(() -> EnumInvestUserType.MANAGER); public static Long getUserId() { @@ -15,16 +19,36 @@ public class InvestUserContext { } 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) { 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() { - threadLocal.remove(); + USER_INFO_THREAD_LOCAL.remove(); + MANAGER_THREAD_LOCAL.remove(); } } diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumInvestMessageType.java b/mallinkService/src/main/java/com/iformall/enums/EnumInvestMessageType.java new file mode 100644 index 000000000..f8ab72833 --- /dev/null +++ b/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; + } +} diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumInvestUserType.java b/mallinkService/src/main/java/com/iformall/enums/EnumInvestUserType.java new file mode 100644 index 000000000..272fae033 --- /dev/null +++ b/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; + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java b/mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java index 24d81bbdc..a281b894b 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxUserDataRuleService.java @@ -2,6 +2,8 @@ package com.iformall.service; import com.iformall.domain.po.WxUserDataRule; +import java.util.List; + /** * @author gongbiao */ @@ -11,4 +13,5 @@ public interface WxUserDataRuleService { WxUserDataRule findByUserId(Long userId); + List list(WxUserDataRule rule) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java index 2c39d462e..2419b4e71 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/MallUserInfoServiceImpl.java +++ b/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.service.MallUserInfoService; import com.iformall.service.WxMallService; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,6 +68,9 @@ public class MallUserInfoServiceImpl implements MallUserInfoService { @Override public List getByIds(Collection ids) { + if(CollectionUtils.isEmpty(ids)) { + return new ArrayList<>() ; + } return mallUserInfoMapper.selectBatchIds(ids) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBrandServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBrandServiceImpl.java index a385f268f..7d693bfd3 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBrandServiceImpl.java +++ b/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.mapper.WxBrandMapper; import com.iformall.service.WxBrandService; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; 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 @@ -46,6 +44,9 @@ public class WxBrandServiceImpl implements WxBrandService { @Override public Collection getByIds(Collection ids) { + if(CollectionUtils.isEmpty(ids)) { + return new ArrayList<>() ; + } return wxBrandMapper.selectBatchIds(ids); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java index bf103fbe4..f5b79d217 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/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.service.ExcelService; import com.iformall.service.WxShopService; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,6 +78,9 @@ public class WxShopServiceImpl implements WxShopService { } public List getByIds(Collection ids) { + if(CollectionUtils.isEmpty(ids)) { + return new ArrayList<>() ; + } return wxShopMapper.selectBatchIds(ids) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java index 758f871b4..8cc54e2b8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxUserDataRuleServiceImpl.java +++ b/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 java.util.Date; +import java.util.List; /** * @author gongbiao @@ -49,4 +50,9 @@ public class WxUserDataRuleServiceImpl implements WxUserDataRuleService { wxUserDataRule.setUserId(userId); return wxUserDataRuleMapper.selectOne(new QueryWrapper(wxUserDataRule)); } + + @Override + public List list(WxUserDataRule rule) { + return wxUserDataRuleMapper.selectList(new QueryWrapper<>(rule)) ; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestBaseService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestBaseService.java index c8ab0b78e..6367b486f 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBaseService.java +++ b/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.iformall.domain.vo.invest.InvestPageQuery; import com.iformall.domain.vo.invest.InvestPageResult; +import com.iformall.enums.EnumFollowType; +import com.iformall.enums.EnumInvestMessageType; import java.io.Serializable; +import java.util.List; /** * 招商任务 @@ -20,5 +23,17 @@ public interface InvestBaseService { InvestPageResult queryPage(InvestPageQuery params, LambdaQueryWrapper queryWrapper) ; T getByIdNotNull(Serializable id); + + /** + * + * @param ownerArray + * @param message + * @param type + * @param tid + * @return + */ + default boolean saveBatchMessage(List ownerArray, EnumInvestMessageType message, EnumFollowType type, Long tid) { + return false; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java index 8699bf32f..2b6e2aa72 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestBizService.java +++ b/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 java.util.Collection; +import java.util.List; public interface InvestBizService { InvestPageResult queryPageDemand(InvestDemandQuery params); + List queryCustomer(); InvestPageResult queryPageTask(InvestTaskQuery params); diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java index dbaccc8fd..7625e2d30 100644 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestHelper.java +++ b/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.util.Collection; import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.function.Function; +import java.util.stream.Collectors; public class InvestHelper { @@ -151,7 +154,7 @@ public class InvestHelper { return (T) T.valueOf(enumType, name); } - private ImmutableListMultimap getMultiMap(Collection dataList) { + public ImmutableListMultimap getMultiMap(Collection dataList) { return Multimaps.index(dataList, new com.google.common.base.Function() { @Nullable @Override @@ -163,4 +166,12 @@ public class InvestHelper { } }); } + + public static Map getMap(Collection dataList, Function keyMapper) { + return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); + } + + public static Collection getIds(Collection dataList, Function mapper) { + return dataList.parallelStream().map(mapper).collect(Collectors.toList()); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/InvestMessageService.java b/mallinkService/src/main/java/com/iformall/service/invest/InvestMessageService.java index 3fa4c2fcc..474a98540 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/InvestMessageService.java +++ b/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.iformall.domain.po.invest.InvestMessageEntity; +import com.iformall.enums.EnumInvestMessageType; + +import java.util.List; /** * 招商任务 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 deecb7965..6a447c408 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 @@ -9,13 +9,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iformall.common.ErrorCode; 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.InvestPageResult; 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.EnumShopStatus; 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.InvestCustomerService; import com.iformall.service.invest.InvestHelper; +import com.iformall.service.invest.InvestMessageService; import com.iformall.utils.JsonUtil; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import java.io.Serializable; +import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.function.Consumer; import java.util.stream.Collectors; public class InvestBaseServiceImpl, T> extends ServiceImpl implements InvestBaseService { + @Autowired + private InvestMessageService messageService; + @Override public InvestPageResult queryPage(InvestPageQuery params) { return this.queryPage(params, null); @@ -98,6 +104,33 @@ public class InvestBaseServiceImpl, T> extends ServiceIm consumer.accept(input); } + @Override + public boolean saveBatchMessage(List ownerArray, EnumInvestMessageType message, EnumFollowType type, Long tid) { + if (CollectionUtils.isEmpty(ownerArray)) { + return false; + } + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InvestMessageEntity::getType, type); + queryWrapper.eq(InvestMessageEntity::getTid, tid); + queryWrapper.in(InvestMessageEntity::getOwner, ownerArray); + List before = messageService.list(); + Map map = InvestHelper.getMap(before,InvestMessageEntity::getOwner) ; + List 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); + } + /** * 校验商铺 * 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 4c20f1cc7..55a62e574 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 @@ -10,10 +10,12 @@ import com.iformall.domain.po.*; import com.iformall.domain.po.invest.*; import com.iformall.domain.vo.invest.*; import com.iformall.enums.EnumFollowType; +import com.iformall.enums.EnumInvestUserType; import com.iformall.enums.EnumNegotiationType; import com.iformall.service.MallUserInfoService; import com.iformall.service.WxBrandService; import com.iformall.service.WxShopService; +import com.iformall.service.WxUserDataRuleService; import com.iformall.service.invest.*; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; @@ -52,6 +54,8 @@ public class InvestBizServiceImpl implements InvestBizService { private WxBrandService brandService; @Autowired private MallUserInfoService userInfoService; + @Autowired + private WxUserDataRuleService wxUserDataRuleService; @Override public InvestPageResult queryPageDemand(InvestDemandQuery params) { @@ -80,6 +84,12 @@ public class InvestBizServiceImpl implements InvestBizService { return investPage; } + @Override + public List queryCustomer() { + List customerEntities = customerService.list(); + return getTargeInfoList(new ArrayList<>(), customerEntities); + } + private InvestDemandDto doConvertDemand(InvestDemandQuery params) { InvestCustomerEntity customerEntity = null; if (ObjectUtils.anyNotNull(params.getCustomerId(), params.getCustomerType(), params.getBusinessId())) { @@ -89,10 +99,11 @@ public class InvestBizServiceImpl implements InvestBizService { customerEntity.setBusinessId(params.getBusinessId()); } - InvestDemandEntity demandEntity = null; + InvestDemandEntity demandEntity = new InvestDemandEntity(); if (ObjectUtils.anyNotNull(params.getDemandOwner())) { - demandEntity = new InvestDemandEntity(); demandEntity.setOwner(params.getDemandOwner()); + } else { + demandEntity.setOwner(InvestUserContext.getDataUser()); } InvestDemandDto demandDto = new InvestDemandDto(); @@ -112,11 +123,9 @@ public class InvestBizServiceImpl implements InvestBizService { } LambdaQueryWrapper taskQueryWrapper = new LambdaQueryWrapper<>(); InvestPageResult 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)) { Collection shops = shopService.selectList(new QueryWrapper<>(shopParams)); @@ -126,7 +135,7 @@ public class InvestBizServiceImpl implements InvestBizService { taskQueryWrapper.in(InvestTaskEntity::getTargetId, getIds(shops, WxShop::getId)); } - InvestPageResult taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper); + InvestPageResult taskPage = taskService.queryPage(buildPageQuery(params, null), taskQueryWrapper); if (CollectionUtils.isEmpty(taskPage.getRecords())) { return investPage; } @@ -149,12 +158,13 @@ public class InvestBizServiceImpl implements InvestBizService { 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.setStatus(params.getTaskStatus()); + } else { + task.setOwner(Objects.isNull(InvestUserContext.getDataUser()) ? "" : String.valueOf(InvestUserContext.getDataUser())); } + task.setStatus(params.getTaskStatus()); WxShop shop = null; if (ObjectUtils.anyNotNull(params.getShopNumber(), params.getShopStatus(), params.getBusinessId())) { @@ -215,7 +225,11 @@ public class InvestBizServiceImpl implements InvestBizService { InvestPageQuery remindPageQuery = new InvestPageQuery<>(); BeanUtils.copyProperties(params, remindPageQuery); 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); InvestPageResult recordPage = remindService.queryPage(remindPageQuery); if (CollectionUtils.isEmpty(recordPage.getRecords())) { @@ -281,9 +295,11 @@ public class InvestBizServiceImpl implements InvestBizService { @Override public List 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 ruleList = wxUserDataRuleService.list(query); + return userInfoService.getByIds(getIds(ruleList, WxUserDataRule::getUserId)); } @Transactional(rollbackFor = Exception.class) @@ -497,7 +513,7 @@ public class InvestBizServiceImpl implements InvestBizService { //4、品牌 Map brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); //5、用户 - Map usersMap = getMap(userInfoService.findList(null), MallUserInfo::getId); + Map usersMap = getMap(userInfoService.getByIds(getIds(demandList,InvestDemandEntity::getOwner)), MallUserInfo::getId); List resultList = new ArrayList<>(); for (InvestCustomerEntity costomerItem : customers) { @@ -527,10 +543,13 @@ public class InvestBizServiceImpl implements InvestBizService { } private Map getMap(Collection dataList, Function keyMapper) { - return dataList.parallelStream().collect(Collectors.toMap(keyMapper, entity -> entity)); + if(CollectionUtils.isEmpty(dataList)) { + return new HashMap<>() ; + } + return InvestHelper.getMap(dataList, keyMapper); } private Collection getIds(Collection dataList, Function mapper) { - return dataList.parallelStream().map(mapper).collect(Collectors.toList()); + return InvestHelper.getIds(dataList, mapper); } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java index 3314b32c8..f5ad55c43 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestDemandServiceImpl.java +++ b/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.iformall.common.TableLog; 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.service.MallUserInfoService; 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.stereotype.Service; +import java.util.Arrays; +import java.util.List; import java.util.Objects; @@ -27,19 +31,33 @@ public class InvestDemandServiceImpl extends InvestBaseServiceImpl updateWrapper) { - return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); + super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); + saveMessage(entity); + return true; } @TableLog @Override 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 ownerArray = Arrays.asList(owner); + this.saveBatchMessage(ownerArray, EnumInvestMessageType.CUSTOMER_CREATE, EnumFollowType.DEMAND, entity.getId()); + } } private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) { diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java index f1963b4d1..18b1dc6b0 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestMessageServiceImpl.java +++ b/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.update.LambdaUpdateWrapper; -import com.iformall.common.TableLog; import com.iformall.domain.po.invest.InvestMessageEntity; import com.iformall.domain.vo.invest.InvestUserContext; import com.iformall.mapper.InvestMessageDao; @@ -11,23 +10,19 @@ import com.iformall.service.invest.InvestMessageService; import org.springframework.stereotype.Service; - @Service public class InvestMessageServiceImpl extends InvestBaseServiceImpl implements InvestMessageService { - @TableLog @Override public boolean save(InvestMessageEntity entity) { return super.saveAction(entity, this::checkBeforeSaveOrUpdate); } - @TableLog @Override public boolean update(InvestMessageEntity entity, Wrapper updateWrapper) { return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); } - @TableLog @Override public boolean updateById(InvestMessageEntity entity) { return super.updateByIdAction(entity, this::checkBeforeSaveOrUpdate); @@ -56,6 +51,7 @@ public class InvestMessageServiceImpl extends InvestBaseServiceImpl wrapper = new LambdaUpdateWrapper<>(); wrapper.eq(InvestMessageEntity::getTenantId, InvestUserContext.getUser().getTenantId()); wrapper.eq(InvestMessageEntity::getOwner, InvestUserContext.getUserId()); - return super.remove(wrapper); + wrapper.set(InvestMessageEntity::getDeleted, 1); + return super.update(wrapper); } } diff --git a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java index bc5a7f686..5433dc26a 100755 --- a/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/invest/impl/InvestTaskServiceImpl.java @@ -1,12 +1,16 @@ package com.iformall.service.invest.impl; +import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.iformall.common.TableLog; 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.service.MallUserInfoService; import com.iformall.service.WxShopService; import com.iformall.service.invest.InvestTaskService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,19 +28,33 @@ public class InvestTaskServiceImpl extends InvestBaseServiceImpl updateWrapper) { - return super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); + super.updateActon(entity, updateWrapper, this::checkBeforeSaveOrUpdate); + saveMessage(entity); + return true; } @TableLog @Override 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 ownerArray = JSONArray.parseArray(owner, Long.class); + this.saveBatchMessage(ownerArray, EnumInvestMessageType.TASK_CREATE, EnumFollowType.TASK, entity.getId()); + } } private void checkBeforeSaveOrUpdate(InvestTaskEntity entity) {