Commit c6d64a95 by xinlaa

Merge branch 'master' of https://gitee.com/LinkWeChat/link-wechat into master

2 parents 297ec1f6 cae67579
......@@ -8,7 +8,7 @@
<div align="center">
![GVP Stars](http://img.shields.io/badge/GPV%20Stars-550+-yellow)
![GVP Stars](http://img.shields.io/badge/GPV%20Stars-600+-yellow)
![GVP Forks](http://img.shields.io/badge/GPV%20Forks-200+-yellow)
![license](http://img.shields.io/badge/license-GPL%203.0-green)
......
......@@ -11,6 +11,8 @@ import com.linkwechat.wecom.service.IWeGroupMemberService;
import com.linkwechat.wecom.service.IWeGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -59,10 +61,14 @@ public class WeGroupController extends BaseController {
@PreAuthorize("@ss.hasPermi('customerManage:group:sync')")
@GetMapping({"/synchWeGroup"})
public AjaxResult synchWeGroup(){
weGroupService.synchWeGroup();
try {
SecurityContext context = SecurityContextHolder.getContext();
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
SecurityContextHolder.setContext(context);
weGroupService.synchWeGroup();
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
......
......@@ -51,7 +51,7 @@ public class WeMaterialController extends BaseController {
startPage();
List<WeMaterial> list;
if(StringUtils.isNotBlank(mediaType) && mediaType.equals(MediaType.POSTER.getType())){
list = wePosterService.list(Long.valueOf(categoryId),search).stream().map(wePoster -> {
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());
......
......@@ -178,6 +178,8 @@ wecome:
- /externalcontact/get_unassigned_list
- /externalcontact/send_welcome_msg
- /externalcontact/unionid_to_external_userid
- /get_jsapi_ticket
- /ticket/get
fileUplodUrl: /media/upload,/media/uploadimg
needProviderTokenUrl:
- /service/get_login_info
......
......@@ -2,10 +2,10 @@
```bash
# 克隆项目
git clone https://gitee.com/y_project/RuoYi-Vue
git clone https://gitee.com/LinkWeChat/link-wechat.git
# 进入项目目录
cd ruoyi-ui
cd linkwe-ui
# 安装依赖
npm install
......@@ -14,7 +14,7 @@ npm install
npm install --registry=https://registry.npm.taobao.org
# 启动服务
npm run dev
npm run serve
```
浏览器访问 http://localhost:80
......
......@@ -398,12 +398,13 @@ export default {
></el-table-column>
<el-table-column prop="userName" label="添加人(首位)" align="center">
<template slot-scope="scope">{{
scope.row.weFlowerCustomerRels[0].userName
scope.row.weFlowerCustomerRels[0]?scope.row.weFlowerCustomerRels[0].userName:""
}}</template>
</el-table-column>
<el-table-column prop="createTime" label="添加时间" align="center">
<template slot-scope="scope">{{
scope.row.weFlowerCustomerRels[0].createTime
scope.row.weFlowerCustomerRels[0]?scope.row.weFlowerCustomerRels[0].createTime:""
}}</template>
</el-table-column>
<el-table-column prop="address" label="标签" align="center">
......
......@@ -2,8 +2,6 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans;
......@@ -14,11 +12,16 @@ import com.linkwechat.wecom.domain.WeAllocateGroup;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupMember;
import com.linkwechat.wecom.domain.dto.AllocateWeGroupDto;
import com.linkwechat.wecom.domain.dto.customer.*;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupMember;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.mapper.WeGroupMapper;
import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -33,8 +36,7 @@ import java.util.stream.Collectors;
* @Date: create in 2020/9/22 0022 0:03
*/
@Service
public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> implements IWeGroupService {
public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper, WeGroup> implements IWeGroupService {
@Autowired
......@@ -69,6 +71,7 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
/**
* 离职员工群分配
*
* @param weLeaveUserInfoAllocateVo
* @return
*/
......@@ -78,10 +81,10 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
List<WeGroup> weGroups
= this.list(new LambdaQueryWrapper<WeGroup>().eq(WeGroup::getOwner, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(weGroups)){
List<WeAllocateGroup> weAllocateGroups=new ArrayList<>();
if (CollectionUtil.isNotEmpty(weGroups)) {
List<WeAllocateGroup> weAllocateGroups = new ArrayList<>();
//更改本地群主
weGroups.stream().forEach(k->{
weGroups.stream().forEach(k -> {
k.setOwner(weLeaveUserInfoAllocateVo.getTakeoverUserid());
weAllocateGroups.add(WeAllocateGroup.builder()
.allocateTime(new Date())
......@@ -92,13 +95,13 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
});
this.saveOrUpdateBatch(weGroups);
//分配记录保存
if(CollectionUtil.isNotEmpty(weAllocateGroups)){
if(iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)){
if (CollectionUtil.isNotEmpty(weAllocateGroups)) {
if (iWeAllocateGroupService.saveOrUpdateBatch(weAllocateGroups)) {
//同步企业微信端
weUserClient.allocateGroup(
AllocateWeGroupDto.builder()
.chat_id_list(ArrayUtil.toArray(weAllocateGroups.stream().map(WeAllocateGroup::getChatId).collect(Collectors.toList()),String.class))
.chat_id_list(ArrayUtil.toArray(weAllocateGroups.stream().map(WeAllocateGroup::getChatId).collect(Collectors.toList()), String.class))
.new_owner(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.build()
);
......@@ -114,27 +117,28 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
* 客户群同步
*/
@Override
@Async
@Transactional(rollbackFor = Exception.class)
public void synchWeGroup() {
CustomerGroupList customerGroupList =
weCustomerGroupClient.groupChatLists(new CustomerGroupList().new Params());
if(customerGroupList.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupList.getGroup_chat_list())){
if (customerGroupList.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupList.getGroup_chat_list())) {
List<WeGroup> weGroups=new ArrayList<>();
List<WeGroupMember> weGroupMembers=new ArrayList<>();
customerGroupList.getGroup_chat_list().stream().forEach(k->{
List<WeGroup> weGroups = new ArrayList<>();
List<WeGroupMember> weGroupMembers = new ArrayList<>();
customerGroupList.getGroup_chat_list().stream().forEach(k -> {
CustomerGroupDetail customerGroupDetail = weCustomerGroupClient.groupChatDetail(
new CustomerGroupDetail().new Params(k.getChat_id())
);
if(customerGroupDetail.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupDetail.getGroup_chat())){
if (customerGroupDetail.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupDetail.getGroup_chat())) {
customerGroupDetail.getGroup_chat().stream().forEach(kk->{
customerGroupDetail.getGroup_chat().stream().forEach(kk -> {
weGroups.add(
WeGroup.builder()
.chatId(kk.getChat_id())
......@@ -146,8 +150,8 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
.build()
);
List<CustomerGroupMember> memberLists = kk.getMember_list();
if(CollectionUtil.isNotEmpty(memberLists)){
memberLists.stream().forEach(member->{
if (CollectionUtil.isNotEmpty(memberLists)) {
memberLists.stream().forEach(member -> {
//unionid不为空,获取非好友客户相关消息
......@@ -171,8 +175,6 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
// }
//
// }
weGroupMembers.add(
WeGroupMember.builder()
.chatId(kk.getChat_id())
......@@ -192,17 +194,33 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
}
});
//同步组织架构成员
weUserService.synchWeUser();
//同步客户
weCustomerService.synchWeCustomer();
/**
* 此处不同步成员和客户理由
* 1、如果是存量同步,不存在新客户新成员问题
* 2、增量同步的,成员和客户增删改群变更都会走回调通知,不用考虑新增成员和客户回调通知没有处理问题
*/
//同步组织架构成员
//weUserService.synchWeUser();
//同步客户
//weCustomerService.synchWeCustomer();
this.saveOrUpdateBatch(weGroups);
iWeGroupMemberService.remove(new LambdaQueryWrapper<WeGroupMember>().in(WeGroupMember::getChatId,
this.saveOrUpdateBatch(weGroups);
List<WeGroupMember> weGroupMemberList = iWeGroupMemberService.list(new LambdaQueryWrapper<WeGroupMember>().in(WeGroupMember::getChatId,
weGroups.stream().map(WeGroup::getChatId).collect(Collectors.toList())));
iWeGroupMemberService.saveOrUpdateBatch(weGroupMembers);
//存量去重
if (CollectionUtil.isNotEmpty(weGroupMemberList)){
List<WeGroupMember> groupMemberList = weGroupMembers.stream().filter(e -> {
for (WeGroupMember weGroupMember : weGroupMemberList) {
if (e.getUserId().equals(weGroupMember.getUserId())) {
return false;
}
}
return true;
}).collect(Collectors.toList());
iWeGroupMemberService.saveBatch(groupMemberList);
}else {
iWeGroupMemberService.saveBatch(weGroupMembers);
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!