Commit 7a2e471d by 徐高华

好办安全升级调整

parent a16078e8
...@@ -11,8 +11,6 @@ public class WxEnterpriseDTO implements Serializable { ...@@ -11,8 +11,6 @@ public class WxEnterpriseDTO implements Serializable {
private String wxEnterpriseId; private String wxEnterpriseId;
private String corpid;
private String permanentCode; private String permanentCode;
private String corpName; private String corpName;
...@@ -106,6 +104,33 @@ public class WxEnterpriseDTO implements Serializable { ...@@ -106,6 +104,33 @@ public class WxEnterpriseDTO implements Serializable {
private Integer useridFlag; private Integer useridFlag;
private String enterpriseId; private String enterpriseId;
private Integer wxSecurityType ;
private String wxCorpid ;
private String openCorpid ;
public Integer getWxSecurityType() {
return wxSecurityType;
}
public void setWxSecurityType(Integer wxSecurityType) {
this.wxSecurityType = wxSecurityType;
}
public String getWxCorpid() {
return wxCorpid;
}
public String getOpenCorpid() {
return openCorpid;
}
public void setWxCorpid(String wxCorpid) {
this.wxCorpid = wxCorpid;
}
public void setOpenCorpid(String openCorpid) {
this.openCorpid = openCorpid;
}
public String getMemberSecret() { public String getMemberSecret() {
return memberSecret; return memberSecret;
...@@ -131,14 +156,6 @@ public class WxEnterpriseDTO implements Serializable { ...@@ -131,14 +156,6 @@ public class WxEnterpriseDTO implements Serializable {
this.wxEnterpriseId = wxEnterpriseId == null ? null : wxEnterpriseId.trim(); this.wxEnterpriseId = wxEnterpriseId == null ? null : wxEnterpriseId.trim();
} }
public String getCorpid() {
return corpid;
}
public void setCorpid(String corpid) {
this.corpid = corpid == null ? null : corpid.trim();
}
public String getPermanentCode() { public String getPermanentCode() {
return permanentCode; return permanentCode;
} }
......
...@@ -5,20 +5,23 @@ import java.io.Serializable; ...@@ -5,20 +5,23 @@ import java.io.Serializable;
public class WxEnterpriseQwDTO implements Serializable { public class WxEnterpriseQwDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int wxSecurityType ; private int wxSecurityType;
private String wxEnterpriseId; private String wxEnterpriseId;
// 企业表中的id(正常同第三方)
private String corpid;
// 好办 助手 // 好办 助手
private String dkCorpid; private String dkCorpid;
private String dkSuiteId ; private String dkSuiteId;
// 会员小程序dk // 会员小程序dk
private String memberCorpid; private String memberCorpid;
private String memberSuiteId ; private String memberSuiteId;
// 第三方 // 第三方
private String thirdCorpid; private String thirdCorpid;
// 第三方使用的加密的userid
public boolean needOpenUserId3th() {
return this.wxSecurityType == 2 || this.wxSecurityType == 3;
}
public String getDkSuiteId() { public String getDkSuiteId() {
return dkSuiteId; return dkSuiteId;
} }
...@@ -47,10 +50,6 @@ public class WxEnterpriseQwDTO implements Serializable { ...@@ -47,10 +50,6 @@ public class WxEnterpriseQwDTO implements Serializable {
return wxEnterpriseId; return wxEnterpriseId;
} }
public String getCorpid() {
return corpid;
}
public String getDkCorpid() { public String getDkCorpid() {
return dkCorpid; return dkCorpid;
} }
...@@ -67,10 +66,6 @@ public class WxEnterpriseQwDTO implements Serializable { ...@@ -67,10 +66,6 @@ public class WxEnterpriseQwDTO implements Serializable {
this.wxEnterpriseId = wxEnterpriseId; this.wxEnterpriseId = wxEnterpriseId;
} }
public void setCorpid(String corpid) {
this.corpid = corpid;
}
public void setDkCorpid(String dkCorpid) { public void setDkCorpid(String dkCorpid) {
this.dkCorpid = dkCorpid; this.dkCorpid = dkCorpid;
} }
......
...@@ -5,10 +5,6 @@ package com.gic.haoban.manage.api.enums; ...@@ -5,10 +5,6 @@ package com.gic.haoban.manage.api.enums;
*/ */
public enum SecretTypeEnum { public enum SecretTypeEnum {
CONTACT_CUSTOMER(1, "顾客联系"), CONTACT_CUSTOMER(1, "顾客联系"),
// 2和3废弃
CONTACT_SECRET(2, "通讯录"),
// 3和5公用
HAOBAN_HELP(3, "好办助手"),
MEMBER_WAPP(4, "会员小程序"), MEMBER_WAPP(4, "会员小程序"),
CUSTOMIZED_APP(5, "自建代开发"), CUSTOMIZED_APP(5, "自建代开发"),
WEWORK_PAY(6, "企业支付"), WEWORK_PAY(6, "企业支付"),
......
...@@ -54,12 +54,6 @@ public interface DepartmentApiService { ...@@ -54,12 +54,6 @@ public interface DepartmentApiService {
* @return * @return
*/ */
DepartmentDTO selectByRelatedId(String departId); DepartmentDTO selectByRelatedId(String departId);
/**
* 放入回收站
* @param departmentId
* @return
*/
ServiceResponse recycle(String departmentId);
/** /**
* 根据参数查询 * 根据参数查询
...@@ -72,11 +66,7 @@ public interface DepartmentApiService { ...@@ -72,11 +66,7 @@ public interface DepartmentApiService {
*/ */
Page<DepartmentDTO> pageDepartmentByParams(BasePageInfo pageInfo, String wxEnterpriseId, String keyword, Page<DepartmentDTO> pageDepartmentByParams(BasePageInfo pageInfo, String wxEnterpriseId, String keyword,
Integer storeFlag, Integer recycleFlag); Integer storeFlag, Integer recycleFlag);
/**
* 回收站恢复
* @param departmentId
*/
ServiceResponse repairRecycle(String departmentId,String parentId);
/** /**
* 获取根节点 * 获取根节点
* @param wxEnterpriseId * @param wxEnterpriseId
......
...@@ -11,24 +11,17 @@ public interface StaffApiService { ...@@ -11,24 +11,17 @@ public interface StaffApiService {
StaffDTO selectById(String staffId); StaffDTO selectById(String staffId);
StaffDTO selectSuperByWxEnterpriseId(String wxEnterpriseId);
List<StaffDTO> listByIds(List<String> staffIds); List<StaffDTO> listByIds(List<String> staffIds);
List<StaffDTO> listByWxUserId(String wxUserId, String wxEnterpriseId); List<StaffDTO> listByWxUserId(String wxUserId, String wxEnterpriseId);
StaffDTO selectByNationcodeAndPhoneNumber(String wxEnterpriseId, String nationcode, String phoneNumber); StaffDTO selectByNationcodeAndPhoneNumber(String wxEnterpriseId, String nationcode, String phoneNumber);
ServiceResponse add(StaffDTO staff, String departmentIds);
List<StaffDepartmentRelatedDTO> listStaffDepartmentByStaffId(String staffId); List<StaffDepartmentRelatedDTO> listStaffDepartmentByStaffId(String staffId);
Page<StaffDTO> pageStaff(List<String> departmentId, Integer activeFlag, Page<StaffDTO> pageStaff(List<String> departmentId, Integer activeFlag,
String keyword, BasePageInfo pageInfo, Integer relationFlag, String wxEnterpriseId); String keyword, BasePageInfo pageInfo, Integer relationFlag, String wxEnterpriseId);
@Deprecated
void del(String staffDepartmentStaffRelatedId);
/** /**
* 保存微信成员 * 保存微信成员
* *
...@@ -76,23 +69,12 @@ public interface StaffApiService { ...@@ -76,23 +69,12 @@ public interface StaffApiService {
StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId); StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId);
int countByDepartmentId(String departmentId);
@Deprecated
void syncGicClerk(String fieldListString);
@Deprecated
void addGicClerk(GicClerkDTO clerkDTO);
StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code); StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code);
void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId, String taskId); void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId, String taskId);
List<String> listUnBindClerk(String storeId); List<String> listUnBindClerk(String storeId);
@Deprecated
void cleanGicClerk(String clerkCode, String departmentId);
String insertUserLoginLog(UserLoginLogDTO userLoginLogDTO); String insertUserLoginLog(UserLoginLogDTO userLoginLogDTO);
int countByDepartmentIds(List<String> departmentIds); int countByDepartmentIds(List<String> departmentIds);
...@@ -102,14 +84,6 @@ public interface StaffApiService { ...@@ -102,14 +84,6 @@ public interface StaffApiService {
List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId); List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
/** /**
* 保存gic成员
*
* @param clerkDTO
* @return
*/
ServiceResponse saveSyncStaffByGic(GicClerkDTO clerkDTO);
/**
* 获取成员头像 * 获取成员头像
* *
* @param clerkCode * @param clerkCode
...@@ -141,15 +115,6 @@ public interface StaffApiService { ...@@ -141,15 +115,6 @@ public interface StaffApiService {
StaffDTO getWxStaffOne(String wxEnterpriseId); StaffDTO getWxStaffOne(String wxEnterpriseId);
/** /**
* 获取超管
*
* @param wxEnterpriseId
* @return
*/
StaffDTO getAndAddSupperAdmin(String wxEnterpriseId);
/**
* 是否隐私 * 是否隐私
* *
* @param staffId 员工id * @param staffId 员工id
......
...@@ -45,6 +45,8 @@ public interface WxEnterpriseApiService { ...@@ -45,6 +45,8 @@ public interface WxEnterpriseApiService {
* @return * @return
*/ */
WxEnterpriseDTO getOne(String wxEnterpriseId); WxEnterpriseDTO getOne(String wxEnterpriseId);
WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId);
/** /**
* 根据corpId查询一条数据 * 根据corpId查询一条数据
......
...@@ -41,77 +41,11 @@ public class TestDataImportController extends WebBaseController { ...@@ -41,77 +41,11 @@ public class TestDataImportController extends WebBaseController {
private static final Logger logger = getLogger(TestDataImportController.class); private static final Logger logger = getLogger(TestDataImportController.class);
@Autowired @Autowired
private StaffApiService staffApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private MemberUnionidRelatedApiService memberUnionidRelatedApiService;
@Autowired
private IMarketClueTaskApiService iMarketClueTaskApiService; private IMarketClueTaskApiService iMarketClueTaskApiService;
@Autowired @Autowired
private IMarketTaskMemberApiService iMarketTaskMemberApiService; private IMarketTaskMemberApiService iMarketTaskMemberApiService;
/**
* 导入会员好友
*
* @param qo
* @return
*/
@RequestMapping("/friend-import")
public HaobanResponse importFriend(ImportMemberQo qo) {
if (StringUtils.isAnyBlank(qo.getClerkCode(), qo.getClerkId(), qo.getDepartmentId(), qo.getEnterpriseId(), qo.getMemberId()
, qo.getPhoneNumber(), qo.getStoreId(), qo.getUnionid(), qo.getWxEnterpriseId())) {
return resultResponse(HaoBanErrCode.ERR_2);
}
StaffDTO staffDTO = staffApiService.selectByUserIdAndEnterpriseId(qo.getWxUserId(), qo.getWxEnterpriseId());
if (null == staffDTO) {
StaffDTO staff = new StaffDTO();
staff.setPhoneNumber(qo.getPhoneNumber());
staff.setWxUserId(qo.getWxUserId());
staff.setWxEnterpriseId(qo.getWxEnterpriseId());
staff.setStaffName(qo.getClerkCode());
staff.setSex(1);
staff.setNationCode("86");
staff.setActiveFlag(1);
ServiceResponse add = staffApiService.add(staff, qo.getDepartmentId());
if (add.getCode() == 1) {
staffDTO = staffApiService.selectById(add.getResult().toString());
}
}
StaffClerkRelationDTO clerkRelationDTO = staffClerkRelationApiService.getOneByStoreIdAndStaffId(qo.getStoreId(), staffDTO.getStaffId());
if (clerkRelationDTO == null) {
StaffClerkRelationDTO staffClerkRelationDTO = new StaffClerkRelationDTO();
staffClerkRelationDTO.setStoreId(qo.getStoreId());
staffClerkRelationDTO.setClerkId(qo.getClerkId());
staffClerkRelationDTO.setClerkCode(qo.getClerkCode());
staffClerkRelationDTO.setWxUserId(staffDTO.getWxUserId());
staffClerkRelationDTO.setStaffId(staffDTO.getStaffId());
staffClerkRelationDTO.setWxEnterpriseId(qo.getWxEnterpriseId());
staffClerkRelationDTO.setEnterpriseId(qo.getEnterpriseId());
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(staffClerkRelationDTO, "-1", ChannelCodeEnum.ADMIN_BIND.getCode());
}
//新增好友
ExternalUserDTO dto = new ExternalUserDTO();
dto.setUnionId(qo.getUnionid());
dto.setWxUserId(qo.getWxUserId());
dto.setWxEnterpriseId(qo.getWxEnterpriseId());
dto.setMemberId(qo.getMemberId());
dto.setExternalUserId(qo.getMemberId());
dto.setClerkId(qo.getClerkId());
dto.setStoreId(qo.getStoreId());
dto.setEnterpriseId(qo.getEnterpriseId());
dto.setName("测试会员" + RandomUtil.getRandomString(5));
dto.setStaffId(staffDTO.getStaffId());
dto.setAddCreateTime(Long.valueOf(System.currentTimeMillis() / 1000).toString());
memberUnionidRelatedApiService.addExternal(dto);
return resultResponse(HaoBanErrCode.ERR_1);
}
/** /**
* 处理任务 * 处理任务
......
...@@ -32,8 +32,6 @@ public interface StaffDepartmentRelatedMapper { ...@@ -32,8 +32,6 @@ public interface StaffDepartmentRelatedMapper {
TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(@Param("departmentId")String departmentId, @Param("staffId")String staffId); TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(@Param("departmentId")String departmentId, @Param("staffId")String staffId);
int countByDepartmentId(@Param("departmentId")String departmentId);
TabHaobanStaffDepartmentRelated getDepartmentIdAndCode(@Param("departmentId")String departmentId, @Param("clerkCode")String code); TabHaobanStaffDepartmentRelated getDepartmentIdAndCode(@Param("departmentId")String departmentId, @Param("clerkCode")String code);
List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(@Param("departmentIds")List<String> departmentIds, @Param("keyword")String keyword); List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(@Param("departmentIds")List<String> departmentIds, @Param("keyword")String keyword);
......
...@@ -42,8 +42,6 @@ public interface StaffMapper { ...@@ -42,8 +42,6 @@ public interface StaffMapper {
TabHaobanStaff selectByUserIdAndEnterpriseId(@Param("userId") String userId, TabHaobanStaff selectByUserIdAndEnterpriseId(@Param("userId") String userId,
@Param("wxEnterpriseId") String wxEnterpriseId); @Param("wxEnterpriseId") String wxEnterpriseId);
TabHaobanStaff selectSuperByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
List<TabHaobanStaff> listByPhoneNumber(@Param("phoneNumber") String phoneNumber); List<TabHaobanStaff> listByPhoneNumber(@Param("phoneNumber") String phoneNumber);
List<TabHaobanStaff> listByUserIdsAndWxEnterpriseId(@Param("userIds") List<String> userIds, @Param("wxEnterpriseId") String wxEnterpriseId); List<TabHaobanStaff> listByUserIdsAndWxEnterpriseId(@Param("userIds") List<String> userIds, @Param("wxEnterpriseId") String wxEnterpriseId);
......
...@@ -9,8 +9,6 @@ public class TabHaobanWxEnterprise implements Serializable { ...@@ -9,8 +9,6 @@ public class TabHaobanWxEnterprise implements Serializable {
private String wxEnterpriseId; private String wxEnterpriseId;
private String corpid;
private String permanentCode; private String permanentCode;
private String corpName; private String corpName;
...@@ -88,6 +86,25 @@ public class TabHaobanWxEnterprise implements Serializable { ...@@ -88,6 +86,25 @@ public class TabHaobanWxEnterprise implements Serializable {
private Integer externalFlag; private Integer externalFlag;
private Integer useridFlag; private Integer useridFlag;
private Integer wxSecurityType ; private Integer wxSecurityType ;
private String wxCorpid ;
private String openCorpid ;
public String getWxCorpid() {
return wxCorpid;
}
public String getOpenCorpid() {
return openCorpid;
}
public void setWxCorpid(String wxCorpid) {
this.wxCorpid = wxCorpid;
}
public void setOpenCorpid(String openCorpid) {
this.openCorpid = openCorpid;
}
public Integer getWxSecurityType() { public Integer getWxSecurityType() {
return wxSecurityType; return wxSecurityType;
...@@ -113,14 +130,6 @@ public class TabHaobanWxEnterprise implements Serializable { ...@@ -113,14 +130,6 @@ public class TabHaobanWxEnterprise implements Serializable {
this.wxEnterpriseId = wxEnterpriseId == null ? null : wxEnterpriseId.trim(); this.wxEnterpriseId = wxEnterpriseId == null ? null : wxEnterpriseId.trim();
} }
public String getCorpid() {
return corpid;
}
public void setCorpid(String corpid) {
this.corpid = corpid == null ? null : corpid.trim();
}
public String getPermanentCode() { public String getPermanentCode() {
return permanentCode; return permanentCode;
} }
......
...@@ -21,8 +21,6 @@ public interface StaffDepartmentRelatedService { ...@@ -21,8 +21,6 @@ public interface StaffDepartmentRelatedService {
TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(String departmentId, String staffId); TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(String departmentId, String staffId);
int countByDepartmentId(String departmentId);
/** /**
* 效率很低 * 效率很低
* @param departmentId * @param departmentId
......
...@@ -37,9 +37,6 @@ public interface WxEnterpriseService { ...@@ -37,9 +37,6 @@ public interface WxEnterpriseService {
int unbind(String wxEnterpriseId); int unbind(String wxEnterpriseId);
TabHaobanWxEnterprise getEnterpriseBycorpIdNoStatus(String corpid);
/** /**
* 得到企业bycorp名称 * 得到企业bycorp名称
* *
......
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.ToolUtil; import com.gic.commons.util.ToolUtil;
...@@ -8,13 +22,24 @@ import com.gic.haoban.common.utils.PageUtil; ...@@ -8,13 +22,24 @@ import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.HandoverExternalDTO; import com.gic.haoban.manage.api.dto.HandoverExternalDTO;
import com.gic.haoban.manage.api.dto.HandoverStaffFriendCountDTO; import com.gic.haoban.manage.api.dto.HandoverStaffFriendCountDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO; import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum; import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.dao.mapper.HandoverExternalMapper;
import com.gic.haoban.manage.service.dao.mapper.*; import com.gic.haoban.manage.service.dao.mapper.HandoverStaffMapper;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.dao.mapper.HandoverTransferMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanClerkMainStoreRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHandoverExternal;
import com.gic.haoban.manage.service.entity.TabHandoverStaff;
import com.gic.haoban.manage.service.entity.TabHandoverTransfer;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.service.HandoverService; import com.gic.haoban.manage.service.service.HandoverService;
import com.gic.haoban.manage.service.service.SecretSettingService; import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService; import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.QywxTransferCustomerInfoDTO; import com.gic.wechat.api.dto.qywx.QywxTransferCustomerInfoDTO;
import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO; import com.gic.wechat.api.dto.qywx.QywxUnassignedInfoDTO;
import com.gic.wechat.api.dto.qywx.UserDTO; import com.gic.wechat.api.dto.qywx.UserDTO;
...@@ -22,15 +47,6 @@ import com.gic.wechat.api.service.qywx.QywxUserApiService; ...@@ -22,15 +47,6 @@ import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import static org.slf4j.LoggerFactory.getLogger;
/** /**
* Created 2021/6/15. * Created 2021/6/15.
...@@ -44,56 +60,43 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -44,56 +60,43 @@ public class HandoverServiceImpl implements HandoverService {
@Autowired @Autowired
private HandoverStaffMapper handoverStaffMapper; private HandoverStaffMapper handoverStaffMapper;
@Autowired @Autowired
private HandoverExternalMapper handoverExternalMapper; private HandoverExternalMapper handoverExternalMapper;
@Autowired @Autowired
private HandoverTransferMapper handoverTransferMapper; private HandoverTransferMapper handoverTransferMapper;
@Autowired @Autowired
private StaffMapper staffMapper; private StaffMapper staffMapper;
@Autowired @Autowired
private TabHaobanExternalClerkRelatedMapper externalClerkRelatedMapper; private TabHaobanExternalClerkRelatedMapper externalClerkRelatedMapper;
@Autowired @Autowired
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired
private Config config;
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired @Autowired
private SecretSettingService secretSettingService; private SecretSettingService secretSettingService;
@Autowired @Autowired
private TabHaobanClerkMainStoreRelatedMapper clerkMainStoreRelatedMapper; private TabHaobanClerkMainStoreRelatedMapper clerkMainStoreRelatedMapper;
@Autowired @Autowired
private StaffClerkRelationService staffClerkRelationService; private StaffClerkRelationService staffClerkRelationService;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Override @Override
public boolean saveHandover(String wxEnterpriseId, List<QywxUnassignedInfoDTO> infoList) { public boolean saveHandover(String wxEnterpriseId, List<QywxUnassignedInfoDTO> infoList) {
logger.info("saveHandover-保存离职基础数据:{}", wxEnterpriseId); logger.info("saveHandover-保存离职基础数据:{}", wxEnterpriseId);
TabHaobanWxEnterprise wxEnterprise = wxEnterpriseMapper.selectByPrimaryKey(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (CollectionUtils.isEmpty(infoList)) { if (CollectionUtils.isEmpty(infoList)) {
logger.info("没有要保存的数据,删除所有需要删除逇"); logger.info("没有要保存的数据,删除所有需要删除逇");
delHandoverStaff(wxEnterpriseId, null); delHandoverStaff(wxEnterpriseId, null);
return false; return false;
} }
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterprise.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
logger.info("没有配置secret:{}", JSONObject.toJSONString(wxEnterprise)); logger.info("没有配置secret:{}", JSONObject.toJSONString(qwDTO));
return false; return false;
} }
Map<String, List<QywxUnassignedInfoDTO>> handoverUserMap = infoList.stream().collect(Collectors.groupingBy(dto -> dto.getHandoverUserid())); Map<String, List<QywxUnassignedInfoDTO>> handoverUserMap = infoList.stream().collect(Collectors.groupingBy(dto -> dto.getHandoverUserid()));
handoverUserMap.forEach((userId, list) -> { handoverUserMap.forEach((userId, list) -> {
boolean checkFlag = checkStaffOver(secretSetting, userId, wxEnterprise.getCorpid()); boolean checkFlag = checkStaffOver(secretSetting, userId, qwDTO.getThirdCorpid());
if (checkFlag) { if (checkFlag) {
logger.info("该用户存在,不需要离职基础:{},{}", userId, wxEnterpriseId); logger.info("该用户存在,不需要离职基础:{},{}", userId, wxEnterpriseId);
return; return;
...@@ -103,7 +106,7 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -103,7 +106,7 @@ public class HandoverServiceImpl implements HandoverService {
return; return;
} }
List<TabHandoverExternal> externalList = list.stream().map(dto -> { List<TabHandoverExternal> externalList = list.stream().map(dto -> {
TabHandoverExternal mid = getHandExternal(dto, wxEnterprise, handoverStaff); TabHandoverExternal mid = getHandExternal(dto, qwDTO.getWxEnterpriseId(), handoverStaff);
mid.setStaffId(handoverStaff.getStaffId()); mid.setStaffId(handoverStaff.getStaffId());
handoverStaff.setDimissionTime(dto.getDimissionTimeDate()); handoverStaff.setDimissionTime(dto.getDimissionTimeDate());
mid.setStatusFlag(mid.getStatusFlag() != null ? mid.getStatusFlag() : 1); mid.setStatusFlag(mid.getStatusFlag() != null ? mid.getStatusFlag() : 1);
...@@ -212,16 +215,16 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -212,16 +215,16 @@ public class HandoverServiceImpl implements HandoverService {
* @param infoDTO * @param infoDTO
* @return * @return
*/ */
private TabHandoverExternal getHandExternal(QywxUnassignedInfoDTO infoDTO, TabHaobanWxEnterprise wxEnterprise, TabHandoverStaff handoverStaff) { private TabHandoverExternal getHandExternal(QywxUnassignedInfoDTO infoDTO, String wxEnterpriseId, TabHandoverStaff handoverStaff) {
TabHandoverExternal handoverExternal = handoverExternalMapper.getByExternalUserIdAndStaffId(wxEnterprise.getWxEnterpriseId(), handoverStaff.getStaffId(), infoDTO.getExternalUserid()); TabHandoverExternal handoverExternal = handoverExternalMapper.getByExternalUserIdAndStaffId(wxEnterpriseId, handoverStaff.getStaffId(), infoDTO.getExternalUserid());
if (null != handoverExternal) { if (null != handoverExternal) {
return handoverExternal; return handoverExternal;
} }
TabHandoverExternal mid = new TabHandoverExternal(); TabHandoverExternal mid = new TabHandoverExternal();
mid.setExternalUserId(infoDTO.getExternalUserid()); mid.setExternalUserId(infoDTO.getExternalUserid());
mid.setWxEnterpriseId(wxEnterprise.getWxEnterpriseId()); mid.setWxEnterpriseId(wxEnterpriseId);
mid.setHaobanFriendFlag(0); mid.setHaobanFriendFlag(0);
TabHaobanExternalClerkRelated externalClerkRelated = externalClerkRelatedMapper.getLastByExTernalUseridAndWxUserIdNoStatus(wxEnterprise.getWxEnterpriseId(), infoDTO.getExternalUserid(), infoDTO.getHandoverUserid()); TabHaobanExternalClerkRelated externalClerkRelated = externalClerkRelatedMapper.getLastByExTernalUseridAndWxUserIdNoStatus(wxEnterpriseId, infoDTO.getExternalUserid(), infoDTO.getHandoverUserid());
if (null == externalClerkRelated) { if (null == externalClerkRelated) {
mid.setExternalUserName("企业微信客户"); mid.setExternalUserName("企业微信客户");
mid.setRelationId("-1"); mid.setRelationId("-1");
......
...@@ -69,14 +69,14 @@ public class SecretSettingServiceImpl implements SecretSettingService { ...@@ -69,14 +69,14 @@ public class SecretSettingServiceImpl implements SecretSettingService {
} }
//兼容好办助手和代开发 //兼容好办助手和代开发
TabSecretSetting secretSetting = null; TabSecretSetting secretSetting = null;
if (secretType == SecretTypeEnum.HAOBAN_HELP.getVal()) { if (secretType == SecretTypeEnum.CUSTOMIZED_APP.getVal()) {
secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, secretType, null); secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, secretType, null);
if (secretSetting == null) { if (secretSetting == null) {
secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal(), null); secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal(), null);
} }
} else { } else {
secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, secretType, null);
} }
secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, secretType, null);
return EntityUtil.changeEntityByJSON(SecretSettingDTO.class, secretSetting); return EntityUtil.changeEntityByJSON(SecretSettingDTO.class, secretSetting);
} }
......
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
...@@ -8,7 +22,7 @@ import com.gic.haoban.base.api.common.BasePageInfo; ...@@ -8,7 +22,7 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO; import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.api.enums.BindTypeEnum; import com.gic.haoban.manage.api.enums.BindTypeEnum;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum; import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
...@@ -19,18 +33,14 @@ import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMappe ...@@ -19,18 +33,14 @@ import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMappe
import com.gic.haoban.manage.service.entity.MemberClerkChatConfig; import com.gic.haoban.manage.service.entity.MemberClerkChatConfig;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation; import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.service.*; import com.gic.haoban.manage.service.service.ClerkMainStoreRelatedService;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkBindLogService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service @Service
public class StaffClerkRelationServiceImpl implements StaffClerkRelationService { public class StaffClerkRelationServiceImpl implements StaffClerkRelationService {
...@@ -325,9 +335,8 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService ...@@ -325,9 +335,8 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
if (CollectionUtils.isEmpty(clerkList)) { if (CollectionUtils.isEmpty(clerkList)) {
return null; return null;
} }
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
String corpid = wxEnterpriseDTO.getCorpid(); if (qwDTO.needOpenUserId3th()) {
if (corpid.length() > 20) {
return mapper.listWxOpenUserIdByClerkIds(clerkList, wxEnterpriseId); return mapper.listWxOpenUserIdByClerkIds(clerkList, wxEnterpriseId);
} }
return mapper.listWxUserIdByClerkIds(clerkList, wxEnterpriseId); return mapper.listWxUserIdByClerkIds(clerkList, wxEnterpriseId);
......
...@@ -72,12 +72,6 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated ...@@ -72,12 +72,6 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
} }
@Override @Override
public int countByDepartmentId(String departmentId) {
return mapper.countByDepartmentId(departmentId);
}
@Override
public List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentIds, String keyword) { public List<TabHaobanStaffDepartmentRelated> listByDepartmentIdByKeyword(List<String> departmentIds, String keyword) {
if(departmentIds == null || departmentIds.isEmpty()){ if(departmentIds == null || departmentIds.isEmpty()){
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
......
...@@ -58,7 +58,6 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService { ...@@ -58,7 +58,6 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) { public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) {
TabHaobanWxEnterprise wxEnterprise = this.mapper.selectByPrimaryKey(wxEnterpriseId) ; TabHaobanWxEnterprise wxEnterprise = this.mapper.selectByPrimaryKey(wxEnterpriseId) ;
WxEnterpriseQwDTO qw = new WxEnterpriseQwDTO(); WxEnterpriseQwDTO qw = new WxEnterpriseQwDTO();
qw.setCorpid(wxEnterprise.getCorpid());
qw.setWxEnterpriseId(wxEnterpriseId); qw.setWxEnterpriseId(wxEnterpriseId);
if(null != wxEnterprise.getWxSecurityType()) { if(null != wxEnterprise.getWxSecurityType()) {
qw.setWxSecurityType(wxEnterprise.getWxSecurityType()); qw.setWxSecurityType(wxEnterprise.getWxSecurityType());
...@@ -115,11 +114,6 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService { ...@@ -115,11 +114,6 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
} }
@Override @Override
public TabHaobanWxEnterprise getEnterpriseBycorpIdNoStatus(String corpId) {
return this.mapper.getEnterpriseBycorpId(corpId, null);
}
@Override
public TabHaobanWxEnterprise getEnterpriseByCorpName(String corpName) { public TabHaobanWxEnterprise getEnterpriseByCorpName(String corpName) {
if (StringUtils.isBlank(corpName)) { if (StringUtils.isBlank(corpName)) {
return null; return null;
......
package com.gic.haoban.manage.service.service.notify.out; package com.gic.haoban.manage.service.service.notify.out;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo; import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Constant; import com.gic.api.base.commons.Constant;
...@@ -7,7 +24,7 @@ import com.gic.api.base.commons.Page; ...@@ -7,7 +24,7 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.PageHelperUtils; import com.gic.commons.util.PageHelperUtils;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO; import com.gic.haoban.manage.api.dto.notify.dto.NoticeMessageInfoDTO;
import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO; import com.gic.haoban.manage.api.dto.notify.qdto.NoticeMessageQDTO;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum; import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
...@@ -25,22 +42,6 @@ import com.gic.haoban.manage.service.service.notify.NoticeMessageTemplateService ...@@ -25,22 +42,6 @@ import com.gic.haoban.manage.service.service.notify.NoticeMessageTemplateService
import com.gic.wechat.api.dto.qywx.ItemDTO; 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.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.slf4j.LoggerFactory.getLogger;
/** /**
* Created 2021/12/17. * Created 2021/12/17.
...@@ -231,18 +232,15 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -231,18 +232,15 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
* @param messageTypeEnum * @param messageTypeEnum
*/ */
private void sendMessage(List<TemplateContentBO> contentList, String wxEnterpriseId, String wxUserId, NoticeMessageTypeEnum messageTypeEnum, String data) { private void sendMessage(List<TemplateContentBO> contentList, String wxEnterpriseId, String wxUserId, NoticeMessageTypeEnum messageTypeEnum, String data) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO(); QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
String corpid = qwDTO.getThirdCorpid() ;
String corpid = wxEnterpriseDTO.getCorpid();
TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(wxUserId, wxEnterpriseId); TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(wxUserId, wxEnterpriseId);
if (tabHaobanStaff == null) { if (tabHaobanStaff == null) {
logger.error("未查询到员工:wxUserId:{}", wxUserId); logger.error("未查询到员工:wxUserId:{}", wxUserId);
return; return;
} }
if (qwDTO.needOpenUserId3th()) {
if (corpid.length() > 20) {
wxUserId = tabHaobanStaff.getWxOpenUseId(); wxUserId = tabHaobanStaff.getWxOpenUseId();
} else { } else {
wxUserId = tabHaobanStaff.getWxUserId(); wxUserId = tabHaobanStaff.getWxUserId();
...@@ -273,6 +271,6 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -273,6 +271,6 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
messageDTO.setPage(appUrl); messageDTO.setPage(appUrl);
messageDTO.setTitle(messageTypeEnum.getName()); messageDTO.setTitle(messageTypeEnum.getName());
messageDTO.setItems(items); messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), messageDTO); qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO);
} }
} }
...@@ -528,15 +528,15 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ ...@@ -528,15 +528,15 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
@Override @Override
public String dealQywxDepartment(String taskId, String wxEnterpriseId) { public String dealQywxDepartment(String taskId, String wxEnterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
logger.info("没有配置secret"); logger.info("没有配置secret");
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal()); syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal());
unlockTask(wxEnterpriseId); unlockTask(wxEnterpriseId);
return "没有配置secret"; return "没有配置secret";
} }
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), 1); List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getThirdCorpid(), secretSetting.getSecretVal(), 1);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
logger.info("没有数据同步"); logger.info("没有数据同步");
syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal()); syncTaskService.updateTaskStatus(taskId, SyncTaskStatusEnum.exception_close.getVal());
......
...@@ -108,48 +108,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -108,48 +108,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
} }
@Override @Override
public ServiceResponse recycle(String departmentId) {
ServiceResponse hr = new ServiceResponse();
hr.setCode(1);
List<TabHaobanDepartment> list = departmentService.listByParentId(departmentId);
logger.info("【部门删除】list.size={}", list.size());
if (!list.isEmpty()) {
hr.setCode(0);
hr.setMessage("存在子部门,删除部门失败");
return hr;
}
List<TabHaobanStaffDepartmentRelated> staffList = staffDepartmentService.listByDepartmentId(departmentId);
logger.info("【部门删除】staffList.size={}", staffList.size());
if (!staffList.isEmpty()) {
hr.setCode(0);
hr.setMessage("存在成员,删除部门失败");
return hr;
}
//调微信的新增接口
TabHaobanDepartment department = departmentService.selectById(departmentId);
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
if (enterpriseDTO != null) {
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.CONTACT_SECRET.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
hr.setCode(0);
hr.setMessage("没有设置通讯录secret");
return hr;
}
JSONResponse jp = qywxDepartmentApiService.deleteSelfDepartment(enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), Integer.parseInt(department.getWxDepartmentId()));
if (jp.getErrorCode() != 0) {
hr.setCode(0);
hr.setMessage("微信删除部门失败");
return hr;
}
}
departmentService.recycle(departmentId);
return hr;
}
@Override
public ServiceResponse wxCallBackrecycle(String departmentId) { public ServiceResponse wxCallBackrecycle(String departmentId) {
ServiceResponse hr = new ServiceResponse(); ServiceResponse hr = new ServiceResponse();
hr.setCode(1); hr.setCode(1);
...@@ -179,47 +137,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -179,47 +137,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
} }
@Override @Override
public ServiceResponse repairRecycle(String departmentId, String parentId) {
ServiceResponse hr = new ServiceResponse();
hr.setCode(0);
TabHaobanDepartment tab = departmentService.selectById(departmentId);
//调微信的新增接口
String wxDepartmentId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(tab.getWxEnterpriseId());
logger.info("【部门新增】enterpriseDTO = {}", JSON.toJSONString(enterpriseDTO));
if (enterpriseDTO != null) {
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
dto.setCorpid(enterpriseDTO.getCorpid());
dto.setName(tab.getDepartmentName());
dto.setOrder(tab.getSort());
TabHaobanDepartment parent = departmentService.selectById(parentId);
dto.setParentid(Integer.valueOf(parent.getWxDepartmentId()));
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.CONTACT_SECRET.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
hr.setCode(0);
hr.setMessage("没有设置通讯录secret");
return hr;
}
logger.info("【部门新增】corpid() = {},siteId={},dto={}", enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), JSON.toJSONString(dto));
JSONResponse jp = qywxDepartmentApiService.createSelfDepartment(enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), dto);
logger.info("【部门新增】jp = {}", JSON.toJSONString(jp));
if (jp.getErrorCode() != 0) {
hr.setCode(0);
hr.setMessage("微信新增部门失败");
return hr;
}
wxDepartmentId = jp.getResult().toString();
tab.setWxDepartmentId(wxDepartmentId);
tab.setParentDepartmentId(parentId);
logger.info("【部门新增】wxDepartmentId = {}", wxDepartmentId);
}
departmentService.repairRecycle(tab);
return hr;
}
@Override
public List<DepartmentDTO> listByDepartmentIds(List<String> departmentIds, public List<DepartmentDTO> listByDepartmentIds(List<String> departmentIds,
Integer storeFlag) { Integer storeFlag) {
List<TabHaobanDepartment> list = departmentMapper.listByDepartmentIds(departmentIds, storeFlag); List<TabHaobanDepartment> list = departmentMapper.listByDepartmentIds(departmentIds, storeFlag);
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
...@@ -13,16 +32,30 @@ import com.gic.haoban.base.api.common.BasePageInfo; ...@@ -13,16 +32,30 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse; import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon; import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.AlertMessageDTO;
import com.gic.haoban.manage.api.dto.ClerkStaffWxUserDTO;
import com.gic.haoban.manage.api.dto.ExternalClerkRelatedDTO;
import com.gic.haoban.manage.api.dto.ExternalClerkRelatedShortInfoDTO;
import com.gic.haoban.manage.api.dto.FriendMemberStatusDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.AlertTypeEnum; import com.gic.haoban.manage.api.enums.AlertTypeEnum;
import com.gic.haoban.manage.api.service.CheckQywxSettingApiService; import com.gic.haoban.manage.api.service.CheckQywxSettingApiService;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService; import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService; import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.*; import com.gic.haoban.manage.service.dao.mapper.ExternalUseridLogMapper;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.gic.haoban.manage.service.entity.TabExternalUseridLog;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO; import com.gic.haoban.manage.service.entity.ext.MemberStaffRelExtDO;
import com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo; import com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.hm.WxUserAddLogService; import com.gic.haoban.manage.service.service.hm.WxUserAddLogService;
import com.gic.member.api.service.MemberApiService; import com.gic.member.api.service.MemberApiService;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
...@@ -31,20 +64,6 @@ import com.gic.wechat.api.dto.qywx.QywxNewExternalUseridDTO; ...@@ -31,20 +64,6 @@ import com.gic.wechat.api.dto.qywx.QywxNewExternalUseridDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service @Service
public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedApiService { public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedApiService {
...@@ -73,6 +92,8 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA ...@@ -73,6 +92,8 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
private MemberApiService memberApiService; private MemberApiService memberApiService;
@Autowired @Autowired
private WxUserAddLogService wxUserAddLogService; private WxUserAddLogService wxUserAddLogService;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
/** /**
* 查询导购好友关联 * 查询导购好友关联
...@@ -355,14 +376,12 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA ...@@ -355,14 +376,12 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
// 2个列表都为空查不了关系 // 2个列表都为空查不了关系
return Collections.emptyMap(); return Collections.emptyMap();
} }
TabHaobanWxEnterprise tabHaobanWxEnterprise = wxEnterriseMapper.selectByPrimaryKey(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (tabHaobanWxEnterprise == null) { if (qwDTO == null) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
//新老企业兼容
String corpid = tabHaobanWxEnterprise.getCorpid();
List<MemberStaffRelExtDO> res = new ArrayList<>(); List<MemberStaffRelExtDO> res = new ArrayList<>();
if (corpid.length() > 20) { if (qwDTO.needOpenUserId3th()) {
res = staffClerkRelationMapper.listMemberStaffRelNew(memberIdList, clerkIdList, enterpriseId); res = staffClerkRelationMapper.listMemberStaffRelNew(memberIdList, clerkIdList, enterpriseId);
} else { } else {
res = staffClerkRelationMapper.listMemberStaffRel(memberIdList, clerkIdList, enterpriseId); res = staffClerkRelationMapper.listMemberStaffRel(memberIdList, clerkIdList, enterpriseId);
...@@ -413,7 +432,8 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA ...@@ -413,7 +432,8 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
} }
RedisUtil.lock(lockKey, 1L, TimeUnit.DAYS, 0L); RedisUtil.lock(lockKey, 1L, TimeUnit.DAYS, 0L);
try { try {
updateNewExUserId(tabHaobanWxEnterprise.getWxEnterpriseId(), tabHaobanWxEnterprise.getCorpid()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
updateNewExUserId(tabHaobanWxEnterprise.getWxEnterpriseId(), qwDTO.getThirdCorpid());
log.info("企业外部联系人id end,wxEnterpriseId:{}", wxEnterpriseId); log.info("企业外部联系人id end,wxEnterpriseId:{}", wxEnterpriseId);
RedisUtil.unlock(lockKey); RedisUtil.unlock(lockKey);
serviceResponse.setCode(HaoBanErrCodeCommon.ERR_1.getCode()); serviceResponse.setCode(HaoBanErrCodeCommon.ERR_1.getCode());
......
...@@ -99,9 +99,8 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -99,9 +99,8 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
@Override @Override
public void dealQywxEnterpriseHandover(String wxEnterpriseId) { public void dealQywxEnterpriseHandover(String wxEnterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); logger.info("拉取单个企业微信的离职成员:{}", wxEnterpriseId);
logger.info("拉取单个企业微信的离职成员:{},{}", wxEnterpriseId, JSONObject.toJSONString(wxEnterpriseDTO)); List<QywxUnassignedInfoDTO> allQywxUnassigned = getAllQywxUnassigned(wxEnterpriseId);
List<QywxUnassignedInfoDTO> allQywxUnassigned = getAllQywxUnassigned(wxEnterpriseDTO);
logger.info("处理离职成员数量:{},{}", wxEnterpriseId, allQywxUnassigned.size()); logger.info("处理离职成员数量:{},{}", wxEnterpriseId, allQywxUnassigned.size());
handoverService.saveHandover(wxEnterpriseId, allQywxUnassigned); handoverService.saveHandover(wxEnterpriseId, allQywxUnassigned);
} }
...@@ -111,13 +110,14 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -111,13 +110,14 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
* @param wxEnterpriseDTO * @param wxEnterpriseDTO
* @return * @return
*/ */
private List<QywxUnassignedInfoDTO> getAllQywxUnassigned(WxEnterpriseDTO wxEnterpriseDTO) { private List<QywxUnassignedInfoDTO> getAllQywxUnassigned(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<QywxUnassignedInfoDTO> ret = new ArrayList<>(); List<QywxUnassignedInfoDTO> ret = new ArrayList<>();
QywxGetUnassignedListDTO unassignedListDTO = null; QywxGetUnassignedListDTO unassignedListDTO = null;
String cursor = null; String cursor = null;
do { do {
//离职成员客户列表 //离职成员客户列表
unassignedListDTO = qywxUserApiService.getUnassignedList(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), cursor); unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), cursor);
cursor = unassignedListDTO.getNextCursor(); cursor = unassignedListDTO.getNextCursor();
if (CollectionUtils.isNotEmpty(unassignedListDTO.getInfo())) { if (CollectionUtils.isNotEmpty(unassignedListDTO.getInfo())) {
ret.addAll(unassignedListDTO.getInfo()); ret.addAll(unassignedListDTO.getInfo());
...@@ -138,7 +138,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -138,7 +138,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
@Override @Override
public void dealQywxEnterpriseHandoverResult(String wxEnterpriseId) { public void dealQywxEnterpriseHandoverResult(String wxEnterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
Date date = DateUtils.addDays(new Date(), -3); Date date = DateUtils.addDays(new Date(), -3);
String day = DateFormatUtils.format(date, "yyyy-MM-dd"); String day = DateFormatUtils.format(date, "yyyy-MM-dd");
List<TabHandoverTransfer> transfers = handoverService.listTransferByWxEnterpriseId(wxEnterpriseId, day); List<TabHandoverTransfer> transfers = handoverService.listTransferByWxEnterpriseId(wxEnterpriseId, day);
...@@ -150,7 +150,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -150,7 +150,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
try { try {
TabHaobanStaff handover = staffService.selectById(dto.getHandoverStaffId()); TabHaobanStaff handover = staffService.selectById(dto.getHandoverStaffId());
TabHaobanStaff takeover = staffService.selectById(dto.getTakeoverStaffId()); TabHaobanStaff takeover = staffService.selectById(dto.getTakeoverStaffId());
QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), handover.getWxUserId(), takeover.getWxUserId(), true); QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(qwDTO.getThirdCorpid(), config.getWxSuiteid(), handover.getWxUserId(), takeover.getWxUserId(), true);
if (customerDTO.getErrcode() != 0) { if (customerDTO.getErrcode() != 0) {
return; return;
} }
...@@ -243,7 +243,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -243,7 +243,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
@Override @Override
public void transferFriend(String wxEnterpriseId, List<String> handoverExternalIds, String disStaffId, String storeId) { public void transferFriend(String wxEnterpriseId, List<String> handoverExternalIds, String disStaffId, String storeId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
TabHaobanStaff tabHaobanStaff = staffService.selectById(disStaffId); TabHaobanStaff tabHaobanStaff = staffService.selectById(disStaffId);
List<TabHandoverExternal> externalList = handoverService.listByIds(wxEnterpriseId, handoverExternalIds); List<TabHandoverExternal> externalList = handoverService.listByIds(wxEnterpriseId, handoverExternalIds);
//分配人与客户的关联map //分配人与客户的关联map
...@@ -254,7 +254,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -254,7 +254,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
Map<String, List<String>> userByIdMap = externalList.stream().collect(Collectors.groupingBy(dto -> dto.getUserId(), Collectors.mapping(dto -> dto.getHandoverExternalId(), Collectors.toList()))); Map<String, List<String>> userByIdMap = externalList.stream().collect(Collectors.groupingBy(dto -> dto.getUserId(), Collectors.mapping(dto -> dto.getHandoverExternalId(), Collectors.toList())));
handoverStaffExternalMap.forEach((wxUserId, list) -> { handoverStaffExternalMap.forEach((wxUserId, list) -> {
QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), wxUserId, tabHaobanStaff.getWxUserId(), list); QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId, tabHaobanStaff.getWxUserId(), list);
if (transferCustomerResp.getErrcode() != 0) { if (transferCustomerResp.getErrcode() != 0) {
logger.info("转移异常"); logger.info("转移异常");
} }
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.JSONResponse; import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
...@@ -11,6 +28,7 @@ import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO; ...@@ -11,6 +28,7 @@ import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO; import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.MaterialApiService; import com.gic.haoban.manage.api.service.MaterialApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanMaterial; import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
...@@ -23,17 +41,6 @@ import com.gic.haoban.manage.service.util.CommonUtil; ...@@ -23,17 +41,6 @@ import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.wechat.api.enums.QywxMediaTypeEnum; import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service @Service
public class MaterialApiServiceImpl implements MaterialApiService { public class MaterialApiServiceImpl implements MaterialApiService {
...@@ -103,12 +110,14 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -103,12 +110,14 @@ public class MaterialApiServiceImpl implements MaterialApiService {
@Override @Override
public void insertMaterial(MaterialDTO materialDTO) { public void insertMaterial(MaterialDTO materialDTO) {
Integer type = materialDTO.getMaterialType(); Integer type = materialDTO.getMaterialType();
String wxEnterpriseId = materialDTO.getWxEnterpriseId();
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId);
if (type == null) { if (type == null) {
logger.info("type is null");
return; return;
} }
if (enterprise == null) { String wxEnterpriseId = materialDTO.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (qwDTO == null) {
logger.info("qwDTO is null");
return; return;
} }
QywxMediaTypeEnum fileType = null; QywxMediaTypeEnum fileType = null;
...@@ -132,7 +141,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -132,7 +141,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (type == 3) { if (type == 3) {
String imgUrl = materialDTO.getImgUrl(); String imgUrl = materialDTO.getImgUrl();
logger.info("【上传图片】imgUrl={}", imgUrl); logger.info("【上传图片】imgUrl={}", imgUrl);
JSONResponse response = qywxSuiteApiService.uploadImage(enterprise.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl)); JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl));
logger.info("【上传图片返回】response={}", JSON.toJSONString(response)); logger.info("【上传图片返回】response={}", JSON.toJSONString(response));
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString(); String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl); materialDTO.setWxImgUrl(wxImgUrl);
...@@ -140,7 +149,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -140,7 +149,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (fileType != null) { if (fileType != null) {
String[] arr = url.split("/"); String[] arr = url.split("/");
int count = arr.length; int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
materialDTO.setWxLastUploadTime(new Date()); materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString()); materialDTO.setMediaId(jp.getResult().toString());
...@@ -167,11 +176,12 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -167,11 +176,12 @@ public class MaterialApiServiceImpl implements MaterialApiService {
String materialId = materialDTO.getMaterialId(); String materialId = materialDTO.getMaterialId();
MaterialDTO old = materialService.selectMaterialById(materialId); MaterialDTO old = materialService.selectMaterialById(materialId);
String wxEnterpriseId = old.getWxEnterpriseId(); String wxEnterpriseId = old.getWxEnterpriseId();
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId);
if (type == null) { if (type == null) {
return; return;
} }
if (enterprise == null) { WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (qwDTO == null) {
logger.info("qwDTO is null");
return; return;
} }
QywxMediaTypeEnum fileType = null; QywxMediaTypeEnum fileType = null;
...@@ -196,7 +206,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -196,7 +206,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
String imgUrl = materialDTO.getImgUrl(); String imgUrl = materialDTO.getImgUrl();
String oldImgUrl = materialDTO.getImgUrl(); String oldImgUrl = materialDTO.getImgUrl();
if (!imgUrl.equals(oldImgUrl)) { if (!imgUrl.equals(oldImgUrl)) {
JSONResponse response = qywxSuiteApiService.uploadImage(enterprise.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl)); JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl));
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString(); String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl); materialDTO.setWxImgUrl(wxImgUrl);
} }
...@@ -204,7 +214,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -204,7 +214,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (fileType != null && !url.equals(oldUrl)) { if (fileType != null && !url.equals(oldUrl)) {
String[] arr = url.split("/"); String[] arr = url.split("/");
int count = arr.length; int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
materialDTO.setWxLastUploadTime(new Date()); materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString()); materialDTO.setMediaId(jp.getResult().toString());
...@@ -224,8 +234,9 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -224,8 +234,9 @@ public class MaterialApiServiceImpl implements MaterialApiService {
return ""; return "";
} }
String wxEnterpriseId = old.getWxEnterpriseId(); String wxEnterpriseId = old.getWxEnterpriseId();
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (enterprise == null) { if (qwDTO == null) {
logger.info("qwDTO is null");
return ""; return "";
} }
String url = ""; String url = "";
...@@ -252,7 +263,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -252,7 +263,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
} }
String[] arr = url.split("/"); String[] arr = url.split("/");
int count = arr.length; int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(enterprise.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
old.setWxLastUploadTime(new Date()); old.setWxLastUploadTime(new Date());
old.setMediaId(jp.getResult().toString()); old.setMediaId(jp.getResult().toString());
...@@ -381,8 +392,8 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -381,8 +392,8 @@ public class MaterialApiServiceImpl implements MaterialApiService {
public void batchInsertMaterial(BatchAddMaterialDTO dto) { public void batchInsertMaterial(BatchAddMaterialDTO dto) {
// 构造素材实体类 // 构造素材实体类
BatchAddMaterialDTO.Material material = dto.getMaterial(); BatchAddMaterialDTO.Material material = dto.getMaterial();
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(material.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(material.getWxEnterpriseId()) ;
if (enterprise == null) { if (qwDTO == null) {
return; return;
} }
List<BatchAddMaterialDTO.MaterialMedia> materialMediaList = dto.getMaterialMediaList(); List<BatchAddMaterialDTO.MaterialMedia> materialMediaList = dto.getMaterialMediaList();
...@@ -409,7 +420,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -409,7 +420,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
materialDTO.setMaterialTitle(material.getMaterialTitle()); materialDTO.setMaterialTitle(material.getMaterialTitle());
} }
materialDTO.setImgUrl(one.getMediaUrl()); materialDTO.setImgUrl(one.getMediaUrl());
String mediaId = uploadMediaToWx(enterprise.getCorpid(), one.getMediaUrl()); String mediaId = uploadMediaToWx(qwDTO.getThirdCorpid(), one.getMediaUrl());
if (StringUtils.isNotEmpty(mediaId)) { if (StringUtils.isNotEmpty(mediaId)) {
materialDTO.setWxLastUploadTime(new Date()); materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(mediaId); materialDTO.setMediaId(mediaId);
......
...@@ -307,7 +307,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -307,7 +307,7 @@ public class MessageApiServiceImpl implements MessageApiService {
staffApiService.staffEdit(staffDTO, departmentIds.toString()); staffApiService.staffEdit(staffDTO, departmentIds.toString());
} else if (changeType.equals(WxEditType.DELETE_USER.getCode())) { } else if (changeType.equals(WxEditType.DELETE_USER.getCode())) {
log.info("成员同步删除,userid:{}", userid); log.info("成员同步删除,userid:{}", userid);
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId); log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId);
return; return;
...@@ -368,7 +368,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -368,7 +368,7 @@ public class MessageApiServiceImpl implements MessageApiService {
return; return;
} }
String wxEnterpriseId = wxApplication.getWxEnterpriseId(); String wxEnterpriseId = wxApplication.getWxEnterpriseId();
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", wxEnterpriseId); log.info("没有配置secret:{}", wxEnterpriseId);
return; return;
...@@ -462,7 +462,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -462,7 +462,7 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("未查询到企业关联企业 wxEnt"); log.info("未查询到企业关联企业 wxEnt");
return; return;
} }
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", wxEnterpriseId); log.info("没有配置secret:{}", wxEnterpriseId);
return; return;
...@@ -499,15 +499,15 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -499,15 +499,15 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("clerkId未绑定:clerkId={}", clerkId); log.info("clerkId未绑定:clerkId={}", clerkId);
return false; return false;
} }
WxEnterpriseDTO wxEnterprise = wxEnterpriseService.selectById(relation.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(relation.getWxEnterpriseId()) ;
if (wxEnterprise == null) { if (qwDTO == null) {
log.info("企业为空"); log.info("企业为空");
return false; return false;
} }
StaffDTO staffDTO = staffApiService.selectById(relation.getStaffId()); StaffDTO staffDTO = staffApiService.selectById(relation.getStaffId());
String corpid = wxEnterprise.getCorpid(); String corpid = qwDTO.getThirdCorpid() ;
String wxUserId = ""; String wxUserId = "";
if (corpid.length() > 20) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId(); wxUserId = staffDTO.getWxOpenUseId();
} else { } else {
wxUserId = staffDTO.getWxUserId(); wxUserId = staffDTO.getWxUserId();
...@@ -584,8 +584,8 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -584,8 +584,8 @@ public class MessageApiServiceImpl implements MessageApiService {
String title = jsonObject.getString("title"); String title = jsonObject.getString("title");
String content = jsonObject.getString("content"); String content = jsonObject.getString("content");
String memberName = jsonObject.getString("memberName"); String memberName = jsonObject.getString("memberName");
WxEnterpriseDTO wxEnterprise = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (wxEnterprise == null) { if (qwDTO == null) {
log.info("企业为空"); log.info("企业为空");
return; return;
} }
...@@ -602,21 +602,20 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -602,21 +602,20 @@ public class MessageApiServiceImpl implements MessageApiService {
messageDTO.setPage(pageUrl); messageDTO.setPage(pageUrl);
messageDTO.setTitle(title); messageDTO.setTitle(title);
messageDTO.setItems(items); messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(wxEnterprise.getCorpid(), config.getWxSuiteid(), messageDTO); qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
} }
@Override @Override
public String getNewWxUserId(String wxEnterpriseId, String wxUserId) { public String getNewWxUserId(String wxEnterpriseId, String wxUserId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (wxEnterpriseDTO == null) { if (qwDTO == null) {
return ""; return "";
} }
String corpid = wxEnterpriseDTO.getCorpid();
TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(wxUserId, wxEnterpriseId); TabHaobanStaff tabHaobanStaff = staffService.selectByUserIdAndEnterpriseId(wxUserId, wxEnterpriseId);
if (tabHaobanStaff == null) { if (tabHaobanStaff == null) {
return ""; return "";
} }
return corpid.length() > 20 ? tabHaobanStaff.getWxOpenUseId() : tabHaobanStaff.getWxUserId(); return qwDTO.needOpenUserId3th() ? tabHaobanStaff.getWxOpenUseId() : tabHaobanStaff.getWxUserId();
} }
...@@ -695,7 +694,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -695,7 +694,7 @@ public class MessageApiServiceImpl implements MessageApiService {
staffApiService.staffEdit(staffDTO, departmentIds.toString()); staffApiService.staffEdit(staffDTO, departmentIds.toString());
} else if (changeType.equals(WxEditType.DELETE_USER.getCode())) { } else if (changeType.equals(WxEditType.DELETE_USER.getCode())) {
log.info("成员同步删除,userid:{}", userid); log.info("成员同步删除,userid:{}", userid);
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId); log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId);
return; return;
...@@ -756,7 +755,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -756,7 +755,7 @@ public class MessageApiServiceImpl implements MessageApiService {
return; return;
} }
String wxEnterpriseId = wxApplication.getWxEnterpriseId(); String wxEnterpriseId = wxApplication.getWxEnterpriseId();
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", wxEnterpriseId); log.info("没有配置secret:{}", wxEnterpriseId);
return; return;
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.api.base.commons.JSONResponse; import com.gic.api.base.commons.JSONResponse;
import com.gic.commons.util.ToolUtil; import com.gic.commons.util.ToolUtil;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.TabMiniprogramSettingMapper; import com.gic.haoban.manage.service.dao.mapper.TabMiniprogramSettingMapper;
import com.gic.haoban.manage.service.entity.TabMiniprogramSetting; import com.gic.haoban.manage.service.entity.TabMiniprogramSetting;
...@@ -11,14 +21,6 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService; ...@@ -11,14 +21,6 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil; import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.wechat.api.enums.QywxMediaTypeEnum; import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/** /**
* Created 2021/4/16. * Created 2021/4/16.
...@@ -55,8 +57,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService ...@@ -55,8 +57,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
return miniprogramSetting; return miniprogramSetting;
} }
String[] arr = miniprogramSetting.getImageUrl().split("/"); String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(miniprogramSetting.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(miniprogramSetting.getWxEnterpriseId()) ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode()); JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date); miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString()); miniprogramSetting.setMediaId(jp.getResult().toString());
...@@ -105,8 +107,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService ...@@ -105,8 +107,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
return miniprogramSetting; return miniprogramSetting;
} }
String[] arr = miniprogramSetting.getImageUrl().split("/"); String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode()); JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date); miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString()); miniprogramSetting.setMediaId(jp.getResult().toString());
......
...@@ -400,15 +400,15 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -400,15 +400,15 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
send.setUser(userIds); send.setUser(userIds);
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(relationDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(relationDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
logger.info("没有配置secret:{}", relationDTO.getWxEnterpriseId()); logger.info("没有配置secret:{}", relationDTO.getWxEnterpriseId());
response.setCode(3); response.setCode(3);
response.setMessage("企业微信配置异常"); response.setMessage("企业微信配置异常");
return response; return response;
} }
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(relationDTO.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(relationDTO.getWxEnterpriseId()) ;
String configId = qywxUserApiService.getSelfExternalcontactByUserId(enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), send); String configId = qywxUserApiService.getSelfExternalcontactByUserId(qwDTO.getDkCorpid() , secretSetting.getSecretVal(), send);
logger.info("configId:{}", configId); logger.info("configId:{}", configId);
if (StringUtils.isBlank(configId)) { if (StringUtils.isBlank(configId)) {
logger.info("staff:{}", configId, JSONObject.toJSONString(relationDTO)); logger.info("staff:{}", configId, JSONObject.toJSONString(relationDTO));
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import cn.hutool.core.collection.CollectionUtil; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO; import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService; import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO; import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.AppPageType; import com.gic.haoban.manage.api.enums.AppPageType;
import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum; import com.gic.haoban.manage.api.enums.NoticeMessageTypeEnum;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService; import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
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.dao.mapper.StaffDepartmentRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
...@@ -21,20 +37,12 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation; ...@@ -21,20 +37,12 @@ import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated; import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService; import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.ItemDTO; 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.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.UnsupportedEncodingException; import cn.hutool.core.collection.CollectionUtil;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
@Service @Service
public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRelatedApiService { public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRelatedApiService {
...@@ -57,7 +65,7 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -57,7 +65,7 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
@Autowired @Autowired
private StaffApiService staffApiService; private StaffApiService staffApiService;
@Autowired @Autowired
private HmQrcodeApiService hmQrcodeApiService; private WxEnterpriseService wxEnterpriseService;
@Override @Override
public List<StaffDepartmentRelatedDTO> listByDepartmentId(String departmentId) { public List<StaffDepartmentRelatedDTO> listByDepartmentId(String departmentId) {
...@@ -146,21 +154,20 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -146,21 +154,20 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
if (clerkDTO == null) { if (clerkDTO == null) {
return map; return map;
} }
TabHaobanWxEnterprise wxEnterprise = wxEnterpriseMapper.selectByPrimaryKey(relation.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(relation.getWxEnterpriseId()) ;
StaffDTO staffDTO = staffApiService.selectById(relation.getStaffId()); StaffDTO staffDTO = staffApiService.selectById(relation.getStaffId());
if (staffDTO == null) { if (staffDTO == null) {
return map; return map;
} }
String corpid = wxEnterprise.getCorpid();
String wxUserId = ""; String wxUserId = "";
if (corpid.length() > 20) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId(); wxUserId = staffDTO.getWxOpenUseId();
} else { } else {
wxUserId = staffDTO.getWxUserId(); wxUserId = staffDTO.getWxUserId();
} }
map.put("wxUserId", wxUserId); map.put("wxUserId", wxUserId);
map.put("wxEnterpriseId", wxEnterprise.getWxEnterpriseId()); map.put("wxEnterpriseId", qwDTO.getWxEnterpriseId());
map.put("corpId", wxEnterprise.getCorpid()); map.put("corpId", qwDTO.getThirdCorpid());
map.put("clerkName", clerkDTO.getClerkName()); map.put("clerkName", clerkDTO.getClerkName());
return map; return map;
} }
...@@ -171,17 +178,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -171,17 +178,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
if (staffDTO == null) { if (staffDTO == null) {
return map; return map;
} }
TabHaobanWxEnterprise tabHaobanWxEnterprise = wxEnterpriseMapper.selectByPrimaryKey(staffDTO.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffDTO.getWxEnterpriseId()) ;
String corpid = tabHaobanWxEnterprise.getCorpid();
String wxUserId = ""; String wxUserId = "";
if (corpid.length() > 20) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId(); wxUserId = staffDTO.getWxOpenUseId();
} else { } else {
wxUserId = staffDTO.getWxUserId(); wxUserId = staffDTO.getWxUserId();
} }
map.put("wxUserId", wxUserId); map.put("wxUserId", wxUserId);
map.put("wxEnterpriseId", tabHaobanWxEnterprise.getWxEnterpriseId()); map.put("wxEnterpriseId", qwDTO.getWxEnterpriseId());
map.put("corpId", tabHaobanWxEnterprise.getCorpid()); map.put("corpId", qwDTO.getThirdCorpid());
map.put("staffName", staffDTO.getStaffName()); map.put("staffName", staffDTO.getStaffName());
return map; return map;
} }
...@@ -201,22 +207,21 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -201,22 +207,21 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
jsonObject.put("storeId", storeId); jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString(); String data = jsonObject.toJSONString();
String pageUrl = this.getPageUrl(AppPageType.MY_RELATED_RECORD.getCode(), data); String pageUrl = this.getPageUrl(AppPageType.MY_RELATED_RECORD.getCode(), data);
TabHaobanWxEnterprise tabHaobanWxEnterprise = wxEnterpriseMapper.selectByPrimaryKey(staffDTO.getWxEnterpriseId());
String corpId = tabHaobanWxEnterprise.getCorpid();
String name = staffDTO.getStaffName(); String name = staffDTO.getStaffName();
if (content.length() > 30) { if (content.length() > 30) {
content = content.substring(0, 26); content = content.substring(0, 26);
content = content + "..."; content = content + "...";
} }
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(staffDTO.getWxEnterpriseId()) ;
String wxUserId = ""; String wxUserId = "";
if (corpId.length() > 20) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId(); wxUserId = staffDTO.getWxOpenUseId();
} else { } else {
wxUserId = staffDTO.getWxUserId(); wxUserId = staffDTO.getWxUserId();
} }
//先发送下,试试 //先发送下,试试
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO(); QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
List<ItemDTO> items = new ArrayList(); List<ItemDTO> items = new ArrayList<>();
ItemDTO dto1 = new ItemDTO(); ItemDTO dto1 = new ItemDTO();
ItemDTO dto2 = new ItemDTO(); ItemDTO dto2 = new ItemDTO();
ItemDTO dto3 = new ItemDTO(); ItemDTO dto3 = new ItemDTO();
...@@ -243,10 +248,8 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -243,10 +248,8 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
messageDTO.setPage(pageUrl); messageDTO.setPage(pageUrl);
messageDTO.setTitle(messageTitle); messageDTO.setTitle(messageTitle);
messageDTO.setItems(items); messageDTO.setItems(items);
logger.info("发送参数为corpId============:{},suitId============:{},messageDTO============:{},", qwDTO.getThirdCorpid(), config.getWxSuiteid(), JSONObject.toJSONString(messageDTO));
logger.info("发送参数为corpId============:{},suitId============:{},messageDTO============:{},", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO)); boolean b = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO);
boolean b = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO);
logger.info("发送===============》{}", b); logger.info("发送===============》{}", b);
} }
......
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
...@@ -7,27 +23,34 @@ import com.gic.enterprise.api.dto.EnterpriseDTO; ...@@ -7,27 +23,34 @@ import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.base.api.common.BasePageInfo; import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.MiniprogramSettingDTO;
import com.gic.haoban.manage.api.dto.QywxCorpInfoSimpleDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.StaffPrivacyUseLogDTO;
import com.gic.haoban.manage.api.dto.WelcomeDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.YwWxEnterpriseDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum; import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService; import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanWelcomeMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanWelcomeMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.*; import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.entity.TabMiniprogramSetting;
import com.gic.haoban.manage.service.entity.TabWelcome;
import com.gic.haoban.manage.service.pojo.bo.StaffPrivacyUseLogBO; import com.gic.haoban.manage.service.pojo.bo.StaffPrivacyUseLogBO;
import com.gic.haoban.manage.service.service.*; import com.gic.haoban.manage.service.service.MiniprogramSettingService;
import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.haoban.manage.service.service.StaffPrivacyUseLogService;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service @Service
public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
...@@ -52,6 +75,8 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -52,6 +75,8 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
private Config config; private Config config;
@Autowired @Autowired
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper; private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper;
@Autowired
private QywxUserApiService qywxUserApiService ;
@Override @Override
public void callbackReviceEnterprise(QywxCorpInfoSimpleDTO dto) { public void callbackReviceEnterprise(QywxCorpInfoSimpleDTO dto) {
...@@ -67,31 +92,39 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -67,31 +92,39 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
String qywxMemberSuite = config.getQywxMemberSuite(); String qywxMemberSuite = config.getQywxMemberSuite();
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, dto); WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, dto);
String wxEnterpriseId = ""; String wxEnterpriseId = "";
TabHaobanWxEnterprise wxEnterprise = null; TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpid);
// 调用企微接口
String serviceCorpid = config.getCorpid();
String openCorpid = qywxUserApiService.toOpenCorpid(serviceCorpid, corpid);
log.info("查询企微id,入参={},返回={}",corpid , openCorpid);
if(StringUtils.isNotBlank(openCorpid) && !openCorpid.equals(corpid)) {
wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(openCorpid);
log.info("通过密文corpid查询={},{}",openCorpid , wxEnterprise!=null?wxEnterprise.getWxEnterpriseId():null);
}
// 获取授权好办小程序 // 获取授权好办小程序
wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpid);
if (wxEnterprise == null) { if (wxEnterprise == null) {
log.info("通过corpid={}未查到记录",corpid); log.info("通过corpid={}未查到记录",corpid);
wxEnterprise = this.wxEnterpriseService.getEnterpriseByCorpName(corpName); wxEnterprise = this.wxEnterpriseService.getEnterpriseByCorpName(corpName);
} }
if (wxEnterprise != null) { if (wxEnterprise != null) {
log.info("查询wxEnterpriseId={}", wxEnterprise.getWxEnterpriseId());
wxEnterpriseId = wxEnterprise.getWxEnterpriseId(); wxEnterpriseId = wxEnterprise.getWxEnterpriseId();
WxEnterpriseDTO wxEnterpriseDTO = new WxEnterpriseDTO(); WxEnterpriseDTO wxEnterpriseDTO = new WxEnterpriseDTO();
wxEnterpriseDTO.setWxEnterpriseId(wxEnterpriseId); wxEnterpriseDTO.setWxEnterpriseId(wxEnterpriseId);
wxEnterpriseDTO.setStatusFlag(1); wxEnterpriseDTO.setStatusFlag(1);
wxEnterpriseDTO.setBindFlag(1); wxEnterpriseDTO.setBindFlag(1);
// 如果corpid为空且是好办小程序,写入corpid if(StringUtils.isNotBlank(openCorpid)) {
this.setCorpid(corpid, openCorpid, wxEnterpriseDTO);
}
wxEnterpriseService.update(wxEnterpriseDTO); wxEnterpriseService.update(wxEnterpriseDTO);
} else { } else {
// 如果不是好办,不需要写入corpid if(StringUtils.isNotBlank(openCorpid)) {
this.setCorpid(corpid, openCorpid, wxDTO);
}
wxDTO.setWxSecurityType(2);
wxEnterpriseId = wxEnterpriseService.add(wxDTO); wxEnterpriseId = wxEnterpriseService.add(wxDTO);
} }
/*if (StringUtils.isNotBlank(userId)) { TabHaobanWxApplication haobanWxApplication = wxApplicationService.selectBySiteIdAndWxEnterpriseId(siteId, wxEnterpriseId);
staffApiService.wxGetAdd(userId, wxEnterpriseId);
}*/
TabHaobanWxApplication haobanWxApplication = wxApplicationService.selectBySiteIdAndWxEnterpriseId(siteId,
wxEnterpriseId);
if (haobanWxApplication == null) { if (haobanWxApplication == null) {
log.info("新增应用,suiteid={}",siteId); log.info("新增应用,suiteid={}",siteId);
haobanWxApplication = new TabHaobanWxApplication(); haobanWxApplication = new TabHaobanWxApplication();
...@@ -151,6 +184,16 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -151,6 +184,16 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
log.info("企业微信授权处理完成"); log.info("企业微信授权处理完成");
} }
private void setCorpid(String corpid, String openCorpid, WxEnterpriseDTO wxEnterpriseDTO) {
if(openCorpid.equals(corpid)) {
// 密文
wxEnterpriseDTO.setOpenCorpid(openCorpid);
}else {
wxEnterpriseDTO.setOpenCorpid(openCorpid);
wxEnterpriseDTO.setWxCorpid(corpid);
}
}
@Override @Override
public com.gic.api.base.commons.Page<YwWxEnterpriseDTO> list(BasePageInfo pageInfo, String keyword, public com.gic.api.base.commons.Page<YwWxEnterpriseDTO> list(BasePageInfo pageInfo, String keyword,
List<String> enterpriseIds, Integer gicContactFlag, String version, List<String> enterpriseIdsNotIn, List<String> enterpriseIds, Integer gicContactFlag, String version, List<String> enterpriseIdsNotIn,
...@@ -211,6 +254,11 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -211,6 +254,11 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, tab); WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, tab);
return wxDTO; return wxDTO;
} }
@Override
public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) {
return this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
}
@Override @Override
public WxEnterpriseDTO getEnterpriseBycorpId(String corpId) { public WxEnterpriseDTO getEnterpriseBycorpId(String corpId) {
......
...@@ -30,6 +30,7 @@ import com.gic.enterprise.api.dto.StoreDTO; ...@@ -30,6 +30,7 @@ import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService; import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.common.utils.DingUtils; import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.hm.HmLinkDTO; import com.gic.haoban.manage.api.dto.hm.HmLinkDTO;
import com.gic.haoban.manage.api.dto.hm.HmLinkStoreDTO; import com.gic.haoban.manage.api.dto.hm.HmLinkStoreDTO;
import com.gic.haoban.manage.api.dto.hm.HmLinkStoreSettingDTO; import com.gic.haoban.manage.api.dto.hm.HmLinkStoreSettingDTO;
...@@ -381,7 +382,8 @@ public class HmLinkApiServiceImpl implements HmLinkApiService { ...@@ -381,7 +382,8 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
String dthmKey = this.keyDataService.saveDataForLink(enterpriseId, bo); String dthmKey = this.keyDataService.saveDataForLink(enterpriseId, bo);
remarkMap.put("dthmKey", dthmKey); remarkMap.put("dthmKey", dthmKey);
if (null != dthmKey) { if (null != dthmKey) {
ServiceResponse<String> addResp = this.addQrcode(hm, dthmKey, wxEnterpriseDTO.getCorpid(), retDTO); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
ServiceResponse<String> addResp = this.addQrcode(hm, dthmKey, qwDTO.getThirdCorpid(), retDTO);
if (!addResp.isSuccess()) { if (!addResp.isSuccess()) {
remarkMap.put("sm", "创建动态活码失败,取单人活码"); remarkMap.put("sm", "创建动态活码失败,取单人活码");
if (StringUtils.isBlank(hm.getWxQrcode())) { if (StringUtils.isBlank(hm.getWxQrcode())) {
......
...@@ -14,6 +14,7 @@ import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon; ...@@ -14,6 +14,7 @@ import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO; import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO; import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.dto.hm.HmClerkDTO; import com.gic.haoban.manage.api.dto.hm.HmClerkDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO; import com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO; import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO;
...@@ -112,12 +113,11 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -112,12 +113,11 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ServiceResponse add(HmQrcodeQDTO hmQrcodeQDTO) { public ServiceResponse add(HmQrcodeQDTO hmQrcodeQDTO) {
String wxEnterpriseId = hmQrcodeQDTO.getWxEnterpriseId(); String wxEnterpriseId = hmQrcodeQDTO.getWxEnterpriseId();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (wxEnterpriseDTO == null) { if (qwDTO == null) {
logger.error("未查询到微信企业"); logger.error("未查询到微信企业");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在"); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在");
} }
hmQrcodeQDTO.setHmId(UniqueIdUtils.uniqueLong()); hmQrcodeQDTO.setHmId(UniqueIdUtils.uniqueLong());
Integer hmType = hmQrcodeQDTO.getHmType(); Integer hmType = hmQrcodeQDTO.getHmType();
Long hmId = hmQrcodeQDTO.getHmId(); Long hmId = hmQrcodeQDTO.getHmId();
...@@ -142,7 +142,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -142,7 +142,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setRemark(hmQrcodeQDTO.getName()); qywxExternalcontactDTO.setRemark(hmQrcodeQDTO.getName());
qywxExternalcontactDTO.setSkipVerify(hmQrcodeQDTO.getPassFlag() == 1); qywxExternalcontactDTO.setSkipVerify(hmQrcodeQDTO.getPassFlag() == 1);
qywxExternalcontactDTO.setState("HM" + hmId); qywxExternalcontactDTO.setState("HM" + hmId);
String corpid = wxEnterpriseDTO.getCorpid(); String corpid = qwDTO.getThirdCorpid() ;
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId); List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
if (CollectionUtils.isEmpty(userIds)) { if (CollectionUtils.isEmpty(userIds)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办"); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办");
...@@ -276,8 +276,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -276,8 +276,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ServiceResponse update(HmQrcodeQDTO hmQrcodeQDTO) { public ServiceResponse update(HmQrcodeQDTO hmQrcodeQDTO) {
String wxEnterpriseId = hmQrcodeQDTO.getWxEnterpriseId(); String wxEnterpriseId = hmQrcodeQDTO.getWxEnterpriseId();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if (wxEnterpriseDTO == null) { if (qwDTO == null) {
logger.error("未查询到微信企业"); logger.error("未查询到微信企业");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在"); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在");
} }
...@@ -304,7 +304,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -304,7 +304,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办"); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办");
} }
qywxExternalcontactDTO.setUser(userIds); qywxExternalcontactDTO.setUser(userIds);
QywxResponseDTO qywxResponseDTO = qywxUserApiService.updateContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO); QywxResponseDTO qywxResponseDTO = qywxUserApiService.updateContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
if (qywxResponseDTO.getErrcode() != 0) { if (qywxResponseDTO.getErrcode() != 0) {
logger.error("更新企微活码失败"); logger.error("更新企微活码失败");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), qywxResponseDTO.getErrmsg()); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), qywxResponseDTO.getErrmsg());
...@@ -656,8 +656,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -656,8 +656,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String wxConfigId = hmQrcodeBO.getWxConfigId(); String wxConfigId = hmQrcodeBO.getWxConfigId();
if (StringUtils.isNotBlank(wxConfigId)) { if (StringUtils.isNotBlank(wxConfigId)) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(hmQrcodeBO.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(hmQrcodeBO.getWxEnterpriseId()) ;
QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), wxConfigId); QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxConfigId);
int errcode = qywxResponseDTO.getErrcode(); int errcode = qywxResponseDTO.getErrcode();
if (errcode != 0) { if (errcode != 0) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), qywxResponseDTO.getErrmsg()); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), qywxResponseDTO.getErrmsg());
...@@ -741,8 +741,9 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -741,8 +741,9 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logger.info("该企业未与gic关联,无需开启:enterpriseId:{},wxEnterpriseId:{}", enterpriseId, wxEnterpriseId); logger.info("该企业未与gic关联,无需开启:enterpriseId:{},wxEnterpriseId:{}", enterpriseId, wxEnterpriseId);
continue; continue;
} }
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
//企微已经开启联系我 //企微已经开启联系我
List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid()); List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxOpenUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId); List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxOpenUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) { if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) {
logger.error("无导购关联数据"); logger.error("无导购关联数据");
...@@ -785,10 +786,10 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -785,10 +786,10 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
@Override @Override
public void checkStaffOpenContactByWxEnterpriseId(String wxEnterpriseId, String enterpriseId) { public void checkStaffOpenContactByWxEnterpriseId(String wxEnterpriseId, String enterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
//查询出所有正常的导购 //查询出所有正常的导购
//企微已经开启联系我 //企微已经开启联系我
List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid()); List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxOpenUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId); List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxOpenUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) { if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) {
logger.error("无导购关联数据"); logger.error("无导购关联数据");
......
...@@ -18,7 +18,6 @@ import com.gic.haoban.base.api.common.Constant; ...@@ -18,7 +18,6 @@ import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.manage.api.dto.DealParamMqDTO; import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO; import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.SecretSettingDTO; import com.gic.haoban.manage.api.dto.SecretSettingDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.PreDealStatusEnum; import com.gic.haoban.manage.api.enums.PreDealStatusEnum;
import com.gic.haoban.manage.api.enums.PreDealTypeEnum; import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
...@@ -161,8 +160,7 @@ public class QywxDeptSyncOperation implements BaseSyncOperation { ...@@ -161,8 +160,7 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
@Override @Override
public void dealSuccess(String taskId, String dataId, String enterpriseId, String wxEnterpriseId) { public void dealSuccess(String taskId, String dataId, String enterpriseId, String wxEnterpriseId) {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
logger.info("没有配置secret:{},{}", taskId, wxEnterpriseId); logger.info("没有配置secret:{},{}", taskId, wxEnterpriseId);
return; return;
...@@ -174,10 +172,10 @@ public class QywxDeptSyncOperation implements BaseSyncOperation { ...@@ -174,10 +172,10 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
List<UserDTO> list = null ; List<UserDTO> list = null ;
WxEnterpriseQwDTO wxInfo = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO wxInfo = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(wxInfo.getWxSecurityType()==4) { if(wxInfo.getWxSecurityType()==4) {
list = this.qywxUserApiService.listDepartmentUser(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), dataId, 1) ; list = this.qywxUserApiService.listDepartmentUser(wxInfo.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ;
logger.info("从(第三方)获取通讯录={}",JSON.toJSONString(list)) ; logger.info("从(第三方)获取通讯录={}",JSON.toJSONString(list)) ;
}else { }else {
list = this.qywxUserApiService.listSelfDepartmentUser(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), dataId, 1); list = this.qywxUserApiService.listSelfDepartmentUser(wxInfo.getDkCorpid(), secretSetting.getSecretVal(), dataId, 1);
logger.info("从(代开)获取通讯录={}",JSON.toJSONString(list)) ; logger.info("从(代开)获取通讯录={}",JSON.toJSONString(list)) ;
} }
if (null == list) { if (null == list) {
......
package com.gic.haoban.manage.service.task; package com.gic.haoban.manage.service.task;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.ServiceResponse; import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.manage.api.dto.DealParamMqDTO; import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.PreDealStatusEnum; import com.gic.haoban.manage.api.enums.PreDealStatusEnum;
import com.gic.haoban.manage.api.enums.PreDealTypeEnum; import com.gic.haoban.manage.api.enums.PreDealTypeEnum;
import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum; import com.gic.haoban.manage.api.enums.SyncTaskStatusEnum;
...@@ -13,26 +26,13 @@ import com.gic.haoban.manage.api.service.DealSyncOperationApiService; ...@@ -13,26 +26,13 @@ import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService; import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.config.Config; import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper;
import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog; import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.entity.TabHaobanSyncTask; import com.gic.haoban.manage.service.entity.TabHaobanSyncTask;
import com.gic.haoban.manage.service.service.PreDealService; import com.gic.haoban.manage.service.service.PreDealService;
import com.gic.haoban.manage.service.service.SecretSettingService;
import com.gic.haoban.manage.service.service.SyncTaskService; import com.gic.haoban.manage.service.service.SyncTaskService;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.QywxNewUseridDTO; import com.gic.wechat.api.dto.qywx.QywxNewUseridDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 企微通讯录同步 * 企微通讯录同步
...@@ -129,7 +129,8 @@ public class QywxStaffSyncOperation implements BaseSyncOperation { ...@@ -129,7 +129,8 @@ public class QywxStaffSyncOperation implements BaseSyncOperation {
dealSyncOperationApiService.unlockTask(wxEnterpriseId); dealSyncOperationApiService.unlockTask(wxEnterpriseId);
dealSyncOperationApiService.cleanDiffrence(wxEnterpriseId, taskId); dealSyncOperationApiService.cleanDiffrence(wxEnterpriseId, taskId);
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
String corpid = wxEnterpriseDTO.getCorpid(); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
String corpid = qwDTO.getThirdCorpid() ;
Integer externalFlag = wxEnterpriseDTO.getExternalFlag(); Integer externalFlag = wxEnterpriseDTO.getExternalFlag();
logger.info("同步通讯录完成,批量处理wx_open_user_id,corpid:{},externalFlag:{}", corpid,externalFlag); logger.info("同步通讯录完成,批量处理wx_open_user_id,corpid:{},externalFlag:{}", corpid,externalFlag);
if (corpid.length() > 20 || externalFlag == 1) { if (corpid.length() > 20 || externalFlag == 1) {
......
...@@ -261,13 +261,6 @@ ...@@ -261,13 +261,6 @@
and status_flag = 1 and status_flag = 1
</select> </select>
<select id="countByDepartmentId" resultType="java.lang.Integer" parameterType="java.lang.String">
select count(1)
from tab_haoban_staff_department_related
where department_id = #{departmentId,jdbcType=VARCHAR}
and status_flag = 1
</select>
<select id="getDepartmentIdAndCode" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="getDepartmentIdAndCode" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
...@@ -354,15 +354,6 @@ ...@@ -354,15 +354,6 @@
and status_flag = 1 limit 1 and status_flag = 1 limit 1
</select> </select>
<select id="selectSuperByWxEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_staff
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
and super_manager_flag = 1
</select>
<select id="listByUserIdsAndWxEnterpriseId" resultMap="BaseResultMap"> <select id="listByUserIdsAndWxEnterpriseId" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper"> <mapper namespace="com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper">
<resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise"> <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise">
<id column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR"/> <id column="wx_enterprise_id" property="wxEnterpriseId" jdbcType="VARCHAR"/>
<result column="corpid" property="corpid" jdbcType="VARCHAR"/>
<result column="permanent_code" property="permanentCode" jdbcType="VARCHAR"/> <result column="permanent_code" property="permanentCode" jdbcType="VARCHAR"/>
<result column="corp_name" property="corpName" jdbcType="VARCHAR"/> <result column="corp_name" property="corpName" jdbcType="VARCHAR"/>
<result column="corp_type" property="corpType" jdbcType="VARCHAR"/> <result column="corp_type" property="corpType" jdbcType="VARCHAR"/>
...@@ -41,6 +40,8 @@ ...@@ -41,6 +40,8 @@
<result column="external_flag" property="externalFlag" jdbcType="INTEGER"/> <result column="external_flag" property="externalFlag" jdbcType="INTEGER"/>
<result column="userid_flag" property="useridFlag" jdbcType="INTEGER"/> <result column="userid_flag" property="useridFlag" jdbcType="INTEGER"/>
<result column="wx_security_type" property="wxSecurityType"/> <result column="wx_security_type" property="wxSecurityType"/>
<result column="wx_corpid" property="wxCorpid"/>
<result column="open_corpid" property="openOorpid"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -48,7 +49,7 @@ ...@@ -48,7 +49,7 @@
corp_user_max, corp_full_name, subject_type, verified_end_time, corp_wxqrcode, corp_scale, corp_user_max, corp_full_name, subject_type, verified_end_time, corp_wxqrcode, corp_scale,
corp_industry, corp_sub_industry, location, auth_info, agent, agentid, appid, name, corp_industry, corp_sub_industry, location, auth_info, agent, agentid, appid, name,
square_logo_url, round_logo_url, level, bind_flag, status_flag, create_time, update_time,contact_flag,wx_secret_key,wx_secret_key_last_time,member_secret_last_time,contact_secret_last_time square_logo_url, round_logo_url, level, bind_flag, status_flag, create_time, update_time,contact_flag,wx_secret_key,wx_secret_key_last_time,member_secret_last_time,contact_secret_last_time
,member_secret,contact_secret,agree_external_userid_flag,agree_external_userid_time,external_flag,userid_flag ,wx_security_type ,member_secret,contact_secret,agree_external_userid_flag,agree_external_userid_time,external_flag,userid_flag ,wx_security_type , wx_corpid , open_corpid
</sql> </sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
...@@ -68,9 +69,6 @@ ...@@ -68,9 +69,6 @@
<if test="wxEnterpriseId != null"> <if test="wxEnterpriseId != null">
wx_enterprise_id, wx_enterprise_id,
</if> </if>
<if test="corpid != null">
corpid,
</if>
<if test="permanentCode != null"> <if test="permanentCode != null">
permanent_code, permanent_code,
</if> </if>
...@@ -167,14 +165,17 @@ ...@@ -167,14 +165,17 @@
<if test="useridFlag != null"> <if test="useridFlag != null">
userid_flag, userid_flag,
</if> </if>
<if test="null != wxCorpid">
wx_corpid ,
</if>
<if test="null != openCorpid">
open_corpid ,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="wxEnterpriseId != null"> <if test="wxEnterpriseId != null">
#{wxEnterpriseId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR},
</if> </if>
<if test="corpid != null">
#{corpid,jdbcType=VARCHAR},
</if>
<if test="permanentCode != null"> <if test="permanentCode != null">
#{permanentCode,jdbcType=VARCHAR}, #{permanentCode,jdbcType=VARCHAR},
</if> </if>
...@@ -269,16 +270,20 @@ ...@@ -269,16 +270,20 @@
#{externalFlag,jdbcType=INTEGER}, #{externalFlag,jdbcType=INTEGER},
</if> </if>
<if test="useridFlag != null"> <if test="useridFlag != null">
#{useridFlag} #{useridFlag} ,
</if> </if>
<if test="null != wxCorpid">
${wxCorpid} ,
</if>
<if test="null != openCorpid">
${openCorpid} ,
</if>
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise"> <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise">
update tab_haoban_wx_enterprise update tab_haoban_wx_enterprise
<set> <set>
<if test="corpid != null">
corpid = #{corpid,jdbcType=VARCHAR},
</if>
<if test="permanentCode != null"> <if test="permanentCode != null">
permanent_code = #{permanentCode,jdbcType=VARCHAR}, permanent_code = #{permanentCode,jdbcType=VARCHAR},
</if> </if>
...@@ -387,6 +392,12 @@ ...@@ -387,6 +392,12 @@
<if test="useridFlag != null"> <if test="useridFlag != null">
userid_flag = #{useridFlag} userid_flag = #{useridFlag}
</if> </if>
<if test="null != wxCorpid">
wx_corpid = #{wxCorpid}
</if>
<if test="null != openCorpid">
open_corpid = #{openCorpid}
</if>
</set> </set>
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR} where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</update> </update>
...@@ -433,13 +444,6 @@ ...@@ -433,13 +444,6 @@
order by create_time desc order by create_time desc
</select> </select>
<select id="listDelBycorpId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_wx_enterprise
where status_flag = 0 and corpid= #{corpId}
</select>
<select id="listAll" resultMap="BaseResultMap"> <select id="listAll" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
...@@ -464,7 +468,7 @@ ...@@ -464,7 +468,7 @@
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
from tab_haoban_wx_enterprise from tab_haoban_wx_enterprise
where corpid= #{corpId} where corpid= #{corpId} or wx_corpid = #{corpId} or open_corpid = #{corpid}
<if test="statusFlag != null"> <if test="statusFlag != null">
and status_flag = #{statusFlag} and status_flag = #{statusFlag}
</if> </if>
......
...@@ -6,12 +6,16 @@ import java.util.List; ...@@ -6,12 +6,16 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.redisson.api.RateType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo; import com.gic.api.base.commons.BasePageInfo;
import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.manage.api.dto.hm.HmLinkDTO; import com.gic.haoban.manage.api.dto.hm.HmLinkDTO;
import com.gic.haoban.manage.api.dto.hm.HmLinkStoreDTO; import com.gic.haoban.manage.api.dto.hm.HmLinkStoreDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmLinkSearchQDTO; import com.gic.haoban.manage.api.dto.qdto.hm.HmLinkSearchQDTO;
...@@ -22,6 +26,7 @@ import com.gic.haoban.manage.api.service.hm.HmLinkVisitLogApiService; ...@@ -22,6 +26,7 @@ import com.gic.haoban.manage.api.service.hm.HmLinkVisitLogApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService; import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.service.hm.HmLinkStoreService; import com.gic.haoban.manage.service.service.hm.HmLinkStoreService;
import com.gic.haoban.manage.service.util.QwFriendLimitCountUtil; import com.gic.haoban.manage.service.util.QwFriendLimitCountUtil;
import com.gic.redis.data.util.RedisUtil;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext-conf.xml" }) @ContextConfiguration(locations = { "classpath:applicationContext-conf.xml" })
...@@ -40,9 +45,52 @@ public class HmLinkTest { ...@@ -40,9 +45,52 @@ public class HmLinkTest {
@Autowired @Autowired
private HmQrcodeApiService hmQrcodeApiService ; private HmQrcodeApiService hmQrcodeApiService ;
volatile int x = 0 ;
@Test @Test
public void test() throws IOException { public void test() throws IOException, InterruptedException {
for(int i=0;i<100;i++) {
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
while(true) {
String ipKey = "hmadd:limit:ip";
int ipLimitCount = 300;
RRateLimiter rateLimiter = RedisUtil.getRedisClient().getRateLimiter(ipKey);
rateLimiter.trySetRate(RateType.OVERALL, ipLimitCount, 1, RateIntervalUnit.SECONDS);
if (rateLimiter.tryAcquire()) {
System.err.println(x++);
}else {
System.err.println("**************");
String msg = "活码调用次数告警【ip】";
DingUtils.send(msg, false);
}
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
System.in.read();
/*RRateLimiter rateLimiter = RedisUtil.getRedisClient().getRateLimiter("hm:limit:xx"); /*RRateLimiter rateLimiter = RedisUtil.getRedisClient().getRateLimiter("hm:limit:xx");
rateLimiter.trySetRate(RateType.OVERALL, 10, 1, RateIntervalUnit.SECONDS); rateLimiter.trySetRate(RateType.OVERALL, 10, 1, RateIntervalUnit.SECONDS);
...@@ -55,7 +103,7 @@ public class HmLinkTest { ...@@ -55,7 +103,7 @@ public class HmLinkTest {
for(int i=0;i<100;i++) for(int i=0;i<100;i++)
System.out.println(rateLimiter.tryAcquire()); System.out.println(rateLimiter.tryAcquire());
System.out.println("----" + (System.currentTimeMillis() - start));*/ System.out.println("----" + (System.currentTimeMillis() - start));*/
/*
HmQrcodeListQDTO qdto =new HmQrcodeListQDTO(); HmQrcodeListQDTO qdto =new HmQrcodeListQDTO();
qdto.setClerkSelect("1"); qdto.setClerkSelect("1");
qdto.setStoreSelect("sele"); qdto.setStoreSelect("sele");
...@@ -67,7 +115,7 @@ public class HmLinkTest { ...@@ -67,7 +115,7 @@ public class HmLinkTest {
List<String> storeids = Arrays.asList("11"); List<String> storeids = Arrays.asList("11");
qdto.setStoreId(storeids); qdto.setStoreId(storeids);
this.hmQrcodeApiService.listHmIdForIndex(qdto) ; this.hmQrcodeApiService.listHmIdForIndex(qdto) ;
System.in.read(); System.in.read();*/
} }
@Test @Test
......
package com.gic.haoban.manage.web.controller; package com.gic.haoban.manage.web.controller;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -9,7 +20,7 @@ import com.gic.haoban.common.utils.HaobanResponse; ...@@ -9,7 +20,7 @@ import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.DepartmentDTO; import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO; import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO; import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO; import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.StaffApiService; import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService; import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService; import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
...@@ -17,16 +28,6 @@ import com.gic.haoban.manage.web.errCode.HaoBanErrCode; ...@@ -17,16 +28,6 @@ import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.AdminRoleVO; import com.gic.haoban.manage.web.vo.AdminRoleVO;
import com.gic.haoban.manage.web.vo.AdminVO; import com.gic.haoban.manage.web.vo.AdminVO;
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.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController @RestController
public class AdminController extends WebBaseController { public class AdminController extends WebBaseController {
...@@ -35,20 +36,17 @@ public class AdminController extends WebBaseController { ...@@ -35,20 +36,17 @@ public class AdminController extends WebBaseController {
private QywxSuiteApiService qywxSuiteApiService; private QywxSuiteApiService qywxSuiteApiService;
@Autowired @Autowired
private StaffApiService staffApiService; private StaffApiService staffApiService;
@Autowired @Autowired
private WxApplicationApiService wxApplicationApiService; private WxApplicationApiService wxApplicationApiService;
@Autowired @Autowired
private WxEnterpriseApiService wxEnterpriseApiService; private WxEnterpriseApiService wxEnterpriseApiService ;
@RequestMapping("admin-list") @RequestMapping("admin-list")
public HaobanResponse adminList() { public HaobanResponse adminList() {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser(); WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2); WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId); String corpid = application.getCorpid();
String corpid = enterprise.getCorpid();
logger.info("【管理员查询】corpid={},siteId={},agentId={}", corpid, application.getSiteId(), application.getAgentId()); logger.info("【管理员查询】corpid={},siteId={},agentId={}", corpid, application.getSiteId(), application.getAgentId());
String adminList = qywxSuiteApiService.getAdminList(corpid, application.getSiteId(), Integer.parseInt(application.getAgentId())); String adminList = qywxSuiteApiService.getAdminList(corpid, application.getSiteId(), Integer.parseInt(application.getAgentId()));
logger.info("【管理员查询】userIds={}", JSON.toJSONString(adminList)); logger.info("【管理员查询】userIds={}", JSON.toJSONString(adminList));
...@@ -60,10 +58,11 @@ public class AdminController extends WebBaseController { ...@@ -60,10 +58,11 @@ public class AdminController extends WebBaseController {
openUserIds.add(json.getString("userid")); openUserIds.add(json.getString("userid"));
} }
} }
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
List<StaffDTO> list = new ArrayList<>(); List<StaffDTO> list = new ArrayList<>();
List<AdminVO> resultList = new ArrayList<>(); List<AdminVO> resultList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(openUserIds)) { if (CollectionUtils.isNotEmpty(openUserIds)) {
if (corpid.length() > 20) { if (qwDTO.needOpenUserId3th()) {
logger.info("OpenUserIds"); logger.info("OpenUserIds");
list = staffApiService.listByOpenUserIdsAndWxEnterpriseId(openUserIds, wxEnterpriseId); list = staffApiService.listByOpenUserIdsAndWxEnterpriseId(openUserIds, wxEnterpriseId);
} else { } else {
......
...@@ -176,7 +176,7 @@ public class ApplicationController extends WebBaseController { ...@@ -176,7 +176,7 @@ public class ApplicationController extends WebBaseController {
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if (enterpriseDTO != null) { if (enterpriseDTO != null) {
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal(), null); SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal(), null);
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", JSONObject.toJSONString(enterpriseDTO)); log.info("没有配置secret:{}", JSONObject.toJSONString(enterpriseDTO));
return resultResponse(HaoBanErrCode.ERR_1, true); return resultResponse(HaoBanErrCode.ERR_1, true);
...@@ -209,7 +209,7 @@ public class ApplicationController extends WebBaseController { ...@@ -209,7 +209,7 @@ public class ApplicationController extends WebBaseController {
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if (enterpriseDTO != null) { if (enterpriseDTO != null) {
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal(), null); SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal(), null);
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret"); log.info("没有配置secret");
return resultResponse(HaoBanErrCode.ERR_1, false); return resultResponse(HaoBanErrCode.ERR_1, false);
...@@ -250,7 +250,7 @@ public class ApplicationController extends WebBaseController { ...@@ -250,7 +250,7 @@ public class ApplicationController extends WebBaseController {
applicationDTO.setAgentName(dto.getAgentName()); applicationDTO.setAgentName(dto.getAgentName());
applicationDTO.setSiteId(dto.getSuiteId()); applicationDTO.setSiteId(dto.getSuiteId());
wxApplicationApiService.addSuite(applicationDTO); wxApplicationApiService.addSuite(applicationDTO);
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.HAOBAN_HELP.getVal(), null); SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal(), null);
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
log.info("没有配置secret:{}", JSONObject.toJSONString(enterpriseDTO)); log.info("没有配置secret:{}", JSONObject.toJSONString(enterpriseDTO));
return; return;
......
...@@ -291,116 +291,6 @@ public class DepartmentContoller extends WebBaseController { ...@@ -291,116 +291,6 @@ public class DepartmentContoller extends WebBaseController {
} }
@RequestMapping("department-repair")
public HaobanResponse departmentRepair(String departmentId, String parentId) {
DepartmentDTO dto = departmentApiService.selectById(departmentId);
if (dto == null || dto.getStatusFlag() == 0) {
return resultResponse(HaoBanErrCode.ERR_10003);
}
departmentApiService.repairRecycle(departmentId, parentId);
return resultResponse(HaoBanErrCode.ERR_1);
}
private void handerStoreClerk(String departmentId, String storeId) {
logger.info("【处理门店下导购】storeId={},departmentId={}", storeId, departmentId);
StoreDTO store = storeService.getStore(storeId);
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
if (departmentDTO == null) {
logger.info("【处理门店下导购】部门为空");
return;
}
String wxEnterpriseId = departmentDTO.getWxEnterpriseId();
if (store != null) {
String enterpriseId = store.getEnterpriseId();
List<ClerkListDTO> list = clerkService.getClerkByStoreId(store.getEnterpriseId(), storeId);
logger.info("【处理门店下导购】list={}", JSON.toJSONString(list));
for (ClerkListDTO clerkListDTO : list) {
try {
String nationcode = clerkListDTO.getNationcode();
if (StringUtils.isNotBlank(nationcode) && nationcode.startsWith("+")) {
nationcode = nationcode.replace("+", "");
}
String phoneNumber = clerkListDTO.getPhoneNumber();
if (StringUtils.isBlank(phoneNumber)) {
continue;
}
String clerkCode = clerkListDTO.getClerkCode();
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if (staff == null) {
staff = new StaffDTO();
staff.setNationCode(nationcode);
staff.setActiveFlag(1);
staff.setDepartmentIds(departmentId);
staff.setBindFlag(1);
staff.setClerkCode(clerkCode);
staff.setNickName(clerkListDTO.getClerkName());
staff.setStaffName(clerkListDTO.getClerkName());
staff.setPostion(clerkListDTO.getPositionName());
staff.setWxEnterpriseId(wxEnterpriseId);
staff.setPhoneNumber(phoneNumber);
try {
staff.setSex(clerkListDTO.getClerkGender() == null ? null : Integer.parseInt(clerkListDTO.getClerkGender()));
} catch (Exception e) {
logger.info("【同步店员】设置性别错误sex={}", clerkListDTO.getClerkGender());
}
staff.setSyncPostionFlag(1);
ServiceResponse hr = staffApiService.add(staff, departmentId);
if (hr.getCode() == 1) {
StaffDepartmentRelatedDTO staffRelated = staffApiService.getDepartmentIdAndStaffId(departmentId, hr.getResult().toString());
StaffDepartmentRelatedDTO isCodeExist = staffApiService.getDepartmentIdAndCode(departmentId, clerkCode);
if (staffRelated != null && isCodeExist == null) {
staffRelated.setClerkCode(clerkCode);
staffDepartmentRelatedApiService.updateById(staffRelated);
ClerkDTO clerkDTO = clerkService.getClerkByCodeNoStatus(enterpriseId, clerkCode);
if (clerkDTO != null && (!clerkDTO.getClerkName().equals(staff.getStaffName()) || !staff.getPhoneNumber().equals(clerkDTO.getPhoneNumber()))) {
logger.info("【员工修改】clerkDTO={}", JSON.toJSONString(clerkDTO));
clerkDTO.setClerkName(staff.getStaffName());
clerkDTO.setPhoneNumber(staff.getPhoneNumber());
clerkService.updateClerk(clerkDTO);
}
}
}
} else {
String staffId = staff.getStaffId();
List<StaffDepartmentRelatedDTO> relatedList = staffApiService.listStaffDepartmentByStaffId(staffId);
String departmentIds = departmentId;
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : relatedList) {
departmentIds += "," + staffDepartmentRelatedDTO.getDepartmentId();
}
Map<String, StaffDepartmentRelatedDTO> map = com.gic.commons.util.CollectionUtil.toMap(relatedList, "departmentId");
if (map.get(departmentId) == null) {
staffApiService.staffEdit(staff, departmentIds);
}
StaffDepartmentRelatedDTO staffRelated = staffApiService.getDepartmentIdAndStaffId(departmentId, staffId);
//如果这个人是未绑定的 则绑定clerk
StaffDepartmentRelatedDTO isCodeExist = staffApiService.getDepartmentIdAndCode(departmentId, clerkCode);
if (StringUtils.isBlank(staffRelated.getClerkCode()) && isCodeExist == null) {
ClerkDTO clerkDTO = clerkService.getClerkByCodeNoStatus(enterpriseId, clerkCode);
if (clerkDTO != null && (!clerkDTO.getClerkName().equals(staff.getStaffName()) || !staff.getPhoneNumber().equals(clerkDTO.getPhoneNumber()))) {
logger.info("【员工修改】clerkDTO={}", JSON.toJSONString(clerkDTO));
clerkDTO.setClerkName(staff.getStaffName());
clerkDTO.setPhoneNumber(staff.getPhoneNumber());
clerkService.updateClerk(clerkDTO);
}
staffRelated.setClerkCode(clerkCode);
staffDepartmentRelatedApiService.updateById(staffRelated);
}
}
} catch (Exception e) {
logger.info("同步失败");
}
}
} else {
logger.info("【处理门店下导购】门店为空");
}
}
@RequestMapping("department-cache") @RequestMapping("department-cache")
public HaobanResponse departmentCache(String wxEnterpriseId) { public HaobanResponse departmentCache(String wxEnterpriseId) {
......
package com.gic.haoban.manage.web.controller; package com.gic.haoban.manage.web.controller;
import cn.hutool.core.collection.CollectionUtil; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
...@@ -18,30 +38,36 @@ import com.gic.haoban.common.utils.AuthWebRequestUtil; ...@@ -18,30 +38,36 @@ import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse; import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.dto.*; import com.gic.haoban.manage.api.dto.ClerkMainStoreRelatedDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.StaffClerkBindLogDetailDTO;
import com.gic.haoban.manage.api.dto.StaffClerkInfoDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum; import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.*; import com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.HaobanUserApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.StaffEditJsonQO; import com.gic.haoban.manage.web.qo.StaffEditJsonQO;
import com.gic.haoban.manage.web.vo.ClerkInfoVo; import com.gic.haoban.manage.web.vo.ClerkInfoVo;
import com.gic.haoban.manage.web.vo.StaffExportVO; import com.gic.haoban.manage.web.vo.StaffExportVO;
import com.gic.haoban.manage.web.vo.StaffVO; import com.gic.haoban.manage.web.vo.StaffVO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import cn.hutool.core.collection.CollectionUtil;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
@RestController @RestController
...@@ -73,8 +99,6 @@ public class StaffController extends WebBaseController { ...@@ -73,8 +99,6 @@ public class StaffController extends WebBaseController {
@Autowired @Autowired
private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService; private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService;
@Autowired @Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private HaobanUserApiService haobanUserApiService ; private HaobanUserApiService haobanUserApiService ;
@Autowired @Autowired
private DealSyncOperationApiService dealSyncOperationApiService; private DealSyncOperationApiService dealSyncOperationApiService;
...@@ -88,28 +112,6 @@ public class StaffController extends WebBaseController { ...@@ -88,28 +112,6 @@ public class StaffController extends WebBaseController {
return this.success(null) ; return this.success(null) ;
} }
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO, String departmentIds) {
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String staffName = staffDTO.getStaffName();
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
staffDTO.setWxEnterpriseId(wxEnterpriseId);
if (StringUtils.isBlank(staffName)) {
return resultResponse(HaoBanErrCode.ERR_10004);
}
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if (staff != null) {
return resultResponse(HaoBanErrCode.ERR_10005);
}
ServiceResponse hr = staffApiService.add(staffDTO, departmentIds);
if (hr.getCode() == 0) {
return resultResponse(HaoBanErrCode.ERR_DEFINE, hr.getMessage(), null, hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-sel") @RequestMapping("staff-sel")
public HaobanResponse staffSel(String staffId) { public HaobanResponse staffSel(String staffId) {
StaffDTO staff = staffApiService.selectById(staffId); StaffDTO staff = staffApiService.selectById(staffId);
...@@ -159,44 +161,6 @@ public class StaffController extends WebBaseController { ...@@ -159,44 +161,6 @@ public class StaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, PageUtil.getPageInfo(page)); return resultResponse(HaoBanErrCode.ERR_1, PageUtil.getPageInfo(page));
} }
@RequestMapping("staff-del")
public HaobanResponse staffDel(String staffDepartmentStaffRelatedId) {
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(staffDepartmentStaffRelatedId);
if (related == null) {
return resultResponse(HaoBanErrCode.ERR_8);
}
DepartmentDTO department = departmentApiService.selectById(related.getDepartmentId());
if (department.getTempFlag() != null && department.getTempFlag() == 1) {
return resultResponse(HaoBanErrCode.ERR_10014);
}
staffApiService.del(staffDepartmentStaffRelatedId);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-del")
public HaobanResponse staffBatchDel(String staffDepartmentRelatedIds) {
if (StringUtils.isBlank(staffDepartmentRelatedIds)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffDepartmentRelatedIds.split(",");
int size = staffArr.length;
for (String string : staffArr) {
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(string);
if (related == null) {
continue;
}
DepartmentDTO department = departmentApiService.selectById(related.getDepartmentId());
if (department.getTempFlag() != null && department.getTempFlag() == 1) {
if (size == 1) {
return resultResponse(HaoBanErrCode.ERR_10014);
}
continue;
}
staffApiService.del(string);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-edit") @RequestMapping("staff-edit")
public HaobanResponse staffEdit(StaffDTO staffDTO, String departmentIds) { public HaobanResponse staffEdit(StaffDTO staffDTO, String departmentIds) {
String staffId = staffDTO.getStaffId(); String staffId = staffDTO.getStaffId();
...@@ -231,12 +195,9 @@ public class StaffController extends WebBaseController { ...@@ -231,12 +195,9 @@ public class StaffController extends WebBaseController {
userArr.add(userId); userArr.add(userId);
} }
} }
WxEnterpriseDTO enterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 1); WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 1);
if (enterpriseDTO != null) { if (application != null) {
if (application != null) { qywxUserApiService.inviteUser(application.getCorpid(), application.getSiteId(), userArr);
qywxUserApiService.inviteUser(enterpriseDTO.getCorpid(), application.getSiteId(), userArr);
}
} }
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
......
...@@ -154,7 +154,8 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -154,7 +154,8 @@ public class WxEnterpriseController extends WebBaseController {
if (wxEnterpriseDTO == null) { if (wxEnterpriseDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10012); return resultResponse(HaoBanErrCode.ERR_10012);
} }
QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(qwDTO.getThirdCorpid(), config.getWxSuiteid());
if (dto == null) { if (dto == null) {
return resultResponse(HaoBanErrCode.ERR_10012); return resultResponse(HaoBanErrCode.ERR_10012);
} }
...@@ -286,7 +287,7 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -286,7 +287,7 @@ public class WxEnterpriseController extends WebBaseController {
if (CollectionUtils.isEmpty(secretTypeList)) { if (CollectionUtils.isEmpty(secretTypeList)) {
return resultResponse(HaoBanErrCode.ERR_1, false); return resultResponse(HaoBanErrCode.ERR_1, false);
} }
if ((secretTypeList.contains(SecretTypeEnum.HAOBAN_HELP.getVal()) || secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal())) if ((secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal()))
&& secretTypeList.contains(SecretTypeEnum.CONTACT_CUSTOMER.getVal())) { && secretTypeList.contains(SecretTypeEnum.CONTACT_CUSTOMER.getVal())) {
return resultResponse(HaoBanErrCode.ERR_1, true); return resultResponse(HaoBanErrCode.ERR_1, true);
} else { } else {
...@@ -297,47 +298,6 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -297,47 +298,6 @@ public class WxEnterpriseController extends WebBaseController {
/** /**
* 微信企业绑定接口绑定通讯录key * 微信企业绑定接口绑定通讯录key
* *
* @param contactSecret
* @return
*/
@RequestMapping("wx-enterprise-contact-secret-set")
public HaobanResponse wxEnterpriseSecretSet(String contactSecret) {
if (StringUtils.isBlank(contactSecret)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterprise == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
contactSecret = contactSecret.trim();
UserDTO user = qywxUserApiService.getSelfWorkWxUser(wxEnterprise.getCorpid(), contactSecret, getWxUserId(wxEnterpriseId, login));
logger.info("【保存联系人key】user={}", JSON.toJSONString(user));
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CONTACT_SECRET.getVal(), null);
if (null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
secretSetting.setSecretType(SecretTypeEnum.CONTACT_SECRET.getVal());
secretSetting.setSecretName(SecretTypeEnum.CONTACT_SECRET.getName());
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setEnterpriseId("-1");
if (user != null) {
secretSetting.setSecretVal(contactSecret);
secretSetting.setCheckFlag(1);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_1, true);
} else {
secretSetting.setCheckFlag(0);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_10013);
}
}
/**
* 微信企业绑定接口绑定通讯录key
*
* @param wxSecretKey * @param wxSecretKey
* @return * @return
*/ */
...@@ -348,12 +308,12 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -348,12 +308,12 @@ public class WxEnterpriseController extends WebBaseController {
} }
WebLoginDTO login = AuthWebRequestUtil.getLoginUser(); WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if (wxEnterprise == null) { if (qwDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10012); return resultResponse(HaoBanErrCode.ERR_10012);
} }
wxSecretKey = wxSecretKey.trim(); wxSecretKey = wxSecretKey.trim();
String res = qywxUserApiService.listSelfExternalUserid(wxEnterprise.getCorpid(), wxSecretKey, getWxUserId(wxEnterpriseId, login)); String res = qywxUserApiService.listSelfExternalUserid(qwDTO.getThirdCorpid(), wxSecretKey, getWxUserId(wxEnterpriseId, login));
logger.info("【保存联系人key】res={}", res); logger.info("【保存联系人key】res={}", res);
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CONTACT_CUSTOMER.getVal(), null); SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CONTACT_CUSTOMER.getVal(), null);
if (null == secretSetting) { if (null == secretSetting) {
...@@ -394,7 +354,8 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -394,7 +354,8 @@ public class WxEnterpriseController extends WebBaseController {
if (StringUtils.isBlank(secretId)) { if (StringUtils.isBlank(secretId)) {
secretSetting = new SecretSettingDTO(); secretSetting = new SecretSettingDTO();
} }
UserDTO user = qywxUserApiService.getSelfWorkWxUser(wxEnterprise.getCorpid(), memberSecret, getWxUserId(wxEnterpriseId, login)); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getMemberCorpid(), memberSecret, getWxUserId(wxEnterpriseId, login));
secretSetting.setSecretType(SecretTypeEnum.MEMBER_WAPP.getVal()); secretSetting.setSecretType(SecretTypeEnum.MEMBER_WAPP.getVal());
secretSetting.setSecretName(secretName); secretSetting.setSecretName(secretName);
secretSetting.setEnterpriseId(enterpriseId); secretSetting.setEnterpriseId(enterpriseId);
...@@ -425,53 +386,6 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -425,53 +386,6 @@ public class WxEnterpriseController extends WebBaseController {
} }
/** /**
* 微信企业绑定接口绑定通讯录key(好办助手)
*
* @param contactSecret
* @param memberSecret
* @return
*/
@RequestMapping("wx-enterprise-haoban-secret-set")
public HaobanResponse wxEnterpriseHaobanSecretSet(String contactSecret, String memberSecret) {
if (StringUtils.isNotBlank(memberSecret)) {
contactSecret = memberSecret;
}
if (StringUtils.isAnyBlank(contactSecret)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
String wxEnterpriseId = "";
WebLoginDTO login = AuthWebRequestUtil.getLoginUser();
wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO wxEnterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterprise == null) {
return resultResponse(HaoBanErrCode.ERR_10012);
}
contactSecret = contactSecret.trim();
UserDTO user = qywxUserApiService.getSelfWorkWxUser(wxEnterprise.getCorpid(), contactSecret, getWxUserId(wxEnterpriseId, login));
logger.info("【保存联系人key】user={}", JSON.toJSONString(user));
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal(), null);
if (null == secretSetting) {
secretSetting = new SecretSettingDTO();
}
secretSetting.setSecretType(SecretTypeEnum.HAOBAN_HELP.getVal());
secretSetting.setSecretName(SecretTypeEnum.HAOBAN_HELP.getName());
secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setEnterpriseId("-1");
if (user != null) {
secretSetting.setSecretVal(contactSecret);
secretSetting.setCheckFlag(1);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_1, true);
} else {
secretSetting.setCheckFlag(0);
wxEnterpriseApiService.saveSecretSetting(secretSetting);
return resultResponse(HaoBanErrCode.ERR_10013);
}
}
/**
* 企微相关密钥列表 * 企微相关密钥列表
* *
* @return * @return
......
...@@ -80,12 +80,8 @@ public class ClerkController extends WebBaseController { ...@@ -80,12 +80,8 @@ public class ClerkController extends WebBaseController {
private AuditSettingApiService auditSettingApiService; private AuditSettingApiService auditSettingApiService;
@Autowired @Autowired
private DealSyncOperationApiService dealSyncOperationApiService; private DealSyncOperationApiService dealSyncOperationApiService;
@Autowired @Autowired
private ExternalClerkRelatedApiService externalClerkRelatedApiService; private ExternalClerkRelatedApiService externalClerkRelatedApiService;
@Autowired
private OperationSettingApiService operationSettingApiService;
@Autowired @Autowired
private CustomerApiService customerApiService; private CustomerApiService customerApiService;
@Autowired @Autowired
...@@ -1238,13 +1234,13 @@ public class ClerkController extends WebBaseController { ...@@ -1238,13 +1234,13 @@ public class ClerkController extends WebBaseController {
if (StringUtils.isNotBlank(wxOpenId)) { if (StringUtils.isNotBlank(wxOpenId)) {
return RestResponse.successResult(wxOpenId); return RestResponse.successResult(wxOpenId);
} }
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if (wxEnterpriseDTO == null) { if (qwDTO == null) {
int code = HaoBanErrCode.ERR_400002.getCode(); int code = HaoBanErrCode.ERR_400002.getCode();
return RestResponse.failure(String.valueOf(code), HaoBanErrCode.ERR_400002.getMsg()); return RestResponse.failure(String.valueOf(code), HaoBanErrCode.ERR_400002.getMsg());
} }
String wxUserId = staffDTO.getWxUserId(); String wxUserId = staffDTO.getWxUserId();
String openid = qywxUserApiService.getSelfOpenIdByUserId(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), wxUserId); String openid = qywxUserApiService.getSelfOpenIdByUserId(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId);
if (StringUtils.isBlank(openid)) { if (StringUtils.isBlank(openid)) {
int code = HaoBanErrCode.ERR_600003.getCode(); int code = HaoBanErrCode.ERR_600003.getCode();
return RestResponse.failure(String.valueOf(code), HaoBanErrCode.ERR_600003.getMsg()); return RestResponse.failure(String.valueOf(code), HaoBanErrCode.ERR_600003.getMsg());
......
...@@ -172,8 +172,8 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -172,8 +172,8 @@ public class WxEnterpriseInfoController extends WebBaseController {
} }
String wxEnterpriseId = loginStaff.getWxEnterpriseId(); String wxEnterpriseId = loginStaff.getWxEnterpriseId();
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
String accesstoken = qywxCorpApiService.getCorpAccessToken(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid()); String accesstoken = qywxCorpApiService.getCorpAccessToken(qwDTO.getThirdCorpid(), config.getWxSuiteid());
WellDoneLoginInfoVO wellDoneLoginInfoVo = new WellDoneLoginInfoVO(); WellDoneLoginInfoVO wellDoneLoginInfoVo = new WellDoneLoginInfoVO();
wellDoneLoginInfoVo.setAccessToken(accesstoken); wellDoneLoginInfoVo.setAccessToken(accesstoken);
wellDoneLoginInfoVo.setStaffId(staffId); wellDoneLoginInfoVo.setStaffId(staffId);
...@@ -342,9 +342,10 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -342,9 +342,10 @@ public class WxEnterpriseInfoController extends WebBaseController {
logger.info("该企业不存在wxEnterpriseId={}", wxEnterpriseId); logger.info("该企业不存在wxEnterpriseId={}", wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_400002); return resultResponse(HaoBanErrCode.ERR_400002);
} }
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
MemberLoginQo user = new MemberLoginQo(); MemberLoginQo user = new MemberLoginQo();
if (StringUtils.isBlank(qo.getUserId())) { if (StringUtils.isBlank(qo.getUserId())) {
user = getUserByCode(enterpriseDTO, qo.getCode(), qo.getGicEnterpriseId()); user = getUserByCode(wxEnterpriseId ,qwDTO.getThirdCorpid() , qo.getCode(), qo.getGicEnterpriseId());
if (user == null) { if (user == null) {
logger.info("登录失败,从微信获取用户信息失败"); logger.info("登录失败,从微信获取用户信息失败");
return resultResponse(HaoBanErrCode.ERR_6); return resultResponse(HaoBanErrCode.ERR_6);
...@@ -355,10 +356,6 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -355,10 +356,6 @@ public class WxEnterpriseInfoController extends WebBaseController {
logger.info("该企业不存在corpid={},{}", user.getCorpId(), wxApplicationDTO.getWxEnterpriseId()); logger.info("该企业不存在corpid={},{}", user.getCorpId(), wxApplicationDTO.getWxEnterpriseId());
return resultResponse(HaoBanErrCode.ERR_400002); return resultResponse(HaoBanErrCode.ERR_400002);
} }
if (!wxEnterpriseDTO.getCorpid().equals(enterpriseDTO.getCorpid())) {
logger.info("{},{}", wxEnterpriseDTO.getCorpid(), enterpriseDTO.getCorpid());
return resultResponse(HaoBanErrCode.ERR_500003, wxEnterpriseDTO.getCorpid());
}
} else { } else {
user.setUserId(qo.getUserId()); user.setUserId(qo.getUserId());
} }
...@@ -416,13 +413,13 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -416,13 +413,13 @@ public class WxEnterpriseInfoController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, user); return resultResponse(HaoBanErrCode.ERR_1, user);
} }
private MemberLoginQo getUserByCode(WxEnterpriseDTO enterpriseDTO, String code, String enterpriseId) { private MemberLoginQo getUserByCode(String wxEnterpriseId ,String corpid, String code, String enterpriseId) {
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(enterpriseDTO.getWxEnterpriseId(), SecretTypeEnum.MEMBER_WAPP.getVal(), enterpriseId); SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.MEMBER_WAPP.getVal(), enterpriseId);
if (null == secretSetting || StringUtils.isBlank(secretSetting.getSecretVal())) { if (null == secretSetting || StringUtils.isBlank(secretSetting.getSecretVal())) {
logger.info("MEMBER_WAPPsecret没有配置{},{}", enterpriseDTO.getWxEnterpriseId(), enterpriseId); logger.info("MEMBER_WAPPsecret没有配置{},{}", wxEnterpriseId, enterpriseId);
return null; return null;
} }
String userDTOJson = qywxUserApiService.getUserByCode(enterpriseDTO.getCorpid(), secretSetting.getSecretVal(), code); String userDTOJson = qywxUserApiService.getUserByCode(corpid, secretSetting.getSecretVal(), code);
logger.info("会员微信登录信息=============>{}", userDTOJson); logger.info("会员微信登录信息=============>{}", userDTOJson);
return JSON.parseObject(userDTOJson, MemberLoginQo.class); return JSON.parseObject(userDTOJson, MemberLoginQo.class);
} }
......
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