|
|
|
|
@ -1,17 +1,13 @@
|
|
|
|
|
package com.flossom.miniProgram.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.flossom.common.core.domain.entity.SiteInfo;
|
|
|
|
|
import com.flossom.common.core.domain.entity.SiteLog;
|
|
|
|
|
import com.flossom.common.core.domain.entity.WxUserMember;
|
|
|
|
|
import com.flossom.common.core.domain.entity.WxUserTag;
|
|
|
|
|
import com.flossom.common.core.domain.entity.*;
|
|
|
|
|
import com.flossom.common.core.enums.SiteOpenTypeEnum;
|
|
|
|
|
import com.flossom.common.core.enums.SitePushTypeEnum;
|
|
|
|
|
import com.flossom.common.core.enums.SiteTypeEnum;
|
|
|
|
|
import com.flossom.common.core.enums.TagTypeStatus;
|
|
|
|
|
import com.flossom.common.core.exception.ServiceException;
|
|
|
|
|
import com.flossom.common.core.mapper.SiteInfoMapper;
|
|
|
|
|
import com.flossom.common.core.mapper.SiteLogMapper;
|
|
|
|
|
import com.flossom.common.core.mapper.WxUserTagMapper;
|
|
|
|
|
import com.flossom.common.core.mapper.*;
|
|
|
|
|
import com.flossom.common.core.utils.DateUtils;
|
|
|
|
|
import com.flossom.common.core.utils.StringUtils;
|
|
|
|
|
import com.flossom.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.flossom.miniProgram.service.ISiteInfoService;
|
|
|
|
|
@ -40,6 +36,12 @@ public class SiteInfoServiceImpl implements ISiteInfoService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private WxUserTagMapper wxUserTagMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SiteInfoTagMapper siteInfoTagMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysTagMapper sysTagMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SiteInfo> popupList(Integer openType) {
|
|
|
|
|
@ -77,6 +79,70 @@ public class SiteInfoServiceImpl implements ISiteInfoService {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void addTag(Long siteInfoId) {
|
|
|
|
|
SiteInfoTag siteInfoTag = new SiteInfoTag();
|
|
|
|
|
siteInfoTag.setSiteId(siteInfoId);
|
|
|
|
|
// 小程序标签
|
|
|
|
|
siteInfoTag.setTagType(TagTypeStatus.MINI_PROGRAM.getCode());
|
|
|
|
|
siteInfoTag.setStatus(2L);
|
|
|
|
|
List<SiteInfoTag> addMiniTagList = siteInfoTagMapper.selectSiteInfoTagList(siteInfoTag);
|
|
|
|
|
if (addMiniTagList != null && addMiniTagList.size() > 0) {
|
|
|
|
|
List<Integer> tagIdList = addMiniTagList.stream().map(SiteInfoTag::getTagId).map(Long::intValue).collect(Collectors.toList());
|
|
|
|
|
List<Integer> userIdList = Arrays.asList(SecurityUtils.getLoginUser().getWxUserMember().getId()).stream().map(Long::intValue).collect(Collectors.toList());
|
|
|
|
|
batchAddTag(tagIdList, userIdList, TagTypeStatus.MINI_PROGRAM.getCode());
|
|
|
|
|
}
|
|
|
|
|
// 企微标签
|
|
|
|
|
siteInfoTag.setTagType(TagTypeStatus.ENTERPRISE_WECHAT.getCode());
|
|
|
|
|
siteInfoTag.setStatus(2L);
|
|
|
|
|
List<SiteInfoTag> addWecomTagList = siteInfoTagMapper.selectSiteInfoTagList(siteInfoTag);
|
|
|
|
|
if (addWecomTagList != null && addWecomTagList.size() > 0) {
|
|
|
|
|
List<Integer> tagIdList = addWecomTagList.stream().map(SiteInfoTag::getTagId).map(Long::intValue).collect(Collectors.toList());
|
|
|
|
|
List<Integer> userIdList = Arrays.asList(SecurityUtils.getLoginUser().getWxUserMember().getId()).stream().map(Long::intValue).collect(Collectors.toList());
|
|
|
|
|
batchAddTag(tagIdList, userIdList, TagTypeStatus.ENTERPRISE_WECHAT.getCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量添加标签
|
|
|
|
|
* code 标签类型 {@link com.flossom.common.core.enums.TagTypeStatus}
|
|
|
|
|
*
|
|
|
|
|
* @param tagIdList
|
|
|
|
|
* @param userIdList
|
|
|
|
|
*/
|
|
|
|
|
public void batchAddTag(List<Integer> tagIdList, List<Integer> userIdList, Integer code) {
|
|
|
|
|
// 对单个标签操作
|
|
|
|
|
for (Integer tagId : tagIdList) {
|
|
|
|
|
SysTag sysTag = sysTagMapper.selectDeptById(tagId.longValue());
|
|
|
|
|
if (sysTag != null) {
|
|
|
|
|
List<Integer> needAddIdList = new ArrayList<>();
|
|
|
|
|
// 1、查询该标签下,有那些用户关联
|
|
|
|
|
List<Integer> existedUserList = wxUserTagMapper.selectWxUserTagByTagId(tagId, code);
|
|
|
|
|
Iterator<Integer> iterator = userIdList.iterator();
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
|
Integer element = iterator.next();
|
|
|
|
|
if (!existedUserList.contains(element)) {
|
|
|
|
|
needAddIdList.add(element);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2、添加用户与标签的关联
|
|
|
|
|
List<WxUserTag> list = new ArrayList<>();
|
|
|
|
|
WxUserTag wxUserTag;
|
|
|
|
|
if (needAddIdList != null && needAddIdList.size() > 0) {
|
|
|
|
|
for (Integer userId : needAddIdList) {
|
|
|
|
|
wxUserTag = new WxUserTag(null, userId.longValue(), sysTag.getTagName(), tagId.longValue(), code, null);
|
|
|
|
|
wxUserTag.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
list.add(wxUserTag);
|
|
|
|
|
}
|
|
|
|
|
wxUserTagMapper.insertBatch(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// TODO: 对接数赢:批量添加小程序标签
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据 条件做过滤
|
|
|
|
|
*
|
|
|
|
|
@ -151,52 +217,42 @@ public class SiteInfoServiceImpl implements ISiteInfoService {
|
|
|
|
|
userWecomTageIdList = userWecomTags.stream().map(WxUserTag::getTagId).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4.2、禁止小程序标签
|
|
|
|
|
String forbidWechatTagId = info.getForbidWechatTagId();
|
|
|
|
|
if (StringUtils.isNotBlank(forbidWechatTagId)) {
|
|
|
|
|
List<String> forbidWechatTagIdList = Arrays.asList(forbidWechatTagId.split(","));
|
|
|
|
|
if (forbidWechatTagIdList != null && forbidWechatTagIdList.size() > 0) {
|
|
|
|
|
if (userMiniTageIdList.size() > 0) {
|
|
|
|
|
for (Long tagid : userMiniTageIdList) {
|
|
|
|
|
if (forbidWechatTagIdList.contains(tagid)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 4.3、禁止企微标签
|
|
|
|
|
String forbidCompanyTagId = info.getForbidCompanyTagId();
|
|
|
|
|
if (StringUtils.isNotBlank(forbidCompanyTagId)) {
|
|
|
|
|
List<String> forbidCompanyTagIdList = Arrays.asList(forbidCompanyTagId.split(","));
|
|
|
|
|
if (forbidCompanyTagIdList != null && forbidCompanyTagIdList.size() > 0) {
|
|
|
|
|
if (userWecomTageIdList.size() > 0) {
|
|
|
|
|
for (Long tagid : userWecomTageIdList) {
|
|
|
|
|
if (forbidCompanyTagIdList.contains(tagid)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 4.2、禁止标签
|
|
|
|
|
SiteInfoTag siteInfoTag = new SiteInfoTag();
|
|
|
|
|
siteInfoTag.setSiteId(info.getId());
|
|
|
|
|
siteInfoTag.setStatus(1L);
|
|
|
|
|
List<SiteInfoTag> forbidSiteInfoTags = siteInfoTagMapper.selectSiteInfoTagList(siteInfoTag);
|
|
|
|
|
if (forbidSiteInfoTags != null && forbidSiteInfoTags.size() > 0) {
|
|
|
|
|
List<Long> forbidTagIdList = forbidSiteInfoTags.stream().map(SiteInfoTag::getTagId).collect(Collectors.toList());
|
|
|
|
|
if (userMiniTageIdList.size() > 0) {
|
|
|
|
|
for (Long tagid : userMiniTageIdList) {
|
|
|
|
|
if (forbidTagIdList.contains(tagid)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4.4、可见小程序标签
|
|
|
|
|
String showWechatTagId = info.getShowWechatTagId();
|
|
|
|
|
if (StringUtils.isNotBlank(showWechatTagId)) {
|
|
|
|
|
List<String> showWechatTagIdList = Arrays.asList(showWechatTagId.split(","));
|
|
|
|
|
if (showWechatTagIdList != null && userMiniTageIdList.size() > 0) {
|
|
|
|
|
if (!userMiniTageIdList.containsAll(showWechatTagIdList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
siteInfoTag.setSiteId(info.getId());
|
|
|
|
|
siteInfoTag.setTagType(TagTypeStatus.MINI_PROGRAM.getCode());
|
|
|
|
|
siteInfoTag.setStatus(0L);
|
|
|
|
|
List<SiteInfoTag> showWechatSiteInfoTags = siteInfoTagMapper.selectSiteInfoTagList(siteInfoTag);
|
|
|
|
|
if (showWechatSiteInfoTags != null && showWechatSiteInfoTags.size() > 0) {
|
|
|
|
|
List<Long> showWechatTagIdList = showWechatSiteInfoTags.stream().map(SiteInfoTag::getTagId).collect(Collectors.toList());
|
|
|
|
|
if (userMiniTageIdList == null || !userMiniTageIdList.containsAll(showWechatTagIdList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 4.5、可见企微标签
|
|
|
|
|
String showCompanyTagId = info.getShowCompanyTagId();
|
|
|
|
|
if (StringUtils.isNotBlank(showCompanyTagId)) {
|
|
|
|
|
List<String> showCompanyTagIdList = Arrays.asList(showCompanyTagId.split(","));
|
|
|
|
|
if (userWecomTageIdList != null && userWecomTageIdList.size() > 0) {
|
|
|
|
|
if (!userWecomTageIdList.containsAll(showCompanyTagIdList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
siteInfoTag.setSiteId(info.getId());
|
|
|
|
|
siteInfoTag.setTagType(TagTypeStatus.ENTERPRISE_WECHAT.getCode());
|
|
|
|
|
siteInfoTag.setStatus(0L);
|
|
|
|
|
List<SiteInfoTag> showCompanySiteInfoTags = siteInfoTagMapper.selectSiteInfoTagList(siteInfoTag);
|
|
|
|
|
if (showCompanySiteInfoTags != null && showCompanySiteInfoTags.size() > 0) {
|
|
|
|
|
List<Long> showCompanyTagIdList = showCompanySiteInfoTags.stream().map(SiteInfoTag::getTagId).collect(Collectors.toList());
|
|
|
|
|
if (userWecomTageIdList == null || !userWecomTageIdList.containsAll(showCompanyTagIdList)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -252,6 +308,17 @@ public class SiteInfoServiceImpl implements ISiteInfoService {
|
|
|
|
|
|
|
|
|
|
// 最终符合条件
|
|
|
|
|
resultList.add(info);
|
|
|
|
|
|
|
|
|
|
// 添加观看日志
|
|
|
|
|
if (resultList != null && resultList.size() > 0) {
|
|
|
|
|
for (SiteInfo siteInfo : resultList) {
|
|
|
|
|
SiteLog siteLog = new SiteLog();
|
|
|
|
|
siteLog.setUserId(SecurityUtils.getLoginUser().getWxUserMember().getId());
|
|
|
|
|
siteLog.setSiteId(siteInfo.getId());
|
|
|
|
|
siteLog.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
siteLogMapper.insertSiteLog(siteLog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|