Skip to content

Commit

Permalink
Merge pull request #47 from lianluoyi/dev
Browse files Browse the repository at this point in the history
V1.35.0版本更新
  • Loading branch information
lianluoyi authored Dec 5, 2023
2 parents 9556c76 + 680afb4 commit b32af3e
Show file tree
Hide file tree
Showing 49 changed files with 1,285 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public AjaxResult<CustomerOverviewDateVO> exportCustomerTagsView(@RequestBody @V
@ApiOperation("获取客户概况-数据总览-日期维度")
public TableDataInfo<CustomerOverviewDateVO> getCustomerOverViewOfDate(@RequestBody @Validated CustomerOverviewDTO dto) {
dto.setCorpId(LoginTokenService.getLoginUser().getCorpId());
return getDataTable(weUserCustomerMessageStatisticsService.getCustomerOverViewOfDate(dto), dto.getTotal());
return getDataTable(weUserCustomerMessageStatisticsService.getCustomerOverViewOfDate(dto, true), dto.getTotal());
}

@PreAuthorize("@ss.hasPermi('statistic:customerContact:export')")
Expand Down Expand Up @@ -130,7 +130,7 @@ public AjaxResult getCustomerActivityOfDateTrend(@RequestBody @Validated Custome
@ApiOperation("获取客户活跃度-日期维度")
public TableDataInfo<CustomerActivityOfDateVO> getCustomerActivityOfDate(@RequestBody @Validated CustomerActivityDTO dto) {
dto.setCorpId(LoginTokenService.getLoginUser().getCorpId());
return getDataTable(weUserCustomerMessageStatisticsService.getCustomerActivityOfDate(dto, true));
return getDataTable(weUserCustomerMessageStatisticsService.getCustomerActivityOfDate(dto, true), dto.getTotal());
}

@PreAuthorize("@ss.hasPermi('statistic:customerContact:export')")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.easyink.web.controller.wecom;

import com.easyink.common.annotation.DataScope;
import com.easyink.common.annotation.Log;
import com.easyink.common.constant.WeConstans;
import com.easyink.common.core.controller.BaseController;
Expand Down Expand Up @@ -99,7 +98,8 @@ public TableDataInfo<WeCustomerVO> listV2(@RequestBody WeCustomerSearchDTO weCus
@ApiOperation("会话存档客户检索客户列表")
public TableDataInfo<SessionArchiveCustomerVO> listDistinct(WeCustomer weCustomer) {
weCustomer.setCorpId(LoginTokenService.getLoginUser().getCorpId());
List<SessionArchiveCustomerVO> list = weCustomerService.selectWeCustomerListDistinctV2(weCustomer);
PageInfoUtil.setPage();
List<SessionArchiveCustomerVO> list = weCustomerService.selectWeCustomerListDistinctV3(weCustomer);
return getDataTable(list);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.easyink.common.core.controller.BaseController;
import com.easyink.common.core.domain.AjaxResult;
import com.easyink.common.core.page.TableDataInfo;
import com.easyink.common.utils.PageInfoUtil;
import com.easyink.wecom.domain.WeCustomer;
import com.easyink.wecom.domain.dto.transfer.TransferCustomerDTO;
import com.easyink.wecom.domain.dto.transfer.TransferRecordPageDTO;
Expand Down Expand Up @@ -64,7 +65,7 @@ public TableDataInfo<WeCustomerTransferRecordVO> recordList(@Validated TransferR
@GetMapping("/customerList")
@ApiOperation("在职继承客户列表")
public TableDataInfo<WeCustomerVO> transferCustomerList(WeCustomer weCustomer) {
startPage();
PageInfoUtil.setPage();
weCustomer.setCorpId(LoginTokenService.getLoginUser().getCorpId());
List<WeCustomerVO> list = weCustomerTransferRecordService.transferCustomerList(weCustomer);
return getDataTable(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ public WeGroupTagController(WeGroupTagCategoryService weGroupTagCategoryService,
@ApiOperation("新增群标签组")
public AjaxResult add(@Validated @RequestBody AddWeGroupTagCategoryDTO weGroupTagCategory) {
weGroupTagCategory.setCorpId(LoginTokenService.getLoginUser().getCorpId());
weGroupTagCategoryService.add(weGroupTagCategory);
return AjaxResult.success();
return AjaxResult.success(weGroupTagCategoryService.add(weGroupTagCategory));
}

@Log(title = "编辑群标签组", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation("编辑群标签组")
public AjaxResult update(@Validated @RequestBody UpdateWeGroupTagCategoryDTO weGroupTagCategory) {
weGroupTagCategory.setCorpId(LoginTokenService.getLoginUser().getCorpId());
weGroupTagCategoryService.update(weGroupTagCategory);
return AjaxResult.success();
return AjaxResult.success(weGroupTagCategoryService.update(weGroupTagCategory));
}

@Log(title = "删除群标签组", businessType = BusinessType.DELETE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ public AjaxResult add(@Validated @RequestBody WeTagGroup weTagGroup) {
}
}
weTagGroup.setCorpId(LoginTokenService.getLoginUser().getCorpId());
weTagGroupService.insertWeTagGroup(weTagGroup);

return AjaxResult.success();
return AjaxResult.success(weTagGroupService.insertWeTagGroup(weTagGroup));
}

/**
Expand All @@ -137,8 +135,7 @@ public AjaxResult add(@Validated @RequestBody WeTagGroup weTagGroup) {
@PutMapping
public AjaxResult edit(@Validated @RequestBody WeTagGroup weTagGroup) {
weTagGroup.setCorpId(LoginTokenService.getLoginUser().getCorpId());
weTagGroupService.updateWeTagGroup(weTagGroup);
return AjaxResult.success();
return AjaxResult.success(weTagGroupService.updateWeTagGroup(weTagGroup));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 类名: RootEntity
Expand All @@ -23,6 +24,13 @@ public class RootEntity implements Serializable {
@ApiModelProperty(hidden = true)
private Map<String, Object> params;

/**
* 数据权限下的员工id列表
*/
@TableField(exist = false)
@ApiModelProperty(hidden = true)
private List<String> dataScopeUserIds;

public Map<String, Object> getParams() {
if (params == null) {
params = new HashMap<>();
Expand All @@ -33,4 +41,12 @@ public Map<String, Object> getParams() {
public void setParams(Map<String, Object> params) {
this.params = params;
}

public List<String> getDataScopeUserIds() {
return dataScopeUserIds;
}

public void setDataScopeUserIds(List<String> dataScopeUserIds) {
this.dataScopeUserIds = dataScopeUserIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public enum ResultTip {
TIP_LOCK_CONFIG_MISSING(1025, "AppID或AppSecret错误,请重新配置"),
TIP_ILLEGAL_TRUSTEDIP(1026, "企业可信IP配置失败"),
TIP_MULTIPART_FILE_NOT_EXISTS(1027, "上传的Multipart文件内容不存在"),
TIP_DATA_SCOPE_ERROR(1028, "数据权限获取异常,检查登陆员工是否非法"),


//运营模块返回码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
import com.easyink.common.core.domain.model.LoginUser;
import com.easyink.common.core.domain.wecom.WeUser;
import com.easyink.common.enums.DataScopeEnum;
import com.easyink.common.enums.ResultTip;
import com.easyink.common.exception.CustomException;
import com.easyink.common.exception.user.NoLoginTokenException;
import com.easyink.common.utils.DictUtils;
import com.easyink.common.utils.StringUtils;
import com.easyink.wecom.login.util.LoginTokenService;
import com.easyink.wecom.service.WeDepartmentService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
Expand All @@ -20,6 +23,9 @@
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
* 数据过滤处理
Expand All @@ -34,6 +40,12 @@ public class DataScopeAspect {
*/
public static final String DATA_SCOPE = "dataScope";

private final WeDepartmentService weDepartmentService;

public DataScopeAspect(WeDepartmentService weDepartmentService) {
this.weDepartmentService = weDepartmentService;
}

@Pointcut("@annotation(com.easyink.common.annotation.DataScope)")
public void dataScopePointCut() {
// 配置织入点
Expand Down Expand Up @@ -61,7 +73,50 @@ protected void handleDataScope(final JoinPoint joinPoint) {
// 如果是超级管理员 则不用过滤
if (loginUser != null && !loginUser.isSuperAdmin()) {
dataScopeFilter(joinPoint, loginUser, controllerDataScope.userAlias());
setDataScopeUserIds(joinPoint, loginUser);
}
}

/**
* 设置数据权限下的userId列表
*
* @param joinPoint 切点
* @param loginUser 登录用户实体
*/
public void setDataScopeUserIds(JoinPoint joinPoint, LoginUser loginUser) {
SysRole role = loginUser.getRole();
WeUser weUser = loginUser.getWeUser();
String corpId = loginUser.getCorpId();
if (ObjectUtil.isNull(role) || ObjectUtil.isNull(weUser)) {
throw new CustomException(ResultTip.TIP_DATA_SCOPE_ERROR);
}
// 当前登录员工的部门id列表
List<String> departmentScopeList = Arrays.asList(loginUser.getDepartmentDataScope().split(DictUtils.SEPARATOR));
// 当前登录员工的id
List<String> userIdList = new ArrayList<>();
userIdList.add(weUser.getUserId());
// 数据权限下的员工id列表
List<String> dataScopeUserIds = new ArrayList<>();
switch (DataScopeEnum.getDataScope(role.getDataScope())) {
case CUSTOM:
dataScopeUserIds = weDepartmentService.getDataScopeUserIdList(departmentScopeList, userIdList, corpId);
break;
case SELF_DEPT:
List<String> mainDepartMentList = new ArrayList<>();
mainDepartMentList.add(String.valueOf(weUser.getMainDepartment()));
dataScopeUserIds = weDepartmentService.getDataScopeUserIdList(mainDepartMentList, null, corpId);
break;
case DEPT_AND_CHILD:
dataScopeUserIds = weDepartmentService.getDataScopeUserIdList(departmentScopeList, null, corpId);
break;
case SELF:
dataScopeUserIds = weDepartmentService.getDataScopeUserIdList(null, userIdList, corpId);
break;
default:
break;
}
RootEntity rootEntity = (RootEntity) joinPoint.getArgs()[0];
rootEntity.setDataScopeUserIds(dataScopeUserIds);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public class WeChatContactMapping extends RootEntity implements Comparable<WeCha
@Excel(name = "是否为客户 0-成员 1-客户 2-机器人")
private Integer isCustom;

@ApiModelProperty(value = "聊天时间")
@TableField("chat_time")
private String chatTime;

/**
* 是否为客户 0-内部 1-外部 2-群聊
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@
import com.easyink.common.annotation.Excel;
import com.easyink.common.core.domain.BaseEntity;
import com.easyink.common.core.domain.wecom.BaseExtendPropertyRel;
import com.easyink.common.utils.DictUtils;
import com.easyink.common.utils.StringUtils;
import com.easyink.wecom.domain.dto.customer.ExternalContact;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;

import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.*;

/**
* 企业微信客户对象 we_customer
Expand Down Expand Up @@ -223,6 +222,10 @@ public class WeCustomer extends BaseEntity {
@TableField(exist = false)
private String markTagIds;

@ApiModelProperty(value = "过滤查询条件的客户id列表")
@TableField(exist = false)
private List<String> filterExternalUseridList;


/**
* 根据API返回的客户详情实体 构建数据交互的企微客户实体
Expand Down Expand Up @@ -264,4 +267,46 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(corpId, externalUserid);
}

/**
* 将以","分隔的部门id字符串,转换为部门id列表
*
* @return 部门id列表
*/
public List<String> convertDepartmentList() {
if (StringUtils.isBlank(this.getDepartmentIds())) {
return Collections.emptyList();
}
return Arrays.asList(this.departmentIds.split(DictUtils.SEPARATOR));
}

/**
* 将以","分隔的员工id字符串,转换为员工id列表
*
* @return 员工id列表
*/
public List<String> convertUserIdList() {
if (StringUtils.isBlank(this.userIds)) {
return Collections.emptyList();
}
return Arrays.asList(this.userIds.split(DictUtils.SEPARATOR));
}

/**
* 添加过滤查询条件的客户id列表
*
* @param externalUseridList 客户id列表
*/
public void addFilterExternalUserIdList(List<String> externalUseridList) {
// 不存在,就初始化
if (CollectionUtils.isEmpty(this.filterExternalUseridList)) {
this.filterExternalUseridList = new ArrayList<>();
}
this.filterExternalUseridList.addAll(externalUseridList);
// 过滤,去重
HashSet<String> hashSet = new HashSet<>(this.filterExternalUseridList);
List<String> distinctList = new ArrayList<>(hashSet);
this.setFilterExternalUseridList(distinctList);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ public class CustomerActivityDTO extends StatisticsDTO{

@ApiModelProperty("发送时间的结束时间")
private String sendEndTime;

@ApiModelProperty("数据总数")
private Long total;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.easyink.wecom.domain.vo;

import com.easyink.common.constant.redeemcode.RedeemCodeConstants;
import com.easyink.common.enums.EmployCodeSourceEnum;
import com.easyink.wecom.domain.dto.AddWeMaterialDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

Expand Down Expand Up @@ -105,4 +107,20 @@ public class SelectWeEmplyCodeWelcomeMsgVO {

@ApiModelProperty(value = "活动欢迎语type,1:发送成功,2:发送失败,3:发送限制", hidden = true)
private Integer redeemCodeActivityType;


/**
* 判断发送的欢迎语是否存在"#兑换码#"替换词
*
* @return true 存在, false 不存在
*/
public boolean isHaveCodeActivityMsg() {
if (StringUtils.isBlank(this.welcomeMsg)) {
return false;
}
if (this.welcomeMsg.contains(RedeemCodeConstants.REDEEM_CODE)) {
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@ public class CustomerActivityOfDateVO extends ChatMessageCntVO {
@ApiModelProperty("时间")
private Date time;

/**
* 日期维度-根据日期初始化数据
*
* @param time 日期
*/
public CustomerActivityOfDateVO(Date time) {
this.time = time;
super.setChatCustomerCnt(0);
super.setUserSendMessageCnt(0);
super.setCustomerSendMessageCnt(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ private void sendMessageToNewExternalUserId(WeWelcomeMsg.WeWelcomeMsgBuilder weW
// 3.调用企业微信接口发送欢迎语
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.attachments(attachmentList).build(), corpId);

if (WelcomeMsgTypeEnum.REDEEM_CODE_WELCOME_MSG_TYPE.getType().equals(messageMap.getWelcomeMsgType())) {
if (WelcomeMsgTypeEnum.REDEEM_CODE_WELCOME_MSG_TYPE.getType().equals(messageMap.getWelcomeMsgType()) && messageMap.isHaveCodeActivityMsg()) {
// 4.更新兑换码的发送状态
if (StringUtils.isNotBlank(messageMap.getRedeemCode())) {
weRedeemCodeService.updateRedeemCode(WeRedeemCodeDTO.builder()
Expand Down
Loading

0 comments on commit b32af3e

Please sign in to comment.