Commit df539710 by 水库浪子

修改客户群相关bug

1 parent 16935b8c
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.constant.WeConstans;
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.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.wecom.domain.WeGroup; import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupMember; import com.linkwechat.wecom.domain.WeGroupMember;
...@@ -45,4 +47,18 @@ public class WeGroupController extends BaseController { ...@@ -45,4 +47,18 @@ public class WeGroupController extends BaseController {
List<WeGroupMember> list = this.weGroupMemberService.selectWeGroupMemberList(weGroupMember); List<WeGroupMember> list = this.weGroupMemberService.selectWeGroupMemberList(weGroupMember);
return getDataTable(list); return getDataTable(list);
} }
/**
* 同步客户群
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:group:synchWeGroup')")
@GetMapping({"/synchWeGroup"})
public AjaxResult synchWeGroup(){
weGroupService.synchWeGroup();
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
} }
...@@ -9,6 +9,7 @@ import com.linkwechat.common.enums.BusinessType; ...@@ -9,6 +9,7 @@ import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeUser; import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo; import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeLeaveUserVo; import com.linkwechat.wecom.domain.vo.WeLeaveUserVo;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeUserService; import com.linkwechat.wecom.service.IWeUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -30,9 +31,12 @@ import java.util.List; ...@@ -30,9 +31,12 @@ import java.util.List;
@RequestMapping("/wecom/user") @RequestMapping("/wecom/user")
@Api("通讯录人员接口") @Api("通讯录人员接口")
public class WeUserController extends BaseController { public class WeUserController extends BaseController {
@Autowired @Autowired
private IWeUserService weUserService; private IWeUserService weUserService;
/** /**
* 查询通讯录相关客户列表 * 查询通讯录相关客户列表
*/ */
......
...@@ -133,5 +133,15 @@ wecome: ...@@ -133,5 +133,15 @@ wecome:
serverUrl: https://qyapi.weixin.qq.com/ serverUrl: https://qyapi.weixin.qq.com/
weComePrefix: cgi-bin weComePrefix: cgi-bin
noAccessTokenUrl: /gettoken noAccessTokenUrl: /gettoken
needContactTokenUrl: /externalcontact/get_follow_user_list,/externalcontact/add_contact_way,/externalcontact/add_corp_tag,/externalcontact/get_corp_tag_list,/externalcontact/del_corp_tag,/externalcontact/edit_corp_tag,/externalcontact/list,/externalcontact/get needContactTokenUrl:
- /externalcontact/get_follow_user_list
- /externalcontact/add_contact_way
- /externalcontact/add_corp_tag
- /externalcontact/get_corp_tag_list
- /externalcontact/del_corp_tag
- /externalcontact/edit_corp_tag
- /externalcontact/list
- /externalcontact/get
- /externalcontact/groupchat/list
- /externalcontact/groupchat/get
fileUplodUrl: /media/upload,/media/uploadimg fileUplodUrl: /media/upload,/media/uploadimg
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.DataObject;
import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList;
/**
* @description: 客户群
* @author: HaoN
* @create: 2020-10-20 21:50
**/
public interface WeCustomerGroupClient {
/**
* 获取客户群列表
* @param params
* @return
*/
@Request(url="/externalcontact/groupchat/list",
type = "POST"
)
CustomerGroupList groupChatLists(@DataObject CustomerGroupList.Params params);
/**
* 获取客户群详情
* @param params
* @return
*/
@Request(url="/externalcontact/groupchat/get",
type = "POST"
)
CustomerGroupDetail groupChatDetail(@DataObject CustomerGroupDetail.Params params);
}
\ No newline at end of file \ No newline at end of file
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
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 lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/** /**
*
* @Author: Robin * @Author: Robin
* @Description: * @Description:
* @Date: create in 2020/9/21 0021 23:55 * @Date: create in 2020/9/21 0021 23:55
...@@ -16,18 +24,29 @@ import lombok.NoArgsConstructor; ...@@ -16,18 +24,29 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class WeGroup extends BaseEntity { @TableName("we_group")
public class WeGroup {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id= SnowFlakeUtil.nextId(); @TableId
private String chatId;
private String groupName; private String groupName;
@TableField(exist = false)
private Long memberNum; private Long memberNum;
private String groupLeader;
private String notice; private String notice;
private String groupLeaderUserId; private String owner;
private Integer status;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date createTime;
@TableField(exist = false)
private String groupLeaderName;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.Date; import java.util.Date;
...@@ -13,18 +21,38 @@ import java.util.Date; ...@@ -13,18 +21,38 @@ import java.util.Date;
* @Date: create in 2020/9/21 0021 23:56 * @Date: create in 2020/9/21 0021 23:56
*/ */
@Data @Data
public class WeGroupMember extends BaseEntity { @TableName("we_group_member")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeGroupMember {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id; @TableId
private Long id= SnowFlakeUtil.nextId();;
@NotBlank(message = "groupId") @NotBlank(message = "groupId")
private Long groupId; private String chatId;
@TableField(exist = false)
private String memberName; private String memberName;
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
private Date joinTime; private Date joinTime;
private Long joinType; private Integer joinScene;
@TableField(value="type")
private Integer joinType;
private String userId;
private String unionId;
} }
package com.linkwechat.wecom.domain.dto; package com.linkwechat.wecom.domain.dto;
import com.linkwechat.wecom.domain.WeUser;
import lombok.Data; import lombok.Data;
/** /**
......
package com.linkwechat.wecom.domain.dto.customer;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @description: 客户群相关
* @author: HaoN
* @create: 2020-10-20 21:52
**/
@Data
public class CustomerGroupDetail extends WeResultDto {
private List<GroupChat> group_chat;
@Data
public class GroupChat{
/**客户群ID*/
private String chat_id;
/**群名*/
private String name;
/**群主ID*/
private String owner;
/**群的创建时间*/
private Date create_time;
/**群公告*/
private String notice;
/**群成员列表*/
private List<CustomerGroupMember> member_list;
}
/**
* 请求参数
*/
@Data
public class Params{
private String chat_id;
public Params(String chat_id) {
this.chat_id = chat_id;
}
}
}
package com.linkwechat.wecom.domain.dto.customer;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @description: 客户群相关
* @author: HaoN
* @create: 2020-10-20 21:52
**/
@Data
public class CustomerGroupList extends WeResultDto {
//返回结果
private List<GroupChat> group_chat_list;
/**
* 请求参数
*/
@Data
public class Params{
/**群状态过滤: 0 - 所有列表;1 - 离职待继承;2 - 离职继承中;3 - 离职继承完成; */
private Integer status_filter;
/**分页,偏移量。默认为0 */
private Integer offset=new Integer(0);
/**分页,预期请求的数据量,取值范围 1 ~ 1000 */
private Integer limit=new Integer(1000);
}
@Data
public class GroupChat{
/**客户群ID*/
private String chat_id;
/**0 - 正常;1 - 跟进人离职;2 - 离职继承中;3 - 离职继承完成*/
private Integer status;
}
}
package com.linkwechat.wecom.domain.dto.customer;
import lombok.Data;
import java.util.Date;
/**
* @description: 客户群成员
* @author: HaoN
* @create: 2020-10-20 22:37
**/
@Data
public class CustomerGroupMember {
/**群成员id*/
private String userid;
/**1 - 企业成员;2 - 外部联系人*/
private Integer type;
/**入群时间*/
private Date join_time;
/**1 - 由成员邀请入群(直接邀请入群);2 - 由成员邀请入群(通过邀请链接入群);3 - 通过扫描群二维码入群*/
private Integer join_scene;
/**外部联系人在微信开放平台的唯一身份标识(微信unionid);通过此字段企业可将外部联系人与公众号/小程序用户关联起来。*/
private String unionid;
}
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroup; import com.linkwechat.wecom.domain.WeGroup;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -10,20 +11,20 @@ import java.util.List; ...@@ -10,20 +11,20 @@ import java.util.List;
* @Description: * @Description:
* @Date: create in 2020/9/21 0021 23:58 * @Date: create in 2020/9/21 0021 23:58
*/ */
public interface WeGroupMapper { public interface WeGroupMapper extends BaseMapper<WeGroup> {
WeGroup selectWeGroupById(Long paramLong); // WeGroup selectWeGroupById(Long paramLong);
//
List<WeGroup> selectWeGroupList(WeGroup paramWeGroup); List<WeGroup> selectWeGroupList(WeGroup paramWeGroup);
//
int insertWeGroup(WeGroup paramWeGroup); // int insertWeGroup(WeGroup paramWeGroup);
//
int updateWeGroup(WeGroup paramWeGroup); // int updateWeGroup(WeGroup paramWeGroup);
//
int deleteWeGroupById(Long paramLong); // int deleteWeGroupById(Long paramLong);
//
int deleteWeGroupByIds(Long[] paramArrayOfLong); // int deleteWeGroupByIds(Long[] paramArrayOfLong);
//
int batchLogicDeleteByIds(@Param("ids") List<Long> ids); // int batchLogicDeleteByIds(@Param("ids") List<Long> ids);
//
int batchInsetWeGroup(@Param("weGroups") List<WeGroup> weGroups); // int batchInsetWeGroup(@Param("weGroups") List<WeGroup> weGroups);
} }
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMember; import com.linkwechat.wecom.domain.WeGroupMember;
import java.util.List; import java.util.List;
...@@ -9,16 +10,16 @@ import java.util.List; ...@@ -9,16 +10,16 @@ import java.util.List;
* @Description: * @Description:
* @Date: create in 2020/9/21 0021 23:58 * @Date: create in 2020/9/21 0021 23:58
*/ */
public interface WeGroupMemberMapper { public interface WeGroupMemberMapper extends BaseMapper<WeGroupMember> {
WeGroupMember selectWeGroupMemberById(Long paramLong); // WeGroupMember selectWeGroupMemberById(Long paramLong);
List<WeGroupMember> selectWeGroupMemberList(WeGroupMember paramWeGroupMember); List<WeGroupMember> selectWeGroupMemberList(WeGroupMember paramWeGroupMember);
int insertWeGroupMember(WeGroupMember paramWeGroupMember); // int insertWeGroupMember(WeGroupMember paramWeGroupMember);
//
int updateWeGroupMember(WeGroupMember paramWeGroupMember); // int updateWeGroupMember(WeGroupMember paramWeGroupMember);
//
int deleteWeGroupMemberById(Long paramLong); // int deleteWeGroupMemberById(Long paramLong);
//
int deleteWeGroupMemberByIds(Long[] paramArrayOfLong); // int deleteWeGroupMemberByIds(Long[] paramArrayOfLong);
} }
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMember; import com.linkwechat.wecom.domain.WeGroupMember;
import java.util.List; import java.util.List;
...@@ -9,16 +10,8 @@ import java.util.List; ...@@ -9,16 +10,8 @@ import java.util.List;
* @Description: * @Description:
* @Date: create in 2020/9/22 0022 0:02 * @Date: create in 2020/9/22 0022 0:02
*/ */
public interface IWeGroupMemberService { public interface IWeGroupMemberService extends IService<WeGroupMember> {
WeGroupMember selectWeGroupMemberById(Long paramLong);
List<WeGroupMember> selectWeGroupMemberList(WeGroupMember paramWeGroupMember); List<WeGroupMember> selectWeGroupMemberList(WeGroupMember paramWeGroupMember);
int insertWeGroupMember(WeGroupMember paramWeGroupMember);
int updateWeGroupMember(WeGroupMember paramWeGroupMember);
int deleteWeGroupMemberByIds(Long[] paramArrayOfLong);
int deleteWeGroupMemberById(Long paramLong);
} }
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroup; import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo; import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
...@@ -10,22 +11,17 @@ import java.util.List; ...@@ -10,22 +11,17 @@ import java.util.List;
* @Description: * @Description:
* @Date: create in 2020/9/22 0022 0:01 * @Date: create in 2020/9/22 0022 0:01
*/ */
public interface IWeGroupService { public interface IWeGroupService extends IService<WeGroup> {
WeGroup selectWeGroupById(Long paramLong);
List<WeGroup> selectWeGroupList(WeGroup paramWeGroup); List<WeGroup> selectWeGroupList(WeGroup paramWeGroup);
int insertWeGroup(WeGroup paramWeGroup);
int updateWeGroup(WeGroup paramWeGroup); // int batchLogicDeleteByIds(List<Long> ids);
//
// int batchInsetWeGroup(List<WeGroup> weGroups);
int deleteWeGroupByIds(Long[] paramArrayOfLong); void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
int deleteWeGroupById(Long paramLong);
int batchLogicDeleteByIds(List<Long> ids);
int batchInsetWeGroup(List<WeGroup> weGroups);
void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo); void synchWeGroup();
} }
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeGroupMember; import com.linkwechat.wecom.domain.WeGroupMember;
import com.linkwechat.wecom.mapper.WeGroupMemberMapper; import com.linkwechat.wecom.mapper.WeGroupMemberMapper;
import com.linkwechat.wecom.service.IWeGroupMemberService; import com.linkwechat.wecom.service.IWeGroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -14,31 +14,13 @@ import java.util.List; ...@@ -14,31 +14,13 @@ import java.util.List;
* @Date: create in 2020/9/22 0022 0:03 * @Date: create in 2020/9/22 0022 0:03
*/ */
@Service @Service
public class WeGroupMemberServiceImpl implements IWeGroupMemberService { public class WeGroupMemberServiceImpl extends ServiceImpl<WeGroupMemberMapper,WeGroupMember> implements IWeGroupMemberService {
@Autowired
private WeGroupMemberMapper weGroupMemberMapper;
public WeGroupMember selectWeGroupMemberById(Long id) {
return this.weGroupMemberMapper.selectWeGroupMemberById(id);
}
public List<WeGroupMember> selectWeGroupMemberList(WeGroupMember weGroupMember) {
return this.weGroupMemberMapper.selectWeGroupMemberList(weGroupMember);
}
public int insertWeGroupMember(WeGroupMember weGroupMember) {
return this.weGroupMemberMapper.insertWeGroupMember(weGroupMember);
}
public int updateWeGroupMember(WeGroupMember weGroupMember) { public List<WeGroupMember> selectWeGroupMemberList(WeGroupMember weGroupMember) {
return this.weGroupMemberMapper.updateWeGroupMember(weGroupMember); return this.baseMapper.selectWeGroupMemberList(weGroupMember);
} }
public int deleteWeGroupMemberByIds(Long[] ids) {
return this.weGroupMemberMapper.deleteWeGroupMemberByIds(ids);
}
public int deleteWeGroupMemberById(Long id) {
return this.weGroupMemberMapper.deleteWeGroupMemberById(id);
}
} }
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.DateUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.wecom.client.WeCustomerGroupClient;
import com.linkwechat.wecom.domain.WeGroup; import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupMember;
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.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.mapper.WeGroupMapper; import com.linkwechat.wecom.mapper.WeGroupMapper;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeGroupMemberService;
import com.linkwechat.wecom.service.IWeGroupService; import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -20,82 +30,128 @@ import java.util.stream.Collectors; ...@@ -20,82 +30,128 @@ import java.util.stream.Collectors;
* @Date: create in 2020/9/22 0022 0:03 * @Date: create in 2020/9/22 0022 0:03
*/ */
@Service @Service
public class WeGroupServiceImpl implements IWeGroupService { public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> implements IWeGroupService {
@Autowired
private WeGroupMapper weGroupMapper;
public WeGroup selectWeGroupById(Long id) {
return this.weGroupMapper.selectWeGroupById(id);
}
public List<WeGroup> selectWeGroupList(WeGroup weGroup) {
return this.weGroupMapper.selectWeGroupList(weGroup);
}
public int insertWeGroup(WeGroup weGroup) { @Autowired
weGroup.setCreateTime(DateUtils.getNowDate()); private WeCustomerGroupClient weCustomerGroupClient;
return this.weGroupMapper.insertWeGroup(weGroup);
}
public int updateWeGroup(WeGroup weGroup) {
return this.weGroupMapper.updateWeGroup(weGroup);
}
public int deleteWeGroupByIds(Long[] ids) { @Autowired
return this.weGroupMapper.deleteWeGroupByIds(ids); private IWeGroupMemberService iWeGroupMemberService;
}
public int deleteWeGroupById(Long id) { @Autowired
return this.weGroupMapper.deleteWeGroupById(id); private IWeUserService weUserService;
}
/** @Autowired
* 逻辑批量删除 private IWeCustomerService weCustomerService;
* @param ids
*/
@Override
public int batchLogicDeleteByIds(List<Long> ids) {
return weGroupMapper.batchLogicDeleteByIds(ids);
}
public List<WeGroup> selectWeGroupList(WeGroup weGroup) {
return this.baseMapper.selectWeGroupList(weGroup);
}
/** /**
* 批量保存 * 离职员工群分配
* @param weGroups * @param weLeaveUserInfoAllocateVo
* @return * @return
*/ */
@Override @Override
public int batchInsetWeGroup(List<WeGroup> weGroups) { @Transactional
return weGroupMapper.batchInsetWeGroup(weGroups); public void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
// //分配群
// List<WeGroup> weGroups = this.selectWeGroupList(WeGroup.builder()
// .groupLeaderUserId(weLeaveUserInfoAllocateVo.getHandoverUserid())
// .build());
// if(CollectionUtil.isNotEmpty(weGroups)){
//
// this.batchLogicDeleteByIds(
// weGroups.stream().map(WeGroup::getId).collect(Collectors.toList())
// );
//
// weGroups.stream().forEach(k->{
// k.setId(SnowFlakeUtil.nextId());
// k.setGroupLeaderUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
// });
//
// this.batchInsetWeGroup(weGroups);
// }
} }
/** /**
* 离职员工群分配 * 客户群同步
* @param weLeaveUserInfoAllocateVo
* @return
*/ */
@Override @Override
@Transactional @Transactional(rollbackFor = Exception.class)
public void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) { public void synchWeGroup() {
//分配群
List<WeGroup> weGroups = this.selectWeGroupList(WeGroup.builder() CustomerGroupList customerGroupList =
.groupLeaderUserId(weLeaveUserInfoAllocateVo.getHandoverUserid()) weCustomerGroupClient.groupChatLists(new CustomerGroupList().new Params());
.build()); if(customerGroupList.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
if(CollectionUtil.isNotEmpty(weGroups)){ && CollectionUtil.isNotEmpty(customerGroupList.getGroup_chat_list())){
this.batchLogicDeleteByIds( List<WeGroup> weGroups=new ArrayList<>();
weGroups.stream().map(WeGroup::getId).collect(Collectors.toList()) List<WeGroupMember> weGroupMembers=new ArrayList<>();
); customerGroupList.getGroup_chat_list().stream().forEach(k->{
weGroups.stream().forEach(k->{
k.setId(SnowFlakeUtil.nextId()); CustomerGroupDetail customerGroupDetail = weCustomerGroupClient.groupChatDetail(
k.setGroupLeaderUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid()); new CustomerGroupDetail().new Params(k.getChat_id())
);
if(customerGroupDetail.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupDetail.getGroup_chat())){
customerGroupDetail.getGroup_chat().stream().forEach(kk->{
weGroups.add(
WeGroup.builder()
.chatId(kk.getChat_id())
.groupName(kk.getName())
.notice(kk.getNotice())
.owner(kk.getOwner())
.createTime(kk.getCreate_time())
.status(k.getStatus())
.build()
);
List<CustomerGroupMember> memberLists = kk.getMember_list();
if(CollectionUtil.isNotEmpty(memberLists)){
memberLists.stream().forEach(member->{
weGroupMembers.add(
WeGroupMember.builder()
.chatId(kk.getChat_id())
.userId(member.getUserid())
.joinTime(member.getJoin_time())
.joinScene(member.getJoin_scene())
.joinType(member.getType())
.unionId(member.getUnionid())
.build()
);
});
}
});
}
}); });
this.batchInsetWeGroup(weGroups); //同步组织架构成员
weUserService.synchWeUser();
//同步客户
weCustomerService.synchWeCustomer();
this.saveOrUpdateBatch(weGroups);
iWeGroupMemberService.remove(new LambdaQueryWrapper<WeGroupMember>().in(WeGroupMember::getChatId,
weGroups.stream().map(WeGroup::getChatId).collect(Collectors.toList())));
iWeGroupMemberService.saveOrUpdateBatch(weGroupMembers);
} }
} }
} }
...@@ -4,96 +4,89 @@ ...@@ -4,96 +4,89 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeGroupMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeGroupMapper">
<resultMap type="WeGroup" id="WeGroupResult">
<result property="id" column="id" />
<result property="groupName" column="group_name" />
<result property="memberNum" column="member_num" />
<result property="groupLeader" column="group_leader" />
<result property="createTime" column="create_time" />
<result property="notice" column="notice" />
<result property="groupLeaderUserId" column="group_leader_user_id"/>
</resultMap>
<sql id="selectWeGroupVo"> <select id="selectWeGroupList" parameterType="WeGroup" resultType="com.linkwechat.wecom.domain.WeGroup">
select id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id from we_group SELECT
</sql> wg.chat_id,
wg.group_name,
<select id="selectWeGroupList" parameterType="WeGroup" resultMap="WeGroupResult"> wg.create_time,
<include refid="selectWeGroupVo"/> wg.notice,
wu.user_name as groupLeaderName,
(SELECT COUNT(*) FROM we_group_member wgm WHERE wgm.chat_id=wg.chat_id) as memberNum
FROM
we_group wg
INNER JOIN we_user wu ON wg.`owner`=wu.user_id
<where> <where>
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if> <if test="groupName != null and groupName != ''"> and wg.group_name like concat('%', #{groupName}, '%')</if>
<if test="memberNum != null "> and member_num = #{memberNum}</if> <if test="owner != null and owner != ''"> and owner = #{owner}</if>
<if test="groupLeader != null and groupLeader != ''"> and group_leader = #{groupLeader}</if>
<if test="notice != null and notice != ''"> and notice = #{notice}</if>
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">and group_leader_user_id =#{groupLeaderUserId}</if>
</where> </where>
</select> </select>
<select id="selectWeGroupById" parameterType="Long" resultMap="WeGroupResult"> <!-- <select id="selectWeGroupById" parameterType="Long" resultMap="WeGroupResult">-->
<include refid="selectWeGroupVo"/> <!-- <include refid="selectWeGroupVo"/>-->
where id = #{id} <!-- where id = #{id}-->
</select> <!-- </select>-->
<insert id="insertWeGroup" parameterType="WeGroup"> <!-- <insert id="insertWeGroup" parameterType="WeGroup">-->
insert into we_group <!-- insert into we_group-->
<trim prefix="(" suffix=")" suffixOverrides=","> <!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<if test="id != null">id,</if> <!-- <if test="id != null">id,</if>-->
<if test="groupName != null">group_name,</if> <!-- <if test="groupName != null">group_name,</if>-->
<if test="memberNum != null">member_num,</if> <!-- <if test="memberNum != null">member_num,</if>-->
<if test="groupLeader != null">group_leader,</if> <!-- <if test="groupLeader != null">group_leader,</if>-->
<if test="createTime != null">create_time,</if> <!-- <if test="createTime != null">create_time,</if>-->
<if test="notice != null">notice,</if> <!-- <if test="notice != null">notice,</if>-->
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id,</if> <!-- <if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id,</if>-->
</trim> <!-- </trim>-->
<trim prefix="values (" suffix=")" suffixOverrides=","> <!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<if test="id != null">#{id},</if> <!-- <if test="id != null">#{id},</if>-->
<if test="groupName != null">#{groupName},</if> <!-- <if test="groupName != null">#{groupName},</if>-->
<if test="memberNum != null">#{memberNum},</if> <!-- <if test="memberNum != null">#{memberNum},</if>-->
<if test="groupLeader != null">#{groupLeader},</if> <!-- <if test="groupLeader != null">#{groupLeader},</if>-->
<if test="createTime != null">#{createTime},</if> <!-- <if test="createTime != null">#{createTime},</if>-->
<if test="notice != null">#{notice},</if> <!-- <if test="notice != null">#{notice},</if>-->
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">#{groupLeaderUserId},</if> <!-- <if test="groupLeaderUserId != null and groupLeaderUserId !=''">#{groupLeaderUserId},</if>-->
</trim> <!-- </trim>-->
</insert> <!-- </insert>-->
<update id="updateWeGroup" parameterType="WeGroup"> <!-- <update id="updateWeGroup" parameterType="WeGroup">-->
update we_group <!-- update we_group-->
<trim prefix="SET" suffixOverrides=","> <!-- <trim prefix="SET" suffixOverrides=",">-->
<if test="groupName != null">group_name = #{groupName},</if> <!-- <if test="groupName != null">group_name = #{groupName},</if>-->
<if test="memberNum != null">member_num = #{memberNum},</if> <!-- <if test="memberNum != null">member_num = #{memberNum},</if>-->
<if test="groupLeader != null">group_leader = #{groupLeader},</if> <!-- <if test="groupLeader != null">group_leader = #{groupLeader},</if>-->
<if test="createTime != null">create_time = #{createTime},</if> <!-- <if test="createTime != null">create_time = #{createTime},</if>-->
<if test="notice != null">notice = #{notice},</if> <!-- <if test="notice != null">notice = #{notice},</if>-->
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id =#{groupLeaderUserId},</if> <!-- <if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id =#{groupLeaderUserId},</if>-->
</trim> <!-- </trim>-->
where id = #{id} <!-- where id = #{id}-->
</update> <!-- </update>-->
<delete id="deleteWeGroupById" parameterType="Long"> <!-- <delete id="deleteWeGroupById" parameterType="Long">-->
delete from we_group where id = #{id} <!-- delete from we_group where id = #{id}-->
</delete> <!-- </delete>-->
<delete id="deleteWeGroupByIds" parameterType="String"> <!-- <delete id="deleteWeGroupByIds" parameterType="String">-->
delete from we_group where id in <!-- delete from we_group where id in-->
<foreach item="id" collection="array" open="(" separator="," close=")"> <!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
#{id} <!-- #{id}-->
</foreach> <!-- </foreach>-->
</delete> <!-- </delete>-->
<update id="batchLogicDeleteByIds" parameterType="String"> <!-- <update id="batchLogicDeleteByIds" parameterType="String">-->
update we_group set del_flag=2 <!-- update we_group set del_flag=2-->
where id in <!-- where id in-->
<foreach item="id" collection="ids" open="(" separator="," close=")"> <!-- <foreach item="id" collection="ids" open="(" separator="," close=")">-->
#{id} <!-- #{id}-->
</foreach> <!-- </foreach>-->
</update> <!-- </update>-->
<insert id="batchInsetWeGroup" > <!-- <insert id="batchInsetWeGroup" >-->
insert into we_group (id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id) <!-- insert into we_group (id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id)-->
values <!-- values-->
<foreach collection="weGroups" item="weGroup" index="index" separator=","> <!-- <foreach collection="weGroups" item="weGroup" index="index" separator=",">-->
(#{weGroup.id},#{weGroup.groupName},#{weGroup.memberNum},#{weGroup.groupLeader},#{weGroup.createTime},#{weGroup.notice},#{weGroup.groupLeaderUserId}) <!-- (#{weGroup.id},#{weGroup.groupName},#{weGroup.memberNum},#{weGroup.groupLeader},#{weGroup.createTime},#{weGroup.notice},#{weGroup.groupLeaderUserId})-->
</foreach> <!-- </foreach>-->
</insert> <!-- </insert>-->
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -4,71 +4,75 @@ ...@@ -4,71 +4,75 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeGroupMemberMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeGroupMemberMapper">
<resultMap type="WeGroupMember" id="WeGroupMemberResult"> <!-- <resultMap type="WeGroupMember" id="WeGroupMemberResult">-->
<result property="id" column="id" /> <!-- <result property="id" column="id" />-->
<result property="groupId" column="group_id" /> <!-- <result property="groupId" column="group_id" />-->
<result property="memberName" column="member_name" /> <!-- <result property="memberName" column="member_name" />-->
<result property="joinTime" column="join_time" /> <!-- <result property="joinTime" column="join_time" />-->
<result property="joinType" column="join_type" /> <!-- <result property="joinType" column="join_type" />-->
</resultMap> <!-- </resultMap>-->
<sql id="selectWeGroupMemberVo"> <!-- <sql id="selectWeGroupMemberVo">-->
select id, group_id, member_name, join_time, join_type from we_group_member <!-- select id, group_id, member_name, join_time, join_type from we_group_member-->
</sql> <!-- </sql>-->
<select id="selectWeGroupMemberList" parameterType="WeGroupMember" resultMap="WeGroupMemberResult"> <select id="selectWeGroupMemberList" parameterType="WeGroupMember" resultType="com.linkwechat.wecom.domain.WeGroupMember">
<include refid="selectWeGroupMemberVo"/> SELECT
wc.`name` AS memberName,
wgm.join_time,
wgm.type
FROM
we_group_member wgm
LEFT JOIN we_customer wc ON wgm.user_id=wc.external_userid
<where> <where>
<if test="groupId != null "> and group_id = #{groupId}</if> <if test="chatId != null "> and wgm.chat_id = #{chatId}</if>
<if test="memberName != null and memberName != ''"> and member_name like concat('%', #{memberName}, '%')</if> <if test="memberName != null and memberName != ''"> and wc.`name` like concat('%', #{memberName}, '%')</if>
<if test="joinTime != null "> and join_time = #{joinTime}</if>
<if test="joinType != null "> and join_type = #{joinType}</if>
</where> </where>
</select> </select>
<select id="selectWeGroupMemberById" parameterType="Long" resultMap="WeGroupMemberResult"> <!-- <select id="selectWeGroupMemberById" parameterType="Long" resultMap="WeGroupMemberResult">-->
<include refid="selectWeGroupMemberVo"/> <!-- <include refid="selectWeGroupMemberVo"/>-->
where id = #{id} <!-- where id = #{id}-->
</select> <!-- </select>-->
<insert id="insertWeGroupMember" parameterType="WeGroupMember"> <!-- <insert id="insertWeGroupMember" parameterType="WeGroupMember">-->
insert into we_group_member <!-- insert into we_group_member-->
<trim prefix="(" suffix=")" suffixOverrides=","> <!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<if test="id != null">id,</if> <!-- <if test="id != null">id,</if>-->
<if test="groupId != null">group_id,</if> <!-- <if test="groupId != null">group_id,</if>-->
<if test="memberName != null">member_name,</if> <!-- <if test="memberName != null">member_name,</if>-->
<if test="joinTime != null">join_time,</if> <!-- <if test="joinTime != null">join_time,</if>-->
<if test="joinType != null">join_type,</if> <!-- <if test="joinType != null">join_type,</if>-->
</trim> <!-- </trim>-->
<trim prefix="values (" suffix=")" suffixOverrides=","> <!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<if test="id != null">#{id},</if> <!-- <if test="id != null">#{id},</if>-->
<if test="groupId != null">#{groupId},</if> <!-- <if test="groupId != null">#{groupId},</if>-->
<if test="memberName != null">#{memberName},</if> <!-- <if test="memberName != null">#{memberName},</if>-->
<if test="joinTime != null">#{joinTime},</if> <!-- <if test="joinTime != null">#{joinTime},</if>-->
<if test="joinType != null">#{joinType},</if> <!-- <if test="joinType != null">#{joinType},</if>-->
</trim> <!-- </trim>-->
</insert> <!-- </insert>-->
<update id="updateWeGroupMember" parameterType="WeGroupMember"> <!-- <update id="updateWeGroupMember" parameterType="WeGroupMember">-->
update we_group_member <!-- update we_group_member-->
<trim prefix="SET" suffixOverrides=","> <!-- <trim prefix="SET" suffixOverrides=",">-->
<if test="groupId != null">group_id = #{groupId},</if> <!-- <if test="groupId != null">group_id = #{groupId},</if>-->
<if test="memberName != null">member_name = #{memberName},</if> <!-- <if test="memberName != null">member_name = #{memberName},</if>-->
<if test="joinTime != null">join_time = #{joinTime},</if> <!-- <if test="joinTime != null">join_time = #{joinTime},</if>-->
<if test="joinType != null">join_type = #{joinType},</if> <!-- <if test="joinType != null">join_type = #{joinType},</if>-->
</trim> <!-- </trim>-->
where id = #{id} <!-- where id = #{id}-->
</update> <!-- </update>-->
<delete id="deleteWeGroupMemberById" parameterType="Long"> <!-- <delete id="deleteWeGroupMemberById" parameterType="Long">-->
delete from we_group_member where id = #{id} <!-- delete from we_group_member where id = #{id}-->
</delete> <!-- </delete>-->
<delete id="deleteWeGroupMemberByIds" parameterType="String"> <!-- <delete id="deleteWeGroupMemberByIds" parameterType="String">-->
delete from we_group_member where id in <!-- delete from we_group_member where id in-->
<foreach item="id" collection="array" open="(" separator="," close=")"> <!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
#{id} <!-- #{id}-->
</foreach> <!-- </foreach>-->
</delete> <!-- </delete>-->
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!