Commit 30cb2495 by 墨竹

Merge remote-tracking branch 'origin/developer' into developer

parents 7e775f46 9699537c
...@@ -17,8 +17,14 @@ public class QywxCallBackDTO implements Serializable{ ...@@ -17,8 +17,14 @@ public class QywxCallBackDTO implements Serializable{
/**1男 2女***/ /**1男 2女***/
private Integer gender; private Integer gender;
private String alias; private String alias;
private String mainDepartment;
/**
* 是否是所在部门负责人 1 是 0 否 例 1,0,0
*/
private Integer[] isLeaderInDept;
private String[] department; private String[] department;
private String newUserid; private String newUserid;
private String telephone;
private String mobile; private String mobile;
private String position; private String position;
private Integer status; //激活状态:1=激活或关注, 2=禁用, 4=未激活 private Integer status; //激活状态:1=激活或关注, 2=禁用, 4=未激活
...@@ -200,6 +206,27 @@ public class QywxCallBackDTO implements Serializable{ ...@@ -200,6 +206,27 @@ public class QywxCallBackDTO implements Serializable{
this.status = status; this.status = status;
} }
public String getMainDepartment() {
return mainDepartment;
}
public void setMainDepartment(String mainDepartment) {
this.mainDepartment = mainDepartment;
}
public Integer[] getIsLeaderInDept() {
return isLeaderInDept;
}
public void setIsLeaderInDept(Integer[] isLeaderInDept) {
this.isLeaderInDept = isLeaderInDept;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
} }
...@@ -20,14 +20,12 @@ public interface MessageApiService { ...@@ -20,14 +20,12 @@ public interface MessageApiService {
* *
* @param qywxCallBackDTO * @param qywxCallBackDTO
*/ */
@Deprecated
void wxMessageReceive(QywxCallBackDTO qywxCallBackDTO); void wxMessageReceive(QywxCallBackDTO qywxCallBackDTO);
/** /**
* 队列消费企业微信推送数据 * 队列消费企业微信推送数据
* @param param * @param param
*/ */
@Deprecated
void dealWxMessage(String param); void dealWxMessage(String param);
/** /**
* 发送消费消息 * 发送消费消息
......
...@@ -2,12 +2,15 @@ package com.gic.haoban.manage.service.service.out.impl; ...@@ -2,12 +2,15 @@ package com.gic.haoban.manage.service.service.out.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkQwDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil; import com.gic.commons.util.GICMQClientUtil;
import com.gic.commons.util.GlobalInfo; import com.gic.commons.util.GlobalInfo;
import com.gic.commons.util.GlobalVar; import com.gic.commons.util.GlobalVar;
import com.gic.haoban.app.customer.service.api.service.InnerApiService; import com.gic.haoban.app.customer.service.api.service.InnerApiService;
import com.gic.haoban.base.api.common.Constant; import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.AppPageType; import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.enums.GicDataType; import com.gic.haoban.manage.api.enums.GicDataType;
...@@ -16,14 +19,8 @@ import com.gic.haoban.manage.api.enums.WxEditType; ...@@ -16,14 +19,8 @@ import com.gic.haoban.manage.api.enums.WxEditType;
import com.gic.haoban.manage.api.service.*; import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil; import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment; import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.thirdparty.api.dto.PicUploadResDTO; import com.gic.thirdparty.api.dto.PicUploadResDTO;
import com.gic.thirdparty.api.service.QQCloudPicService; import com.gic.thirdparty.api.service.QQCloudPicService;
...@@ -31,6 +28,7 @@ import com.gic.wechat.api.dto.qywx.ItemDTO; ...@@ -31,6 +28,7 @@ import com.gic.wechat.api.dto.qywx.ItemDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO; import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService; import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -40,10 +38,9 @@ import org.springframework.stereotype.Service; ...@@ -40,10 +38,9 @@ import org.springframework.stereotype.Service;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap; import java.util.function.Function;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map;
/** /**
* 接收企业微信或者gic推送消息进行处理 * 接收企业微信或者gic推送消息进行处理
...@@ -88,6 +85,11 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -88,6 +85,11 @@ public class MessageApiServiceImpl implements MessageApiService {
@Autowired @Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService; private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@Autowired
private ClerkService clerkService;
@Override @Override
public void gicMessageReceive(GicMessageDTO gicMessageDTO) { public void gicMessageReceive(GicMessageDTO gicMessageDTO) {
if (true) { if (true) {
...@@ -118,23 +120,87 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -118,23 +120,87 @@ public class MessageApiServiceImpl implements MessageApiService {
@Override @Override
public void dealWxMessage(String param) { public void dealWxMessage(String param) {
if (true) {
log.info("不出发更新企业微信变更");
return;
}
QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class); QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class);
log.info("【处理微信回调】dto={}", JSON.toJSONString(param)); log.info("【处理微信回调】dto={}", JSON.toJSONString(param));
if (dto != null) { // 处理定制-目前鸿星尔克用
String corpId = dto.getAuthCorpId(); boolean checkErkeDeal = checkErkeDeal(dto);
TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(corpId); if (!checkErkeDeal) {
if (enterprise != null) { log.info("不符合鸿星尔克需求,返回");
if (dto.getChangeType().endsWith("party")) { return;
this.dealDepartment(dto); }
} else { TabHaobanWxEnterprise enterprise = enterpriseService.getEnterpriseBycorpId(dto.getAuthCorpId());
this.dealUser(dto); if (Objects.isNull(enterprise)) {
log.info("通过corpId:【{}】未查询到授权企业,无法处理", dto.getAuthCorpId());
return;
}
List<TabHaobanWxEnterpriseRelated> relatedList = wxEnterpriseRelatedService.getByWxEnterpriseId(enterprise.getWxEnterpriseId());
if (CollectionUtils.isEmpty(relatedList)) {
log.info("未查询到企业关联企业 wxEnt");
return;
} }
ServiceResponse response = staffApiService.getWxSaveNew(dto.getUserid(), enterprise.getWxEnterpriseId());
if (response.getCode() != 1) {
log.info("添加企业员工失败:{}", response.getMessage());
return;
} }
// 取第一个企业的id
doDealUser(dto, relatedList.get(0).getEnterpriseId());
// 以下暂时不会用到
// if (dto != null) {
// String corpId = dto.getAuthCorpId();
// TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(corpId);
// if (enterprise != null) {
// if (dto.getChangeType().endsWith("party")) {
// this.dealDepartment(dto);
// } else {
// this.dealUser(dto);
// }
// }
// }
}
/**
* desc: 鸿星尔克定制需求校验-后期可扩展为配置形式
*
* @param dto dto
* @return : {@link boolean}
* @author : YongEn
* @date : 2022/1/25
*/
private boolean checkErkeDeal(QywxCallBackDTO dto) {
if (Objects.isNull(dto) || StringUtils.isEmpty(dto.getUserid())) {
return false;
}
String userid = dto.getUserid();
// 当前规则 userId是12位并且以5开头
if (userid.length() != 12) {
return false;
}
return userid.startsWith("5");
}
private void doDealUser(QywxCallBackDTO dto, String enterpriseId) {
ClerkQwDTO clerkQwDTO = new ClerkQwDTO();
clerkQwDTO.setEnterpriseId(enterpriseId);
String mainDeptId = dto.getMainDepartment();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> departments = qywxDepartmentApiService.listDepartment(dto.getAuthCorpId(), dto.getSuiteId(), Integer.valueOf(mainDeptId));
if (CollectionUtils.isEmpty(departments)) {
log.info("通过主部门查询部门列表为空 mainDeptId:{}", mainDeptId);
return;
} }
Map<Integer, com.gic.wechat.api.dto.qywx.DepartmentDTO> departmentIdMap = departments.stream()
.collect(Collectors.toMap(com.gic.wechat.api.dto.qywx.DepartmentDTO::getId, Function.identity(), (a, b) -> a));
com.gic.wechat.api.dto.qywx.DepartmentDTO mainDept = departmentIdMap.get(Integer.valueOf(mainDeptId));
clerkQwDTO.setStoreName(mainDept.getName());
clerkQwDTO.setClerkCode(dto.getUserid());
clerkQwDTO.setClerkName(dto.getUserName());
clerkQwDTO.setClerkType(dto.getIsLeaderInDept()[0]);
clerkQwDTO.setClerkGener(dto.getGender());
clerkQwDTO.setPhoneNumber(dto.getMobile());
clerkQwDTO.setNationcode(dto.getTelephone());
// 调用换导购接口逻辑
clerkService.syncClerkForQw(clerkQwDTO);
} }
private void dealDepartment(QywxCallBackDTO qywxCallBackDTO) { private void dealDepartment(QywxCallBackDTO qywxCallBackDTO) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment