| @@ -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 <T extends Enum<T>> void registerEnumEditor(WebDataBinder binder, Class<T> clz, String propertyName) { | |||
| binder.registerCustomEditor(clz, propertyName, newEnumEditor(clz)); | |||
| } | |||
| @@ -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<InvestPageResult<InvestDemandVo>> listSimple(InvestDemandQuery params) { | |||
| return execute(params, p -> investBizService.queryPageDemand(p)); | |||
| public InvestResultData<List<InvestDemandVo>> listSimple() { | |||
| return execute(null, p -> investBizService.queryCustomer()); | |||
| } | |||
| /** | |||
| @@ -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; | |||
| } | |||
| @@ -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<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() { | |||
| @@ -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(); | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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<WxUserDataRule> list(WxUserDataRule rule) ; | |||
| } | |||
| @@ -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<MallUserInfo> getByIds(Collection<? extends Serializable> ids) { | |||
| if(CollectionUtils.isEmpty(ids)) { | |||
| return new ArrayList<>() ; | |||
| } | |||
| return mallUserInfoMapper.selectBatchIds(ids) ; | |||
| } | |||
| @@ -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<WxBrand> getByIds(Collection<? extends Serializable> ids) { | |||
| if(CollectionUtils.isEmpty(ids)) { | |||
| return new ArrayList<>() ; | |||
| } | |||
| return wxBrandMapper.selectBatchIds(ids); | |||
| } | |||
| @@ -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<WxShop> getByIds(Collection<? extends Serializable> ids) { | |||
| if(CollectionUtils.isEmpty(ids)) { | |||
| return new ArrayList<>() ; | |||
| } | |||
| return wxShopMapper.selectBatchIds(ids) ; | |||
| } | |||
| @@ -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<WxUserDataRule> list(WxUserDataRule rule) { | |||
| return wxUserDataRuleMapper.selectList(new QueryWrapper<>(rule)) ; | |||
| } | |||
| } | |||
| @@ -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<T> { | |||
| InvestPageResult<T> queryPage(InvestPageQuery<T> params, LambdaQueryWrapper<T> queryWrapper) ; | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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<InvestDemandVo> queryPageDemand(InvestDemandQuery params); | |||
| List<InvestDemandVo> queryCustomer(); | |||
| InvestPageResult<InvestTaskVo> queryPageTask(InvestTaskQuery params); | |||
| @@ -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 <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>() { | |||
| @Nullable | |||
| @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()); | |||
| } | |||
| } | |||
| @@ -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; | |||
| /** | |||
| * 招商任务 | |||
| @@ -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<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements InvestBaseService<T> { | |||
| @Autowired | |||
| private InvestMessageService messageService; | |||
| @Override | |||
| public InvestPageResult<T> queryPage(InvestPageQuery<T> params) { | |||
| return this.queryPage(params, null); | |||
| @@ -98,6 +104,33 @@ public class InvestBaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceIm | |||
| 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); | |||
| } | |||
| /** | |||
| * 校验商铺 | |||
| * | |||
| @@ -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<InvestDemandVo> queryPageDemand(InvestDemandQuery params) { | |||
| @@ -80,6 +84,12 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| return investPage; | |||
| } | |||
| @Override | |||
| public List<InvestDemandVo> queryCustomer() { | |||
| List<InvestCustomerEntity> 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<InvestTaskEntity> taskQueryWrapper = new LambdaQueryWrapper<>(); | |||
| 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)) { | |||
| 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)); | |||
| } | |||
| InvestPageResult<InvestTaskEntity> taskPage = taskService.queryPage(buildPageQuery(params, taskParams), taskQueryWrapper); | |||
| InvestPageResult<InvestTaskEntity> 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<InvestRemindEntity> 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<InvestRemindEntity> recordPage = remindService.queryPage(remindPageQuery); | |||
| if (CollectionUtils.isEmpty(recordPage.getRecords())) { | |||
| @@ -281,9 +295,11 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| @Override | |||
| 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) | |||
| @@ -497,7 +513,7 @@ public class InvestBizServiceImpl implements InvestBizService { | |||
| //4、品牌 | |||
| Map<Long, WxBrand> brandMap = getMap(brandService.getByIds(getIds(customers, InvestCustomerEntity::getBrandId)), WxBrand::getId); | |||
| //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<>(); | |||
| 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) { | |||
| 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) { | |||
| return dataList.parallelStream().map(mapper).collect(Collectors.toList()); | |||
| return InvestHelper.getIds(dataList, mapper); | |||
| } | |||
| } | |||
| @@ -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<InvestDemandD | |||
| @TableLog | |||
| @Override | |||
| public boolean save(InvestDemandEntity entity) { | |||
| return super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||
| super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||
| saveMessage(entity); | |||
| return true; | |||
| } | |||
| @TableLog | |||
| @Override | |||
| 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 | |||
| @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<Long> ownerArray = Arrays.asList(owner); | |||
| this.saveBatchMessage(ownerArray, EnumInvestMessageType.CUSTOMER_CREATE, EnumFollowType.DEMAND, entity.getId()); | |||
| } | |||
| } | |||
| private void checkBeforeSaveOrUpdate(InvestDemandEntity entity) { | |||
| @@ -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<InvestMessageDao, InvestMessageEntity> implements InvestMessageService { | |||
| @TableLog | |||
| @Override | |||
| public boolean save(InvestMessageEntity entity) { | |||
| return super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||
| } | |||
| @TableLog | |||
| @Override | |||
| public boolean update(InvestMessageEntity entity, Wrapper<InvestMessageEntity> 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<InvestMessag | |||
| LambdaUpdateWrapper<InvestMessageEntity> 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); | |||
| } | |||
| } | |||
| @@ -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<InvestTaskDao, | |||
| @TableLog | |||
| @Override | |||
| public boolean save(InvestTaskEntity entity) { | |||
| return super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||
| super.saveAction(entity, this::checkBeforeSaveOrUpdate); | |||
| saveMessage(entity); | |||
| return true; | |||
| } | |||
| @TableLog | |||
| @Override | |||
| 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 | |||
| @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<Long> ownerArray = JSONArray.parseArray(owner, Long.class); | |||
| this.saveBatchMessage(ownerArray, EnumInvestMessageType.TASK_CREATE, EnumFollowType.TASK, entity.getId()); | |||
| } | |||
| } | |||
| private void checkBeforeSaveOrUpdate(InvestTaskEntity entity) { | |||