提交 f12c058d 编写于 作者: X xinlaa

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

......@@ -21,16 +21,18 @@ public class LinkWeChatApplication
{
public static void main(String[] args)
{
SpringApplication.run(LinkWeChatApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ LinkWeChat启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
SpringApplication.run(LinkWeChatApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ LinkWeChat启动成功 ლ(´ڡ`ლ)゙ \n" +
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
}
}
......@@ -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();
}
}
......@@ -77,7 +77,7 @@ public class WeEmpleCodeController extends BaseController
@PreAuthorize("@ss.hasPermi('wecom:code:remove')")
@Log(title = "员工活码", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(weEmpleCodeService.batchRemoveWeEmpleCodeIds(ListUtil.toList(ids)));
}
......
......@@ -36,7 +36,6 @@ public class WeUserController extends BaseController {
private IWeUserService weUserService;
/**
* 查询通讯录相关客户列表
*/
......@@ -71,7 +70,8 @@ public class WeUserController extends BaseController {
@ApiOperation("新增通讯录客户")
public AjaxResult add(@Validated @RequestBody WeUser weUser)
{
return toAjax(weUserService.insertWeUser(weUser));
weUserService.insertWeUser(weUser);
return AjaxResult.success();
}
/**
......@@ -83,24 +83,25 @@ public class WeUserController extends BaseController {
@ApiOperation("更新通讯录客户")
public AjaxResult edit(@RequestBody WeUser weUser)
{
return toAjax(weUserService.updateWeUser(weUser));
weUserService.updateWeUser(weUser);
return AjaxResult.success();
}
/**
* 启用或者禁止
* @param id
* @param enable
* @param weUser
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:user:startOrStop')")
@Log(title = "启用禁用用户", businessType = BusinessType.UPDATE)
@PutMapping("/startOrStop")
@ApiOperation("启用禁用用户 true:启用 false:禁用")
public AjaxResult startOrStop(Long id,Boolean enable){
@ApiOperation("是否启用(1表示启用成员,0表示禁用成员)")
public AjaxResult startOrStop(@RequestBody WeUser weUser){
weUserService.startOrStop(weUser);
return toAjax(weUserService.startOrStop(id,enable));
return AjaxResult.success();
}
......@@ -113,14 +114,15 @@ public class WeUserController extends BaseController {
@GetMapping({"/leaveUserAllocateList"})
public TableDataInfo leaveUserAllocateList(WeLeaveUserVo weLeaveUserVo) {
startPage();
weLeaveUserVo.setIsActivate(WeConstans.LEAVE_ALLOCATE_STATE);
List<WeLeaveUserVo> list = this.weUserService.leaveUserList(weLeaveUserVo);
weLeaveUserVo.setIsActivate(WeConstans.WE_USER_IS_LEAVE);
weLeaveUserVo.setIsAllocate(WeConstans.LEAVE_ALLOCATE_STATE);
List<WeLeaveUserVo> list = this.weUserService.leaveNoAllocateUserList(weLeaveUserVo);
return getDataTable(list);
}
/**
* 离职等待分配
* 离职分配
* @param weLeaveUserVo
* @return
*/
......@@ -128,8 +130,9 @@ public class WeUserController extends BaseController {
@GetMapping({"/leaveUserNoAllocateList"})
public TableDataInfo leaveUserNoAllocateList(WeLeaveUserVo weLeaveUserVo) {
startPage();
weLeaveUserVo.setIsActivate(WeConstans.LEAVE_NO_ALLOCATE_STATE);
List<WeLeaveUserVo> list = this.weUserService.leaveUserList(weLeaveUserVo);
weLeaveUserVo.setIsActivate(WeConstans.WE_USER_IS_LEAVE);
weLeaveUserVo.setIsAllocate(WeConstans.LEAVE_NO_ALLOCATE_STATE);
List<WeLeaveUserVo> list = weUserService.leaveNoAllocateUserList(weLeaveUserVo);
return getDataTable(list);
}
......@@ -164,6 +167,22 @@ public class WeUserController extends BaseController {
}
/**
* 删除用户
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:user:deleteUser')")
@DeleteMapping({"/{ids}"})
public AjaxResult deleteUser(@PathVariable String[] ids){
weUserService.deleteUser(ids);
return AjaxResult.success();
}
......
......@@ -144,4 +144,8 @@ wecome:
- /externalcontact/get
- /externalcontact/groupchat/list
- /externalcontact/groupchat/get
- /externalcontact/mark_tag
- /externalcontact/transfer
- /externalcontact/groupchat/transfer
- /externalcontact/get_unassigned_list
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=6;
/**
* 未激活
*/
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,35 @@ 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);
/**
* 获取离职员工列表
* @return
*/
@Request(
url = "/externalcontact/get_unassigned_list",
type = "POST"
)
LeaveWeUserListsDto leaveWeUsers();
}
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;
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
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.utils.SnowFlakeUtil;
import lombok.AllArgsConstructor;
......@@ -66,6 +67,7 @@ public class WeFlowerCustomerRel
private String status;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date createTime;
......
......@@ -25,9 +25,6 @@ import java.util.Date;
@TableName("we_tag")
public class WeTag
{
private static final long serialVersionUID = 1L;
/** 标签组id */
private String groupId;
......
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;
......@@ -12,7 +13,10 @@ import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.dto.WeUserDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.util.Date;
......@@ -25,96 +29,88 @@ import java.util.Date;
* @date 2020-08-31
*/
@Data
@ApiModel("通讯录用户")
@TableName("we_user")
public class WeUser extends BaseEntity
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeUser
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();
/** 用户头像 */
@ApiModelProperty("用户头像,该值来自素材库")
@TableField(value = "head_image_url")
private String avatarMediaid;
/** 用户名称 */
@ApiModelProperty("姓名")
@NotBlank(message = "姓名不可为空")
@TableField(value = "user_name")
private String name;
/** 用户昵称 */
@ApiModelProperty("昵称")
private String alias;
/** 账号 */
@ApiModelProperty("账号")
@NotBlank(message = "账号不可为空")
@TableId
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);
private Integer enable;
/** 身份证号 */
@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;
/** 离职时间 */
private Date dimissionTime;
/** 转化成企业微信需要的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;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @description: 离职成员客户列表
* @author: HaoN
* @create: 2020-10-25 16:07
**/
@Data
public class LeaveWeUserListsDto extends WeResultDto{
private List<LeaveWeUser> info;
@Data
public class LeaveWeUser{
/**离职成员的userid*/
private String handover_userid;
/**外部联系人userid*/
private String external_userid;
/**离职时间*/
private Date dimission_time;
}
}
......@@ -50,6 +50,9 @@ public class WeUserDto extends WeResultDto{
//全局唯一。对于同一个服务商,不同应用获取到企业内同一个成员的open_userid是相同的,最多64个字节。仅第三方应用可获取
private String open_userid;
//激活状态: 1=已激活,2=已禁用,4=未激活,5=退出企业。
private Integer status;
}
......@@ -25,6 +25,7 @@ public class WeUserListDto extends WeResultDto{
userlist.stream().forEach(k->{
WeUser weUser=new WeUser();
BeanUtils.copyPropertiesASM(k,weUser);
weUser.setIsActivate(k.getStatus());
weUsers.add(weUser);
});
}
......
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;
}
......@@ -37,6 +37,7 @@ public class WeCropGroupTagDto {
*/
public static WeCropGroupTagDto transformAddTag(WeTagGroup weTagGroup){
WeCropGroupTagDto weCropGroupTagDto=WeCropGroupTagDto.builder()
.group_id(weTagGroup.getGroupId())
.group_name(weTagGroup.getGourpName())
.build();
List<WeTag> weTags = weTagGroup.getWeTags();
......@@ -45,9 +46,23 @@ public class WeCropGroupTagDto {
List<WeTag> newAddWeTag
= weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
List<WeCropTagDto> weTagDtos=new ArrayList<>();
BeanUtils.copyPropertiesignoreOther(newAddWeTag,weTagDtos);
weCropGroupTagDto.setTag(weTagDtos);
if(CollectionUtil.isNotEmpty(newAddWeTag)){
List<WeCropTagDto> weTagDtos=new ArrayList<>();
newAddWeTag.stream().forEach(weTag -> {
weTagDtos.add(WeCropTagDto.builder()
.id(weTag.getTagId())
.name(weTag.getName())
.build());
});
weCropGroupTagDto.setTag(weTagDtos);
}
}
......
package com.linkwechat.wecom.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity;
import lombok.Data;
......@@ -16,6 +17,7 @@ public class WeLeaveUserVo extends BaseEntity {
private String department;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date dimissionTime;
private Integer allocateCustomerNum;
......@@ -24,4 +26,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>
{
}
......@@ -67,5 +67,5 @@ public interface WeEmpleCodeMapper
* @param ids 需要删除的数据ID
* @return 结果
*/
public int batchRemoveWeEmpleCodeIds(@Param("ids") List<Long> ids);
public int batchRemoveWeEmpleCodeIds(@Param("ids") List<String> ids);
}
......@@ -49,11 +49,20 @@ public interface WeUserMapper extends BaseMapper<WeUser>
/**
* 离职员工
* 离职未分配员工
* @param weLeaveUserVo
* @return
*/
public List<WeLeaveUserVo> leaveUserList(WeLeaveUserVo weLeaveUserVo);
public List<WeLeaveUserVo> leaveNoAllocateUserList(WeLeaveUserVo weLeaveUserVo);
/**
* 离职已分配员工
* @param weLeaveUserVo
* @return
*/
public List<WeLeaveUserVo> leaveAllocateUserList(WeLeaveUserVo weLeaveUserVo);
/**
......
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);
}
......@@ -68,7 +68,7 @@ public interface IWeEmpleCodeService
* @param ids 需要删除的数据ID
* @return 结果
*/
public int batchRemoveWeEmpleCodeIds(List<Long> ids);
public int batchRemoveWeEmpleCodeIds(List<String> ids);
......
......@@ -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);
......
......@@ -37,7 +37,7 @@ public interface IWeUserService extends IService<WeUser>
* @param weUser 通讯录相关客户
* @return 结果
*/
public int insertWeUser(WeUser weUser);
public void insertWeUser(WeUser weUser);
/**
* 修改通讯录相关客户
......@@ -45,24 +45,30 @@ public interface IWeUserService extends IService<WeUser>
* @param weUser 通讯录相关客户
* @return 结果
*/
public int updateWeUser(WeUser weUser);
public void updateWeUser(WeUser weUser);
/**
* 启用或禁用用户
* @param id
* @param enable
* @return
*/
public int startOrStop(Long id, Boolean enable);
public void startOrStop(WeUser weUser);
/**
* 离职员工
* 离职未分配员工
* @param weLeaveUserVo
* @return
*/
List<WeLeaveUserVo> leaveUserList(WeLeaveUserVo weLeaveUserVo);
List<WeLeaveUserVo> leaveNoAllocateUserList(WeLeaveUserVo weLeaveUserVo);
/**
* 离职已分配员工
* @param weLeaveUserVo
* @return
*/
List<WeLeaveUserVo> leaveAllocateUserList(WeLeaveUserVo weLeaveUserVo);
/**
......@@ -77,4 +83,11 @@ public interface IWeUserService extends IService<WeUser>
*/
void synchWeUser();
/**
* 删除用户
* @param ids
*/
void deleteUser(String[] ids);
}
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
{
}
......@@ -12,16 +12,17 @@ import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.framework.web.domain.server.Sys;
import com.linkwechat.wecom.client.WeCropTagClient;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserDetail;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserList;
import com.linkwechat.wecom.domain.dto.customer.ExternalUserTag;
import com.linkwechat.wecom.domain.dto.customer.FollowUserList;
import com.linkwechat.wecom.domain.dto.AllocateWeCustomerDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.customer.*;
import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagDto;
import com.linkwechat.wecom.domain.dto.tag.WeCropGroupTagListDto;
import com.linkwechat.wecom.domain.dto.tag.WeCropTagDto;
import com.linkwechat.wecom.domain.dto.tag.WeFindCropTagParam;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.mapper.WeCustomerMapper;
import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -45,7 +46,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
@Autowired
private WeCustomerClient weFollowUserClient;
private WeCustomerClient weCustomerClient;
@Autowired
......@@ -66,8 +67,17 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
private IWeFlowerCustomerTagRelService iWeFlowerCustomerTagRelService;
// @Autowired
// private WeUserClient weUserClient;
@Autowired
private IWeAllocateCustomerService iWeAllocateCustomerService;
@Autowired
private WeUserClient weUserClient;
......@@ -98,53 +108,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
return weCustomerMapper.selectWeCustomerList(weCustomer);
}
// /**
// * 新增企业微信客户
// *
// * @param weCustomer 企业微信客户
// * @return 结果
// */
// @Override
// public int insertWeCustomer(WeCustomer weCustomer)
// {
// return weCustomerMapper.insertWeCustomer(weCustomer);
// }
//
// /**
// * 修改企业微信客户
// *
// * @param weCustomer 企业微信客户
// * @return 结果
// */
// @Override
// public int updateWeCustomer(WeCustomer weCustomer)
// {
// return weCustomerMapper.updateWeCustomer(weCustomer);
// }
//
// /**
// * 批量删除企业微信客户
// *
// * @param ids 需要删除的企业微信客户ID
// * @return 结果
// */
// @Override
// public int deleteWeCustomerByIds(Long[] ids)
// {
// return weCustomerMapper.deleteWeCustomerByIds(ids);
// }
//
// /**
// * 删除企业微信客户信息
// *
// * @param id 企业微信客户ID
// * @return 结果
// */
// @Override
// public int deleteWeCustomerById(Long id)
// {
// return weCustomerMapper.deleteWeCustomerById(id);
// }
/**
......@@ -155,7 +118,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
@Transactional(rollbackFor = Exception.class)
public void synchWeCustomer() {
FollowUserList followUserList = weFollowUserClient.getFollowUserList();
FollowUserList followUserList = weCustomerClient.getFollowUserList();
if(WeConstans.WE_SUCCESS_CODE.equals(followUserList.getErrcode())
&& ArrayUtil.isNotEmpty(followUserList.getFollow_user())){
......@@ -164,7 +127,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
.stream().forEach(k->{
//获取指定联系人对应的客户
ExternalUserList externalUsers = weFollowUserClient.list(k);
ExternalUserList externalUsers = weCustomerClient.list(k);
if(WeConstans.WE_SUCCESS_CODE.equals(externalUsers.getErrcode())
|| WeConstans.NOT_EXIST_CONTACT.equals(externalUsers.getErrcode())
&& ArrayUtil.isNotEmpty(externalUsers.getExternal_userid())){
......@@ -172,7 +135,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
Arrays.asList(externalUsers.getExternal_userid()).forEach(v->{
//获取指定客户的详情
ExternalUserDetail externalUserDetail = weFollowUserClient.get(v);
ExternalUserDetail externalUserDetail = weCustomerClient.get(v);
if(WeConstans.WE_SUCCESS_CODE.equals(externalUserDetail.getErrcode())){
//客户入库
......@@ -309,22 +272,161 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper,WeCustom
@Transactional
public void allocateWeCustomer(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
//分配客户
List<WeFlowerCustomerRel> weFlowerCustomerRels = iWeFlowerCustomerRelService.selectWeFlowerCustomerRelList(WeFlowerCustomerRel.builder()
.userId(weLeaveUserInfoAllocateVo.getHandoverUserid())
.build());
List<WeFlowerCustomerRel> weFlowerCustomerRels = iWeFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getUserId, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(weFlowerCustomerRels)){
//删除原有的
// iWeFlowerCustomerRelService.batchLogicDeleteByIds(weFlowerCustomerRels.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList()));
// //保存新的
// weFlowerCustomerRels.stream().forEach(k->{
//// k.setId(SnowFlakeUtil.nextId());
// k.setUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
// });
// //保存新
// iWeFlowerCustomerRelService.batchInsetWeFlowerCustomerRel(weFlowerCustomerRels);
List<WeAllocateCustomer> weAllocateCustomers=new ArrayList<>();
weFlowerCustomerRels.stream().forEach(k->{
k.setUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
weAllocateCustomers.add(
WeAllocateCustomer.builder()
.allocateTime(new Date())
.externalUserid(k.getExternalUserid())
.handoverUserid(weLeaveUserInfoAllocateVo.getHandoverUserid())
.takeoverUserid(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.build()
);
});
//更新当前接手用户的id
iWeFlowerCustomerRelService.saveOrUpdateBatch(weFlowerCustomerRels);
if(CollectionUtil.isNotEmpty(weAllocateCustomers)){
//记录分配历史
if(iWeAllocateCustomerService.saveBatch(weAllocateCustomers)){
//同步企业微信端
weAllocateCustomers.stream().forEach(v->{
weUserClient.allocateCustomer(AllocateWeCustomerDto.builder()
.external_userid(v.getExternalUserid())
.handover_userid(v.getHandoverUserid())
.takeover_userid(v.getTakeoverUserid())
.build());
});
}
}
}
}
/**
* 客户打标签
* @param weMakeCustomerTag
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void makeLabel(WeMakeCustomerTag weMakeCustomerTag) {
//查询出当前用户对应的
List<WeFlowerCustomerRel> flowerCustomerRels = iWeFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()));
if(CollectionUtil.isNotEmpty(flowerCustomerRels)){
List<WeTag> addTags = weMakeCustomerTag.getAddTag();
if(CollectionUtil.isNotEmpty(addTags)){
List<WeFlowerCustomerTagRel> tagRels=new ArrayList<>();
List<CutomerTagEdit> cutomerTagEdits=new ArrayList<>();
flowerCustomerRels.stream().forEach(customer->{
CutomerTagEdit cutomerTagEdit = CutomerTagEdit.builder()
.userid(customer.getUserId())
.external_userid(customer.getExternalUserid())
.build();
List<String> tags=new ArrayList<>();
addTags.stream().forEach(tag->{
tags.add(tag.getTagId());
tagRels.add(
WeFlowerCustomerTagRel.builder()
.flowerCustomerRelId(customer.getId())
.tagId(tag.getTagId())
.createTime(new Date())
.build()
);
});
cutomerTagEdit.setAdd_tag(ArrayUtil.toArray(tags,String.class));
cutomerTagEdits.add(cutomerTagEdit);
});
if(iWeFlowerCustomerTagRelService.saveOrUpdateBatch(tagRels)){
if(CollectionUtil.isNotEmpty(cutomerTagEdits)){
cutomerTagEdits.stream().forEach(k->{
weCustomerClient.makeCustomerLabel(
k
);
});
}
}
}
}
}
/**
* 移除客户标签
* @param weMakeCustomerTag
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void removeLabel(WeMakeCustomerTag weMakeCustomerTag) {
List<WeTag> addTags = weMakeCustomerTag.getAddTag();
if(CollectionUtil.isNotEmpty(addTags)){
//查询出当前用户对应的
List<WeFlowerCustomerRel> flowerCustomerRels = iWeFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getExternalUserid, weMakeCustomerTag.getExternalUserid()));
if(CollectionUtil.isNotEmpty(flowerCustomerRels) ){
if(iWeFlowerCustomerTagRelService.remove(
new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.in(WeFlowerCustomerTagRel::getFlowerCustomerRelId, flowerCustomerRels.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList()))
.in(WeFlowerCustomerTagRel::getTagId, addTags.stream().map(WeTag::getTagId).collect(Collectors.toList()))
)){
flowerCustomerRels.stream().forEach(k->{
weCustomerClient.makeCustomerLabel(
CutomerTagEdit.builder()
.external_userid(k.getExternalUserid())
.userid(k.getUserId())
.remove_tag(ArrayUtil.toArray(addTags.stream().map(WeTag::getTagId).collect(Collectors.toList()), String.class))
.build()
);
});
}
}
}
}
......
......@@ -223,7 +223,7 @@ public class WeEmpleCodeServiceImpl implements IWeEmpleCodeService
* @return 结果
*/
@Override
public int batchRemoveWeEmpleCodeIds(List<Long> ids) {
public int batchRemoveWeEmpleCodeIds(List<String> ids) {
return weEmpleCodeMapper.batchRemoveWeEmpleCodeIds(ids);
}
......
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()
);
}
}
}
}
......
......@@ -28,7 +28,9 @@ 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.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -109,29 +111,25 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
public void updateWeTagGroup(WeTagGroup weTagGroup)
{
if(this.updateById(weTagGroup)){
List<WeTag> weTags = weTagGroup.getWeTags();
//获取新增的集合
if(CollectionUtil.isNotEmpty(weTags)) {
List<WeTag> filterWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
//同步新增标签到微信端
if(CollectionUtil.isNotEmpty(WeCropGroupTagDto.transformAddTag(weTagGroup).getTag())){
WeCropGropTagDtlDto
weCropGropTagDtlDto = weCropTagClient.addCorpTag( WeCropGroupTagDto.transformAddTag(weTagGroup));
if(weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){
//微信端返回的标签主键,设置到weTags中
//微信端返回的标签主键,设置到weTags中
Map<String, String> weCropTagMap = weCropGropTagDtlDto.getTag_group().getTag().stream()
.collect(Collectors.toMap(weCropTagDto -> weCropTagDto.getName(), weCropTagDto -> weCropTagDto.getId()));
filterWeTags.stream().forEach(tag->{
tag.setTagId(weCropTagMap.get(tag.getName()));
tag.setCreateTime(new Date());
});
}
}
//同步更新微信端标签名称
WeCropTagDto.transFormto(weTags).stream().forEach(k->{
weCropTagClient.editCorpTag(k);
});
//获取需要删除的数据
......@@ -150,23 +148,12 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
//移除本地
removeWeTags.stream().forEach(v -> v.setStatus(Constants.DELETE_CODE));
iWeTagService.updateBatchById(removeWeTags);
}
//保存或更新wetag
weTags.stream().forEach(v->v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveOrUpdateBatch(weTags);
}
filterWeTags.stream().forEach(v->v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveOrUpdateBatch(filterWeTags);
}
......@@ -213,7 +200,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
* 同步标签
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional
public void synchWeTags() {
......@@ -231,6 +218,7 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
* @param tagGroup
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void batchSaveOrUpdateTagGroupAndTag(List<WeCropGroupTagDto> tagGroup) {
List<WeTagGroup> weTagGroups=new ArrayList<>();
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.framework.web.domain.server.Sys;
......@@ -9,6 +10,7 @@ import com.linkwechat.wecom.client.WeDepartMentClient;
import com.linkwechat.wecom.client.WeUserClient;
import com.linkwechat.wecom.domain.WeDepartment;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.dto.LeaveWeUserListsDto;
import com.linkwechat.wecom.domain.dto.WeDepartMentDto;
import com.linkwechat.wecom.domain.dto.WeUserDto;
import com.linkwechat.wecom.domain.dto.WeUserListDto;
......@@ -25,6 +27,8 @@ import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
......@@ -44,8 +48,6 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
private WeUserClient weUserClient;
@Autowired
private IWeCustomerService iWeCustomerService;
......@@ -89,18 +91,16 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
*/
@Override
@Transactional
public int insertWeUser(WeUser weUser)
public void insertWeUser(WeUser weUser)
{
int returnCode = weUserMapper.insertWeUser(weUser);
if(returnCode>0){
if(this.save(weUser)){
weUserClient.createUser(
weUser.transformWeUserDto()
);
}
return returnCode;
}
/**
......@@ -111,18 +111,14 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
*/
@Override
@Transactional
public int updateWeUser(WeUser weUser)
public void updateWeUser(WeUser weUser)
{
int returnCode = weUserMapper.updateWeUser(weUser);
if(returnCode >0){
if(this.updateById(weUser)){
weUserClient.updateUser(
weUser.transformWeUserDto()
);
}
return returnCode;
}
......@@ -130,38 +126,34 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
/**
* 启用或禁用用户
* @param id
* @param enable
* @param weUser
* @return
*/
@Override
@Transactional
public int startOrStop(Long id, Boolean enable) {
int returnCode = -1;
WeUser weUser = this.selectWeUserById(id);
if(null != weUser){
weUser.setEnable(enable?WeConstans.WE_USER_START:WeConstans.WE_USER_STOP);
returnCode=updateWeUser(weUser);
}
public void startOrStop(WeUser weUser) {
this.updateWeUser(weUser);
}
return returnCode;
/**
* 离职未分配员工
* @param weLeaveUserVo
* @return
*/
@Override
public List<WeLeaveUserVo> leaveNoAllocateUserList(WeLeaveUserVo weLeaveUserVo) {
return this.weUserMapper.leaveNoAllocateUserList(weLeaveUserVo);
}
/**
* 离职分配员工
* 离职分配员工
* @param weLeaveUserVo
* @return
*/
@Override
public List<WeLeaveUserVo> leaveUserList(WeLeaveUserVo weLeaveUserVo) {
return this.weUserMapper.leaveUserList(weLeaveUserVo);
public List<WeLeaveUserVo> leaveAllocateUserList(WeLeaveUserVo weLeaveUserVo) {
return null;
}
......@@ -170,7 +162,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 {
......@@ -200,10 +192,35 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
= weUserClient.list(WeConstans.WE_ROOT_DEPARMENT_ID, WeConstans.DEPARTMENT_SUB_WEUSER).getWeUsers();
if(CollectionUtil.isNotEmpty(weUsers)){
//删除当前员工表员工
weUserMapper.deleteWeUser();
//重新插入员工
weUserMapper.batchInsertWeUser(weUsers);
this.saveOrUpdateBatch(weUsers);
}
}
/**
* 删除用户
* @param ids
*/
@Override
@Transactional
public void deleteUser(String[] ids) {
List<WeUser> weUsers=new ArrayList<>();
CollectionUtil.newArrayList(ids).stream().forEach(k->{
weUsers.add(
WeUser.builder()
.userId(k)
.enable(WeConstans.WE_USER_IS_LEAVE)
.dimissionTime(new Date())
.build()
);
});
if(this.updateBatchById(weUsers)){
weUsers.stream().forEach(k->{
weUserClient.deleteUserByUserId(k.getUserId());
});
}
}
......
<?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">
<!-- <select id="getAllocateCustomers" resultType="com.linkwechat.wecom.domain.vo.WeAllocateCustomer">-->
<!-- -->
<!-- SELECT-->
<!-- wc.`name` as customerName,-->
<!-- wu.user_name as userName,-->
<!-- (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department,-->
<!-- wac.allocate_time-->
<!-- FROM-->
<!-- we_allocate_customer wac-->
<!-- INNER JOIN we_customer wc ON wc.external_userid=wac.external_userid-->
<!-- INNER JOIN we_user wu ON wu.user_id=wac.takeover_userid-->
<!-- WHERE wac.handover_userid=1232-->
<!-- AND -->
<!-- -->
<!-- </select>-->
</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
......@@ -25,7 +25,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="operUserid" column="oper_userid" />
<result property="addWay" column="add_way" />
<result property="state" column="state" />
<!-- <result property="customerId" column="customer_id" />-->
<result property="userName" column="user_name"/>
<collection property="weFlowerCustomerTagRels" ofType="com.linkwechat.wecom.domain.WeFlowerCustomerTagRel">
<result property="flowerCustomerRelId" column="flower_customer_rel_id" />
......
......@@ -18,18 +18,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="position" column="position" />
<result property="isLeaderInDept" column="is_leader_in_dept" typeHandler="com.linkwechat.framework.handler.StringArrayJoinTypeHandler" />
<result property="joinTime" column="join_time" />
<result property="enable" column="enable" />
<result property="idCard" column="id_card" />
<result property="qqAccount" column="qq_account" />
<result property="telephone" column="telephone" />
<result property="address" column="address" />
<result property="birthday" column="birthday" />
<result property="remark" column="remark" />
<result property="isActivate" column="is_activate" />
<result property="isActivate" column="is_activate"/>
</resultMap>
<sql id="selectWeUserVo">
select id, head_image_url as avatarMediaid, user_name, alias, user_id, gender, mobile, email, wx_account, department, position, is_leader_in_dept, join_time, enable, id_card, qq_account, telephone, address, birthday, remark, is_activate from we_user
select head_image_url as avatarMediaid, user_name, alias, user_id, gender, mobile, email, wx_account, department, position, is_leader_in_dept, join_time, enable, id_card, qq_account, telephone, address, birthday, remark from we_user
</sql>
<select id="selectWeUserList" parameterType="WeUser" resultMap="WeUserResult">
......@@ -47,13 +46,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="position != null and position != ''"> and position = #{position}</if>
<if test="isLeaderInDept != null "> and is_leader_in_dept = #{isLeaderInDept}</if>
<if test="joinTime != null "> and join_time = #{joinTime}</if>
<if test="enable != null "> and enable = #{enable}</if>
<if test="idCard != null and idCard != ''"> and id_card = #{idCard}</if>
<if test="qqAccount != null and qqAccount != ''"> and qq_account = #{qqAccount}</if>
<if test="telephone != null and telephone != ''"> and telephone = #{telephone}</if>
<if test="address != null and address != ''"> and address = #{address}</if>
<if test="birthday != null "> and birthday = #{birthday}</if>
<if test="isActivate != null "> and is_activate = #{isActivate}</if>
</where>
</select>
......@@ -142,21 +139,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="leaveUserList" parameterType="WeLeaveUserVo" resultType="com.linkwechat.wecom.domain.vo.WeLeaveUserVo">
<select id="leaveNoAllocateUserList" 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>
<select id="leaveAllocateUserList" parameterType="WeLeaveUserVo" resultType="com.linkwechat.wecom.domain.vo.WeLeaveUserVo">
SELECT
wu.user_id,
wu.user_name,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department,
(SELECT COUNT(*) FROM we_allocate_customer wac WHERE wac.handover_userid=wu.user_id) as allocateCustomerNum,
(SELECT COUNT(*) FROM we_allocate_group wag WHERE wag.old_owner=wu.user_id) as allocateGroupNum,
wu.dimission_time
FROM
we_user wu
<where>
<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(wu.dimission_time,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime}
</if>
<if test="isActivate != null ">and wu.is_activate = #{isActivate}</if>
<if test="isAllocate != null ">and wu.is_allocate = #{isAllocate}</if>
</where>
</select>
......@@ -202,4 +222,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册