Commit ad83990f by ext.shengxiyong1

优化客户同步;增加活码标签同步到企业微信等功能;

1 parent 9af1a0a4
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.wecom.domain.WeChatItem;
import com.linkwechat.wecom.domain.WeMaterial;
import com.linkwechat.wecom.domain.dto.WeChatItemDto; import com.linkwechat.wecom.domain.dto.WeChatItemDto;
import com.linkwechat.wecom.domain.vo.WeChatSideVo; import com.linkwechat.wecom.domain.vo.WeChatSideVo;
import com.linkwechat.wecom.service.IWeChatItemService; import com.linkwechat.wecom.service.IWeChatItemService;
import com.linkwechat.wecom.service.IWeMaterialService;
import com.linkwechat.wecom.service.IWePosterService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 聊天工具侧边栏 * 聊天工具侧边栏
...@@ -26,6 +37,52 @@ public class WeChatItemController extends BaseController { ...@@ -26,6 +37,52 @@ public class WeChatItemController extends BaseController {
@Autowired @Autowired
private IWeChatItemService weChatItemService; private IWeChatItemService weChatItemService;
@Autowired
private IWeMaterialService materialService;
@Resource
private IWePosterService wePosterService;
// @PreAuthorize("@ss.hasPermi('wecom:material:list')")
@GetMapping("/mList")
@ApiOperation("获取侧边栏选中或者未选中素材")
public TableDataInfo mList(@RequestParam(value = "categoryId", required = false) String categoryId
, @RequestParam(value = "search", required = false) String search,@RequestParam(value = "mediaType") String mediaType) {
startPage();
List<WeMaterial> list;
if(StringUtils.isNotBlank(mediaType) && mediaType.equals(MediaType.POSTER.getType())){
list = wePosterService.list(StringUtils.isBlank(categoryId)?null:Long.valueOf(categoryId),search).stream().map(wePoster -> {
WeMaterial weMaterial = new WeMaterial();
weMaterial.setMaterialName(wePoster.getTitle());
weMaterial.setMaterialUrl(wePoster.getSampleImgPath());
weMaterial.setCategoryId(wePoster.getCategoryId());
weMaterial.setId(wePoster.getId());
return weMaterial;
}).collect(Collectors.toList());
}else {
list = materialService.findWeMaterials(categoryId, search,mediaType);
}
if(CollectionUtil.isNotEmpty(list)){
List<WeChatItem> weChatItems = weChatItemService.list(new LambdaQueryWrapper<WeChatItem>()
.in(WeChatItem::getMaterialId));
if(CollectionUtil.isNotEmpty(weChatItems)){
list.stream().forEach(k->{
k.setIsCheck(
weChatItems.stream().filter(item -> item.getMaterialId()
.equals(k.getId())).findFirst().isPresent()?true:false
);
});
}
}
return getDataTable(list);
}
/** /**
* 侧边栏抓取素材 * 侧边栏抓取素材
...@@ -55,4 +112,8 @@ public class WeChatItemController extends BaseController { ...@@ -55,4 +112,8 @@ public class WeChatItemController extends BaseController {
return getDataTable(weChatSideVos); return getDataTable(weChatSideVos);
} }
} }
...@@ -64,6 +64,9 @@ public class WeMaterialController extends BaseController { ...@@ -64,6 +64,9 @@ public class WeMaterialController extends BaseController {
list = materialService.findWeMaterials(categoryId, search,mediaType); list = materialService.findWeMaterials(categoryId, search,mediaType);
} }
return getDataTable(list); return getDataTable(list);
} }
......
...@@ -107,7 +107,7 @@ spring: ...@@ -107,7 +107,7 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://127.0.0.1:10179/lww?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://127.0.0.1:10179/link-wechat-prod?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: root username: root
password: root password: root
# 从库数据源 # 从库数据源
......
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -61,4 +62,11 @@ public class WeMaterial extends BaseEntity { ...@@ -61,4 +62,11 @@ public class WeMaterial extends BaseEntity {
@ApiModelProperty("音频时长") @ApiModelProperty("音频时长")
private String audioTime; private String audioTime;
/**
* 素材是否被选中
*/
@TableField(exist = false)
private Boolean isCheck=false;
} }
...@@ -7,10 +7,12 @@ import com.linkwechat.common.config.CosConfig; ...@@ -7,10 +7,12 @@ import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.MediaType; import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.domain.*; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto; import com.linkwechat.wecom.domain.dto.WeEmpleCodeDto;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg; import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy; import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.*;
...@@ -22,6 +24,7 @@ import java.util.ArrayList; ...@@ -22,6 +24,7 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @author danmo * @author danmo
...@@ -56,6 +59,10 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -56,6 +59,10 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private IWeGroupCodeService weGroupCodeService; private IWeGroupCodeService weGroupCodeService;
@Autowired
private WeCustomerClient weCustomerClient;
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
if (message.getExternalUserId() != null) { if (message.getExternalUserId() != null) {
...@@ -165,8 +172,16 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -165,8 +172,16 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
}); });
if(weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels)){
//标签同步到企业微信端
weCustomerClient.makeCustomerLabel(CutomerTagEdit.builder()
.external_userid(externalUserId)
.userid(userId)
.add_tag(weFlowerCustomerTagRels.stream()
.map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new))
.build());
}
weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels);
}); });
// 发送欢迎语 // 发送欢迎语
......
...@@ -298,7 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -298,7 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM FROM
we_customer wc we_customer wc
LEFT JOIN we_user wu ON wc.first_user_id=wu.user_id LEFT JOIN we_user wu ON wc.first_user_id=wu.user_id
LEFT JOIN we_flower_customer_tag_rel wfctr ON wfctr.external_userid=wc.external_userid AND wfctr.rel_tag_type=1 LEFT JOIN we_flower_customer_tag_rel wfctr ON wfctr.external_userid=wc.external_userid AND wfctr.user_id=wc.first_user_id
LEFT JOIN we_tag wt ON wt.tag_id=wfctr.tag_id LEFT JOIN we_tag wt ON wt.tag_id=wfctr.tag_id
where wc.del_flag=0 where wc.del_flag=0
<if test="name != null and name !=''"> <if test="name != null and name !=''">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!