Commit a5962c56 by 水库浪子

提交添加客户标签,移除客户标签,离职获取,离职分配等功能

1 parent 12843a42
Showing 31 changed files with 490 additions and 258 deletions
......@@ -9,6 +9,7 @@ import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -99,4 +100,36 @@ public class WeCustomerController extends BaseController
}
/**
* 客户打标签
* @param weMakeCustomerTag
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:customer:makeLabel')")
@Log(title = "客户打标签", businessType = BusinessType.UPDATE)
@PostMapping("/makeLabel")
public AjaxResult makeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){
weCustomerService.makeLabel(weMakeCustomerTag);
return AjaxResult.success();
}
/**
* 移除客户标签
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:customer:removeLabel')")
@Log(title = "移除客户标签", businessType = BusinessType.DELETE)
@DeleteMapping("/removeLabel")
public AjaxResult removeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){
weCustomerService.removeLabel(weMakeCustomerTag);
return AjaxResult.success();
}
}
......@@ -128,7 +128,8 @@ public class WeUserController extends BaseController {
@GetMapping({"/leaveUserNoAllocateList"})
public TableDataInfo leaveUserNoAllocateList(WeLeaveUserVo weLeaveUserVo) {
startPage();
weLeaveUserVo.setIsActivate(WeConstans.LEAVE_NO_ALLOCATE_STATE);
weLeaveUserVo.setIsActivate(WeConstans.WE_USER_IS_LEAVE);
weLeaveUserVo.setIsAllocate(WeConstans.LEAVE_NO_ALLOCATE_STATE);
List<WeLeaveUserVo> list = this.weUserService.leaveUserList(weLeaveUserVo);
return getDataTable(list);
}
......
......@@ -144,4 +144,7 @@ wecome:
- /externalcontact/get
- /externalcontact/groupchat/list
- /externalcontact/groupchat/get
- /externalcontact/mark_tag
- /externalcontact/transfer
- /externalcontact/groupchat/transfer
fileUplodUrl: /media/upload,/media/uploadimg
......@@ -52,12 +52,42 @@ public class WeConstans {
/**
* 离职未分配
*/
public static final Integer LEAVE_NO_ALLOCATE_STATE = 5;
public static final Integer LEAVE_NO_ALLOCATE_STATE = 0;
/**
* 离职已分配分配
*/
public static final Integer LEAVE_ALLOCATE_STATE = 6;
public static final Integer LEAVE_ALLOCATE_STATE = 1;
/**
* 已激活
*/
public static final Integer WE_USER_IS_ACTIVATE=1;
/**
* 已禁用
*/
public static final Integer WE_USER_IS_FORBIDDEN=2;
/**
* 已离职
*/
public static final Integer WE_USER_IS_LEAVE=5;
/**
* 未激活
*/
public static final Integer WE_USER_IS_NO_ACTIVATE=4;
/**
......
......@@ -5,6 +5,7 @@ import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.WeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserList;
import com.linkwechat.wecom.domain.dto.customer.FollowUserList;
......@@ -53,4 +54,14 @@ public interface WeCustomerClient {
WeResultDto remark(@DataObject WeCustomerDto.WeCustomerRemark weCustomerRemark);
/**
* 编辑客户标签
* @return
*/
@Request(url = "/externalcontact/mark_tag",
type = "POST"
)
WeResultDto makeCustomerLabel(@DataObject CutomerTagEdit cutomerTagEdit);
}
......@@ -3,9 +3,7 @@ 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.WeResultDto;
import com.linkwechat.wecom.domain.dto.WeUserDto;
import com.linkwechat.wecom.domain.dto.WeUserListDto;
import com.linkwechat.wecom.domain.dto.*;
/**
* @description: 企业微信通讯录成员
......@@ -62,4 +60,24 @@ public interface WeUserClient {
*/
@Request(url="/user/list")
WeUserListDto list(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
/**
* 分配客户
* @return
*/
@Request(url="/externalcontact/transfer",
type = "POST"
)
WeResultDto allocateCustomer(@DataObject AllocateWeCustomerDto allocateWeCustomerDto);
/**
* 分配成员群
* @return
*/
@Request(url="/externalcontact/groupchat/transfer",
type = "POST"
)
WeResultDto allocateGroup(@DataObject AllocateWeGroupDto allocateWeGroupDto);
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 离职分配的客户列对象 we_allocate_customer
*
* @author ruoyi
* @date 2020-10-24
*/
@Data
@TableName("we_allocate_customer")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeAllocateCustomer
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 接替成员的userid */
private String takeoverUserid;
/** 被分配的客户id */
private String externalUserid;
/** 分配时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date allocateTime;
/** 原跟进成员的userid */
private String handoverUserid;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* 分配的群租对象 we_allocate_group
*
* @author ruoyi
* @date 2020-10-24
*/
@Data
@TableName("we_allocate_group")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeAllocateGroup
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();;
/** 分配的群id */
private String chatId;
/** 新群主 */
private String newOwner;
/** 原群主 */
private String oldOwner;
/** 分配时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date allocateTime;
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.domain;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
......@@ -16,7 +17,7 @@ public class WeCustomerTagRel extends BaseEntity
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
private Long id= SnowFlakeUtil.nextId();;
/** 客户id */
private Long customerId;
......
......@@ -25,7 +25,6 @@ import java.util.Date;
* @date 2020-08-31
*/
@Data
@ApiModel("通讯录用户")
@TableName("we_user")
public class WeUser extends BaseEntity
{
......@@ -35,86 +34,70 @@ public class WeUser extends BaseEntity
private Long id= SnowFlakeUtil.nextId();
/** 用户头像 */
@ApiModelProperty("用户头像,该值来自素材库")
private String avatarMediaid;
/** 用户名称 */
@ApiModelProperty("姓名")
@NotBlank(message = "姓名不可为空")
private String name;
/** 用户昵称 */
@ApiModelProperty("昵称")
private String alias;
/** 账号 */
@ApiModelProperty("账号")
@NotBlank(message = "账号不可为空")
private String userId;
/** 性别。1表示男性,2表示女性 */
@ApiModelProperty("性别。1表示男性,2表示女性")
private Integer gender=new Integer(1);
/** 手机号 */
@ApiModelProperty("手机号")
@NotBlank(message = "手机号不可为空")
private String mobile;
/** 邮箱 */
@ApiModelProperty("邮箱")
private String email;
/** 个人微信号 */
@ApiModelProperty("个人微信号")
private String wxAccount;
/** 用户所属部门,使用逗号隔开,字符串格式存储 */
@ApiModelProperty("用户所属部门,使用逗号隔开,字符串格式存储")
private String[] department;
/** 职务 */
@ApiModelProperty("职务")
private String position;
/** 1表示为上级,0表示普通成员(非上级)。 */
@ApiModelProperty("1表示为上级,0表示普通成员(非上级)")
private String[] isLeaderInDept;
/** 入职时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("入职时间")
private Date joinTime;
/** 是否启用(1表示启用成员,0表示禁用成员) */
@ApiModelProperty("是否启用(1表示启用成员,0表示禁用成员)")
private Integer enable=new Integer(1);
/** 身份证号 */
@ApiModelProperty("身份证号")
private String idCard;
/** QQ号 */
@ApiModelProperty("QQ号")
private String qqAccount;
/** 座机 */
@ApiModelProperty("座机")
private String telephone;
/** 地址 */
@ApiModelProperty("地址")
private String address;
/** 生日 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("生日")
private Date birthday;
/** 是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 */
@ApiModelProperty("是否激活(1:是;2:否)该字段主要表示当前信息是否同步微信 ")
private Integer isActivate=new Integer(2);
/** 离职是否分配(1:已分配;0:未分配;) */
private Integer isAllocate;
/** 转化成企业微信需要的dto对象 */
......
package com.linkwechat.wecom.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 分配客户
* @author: HaoN
* @create: 2020-10-24 23:26
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AllocateWeCustomerDto{
/**外部联系人的userid,注意不是企业成员的帐号*/
private String handover_userid;
/**原跟进成员的userid*/
private String external_userid;
/**接替成员的userid*/
private String takeover_userid;
/**转移成功后发给客户的消息,最多200个字符,不填则使用默认文案,目前只对在职成员分配客户的情况生效*/
private String transfer_success_msg;
}
package com.linkwechat.wecom.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 离职成员群分配
* @author: HaoN
* @create: 2020-10-24 23:37
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AllocateWeGroupDto {
/**需要转群主的客户群ID列表。*/
private String[] chat_id_list;
/**新群主ID。*/
private String new_owner;
}
package com.linkwechat.wecom.domain.dto.customer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 客户标签编辑
* @author: HaoN
* @create: 2020-10-24 21:01
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CutomerTagEdit {
/**添加外部联系人的userid*/
private String userid;
/**外部联系人userid*/
private String external_userid;
/**要标记的标签列表*/
private String[] add_tag;
/**要移除的标签列表*/
private String[] remove_tag;
}
......@@ -24,4 +24,8 @@ public class WeLeaveUserVo extends BaseEntity {
private Integer isActivate;
private String userId;
private Integer isAllocate;
}
package com.linkwechat.wecom.domain.vo;
import com.linkwechat.wecom.domain.WeTag;
import lombok.Data;
import java.util.List;
/**
* @description: 客户打标签实体
* @author: HaoN
* @create: 2020-10-24 20:09
**/
@Data
public class WeMakeCustomerTag {
private String externalUserid;
private List<WeTag> addTag;
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeAllocateCustomer;
/**
* 离职分配的客户列Mapper接口
*
* @author ruoyi
* @date 2020-10-24
*/
public interface WeAllocateCustomerMapper extends BaseMapper<WeAllocateCustomer>
{
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeAllocateGroup;
/**
* 分配的群租Mapper接口
*
* @author ruoyi
* @date 2020-10-24
*/
public interface WeAllocateGroupMapper extends BaseMapper<WeAllocateGroup>
{
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeAllocateCustomer;
/**
* 离职分配的客户列Service接口
*
* @author ruoyi
* @date 2020-10-24
*/
public interface IWeAllocateCustomerService extends IService<WeAllocateCustomer>
{
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeAllocateGroup;
/**
* 分配的群租Service接口
*
* @author ruoyi
* @date 2020-10-24
*/
public interface IWeAllocateGroupService extends IService<WeAllocateGroup>
{
}
......@@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
/**
* 企业微信客户Service接口
......@@ -30,38 +31,6 @@ public interface IWeCustomerService extends IService<WeCustomer>
*/
public List<WeCustomer> selectWeCustomerList(WeCustomer weCustomer);
// /**
// * 新增企业微信客户
// *
// * @param weCustomer 企业微信客户
// * @return 结果
// */
// public int insertWeCustomer(WeCustomer weCustomer);
//
// /**
// * 修改企业微信客户
// *
// * @param weCustomer 企业微信客户
// * @return 结果
// */
// public int updateWeCustomer(WeCustomer weCustomer);
//
// /**
// * 批量删除企业微信客户
// *
// * @param ids 需要删除的企业微信客户ID
// * @return 结果
// */
// public int deleteWeCustomerByIds(Long[] ids);
//
// /**
// * 删除企业微信客户信息
// *
// * @param id 企业微信客户ID
// * @return 结果
// */
// public int deleteWeCustomerById(Long id);
/**
* 同步客户接口
......@@ -75,4 +44,18 @@ public interface IWeCustomerService extends IService<WeCustomer>
* @param weLeaveUserInfoAllocateVo
*/
public void allocateWeCustomer(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
/**
* 客户打标签
* @param weMakeCustomerTag
*/
public void makeLabel(WeMakeCustomerTag weMakeCustomerTag);
/**
* 移除客户标签
* @param weMakeCustomerTag
*/
public void removeLabel(WeMakeCustomerTag weMakeCustomerTag);
}
......@@ -13,69 +13,5 @@ import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
*/
public interface IWeFlowerCustomerRelService extends IService<WeFlowerCustomerRel>
{
/**
* 查询具有外部联系人功能企业员工也客户的关系
*
* @param id 具有外部联系人功能企业员工也客户的关系ID
* @return 具有外部联系人功能企业员工也客户的关系
*/
public WeFlowerCustomerRel selectWeFlowerCustomerRelById(Long id);
/**
* 查询具有外部联系人功能企业员工也客户的关系列表
*
* @param weFlowerCustomerRel 具有外部联系人功能企业员工也客户的关系
* @return 具有外部联系人功能企业员工也客户的关系集合
*/
public List<WeFlowerCustomerRel> selectWeFlowerCustomerRelList(WeFlowerCustomerRel weFlowerCustomerRel);
/**
* 新增具有外部联系人功能企业员工也客户的关系
*
* @param weFlowerCustomerRel 具有外部联系人功能企业员工也客户的关系
* @return 结果
*/
public int insertWeFlowerCustomerRel(WeFlowerCustomerRel weFlowerCustomerRel);
/**
* 修改具有外部联系人功能企业员工也客户的关系
*
* @param weFlowerCustomerRel 具有外部联系人功能企业员工也客户的关系
* @return 结果
*/
public int updateWeFlowerCustomerRel(WeFlowerCustomerRel weFlowerCustomerRel);
/**
* 批量删除具有外部联系人功能企业员工也客户的关系
*
* @param ids 需要删除的具有外部联系人功能企业员工也客户的关系ID
* @return 结果
*/
public int deleteWeFlowerCustomerRelByIds(Long[] ids);
/**
* 删除具有外部联系人功能企业员工也客户的关系信息
*
* @param id 具有外部联系人功能企业员工也客户的关系ID
* @return 结果
*/
public int deleteWeFlowerCustomerRelById(Long id);
/**
* 批量插入
* @param WeFlowerCustomerRels
* @return
*/
public int batchInsetWeFlowerCustomerRel(List<WeFlowerCustomerRel> WeFlowerCustomerRels);
/**
* 批量逻辑删除
* @param ids
* @return
*/
public int batchLogicDeleteByIds(List<Long> ids);
}
......@@ -16,10 +16,6 @@ public interface IWeGroupService extends IService<WeGroup> {
List<WeGroup> selectWeGroupList(WeGroup paramWeGroup);
// int batchLogicDeleteByIds(List<Long> ids);
//
// int batchInsetWeGroup(List<WeGroup> weGroups);
void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
......
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeAllocateCustomer;
import com.linkwechat.wecom.mapper.WeAllocateCustomerMapper;
import com.linkwechat.wecom.service.IWeAllocateCustomerService;
import org.springframework.stereotype.Service;
/**
* 离职分配的客户列Service业务层处理
*
* @author ruoyi
* @date 2020-10-24
*/
@Service
public class WeAllocateCustomerServiceImpl extends ServiceImpl<WeAllocateCustomerMapper,WeAllocateCustomer> implements IWeAllocateCustomerService
{
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeAllocateGroup;
import com.linkwechat.wecom.mapper.WeAllocateGroupMapper;
import com.linkwechat.wecom.service.IWeAllocateGroupService;
import org.springframework.stereotype.Service;
/**
* 分配的群租Service业务层处理
*
* @author ruoyi
* @date 2020-10-24
*/
@Service
public class WeAllocateGroupServiceImpl extends ServiceImpl<WeAllocateGroupMapper,WeAllocateGroup> implements IWeAllocateGroupService
{
}
package com.linkwechat.wecom.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeFlowerCustomerRelMapper;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.mapper.WeFlowerCustomerRelMapper;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import org.springframework.stereotype.Service;
/**
* 具有外部联系人功能企业员工也客户的关系Service业务层处理
......@@ -19,101 +15,7 @@ import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
@Service
public class WeFlowerCustomerRelServiceImpl extends ServiceImpl<WeFlowerCustomerRelMapper,WeFlowerCustomerRel> implements IWeFlowerCustomerRelService
{
@Autowired
private WeFlowerCustomerRelMapper weFlowerCustomerRelMapper;
/**
* 查询具有外部联系人功能企业员工也客户的关系
*
* @param id 具有外部联系人功能企业员工也客户的关系ID
* @return 具有外部联系人功能企业员工也客户的关系
*/
@Override
public WeFlowerCustomerRel selectWeFlowerCustomerRelById(Long id)
{
return weFlowerCustomerRelMapper.selectWeFlowerCustomerRelById(id);
}
/**
* 查询具有外部联系人功能企业员工也客户的关系列表
*
* @param weFlowerCustomerRel 具有外部联系人功能企业员工也客户的关系
* @return 具有外部联系人功能企业员工也客户的关系
*/
@Override
public List<WeFlowerCustomerRel> selectWeFlowerCustomerRelList(WeFlowerCustomerRel weFlowerCustomerRel)
{
return weFlowerCustomerRelMapper.selectWeFlowerCustomerRelList(weFlowerCustomerRel);
}
/**
* 新增具有外部联系人功能企业员工也客户的关系
*
* @param weFlowerCustomerRel 具有外部联系人功能企业员工也客户的关系
* @return 结果
*/
@Override
public int insertWeFlowerCustomerRel(WeFlowerCustomerRel weFlowerCustomerRel)
{
weFlowerCustomerRel.setCreateTime(DateUtils.getNowDate());
return weFlowerCustomerRelMapper.insertWeFlowerCustomerRel(weFlowerCustomerRel);
}
/**
* 修改具有外部联系人功能企业员工也客户的关系
*
* @param weFlowerCustomerRel 具有外部联系人功能企业员工也客户的关系
* @return 结果
*/
@Override
public int updateWeFlowerCustomerRel(WeFlowerCustomerRel weFlowerCustomerRel)
{
return weFlowerCustomerRelMapper.updateWeFlowerCustomerRel(weFlowerCustomerRel);
}
/**
* 批量删除具有外部联系人功能企业员工也客户的关系
*
* @param ids 需要删除的具有外部联系人功能企业员工也客户的关系ID
* @return 结果
*/
@Override
public int deleteWeFlowerCustomerRelByIds(Long[] ids)
{
return weFlowerCustomerRelMapper.deleteWeFlowerCustomerRelByIds(ids);
}
/**
* 删除具有外部联系人功能企业员工也客户的关系信息
*
* @param id 具有外部联系人功能企业员工也客户的关系ID
* @return 结果
*/
@Override
public int deleteWeFlowerCustomerRelById(Long id)
{
return weFlowerCustomerRelMapper.deleteWeFlowerCustomerRelById(id);
}
/**
* 批量插入
* @param WeFlowerCustomerRels
* @return
*/
@Override
public int batchInsetWeFlowerCustomerRel(List<WeFlowerCustomerRel> WeFlowerCustomerRels) {
return weFlowerCustomerRelMapper.batchInsetWeFlowerCustomerRel(WeFlowerCustomerRels);
}
/**
* 批量逻辑删除
* @param ids
* @return
*/
@Override
public int batchLogicDeleteByIds(List<Long> ids) {
return weFlowerCustomerRelMapper.batchLogicDeleteByIds(ids);
}
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.wecom.client.WeCustomerGroupClient;
import com.linkwechat.wecom.client.WeUserClient;
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.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.IWeCustomerService;
import com.linkwechat.wecom.service.IWeGroupMemberService;
import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeUserService;
import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -48,6 +50,14 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
private IWeCustomerService weCustomerService;
@Autowired
private IWeAllocateGroupService iWeAllocateGroupService;
@Autowired
private WeUserClient weUserClient;
public List<WeGroup> selectWeGroupList(WeGroup weGroup) {
return this.baseMapper.selectWeGroupList(weGroup);
}
......@@ -60,23 +70,38 @@ public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> imple
@Override
@Transactional
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);
// }
List<WeGroup> weGroups
= this.list(new LambdaQueryWrapper<WeGroup>().eq(WeGroup::getOwner, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(weGroups)){
List<WeAllocateGroup> weAllocateGroups=new ArrayList<>();
//更改本地群主
weGroups.stream().forEach(k->{
k.setOwner(weLeaveUserInfoAllocateVo.getTakeoverUserid());
weAllocateGroups.add(WeAllocateGroup.builder()
.allocateTime(new Date())
.chatId(k.getChatId())
.newOwner(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.oldOwner(weLeaveUserInfoAllocateVo.getHandoverUserid())
.build());
});
this.saveOrUpdateBatch(weGroups);
//分配记录保存
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))
.new_owner(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.build()
);
}
}
}
}
......
......@@ -170,7 +170,7 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
* @param weLeaveUserInfoAllocateVo
*/
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public void allocateLeaveUserAboutData(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
try {
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeAllocateCustomerMapper">
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeAllocateGroupMapper">
</mapper>
\ No newline at end of file
......@@ -144,19 +144,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="leaveUserList" parameterType="WeLeaveUserVo" resultType="com.linkwechat.wecom.domain.vo.WeLeaveUserVo">
SELECT
we.user_name as userName,
we.department,
we.dimission_time as dimissionTime,
(SELECT count(wfcr.id) FROM we_flower_customer_rel wfcr WHERE wfcr.user_id=we.user_id) allocateCustomerNum,
(SELECT count(wg.id) FROM we_group wg WHERE wg.group_leader_user_id=we.user_id) allocateGroupNum
wu.user_id,
wu.user_name,
wu.dimission_time,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department,
(SELECT COUNT(*) FROM we_flower_customer_rel wfcr WHERE wfcr.user_id=wu.user_id) as allocateCustomerNum,
(SELECT COUNT(*) FROM we_group wg WHERE wg.`owner`=wu.user_id) as allocateGroupNum
FROM
we_user we
we_user wu
<where>
<if test="userName != null and userName !=''">and we.user_name=#{userName}</if>
<if test="userName != null and userName !=''">and wu.user_name=#{userName}</if>
<if test="beginTime != null and beginTime !='' and endTime != null and endTime !=''">
DATE_FORMAT(we.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime}
DATE_FORMAT(wu.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime}
</if>
<if test="isActivate != null ">and we.is_activate = #{isActivate}</if>
<if test="isActivate != null ">and wu.is_activate = #{isActivate}</if>
<if test="isAllocate != null ">and wu.is_allocate = #{isAllocate}</if>
</where>
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!