Merge remote-tracking branch 'origin/feature-20240104' into feature-20240104

master
elliott 2 years ago
commit 5eda7e2e37

@ -26,6 +26,9 @@ public class SiteInfoTag extends BaseEntity
@Excel(name = "标签主键")
private Long tagId;
/** 标签类型 */
private Integer tagType;
/** 状态0正常 1禁用 */
@Excel(name = "状态", readConverterExp = "0=正常,1=禁用")
private Long status;
@ -67,6 +70,14 @@ public class SiteInfoTag extends BaseEntity
return status;
}
public Integer getTagType() {
return tagType;
}
public void setTagType(Integer tagType) {
this.tagType = tagType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" />
<result property="siteId" column="site_id" />
<result property="tagId" column="tag_id" />
<result property="tagType" column="tag_type" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -17,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectSiteInfoTagVo">
select id, site_id, tag_id, status, create_by, create_time, update_by, update_time, remark from site_info_tag
select id, site_id, tag_id, tag_type, status, create_by, create_time, update_by, update_time, remark from site_info_tag
</sql>
<select id="selectSiteInfoTagList" parameterType="SiteInfoTag" resultMap="SiteInfoTagResult">
@ -26,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="siteId != null "> and site_id = #{siteId}</if>
<if test="tagId != null "> and tag_id = #{tagId}</if>
<if test="status != null "> and status = #{status}</if>
<if test="tagType != null "> and tag_type = #{tagType}</if>
</where>
</select>
@ -45,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="tagType != null">tag_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="siteId != null">#{siteId},</if>
@ -55,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="tagType != null">#{tagType},</if>
</trim>
</insert>

@ -2,6 +2,10 @@ package com.flossom.miniProgram.controller;
import com.flossom.common.core.domain.R;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.common.core.web.domain.AjaxResult;
import com.flossom.common.log.annotation.Log;
import com.flossom.common.log.enums.BusinessType;
import com.flossom.common.security.annotation.RequiresPermissions;
import com.flossom.miniProgram.service.ISiteInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -33,4 +37,16 @@ public class SiteInfoController extends BaseController {
return R.ok(siteInfoService.carousel());
}
/**
*
*
* @param siteInfoId
* @return
*/
@GetMapping("/addTag/{siteInfoId}")
public AjaxResult addTag(@PathVariable Long siteInfoId) {
siteInfoService.addTag(siteInfoId);
return AjaxResult.success();
}
}

@ -8,4 +8,6 @@ public interface ISiteInfoService {
List<SiteInfo> popupList(Integer openType);
List<SiteInfo> carousel();
void addTag(Long siteInfoId);
}

@ -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;
}

@ -202,11 +202,9 @@ public class WxUserMemberServiceImpl implements IWxUserMemberService {
// TODO 首次完善,增加加分 (对接数云未完成)
}
WxUserMember update = new WxUserMember();
update.setId(wxUserMember.getId());
BeanUtils.copyProperties(userMemberUpdateVo, update);
update.setUpdateTime(DateUtils.getNowDate());
wxUserMemberMapper.updateWxUserMember(update);
BeanUtils.copyProperties(userMemberUpdateVo, wxUserMember);
wxUserMember.setUpdateTime(DateUtils.getNowDate());
wxUserMemberMapper.updateWxUserMember(wxUserMember);
// 刷新用户信息
LoginUserVo loginUserVo = refreshWxUserInfo();

@ -160,6 +160,7 @@ public class SiteInfoServiceImpl implements ISiteInfoService
SiteInfoTag infoTag = new SiteInfoTag();
infoTag.setSiteId(siteInfo.getId());
infoTag.setTagId(tag.getId());
infoTag.setTagType(1);
infoTag.setStatus(0l);
infoTag.setCreateBy(SecurityUtils.getUsername());
infoTag.setCreateTime(DateUtils.getNowDate());
@ -170,6 +171,7 @@ public class SiteInfoServiceImpl implements ISiteInfoService
SiteInfoTag infoTag = new SiteInfoTag();
infoTag.setSiteId(siteInfo.getId());
infoTag.setTagId(tag.getId());
infoTag.setTagType(2);
infoTag.setStatus(0l);
infoTag.setCreateBy(SecurityUtils.getUsername());
infoTag.setCreateTime(DateUtils.getNowDate());
@ -180,6 +182,7 @@ public class SiteInfoServiceImpl implements ISiteInfoService
SiteInfoTag infoTag = new SiteInfoTag();
infoTag.setSiteId(siteInfo.getId());
infoTag.setTagId(tag.getId());
infoTag.setTagType(1);
infoTag.setStatus(1l);
infoTag.setCreateBy(SecurityUtils.getUsername());
infoTag.setCreateTime(DateUtils.getNowDate());
@ -190,6 +193,7 @@ public class SiteInfoServiceImpl implements ISiteInfoService
SiteInfoTag infoTag = new SiteInfoTag();
infoTag.setSiteId(siteInfo.getId());
infoTag.setTagId(tag.getId());
infoTag.setTagType(2);
infoTag.setStatus(1l);
infoTag.setCreateBy(SecurityUtils.getUsername());
infoTag.setCreateTime(DateUtils.getNowDate());
@ -210,6 +214,7 @@ public class SiteInfoServiceImpl implements ISiteInfoService
SiteInfoTag infoTag = new SiteInfoTag();
infoTag.setSiteId(siteInfo.getId());
infoTag.setTagId(tag.getId());
infoTag.setTagType(1);
infoTag.setStatus(2l);
infoTag.setCreateBy(SecurityUtils.getUsername());
infoTag.setCreateTime(DateUtils.getNowDate());
@ -220,6 +225,7 @@ public class SiteInfoServiceImpl implements ISiteInfoService
SiteInfoTag infoTag = new SiteInfoTag();
infoTag.setSiteId(siteInfo.getId());
infoTag.setTagId(tag.getId());
infoTag.setTagType(2);
infoTag.setStatus(2l);
infoTag.setCreateBy(SecurityUtils.getUsername());
infoTag.setCreateTime(DateUtils.getNowDate());

Loading…
Cancel
Save