Commit 90b25c0a by 徐高华

Merge remote-tracking branch 'origin/feature/自建应用验证'

Conflicts:
	haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/ExternalClerkRelatedApiService.java
	haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/impl/StaffClerkRelationServiceImpl.java
	haoban-manage3-service/src/main/resources/mapper/TabHaobanExternalClerkRelatedMapper.xml
parents 7d81462e baf2a439
...@@ -108,6 +108,15 @@ public class WxEnterpriseDTO implements Serializable { ...@@ -108,6 +108,15 @@ public class WxEnterpriseDTO implements Serializable {
private Integer wxSecurityType ; private Integer wxSecurityType ;
private String wxCorpid ; private String wxCorpid ;
private String openCorpid ; private String openCorpid ;
private String wxaAppid ;
public String getWxaAppid() {
return wxaAppid;
}
public void setWxaAppid(String wxaAppid) {
this.wxaAppid = wxaAppid;
}
public Integer getWxSecurityType() { public Integer getWxSecurityType() {
return wxSecurityType; return wxSecurityType;
......
...@@ -14,10 +14,62 @@ public class WxEnterpriseQwDTO implements Serializable { ...@@ -14,10 +14,62 @@ public class WxEnterpriseQwDTO implements Serializable {
private String memberCorpid; private String memberCorpid;
// 第三方 // 第三方
private String thirdCorpid; private String thirdCorpid;
private String selfSecret ;
// 自建请求地址
private String urlHost ;
private String selfAppid ;
// 好办小程序的appid(根据第三方或自建返回)
private String hbWxaAppid ;
// 自建/第三方
private String self3thSecret ;
public String getHbWxaAppid() {
return hbWxaAppid;
}
public String getSelf3thSecret() {
return self3thSecret;
}
public void setHbWxaAppid(String hbWxaAppid) {
this.hbWxaAppid = hbWxaAppid;
}
public void setSelf3thSecret(String self3thSecret) {
this.self3thSecret = self3thSecret;
}
public String getSelfAppid() {
return selfAppid;
}
public void setSelfAppid(String selfAppid) {
this.selfAppid = selfAppid;
}
public String getUrlHost() {
return urlHost;
}
public void setUrlHost(String urlHost) {
this.urlHost = urlHost;
}
public String getSelfSecret() {
return selfSecret;
}
public void setSelfSecret(String selfSecret) {
this.selfSecret = selfSecret;
}
// 好办小程序应用id // 好办小程序应用id
private String agentId; private String agentId;
// 好办小程序名称 // 好办小程序名称
private String agentName; private String agentName;
// 第三方使用的加密的userid // 第三方使用的加密的userid
public boolean needOpenUserId3th() { public boolean needOpenUserId3th() {
...@@ -27,6 +79,10 @@ public class WxEnterpriseQwDTO implements Serializable { ...@@ -27,6 +79,10 @@ public class WxEnterpriseQwDTO implements Serializable {
public boolean needOpenUserIdDk() { public boolean needOpenUserIdDk() {
return this.wxSecurityType == 2 || this.wxSecurityType == 4; return this.wxSecurityType == 2 || this.wxSecurityType == 4;
} }
public boolean isSelf() {
return this.wxSecurityType == 5 ;
}
public int getWxSecurityType() { public int getWxSecurityType() {
return wxSecurityType; return wxSecurityType;
......
...@@ -4,8 +4,9 @@ package com.gic.haoban.manage.api.enums; ...@@ -4,8 +4,9 @@ package com.gic.haoban.manage.api.enums;
* Created by hua on 2020/6/3. * Created by hua on 2020/6/3.
*/ */
public enum SecretTypeEnum { public enum SecretTypeEnum {
CONTACT_CUSTOMER(1, "顾客联系"), SELF_APP(1, "好办自建"),
MEMBER_WAPP(4, "会员小程序"), CONTACT_CUSTOMER(8, "顾客联系(目前无用)"),
MEMBER_WAPP(4, "会员工具"),
CUSTOMIZED_APP(5, "自建代开发"), CUSTOMIZED_APP(5, "自建代开发"),
WEWORK_PAY(6, "企业支付"), WEWORK_PAY(6, "企业支付"),
; ;
......
...@@ -196,6 +196,9 @@ public interface ExternalClerkRelatedApiService { ...@@ -196,6 +196,9 @@ public interface ExternalClerkRelatedApiService {
com.gic.api.base.commons.ServiceResponse<Boolean> isQwFriend(String enterpriseId, String staffId, String memberId) ; com.gic.api.base.commons.ServiceResponse<Boolean> isQwFriend(String enterpriseId, String staffId, String memberId) ;
List<String> listMemberAndStaff(List<String> memberIdList , String StaffId , String enterpriseId) ;
/** /**
* *
* @param enterpriseId * @param enterpriseId
...@@ -205,10 +208,8 @@ public interface ExternalClerkRelatedApiService { ...@@ -205,10 +208,8 @@ public interface ExternalClerkRelatedApiService {
*/ */
com.gic.api.base.commons.ServiceResponse<Boolean> isQwFriendWithUnionId(String enterpriseId, String clerkId, String unionId) ; com.gic.api.base.commons.ServiceResponse<Boolean> isQwFriendWithUnionId(String enterpriseId, String clerkId, String unionId) ;
List<String> listMemberAndStaff(List<String> memberIdList , String StaffId , String enterpriseId) ;
/** /**
* 批量查询会员与导购好友关系 * 批量查询会员与导购好友关系
* *
* @param memberIdList 会员id列表 * @param memberIdList 会员id列表
......
...@@ -46,6 +46,8 @@ public interface WxEnterpriseApiService { ...@@ -46,6 +46,8 @@ public interface WxEnterpriseApiService {
*/ */
WxEnterpriseDTO getOne(String wxEnterpriseId); WxEnterpriseDTO getOne(String wxEnterpriseId);
WxEnterpriseDTO selectByWxaAppid(String appid);
WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId); WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId);
/** /**
......
...@@ -13,7 +13,9 @@ public interface WxEnterpriseMapper { ...@@ -13,7 +13,9 @@ public interface WxEnterpriseMapper {
int insertSelective(TabHaobanWxEnterprise record); int insertSelective(TabHaobanWxEnterprise record);
TabHaobanWxEnterprise selectByPrimaryKey(String wxEnterpriseId); TabHaobanWxEnterprise selectByPrimaryKey(String wxEnterpriseId);
TabHaobanWxEnterprise selectByWxaAppid(@Param("appid")String appid);
int updateByPrimaryKeySelective(TabHaobanWxEnterprise record); int updateByPrimaryKeySelective(TabHaobanWxEnterprise record);
Page<TabHaobanWxEnterprise> list(@Param("keyword") String keyword, Page<TabHaobanWxEnterprise> list(@Param("keyword") String keyword,
......
...@@ -52,7 +52,7 @@ public class TabHaobanStaff implements Serializable { ...@@ -52,7 +52,7 @@ public class TabHaobanStaff implements Serializable {
@Transient @Transient
private String departmentIds; private String departmentIds;
private int openConcatFlag ; private Integer openConcatFlag ;
private Date activeTime; private Date activeTime;
private Date expireTime; private Date expireTime;
...@@ -82,11 +82,11 @@ public class TabHaobanStaff implements Serializable { ...@@ -82,11 +82,11 @@ public class TabHaobanStaff implements Serializable {
this.activeCode = activeCode; this.activeCode = activeCode;
} }
public int getOpenConcatFlag() { public Integer getOpenConcatFlag() {
return openConcatFlag; return openConcatFlag;
} }
public void setOpenConcatFlag(int openConcatFlag) { public void setOpenConcatFlag(Integer openConcatFlag) {
this.openConcatFlag = openConcatFlag; this.openConcatFlag = openConcatFlag;
} }
......
...@@ -91,6 +91,24 @@ public class TabHaobanWxEnterprise implements Serializable { ...@@ -91,6 +91,24 @@ public class TabHaobanWxEnterprise implements Serializable {
private String wxCorpid ; private String wxCorpid ;
private String openCorpid ; private String openCorpid ;
private String wxaAppid ;
private String urlHost ;
public String getUrlHost() {
return urlHost;
}
public void setUrlHost(String urlHost) {
this.urlHost = urlHost;
}
public String getWxaAppid() {
return wxaAppid;
}
public void setWxaAppid(String wxaAppid) {
this.wxaAppid = wxaAppid;
}
public String getWxCorpid() { public String getWxCorpid() {
return wxCorpid; return wxCorpid;
......
...@@ -66,6 +66,25 @@ public class TabSecretSetting implements Serializable { ...@@ -66,6 +66,25 @@ public class TabSecretSetting implements Serializable {
* *
*/ */
private Date updateTime; private Date updateTime;
private String agentName ;
private String agentId ;
public String getAgentName() {
return agentName;
}
public String getAgentId() {
return agentId;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public void setAgentId(String agentId) {
this.agentId = agentId;
}
/** /**
*/ */
......
...@@ -14,6 +14,7 @@ public interface ClerkMainStoreRelatedService { ...@@ -14,6 +14,7 @@ public interface ClerkMainStoreRelatedService {
TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId); TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId);
TabHaobanClerkMainStoreRelated selectStaffMainStore(String staffId, String wxEnterpriseId); TabHaobanClerkMainStoreRelated selectStaffMainStore(String staffId, String wxEnterpriseId);
/** /**
* 获取主门店 如果没有主门店设置主门店 * 获取主门店 如果没有主门店设置主门店
......
...@@ -128,8 +128,7 @@ public class GroupChatDataServiceImpl implements GroupChatDataService { ...@@ -128,8 +128,7 @@ public class GroupChatDataServiceImpl implements GroupChatDataService {
Date date = DateUtil.addDay(DateUtil.getStartTimeOfDay(), -1); Date date = DateUtil.addDay(DateUtil.getStartTimeOfDay(), -1);
Long time = date.getTime() / 1000; Long time = date.getTime() / 1000;
ServiceResponse<List<GroupChatQwDataDTO>> resp = this.qywxChatApiService.statistic(qwDTO.getThirdCorpid(), ServiceResponse<List<GroupChatQwDataDTO>> resp = this.qywxChatApiService.statistic(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), userIdList, time, time , qwDTO.isSelf() , qwDTO.getUrlHost());
config.getWxSuiteid(), userIdList, time, time);
List<GroupChatQwDataDTO> dataList = resp.getResult(); List<GroupChatQwDataDTO> dataList = resp.getResult();
if (CollectionUtils.isEmpty(dataList)) { if (CollectionUtils.isEmpty(dataList)) {
if (list.size() < pageSize) { if (list.size() < pageSize) {
......
...@@ -143,7 +143,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService { ...@@ -143,7 +143,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
if (null != secretSetting) { if (null != secretSetting) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
ServiceResponse<Void> resp = this.qywxChatApiService.delJoinWay(qwDTO.getDkCorpid(), ServiceResponse<Void> resp = this.qywxChatApiService.delJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), hm.getWxConfigId()); secretSetting.getSecretVal(), hm.getWxConfigId(),qwDTO.getUrlHost());
logger.info("删除群活码={}", JSON.toJSON(resp)); logger.info("删除群活码={}", JSON.toJSON(resp));
} }
} }
...@@ -190,7 +190,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService { ...@@ -190,7 +190,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
String configId = hm.getWxConfigId(); String configId = hm.getWxConfigId();
ServiceResponse<AddJoinWayDTO> joinResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(), secret, ServiceResponse<AddJoinWayDTO> joinResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(), secret,
configId); configId,qwDTO.getUrlHost());
logger.info("查询群活码={}", JSON.toJSON(joinResp)); logger.info("查询群活码={}", JSON.toJSON(joinResp));
if (joinResp.isSuccess()) { if (joinResp.isSuccess()) {
AddJoinWayDTO join = joinResp.getResult(); AddJoinWayDTO join = joinResp.getResult();
...@@ -304,7 +304,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService { ...@@ -304,7 +304,7 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
if (updateFlag) { if (updateFlag) {
joinDTO.setConfig_id(hm.getWxConfigId()); joinDTO.setConfig_id(hm.getWxConfigId());
ServiceResponse<Void> updateResp = this.qywxChatApiService.updateJoinWay(qwDTO.getDkCorpid(), ServiceResponse<Void> updateResp = this.qywxChatApiService.updateJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), joinDTO); secretSetting.getSecretVal(), joinDTO,qwDTO.getUrlHost());
if (!updateResp.isSuccess()) { if (!updateResp.isSuccess()) {
return ServiceResponse.failure("9999", updateResp.getMessage()); return ServiceResponse.failure("9999", updateResp.getMessage());
} }
...@@ -340,14 +340,14 @@ public class GroupChatHmServiceImpl implements GroupChatHmService { ...@@ -340,14 +340,14 @@ public class GroupChatHmServiceImpl implements GroupChatHmService {
} else { } else {
ServiceResponse<String> addResp = this.qywxChatApiService.addJoinWay(qwDTO.getDkCorpid(), ServiceResponse<String> addResp = this.qywxChatApiService.addJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), joinDTO); secretSetting.getSecretVal(), joinDTO,qwDTO.getUrlHost());
logger.info("addResp={}", JSON.toJSONString(addResp)); logger.info("addResp={}", JSON.toJSONString(addResp));
if (!addResp.isSuccess()) { if (!addResp.isSuccess()) {
return ServiceResponse.failure("9999", addResp.getMessage()); return ServiceResponse.failure("9999", addResp.getMessage());
} }
String configId = addResp.getResult(); String configId = addResp.getResult();
ServiceResponse<AddJoinWayDTO> getResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(), ServiceResponse<AddJoinWayDTO> getResp = this.qywxChatApiService.getJoinWay(qwDTO.getDkCorpid(),
secretSetting.getSecretVal(), configId); secretSetting.getSecretVal(), configId,qwDTO.getUrlHost());
logger.info("getResp={}", JSON.toJSONString(getResp)); logger.info("getResp={}", JSON.toJSONString(getResp));
if (!getResp.isSuccess()) { if (!getResp.isSuccess()) {
return ServiceResponse.failure("9999", getResp.getMessage()); return ServiceResponse.failure("9999", getResp.getMessage());
......
...@@ -429,8 +429,14 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService { ...@@ -429,8 +429,14 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
if (qwDTO.needOpenUserId3th()) { if (qwDTO.needOpenUserId3th()) {
userid = staff.getWxOpenUseId(); userid = staff.getWxOpenUseId();
} }
JSONResponse respon = qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), JSONResponse respon = null ;
msgid, null, userid); if(qwDTO.isSelf()) {
respon = qywxSuiteApiService.resultExternalMessageSelf(qwDTO.getThirdCorpid(), qwDTO.getSelfSecret(),
msgid, null, userid , qwDTO.getUrlHost());
}else {
respon = qywxSuiteApiService.resultExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
msgid, null, userid);
}
logger.info("统计企微返回={}", JSON.toJSONString(respon)); logger.info("统计企微返回={}", JSON.toJSONString(respon));
if (respon.getErrorCode() != 0) { if (respon.getErrorCode() != 0) {
return; return;
......
...@@ -530,8 +530,8 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -530,8 +530,8 @@ public class GroupChatServiceImpl implements GroupChatService {
private void syncGroupChatList(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor, private void syncGroupChatList(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor,
boolean syncDetailFlag) { boolean syncDetailFlag) {
logger.info("同步群列表={},idlist={},cursor={}", JSON.toJSONString(qwDTO), JSON.toJSONString(userIdList), cursor); logger.info("同步群列表={},idlist={},cursor={}", JSON.toJSONString(qwDTO), JSON.toJSONString(userIdList), cursor);
ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList3th(qwDTO.getThirdCorpid(), ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), userIdList, limit, cursor); qwDTO.getSelf3thSecret() , userIdList, limit, cursor , qwDTO.isSelf(), qwDTO.getUrlHost());
if (!resp.isSuccess()) { if (!resp.isSuccess()) {
logger.info("拉取群列表异常={}", JSON.toJSON(resp)); logger.info("拉取群列表异常={}", JSON.toJSON(resp));
return; return;
...@@ -615,7 +615,8 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -615,7 +615,8 @@ public class GroupChatServiceImpl implements GroupChatService {
String wxEnterpriseId = chat.getWxEnterpriseId(); String wxEnterpriseId = chat.getWxEnterpriseId();
String enterpriseId = chat.getEnterpriseId(); String enterpriseId = chat.getEnterpriseId();
ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService
.groupchatDetail3th(qwDTO.getThirdCorpid(), config.getWxSuiteid(), chat.getWxChatId(), 1); .groupchatDetail(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), chat.getWxChatId(), 1 , qwDTO.isSelf() , qwDTO.getUrlHost());
logger.info("从企微获取群详情{}={}", chat.getWxChatId(), JSON.toJSON(detailResp)); logger.info("从企微获取群详情{}={}", chat.getWxChatId(), JSON.toJSON(detailResp));
if (!detailResp.isSuccess()) { if (!detailResp.isSuccess()) {
logger.info("从企微获取群详情失败"); logger.info("从企微获取群详情失败");
...@@ -983,7 +984,7 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -983,7 +984,7 @@ public class GroupChatServiceImpl implements GroupChatService {
private void updateWxChatIdDk(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor, String staffId, private void updateWxChatIdDk(WxEnterpriseQwDTO qwDTO, List<String> userIdList, String cursor, String staffId,
String secret) { String secret) {
ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList(qwDTO.getDkCorpid(), secret, ServiceResponse<GroupChatListDTO> resp = this.qywxChatApiService.groupchatList(qwDTO.getDkCorpid(), secret,
userIdList, limit, cursor); userIdList, limit, cursor ,true , qwDTO.getUrlHost());
if (!resp.isSuccess()) { if (!resp.isSuccess()) {
logger.info("拉取群异常={}", JSON.toJSON(resp)); logger.info("拉取群异常={}", JSON.toJSON(resp));
return; return;
...@@ -994,7 +995,7 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -994,7 +995,7 @@ public class GroupChatServiceImpl implements GroupChatService {
for (GroupChatListItemDTO item : list) { for (GroupChatListItemDTO item : list) {
String wxChatIdDk = item.getChat_id(); String wxChatIdDk = item.getChat_id();
ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService ServiceResponse<GroupChatDetailDTO> detailResp = this.qywxChatApiService
.groupchatDetail(qwDTO.getDkCorpid(), secret, wxChatIdDk, 1); .groupchatDetail(qwDTO.getDkCorpid(), secret, wxChatIdDk, 1 , true , qwDTO.getUrlHost());
if (detailResp.isSuccess()) { if (detailResp.isSuccess()) {
GroupChatDetailDTO detail = detailResp.getResult(); GroupChatDetailDTO detail = detailResp.getResult();
Long createTimeLong = detail.getCreate_time() * 1000; Long createTimeLong = detail.getCreate_time() * 1000;
...@@ -1092,8 +1093,8 @@ public class GroupChatServiceImpl implements GroupChatService { ...@@ -1092,8 +1093,8 @@ public class GroupChatServiceImpl implements GroupChatService {
} }
List<TabGroupChat> list = this.groupChatMapper.listByIdSet(new HashSet<>(groupChatIdList)); List<TabGroupChat> list = this.groupChatMapper.listByIdSet(new HashSet<>(groupChatIdList));
List<String> wxChatIdList = list.stream().map(dto -> dto.getWxChatId()).collect(Collectors.toList()); List<String> wxChatIdList = list.stream().map(dto -> dto.getWxChatId()).collect(Collectors.toList());
ServiceResponse<List<FailChatListDTO>> resp = this.qywxChatApiService.transfer(qwDTO.getThirdCorpid(), ServiceResponse<List<FailChatListDTO>> resp = this.qywxChatApiService.transfer(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), wxChatIdList, userid); qwDTO.getSelf3thSecret(), wxChatIdList, userid,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("群继承,继承人={}", JSON.toJSONString(resp), userid); logger.info("群继承,继承人={}", JSON.toJSONString(resp), userid);
if (!resp.isSuccess()) { if (!resp.isSuccess()) {
return ServiceResponse.failure("9999", resp.getMessage()); return ServiceResponse.failure("9999", resp.getMessage());
......
...@@ -194,7 +194,7 @@ public class MaterialReportBuilder { ...@@ -194,7 +194,7 @@ public class MaterialReportBuilder {
newsSendMessage.setAgentId(Integer.parseInt(wxEnterpriseQwDTO.getAgentId())); newsSendMessage.setAgentId(Integer.parseInt(wxEnterpriseQwDTO.getAgentId()));
newsSendMessage.setUserIds(Collections.singletonList(wxUserId)); newsSendMessage.setUserIds(Collections.singletonList(wxUserId));
QywxNewsArticleMessageDTO articleInfo = new QywxNewsArticleMessageDTO(); QywxNewsArticleMessageDTO articleInfo = new QywxNewsArticleMessageDTO();
articleInfo.setAppid(config.getAppid()); articleInfo.setAppid(wxEnterpriseQwDTO.getHbWxaAppid());
articleInfo.setTitle(context.getMessageTitle()); articleInfo.setTitle(context.getMessageTitle());
articleInfo.setDescription(context.getMessageDesc()); articleInfo.setDescription(context.getMessageDesc());
String extendParams = StringUtils.isNotBlank(context.getMainStoreId()) ? context.getMainStoreId() : context.getEnterpriseId(); String extendParams = StringUtils.isNotBlank(context.getMainStoreId()) ? context.getMainStoreId() : context.getEnterpriseId();
......
...@@ -191,7 +191,7 @@ public class PotentialCustomerNotifyBuilder { ...@@ -191,7 +191,7 @@ public class PotentialCustomerNotifyBuilder {
} }
QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO, QywxXcxSendMessageDTO messageDTO = this.buildApplicationMessage(staffClerkRelation, wxEnterpriseQwDTO,
customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId())); customerStaticsBOMap.get(staffClerkRelation.getClerkId()).getNum(), context.buildExtendParams(staffClerkRelation.getStoreId(), staffClerkRelation.getClerkId()));
boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO); boolean sendMessage = qywxSuiteApiService.sendMessage(wxEnterpriseQwDTO.getThirdCorpid(), wxEnterpriseQwDTO.getSelf3thSecret(), messageDTO,wxEnterpriseQwDTO.isSelf(),wxEnterpriseQwDTO.getUrlHost());
log.info("发送销售线索应用消息结果 {}", sendMessage); log.info("发送销售线索应用消息结果 {}", sendMessage);
} }
} }
...@@ -209,7 +209,7 @@ public class PotentialCustomerNotifyBuilder { ...@@ -209,7 +209,7 @@ public class PotentialCustomerNotifyBuilder {
itemDTO.setValue(String.format("新增%s个客户的销售线索,请及时跟进", count)); itemDTO.setValue(String.format("新增%s个客户的销售线索,请及时跟进", count));
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
list.add(wxUserId); list.add(wxUserId);
messageDTO.setAppid(config.getAppid()); messageDTO.setAppid(wxEnterpriseQwDTO.getHbWxaAppid());
messageDTO.setUserIds(list); messageDTO.setUserIds(list);
messageDTO.setPage(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, extendParams)); messageDTO.setPage(NoticeMessageUtil.buildMiniAppUrl(NoticeMessageTypeEnum.POTENTIAL_CUSTOMER_NOTIFY, extendParams));
messageDTO.setTitle("销售线索通知"); messageDTO.setTitle("销售线索通知");
......
...@@ -102,7 +102,7 @@ public class MaterialReportServiceImpl implements MaterialReportService { ...@@ -102,7 +102,7 @@ public class MaterialReportServiceImpl implements MaterialReportService {
return; return;
} }
log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO)); log.info("发送企业图文消息参数{}", JSON.toJSONString(newsSendMessageDTO));
boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), newsSendMessageDTO); boolean result = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), newsSendMessageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("成员{}发送素材企微使用报告结果 {}", staffId, result); log.info("成员{}发送素材企微使用报告结果 {}", staffId, result);
} }
} }
...@@ -11,10 +11,12 @@ import org.springframework.stereotype.Service; ...@@ -11,10 +11,12 @@ import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
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.hm.HmQrcodeTempMapper; import com.gic.haoban.manage.service.dao.mapper.hm.HmQrcodeTempMapper;
import com.gic.haoban.manage.service.entity.hm.TabHmQrcodeTemp; import com.gic.haoban.manage.service.entity.hm.TabHmQrcodeTemp;
import com.gic.haoban.manage.service.pojo.qo.HmQrcodeTempQO; import com.gic.haoban.manage.service.pojo.qo.HmQrcodeTempQO;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService; import com.gic.haoban.manage.service.service.hm.HmQrcodeTempService;
import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO; import com.gic.wechat.api.dto.qywx.response.QywxResponseDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
...@@ -30,6 +32,8 @@ public class HmQrcodeTempServiceImpl implements HmQrcodeTempService { ...@@ -30,6 +32,8 @@ public class HmQrcodeTempServiceImpl implements HmQrcodeTempService {
private QywxUserApiService qywxUserApiService; private QywxUserApiService qywxUserApiService;
@Autowired @Autowired
private Config config; private Config config;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Override @Override
public void save(HmQrcodeTempQO qo) { public void save(HmQrcodeTempQO qo) {
...@@ -54,10 +58,10 @@ public class HmQrcodeTempServiceImpl implements HmQrcodeTempService { ...@@ -54,10 +58,10 @@ public class HmQrcodeTempServiceImpl implements HmQrcodeTempService {
private void del(TabHmQrcodeTemp item) { private void del(TabHmQrcodeTemp item) {
try { try {
String suiteId = config.getWxSuiteid();
String corpid = item.getCorpid(); String corpid = item.getCorpid();
String configId = item.getWxConfigId(); String configId = item.getWxConfigId();
QywxResponseDTO resp = this.qywxUserApiService.delContactWay(corpid, suiteId, configId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(item.getWxEnterpriseId());
QywxResponseDTO resp = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), configId,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("删除临时活码={}{},返回={}", configId, corpid, JSON.toJSONString(resp)); log.info("删除临时活码={}{},返回={}", configId, corpid, JSON.toJSONString(resp));
this.hmQrcodeTempMapper.deleteByPrimaryKey(item.getId()); this.hmQrcodeTempMapper.deleteByPrimaryKey(item.getId());
} catch (Exception e) { } catch (Exception e) {
......
...@@ -52,6 +52,11 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe ...@@ -52,6 +52,11 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
public TabHaobanClerkMainStoreRelated selectStaffMainStore(String staffId, String wxEnterpriseId) { public TabHaobanClerkMainStoreRelated selectStaffMainStore(String staffId, String wxEnterpriseId) {
return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId, null); return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId, null);
} }
@Override
public TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId) {
return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId, null);
}
@Override @Override
public void setMainStore(String staffId, String storeId, String wxEnterpriseId) { public void setMainStore(String staffId, String storeId, String wxEnterpriseId) {
......
...@@ -96,7 +96,7 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -96,7 +96,7 @@ public class HandoverServiceImpl implements HandoverService {
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, qwDTO.getDkCorpid()); boolean checkFlag = checkStaffOver(secretSetting, userId, qwDTO.getDkCorpid() ,qwDTO);
if (checkFlag) { if (checkFlag) {
logger.info("该用户存在,不需要离职基础:{},{}", userId, wxEnterpriseId); logger.info("该用户存在,不需要离职基础:{},{}", userId, wxEnterpriseId);
return; return;
...@@ -144,8 +144,8 @@ public class HandoverServiceImpl implements HandoverService { ...@@ -144,8 +144,8 @@ public class HandoverServiceImpl implements HandoverService {
return false; return false;
} }
private boolean checkStaffOver(SecretSettingDTO secretSetting, String userId, String corpId) { private boolean checkStaffOver(SecretSettingDTO secretSetting, String userId, String corpId,WxEnterpriseQwDTO qwDTO) {
UserDTO user = qywxUserApiService.getSelfWorkWxUser(corpId, secretSetting.getSecretVal(), userId); UserDTO user = qywxUserApiService.getSelfWorkWxUser(corpId, secretSetting.getSecretVal(), userId , qwDTO.getUrlHost());
if (null == user) { if (null == user) {
return false; return false;
} }
......
...@@ -27,7 +27,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanMaterial; ...@@ -27,7 +27,6 @@ import com.gic.haoban.manage.service.entity.TabHaobanMaterial;
import com.gic.haoban.manage.service.entity.TabMaterialContent; import com.gic.haoban.manage.service.entity.TabMaterialContent;
import com.gic.haoban.manage.service.service.MaterialService; import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
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.gic.weimob.common.Md5Util; import com.gic.weimob.common.Md5Util;
...@@ -216,6 +215,7 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -216,6 +215,7 @@ public class MaterialServiceImpl implements MaterialService {
arr = url.split("/"); arr = url.split("/");
} }
int count = arr.length; int count = arr.length;
boolean selfFlag = qwDTO.isSelf() ;
if(qwUploadFrom==2) { if(qwUploadFrom==2) {
// 朋友圈上传接口 // 朋友圈上传接口
if (type == 2) { if (type == 2) {
...@@ -226,10 +226,10 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -226,10 +226,10 @@ public class MaterialServiceImpl implements MaterialService {
url+= "?imageView2/2/w/1440/h/1080" ; url+= "?imageView2/2/w/1440/h/1080" ;
logger.info("url={}",url); logger.info("url={}",url);
} }
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode() , selfFlag , qwDTO.getUrlHost());
}else { }else {
// 群发上传 // 群发上传
jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode() , selfFlag , qwDTO.getUrlHost());
} }
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
if(from==1) { if(from==1) {
......
...@@ -107,8 +107,14 @@ public class QywxSendServiceImpl implements QywxSendService { ...@@ -107,8 +107,14 @@ public class QywxSendServiceImpl implements QywxSendService {
messageDTO.setSenderUserId(tabHaobanStaff.getWxUserId()); messageDTO.setSenderUserId(tabHaobanStaff.getWxUserId());
} }
// 调接口执行创建群发 // 调接口执行创建群发
JSONResponse respon = qywxSuiteApiService.sendExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), JSONResponse respon = null ;
messageDTO); if(qwDTO.isSelf()) {
respon = qywxSuiteApiService.sendExternalMessageSelf(qwDTO.getThirdCorpid(), qwDTO.getSelfSecret(),
messageDTO , qwDTO.getUrlHost());
}else {
respon = qywxSuiteApiService.sendExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
messageDTO);
}
log.info("群发返回={}", JSON.toJSONString(respon)); log.info("群发返回={}", JSON.toJSONString(respon));
Map<String, Object> returnMap = respon.getReturnMap(); Map<String, Object> returnMap = respon.getReturnMap();
String msgIdKey = "msgid"; String msgIdKey = "msgid";
...@@ -154,7 +160,7 @@ public class QywxSendServiceImpl implements QywxSendService { ...@@ -154,7 +160,7 @@ public class QywxSendServiceImpl implements QywxSendService {
range.setSender_list(senderList); range.setSender_list(senderList);
moment.setVisible_range(range); moment.setVisible_range(range);
ServiceResponse<String> resp = this.qywxExternalUserService.addMomentTask(qwDTO.getThirdCorpid(), ServiceResponse<String> resp = this.qywxExternalUserService.addMomentTask(qwDTO.getThirdCorpid(),
config.getWxSuiteid(), moment); qwDTO.getSelf3thSecret(), moment,qwDTO.isSelf(),qwDTO.getUrlHost());
log.info("朋友圈消息={},返回={}", JSON.toJSONString(moment), JSON.toJSONString(resp)); log.info("朋友圈消息={},返回={}", JSON.toJSONString(moment), JSON.toJSONString(resp));
return resp; return resp;
} }
......
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
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.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.ToolUtil; import com.gic.commons.util.ToolUtil;
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.dao.mapper.SecretSettingMapper; import com.gic.haoban.manage.service.dao.mapper.SecretSettingMapper;
import com.gic.haoban.manage.service.entity.TabSecretSetting; import com.gic.haoban.manage.service.entity.TabSecretSetting;
import com.gic.haoban.manage.service.service.SecretSettingService; import com.gic.haoban.manage.service.service.SecretSettingService;
import org.apache.commons.lang3.StringUtils; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/** /**
* Created 2020/6/3. * Created 2020/6/3.
...@@ -29,6 +31,8 @@ public class SecretSettingServiceImpl implements SecretSettingService { ...@@ -29,6 +31,8 @@ public class SecretSettingServiceImpl implements SecretSettingService {
@Autowired @Autowired
private SecretSettingMapper secretSettingMapper; private SecretSettingMapper secretSettingMapper;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Override @Override
public boolean saveSecretSetting(SecretSettingDTO secretSetting) { public boolean saveSecretSetting(SecretSettingDTO secretSetting) {
...@@ -68,6 +72,11 @@ public class SecretSettingServiceImpl implements SecretSettingService { ...@@ -68,6 +72,11 @@ public class SecretSettingServiceImpl implements SecretSettingService {
logger.info("会员小程序配置使用getMemberSecretSetting接口"); logger.info("会员小程序配置使用getMemberSecretSetting接口");
return null; return null;
} }
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
// 如果是纯自建,使用自建的token
if(qwDTO.isSelf()) {
secretType = SecretTypeEnum.SELF_APP.getVal() ;
}
TabSecretSetting secretSetting = secretSettingMapper.getSecretSetting(wxEnterpriseId, secretType, null); TabSecretSetting 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 com.gic.api.base.commons.Page;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.clerk.api.service.RightService;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
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.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.hm.HmClerkRelationApiService;
import com.gic.haoban.manage.api.service.hm.HmQrcodeApiService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanMemberClerkChatConfigMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.entity.MemberClerkChatConfig;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.service.*;
import com.gic.member.api.service.MemberApiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
......
...@@ -147,7 +147,7 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated ...@@ -147,7 +147,7 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
} }
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal()); SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(qwDTO.getWxEnterpriseId(), SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null != secretSetting && StringUtils.isNotBlank(secretSetting.getSecretVal())) { if (null != secretSetting && StringUtils.isNotBlank(secretSetting.getSecretVal())) {
UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), wxUserId); UserDTO user = qywxUserApiService.getSelfWorkWxUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), wxUserId, qwDTO.getUrlHost());
logger.info("成员详情(代开)={}",JSON.toJSONString(user)) ; logger.info("成员详情(代开)={}",JSON.toJSONString(user)) ;
if(null != user && null != user.getDepartment()) { if(null != user && null != user.getDepartment()) {
this.staffDepartChange(staff, wxEnterpriseId, user.getDepartment(),false); ; this.staffDepartChange(staff, wxEnterpriseId, user.getDepartment(),false); ;
......
package com.gic.haoban.manage.service.service.impl; package com.gic.haoban.manage.service.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -20,6 +19,9 @@ import com.gic.haoban.common.utils.DingUtils; ...@@ -20,6 +19,9 @@ import com.gic.haoban.common.utils.DingUtils;
import com.gic.haoban.common.utils.StringUtil; import com.gic.haoban.common.utils.StringUtil;
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.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.SecretSettingMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper; import com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper; import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
...@@ -27,6 +29,7 @@ import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper; ...@@ -27,6 +29,7 @@ import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication; import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.entity.TabSecretSetting;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
@Service @Service
...@@ -41,6 +44,10 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService { ...@@ -41,6 +44,10 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
private WxApplicationMapper wxApplicationMapper ; private WxApplicationMapper wxApplicationMapper ;
@Autowired @Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper ; private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper ;
@Autowired
private SecretSettingMapper secretSettingMapper;
@Autowired
private Config config;
@Override @Override
public String add(WxEnterpriseDTO wxDTO) { public String add(WxEnterpriseDTO wxDTO) {
...@@ -98,10 +105,39 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService { ...@@ -98,10 +105,39 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
qw.setMemberCorpid(wxEnterprise.getWxCorpid()); qw.setMemberCorpid(wxEnterprise.getWxCorpid());
} }
} }
if(qw.getWxSecurityType()==5) {
qw.setUrlHost(wxEnterprise.getUrlHost());
qw.setDkCorpid(wxEnterprise.getWxCorpid());
qw.setThirdCorpid(wxEnterprise.getWxCorpid());
qw.setMemberCorpid(wxEnterprise.getWxCorpid());
TabSecretSetting secret = secretSettingMapper.getSecretSetting(wxEnterpriseId, SecretTypeEnum.SELF_APP.getVal(), null);
qw.setSelfSecret(secret.getSecretVal());
qw.setAgentId(secret.getAgentId());
qw.setAgentName(secret.getAgentName());
qw.setSelfAppid(wxEnterprise.getWxaAppid());
}
qw.setHbWxaAppid(this.getHbAppid(qw, config.getAppid()));
qw.setSelf3thSecret(this.getSecret(qw, config.getWxSuiteid()));
logger.info("企微所有corpid信息={}",JSON.toJSON(qw)); logger.info("企微所有corpid信息={}",JSON.toJSON(qw));
return qw; return qw;
} }
public String getSecret(WxEnterpriseQwDTO qwDTO, String suiteId) {
String secret = suiteId;
if (qwDTO.isSelf()) {
secret = qwDTO.getSelfSecret();
}
return secret;
}
public String getHbAppid(WxEnterpriseQwDTO qwDTO, String thirdAppid) {
String appid = thirdAppid;
if (qwDTO.isSelf()) {
appid = qwDTO.getSelfAppid();
}
return appid;
}
@Override @Override
public TabHaobanWxEnterprise getEnterpriseBycorpId(String corpId) { public TabHaobanWxEnterprise getEnterpriseBycorpId(String corpId) {
if (StringUtils.isBlank(corpId)) { if (StringUtils.isBlank(corpId)) {
...@@ -175,6 +211,10 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService { ...@@ -175,6 +211,10 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
@Override @Override
public void updateWxSecurityType(String wxEnterpriseId) { public void updateWxSecurityType(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
return ;
}
int wxSecurityType = this.calcSecretType(wxEnterpriseId); int wxSecurityType = this.calcSecretType(wxEnterpriseId);
if(wxSecurityType < 1 || wxSecurityType > 4) { if(wxSecurityType < 1 || wxSecurityType > 4) {
return ; return ;
......
...@@ -265,14 +265,14 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -265,14 +265,14 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
appUrl += messageTypeEnum.getPageType(); appUrl += messageTypeEnum.getPageType();
} }
appUrl += "&data=" + data; appUrl += "&data=" + data;
messageDTO.setAppid(config.getAppid()); messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setAgentId(Integer.parseInt(qwDTO.getAgentId())); messageDTO.setAgentId(Integer.parseInt(qwDTO.getAgentId()));
messageDTO.setAgentName(qwDTO.getAgentName()); messageDTO.setAgentName(qwDTO.getAgentName());
messageDTO.setUserIds(wxUserIdList); messageDTO.setUserIds(wxUserIdList);
messageDTO.setPage(appUrl); messageDTO.setPage(appUrl);
messageDTO.setTitle(StringUtils.isNotBlank(title)?title: messageTypeEnum.getName()); messageDTO.setTitle(StringUtils.isNotBlank(title)?title: messageTypeEnum.getName());
messageDTO.setContent(contentList.get(0).getVal()); messageDTO.setContent(contentList.get(0).getVal());
boolean sendMessage = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO); boolean sendMessage = qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
NotifyMessageMQDTO mqdto = new NotifyMessageMQDTO(); NotifyMessageMQDTO mqdto = new NotifyMessageMQDTO();
List<String> clerkIdList = list.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toList()); List<String> clerkIdList = list.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toList());
mqdto.setClerkIdList(clerkIdList); mqdto.setClerkIdList(clerkIdList);
...@@ -418,11 +418,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService { ...@@ -418,11 +418,11 @@ public class NoticeMessageApiServiceImpl implements NoticeMessageApiService {
List<String> userList = new ArrayList<>(); List<String> userList = new ArrayList<>();
userList.add(wxUserId); userList.add(wxUserId);
messageDTO.setAppid(config.getAppid()); messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(userList); messageDTO.setUserIds(userList);
messageDTO.setPage(appUrl); messageDTO.setPage(appUrl);
messageDTO.setTitle(StringUtils.isNotBlank(title)?title:messageTypeEnum.getName()); messageDTO.setTitle(StringUtils.isNotBlank(title)?title:messageTypeEnum.getName());
messageDTO.setItems(items); messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(corpid, config.getWxSuiteid(), messageDTO); qywxSuiteApiService.sendMessage(corpid, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
} }
} }
...@@ -535,7 +535,7 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ ...@@ -535,7 +535,7 @@ public class DealSyncOperationApiServiceImpl implements DealSyncOperationApiServ
unlockTask(wxEnterpriseId); unlockTask(wxEnterpriseId);
return "没有配置secret"; return "没有配置secret";
} }
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), 1); List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), 1,qwDTO.getUrlHost());
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());
......
...@@ -13,6 +13,7 @@ import com.gic.haoban.common.utils.StringUtil; ...@@ -13,6 +13,7 @@ import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO; import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.DepartmentShortDTO; import com.gic.haoban.manage.api.dto.DepartmentShortDTO;
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.DepartmentApiService; import com.gic.haoban.manage.api.service.DepartmentApiService;
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;
...@@ -207,7 +208,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -207,7 +208,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
if (RedisUtil.getCache(key) == null) { if (RedisUtil.getCache(key) == null) {
RedisUtil.setCache(key, 1, 60 * 60L); RedisUtil.setCache(key, 1, 60 * 60L);
String taskId = StringUtil.randomUUID(); String taskId = StringUtil.randomUUID();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null , qwDTO.getUrlHost());
logger.info("企业所有部门数据:{}", JSON.toJSONString(list)); logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret, taskId); this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret, taskId);
...@@ -225,7 +227,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -225,7 +227,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
String corpid = json.getString("corpid"); String corpid = json.getString("corpid");
String contactSecret = json.getString("contactSecret"); String contactSecret = json.getString("contactSecret");
String taskId = json.getString("taskId"); String taskId = json.getString("taskId");
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, parentId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, parentId,qwDTO.getUrlHost());
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> handerList = new ArrayList<>(); List<com.gic.wechat.api.dto.qywx.DepartmentDTO> handerList = new ArrayList<>();
if (parentId.equals(0)) { if (parentId.equals(0)) {
for (com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list) { for (com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list) {
......
...@@ -27,7 +27,6 @@ import com.gic.haoban.manage.api.service.WxEnterpriseApiService; ...@@ -27,7 +27,6 @@ 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.*;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated; 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.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;
......
...@@ -104,7 +104,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -104,7 +104,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
String cursor = null; String cursor = null;
do { do {
//离职成员客户列表 //离职成员客户列表
unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), config.getWxSuiteid(), cursor); unassignedListDTO = qywxUserApiService.getUnassignedList(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), cursor , qwDTO.isSelf(),qwDTO.getUrlHost());
cursor = unassignedListDTO.getNextCursor(); cursor = unassignedListDTO.getNextCursor();
if (CollectionUtils.isNotEmpty(unassignedListDTO.getInfo())) { if (CollectionUtils.isNotEmpty(unassignedListDTO.getInfo())) {
ret.addAll(unassignedListDTO.getInfo()); ret.addAll(unassignedListDTO.getInfo());
...@@ -145,7 +145,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -145,7 +145,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
logger.info("takeover is null={}",dto.getTakeoverStaffId()); logger.info("takeover is null={}",dto.getTakeoverStaffId());
return; return;
} }
QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(qwDTO.getThirdCorpid(), config.getWxSuiteid(), handover.getWxUserId(), takeover.getWxUserId(), true); QywxTransferCustomerDTO customerDTO = qywxUserApiService.transferResult(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), handover.getWxUserId(), takeover.getWxUserId(), true , qwDTO.isSelf() , qwDTO.getUrlHost());
if (customerDTO.getErrcode() != 0) { if (customerDTO.getErrcode() != 0) {
return; return;
} }
...@@ -255,7 +255,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ ...@@ -255,7 +255,7 @@ public class HandoverOperationApiServiceImpl implements HandoverOperationApiServ
for (Map.Entry<String, List<String>> entry : handoverStaffExternalMap.entrySet()) { for (Map.Entry<String, List<String>> entry : handoverStaffExternalMap.entrySet()) {
String wxUserId = entry.getKey(); String wxUserId = entry.getKey();
List<String> list = entry.getValue(); List<String> list = entry.getValue();
QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId, takeoverUserId, list); QywxTransferCustomerDTO transferCustomerResp = qywxUserApiService.transferCustomer(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), wxUserId, takeoverUserId, list,qwDTO.isSelf(),qwDTO.getUrlHost());
if (transferCustomerResp.getErrcode() != 0) { if (transferCustomerResp.getErrcode() != 0) {
logger.info("转移异常"); logger.info("转移异常");
} }
......
...@@ -147,7 +147,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -147,7 +147,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(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl)); JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , qwDTO.getSelf3thSecret(), imgUrl , qwDTO.isSelf(),qwDTO.getUrlHost());
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);
...@@ -155,7 +155,8 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -155,7 +155,8 @@ 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(qwDTO.getThirdCorpid() , config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid() , qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
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());
...@@ -232,7 +233,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -232,7 +233,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(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(imgUrl)); JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), imgUrl ,qwDTO.isSelf(),qwDTO.getUrlHost());
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString(); String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl); materialDTO.setWxImgUrl(wxImgUrl);
} }
...@@ -240,7 +241,8 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -240,7 +241,8 @@ 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(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url , arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
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());
...@@ -289,7 +291,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -289,7 +291,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(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode(),qwDTO.isSelf(),qwDTO.getUrlHost());
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());
...@@ -449,7 +451,7 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -449,7 +451,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(qwDTO.getThirdCorpid(), one.getMediaUrl()); String mediaId = uploadMediaToWx(qwDTO.getThirdCorpid(), one.getMediaUrl(),qwDTO);
if (StringUtils.isNotEmpty(mediaId)) { if (StringUtils.isNotEmpty(mediaId)) {
materialDTO.setWxLastUploadTime(new Date()); materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(mediaId); materialDTO.setMediaId(mediaId);
...@@ -460,12 +462,13 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -460,12 +462,13 @@ public class MaterialApiServiceImpl implements MaterialApiService {
materialService.batchInsertMaterial(materialList); materialService.batchInsertMaterial(materialList);
} }
private String uploadMediaToWx(String corPid, String url) { private String uploadMediaToWx(String corPid, String url, WxEnterpriseQwDTO qwDTO) {
String[] arr = url.split("/"); String[] arr = url.split("/");
// 先写死为图片类型, 以后有别的再扩展 // 先写死为图片类型, 以后有别的再扩展
QywxMediaTypeEnum fileType = QywxMediaTypeEnum.IMAGE; QywxMediaTypeEnum fileType = QywxMediaTypeEnum.IMAGE;
int count = arr.length; int count = arr.length;
JSONResponse jp = qywxSuiteApiService.uploadMedia(corPid, config.getWxSuiteid(), CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode()); boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(corPid, qwDTO.getSelf3thSecret(), url, arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
return jp.getResult().toString(); return jp.getResult().toString();
} }
......
...@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service.out.impl; ...@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -18,9 +19,6 @@ import org.apache.logging.log4j.Logger; ...@@ -18,9 +19,6 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.clerk.api.dto.ClerkDTO; import com.gic.clerk.api.dto.ClerkDTO;
...@@ -54,6 +52,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanDepartment; ...@@ -54,6 +52,7 @@ import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated; import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication; 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.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService; import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.MemberQueryService; import com.gic.haoban.manage.service.service.MemberQueryService;
...@@ -80,7 +79,7 @@ import com.gic.wechat.api.service.qywx.QywxSuiteApiService; ...@@ -80,7 +79,7 @@ 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.Sets; import com.google.common.collect.Sets;
import java.util.*; import cn.hutool.core.convert.Convert;
/** /**
* 接收企业微信或者gic推送消息进行处理 * 接收企业微信或者gic推送消息进行处理
...@@ -197,12 +196,12 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -197,12 +196,12 @@ public class MessageApiServiceImpl implements MessageApiService {
* @param enterpriseId * @param enterpriseId
* @param secret * @param secret
*/ */
private void dealClerkUser(QywxCallBackDTO dto, String enterpriseId, String secret, String staffName) { private void dealClerkUser(QywxCallBackDTO dto, String enterpriseId, String secret, String staffName , WxEnterpriseQwDTO qwDTO) {
ClerkQwDTO clerkQwDTO = new ClerkQwDTO(); ClerkQwDTO clerkQwDTO = new ClerkQwDTO();
clerkQwDTO.setEnterpriseId(enterpriseId); clerkQwDTO.setEnterpriseId(enterpriseId);
String mainDeptId = dto.getMainDepartment(); String mainDeptId = dto.getMainDepartment();
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> departments = qywxDepartmentApiService List<com.gic.wechat.api.dto.qywx.DepartmentDTO> departments = qywxDepartmentApiService
.listSelfDepartment(dto.getAuthCorpId(), secret, Integer.valueOf(mainDeptId)); .listSelfDepartment(dto.getAuthCorpId(), secret, Integer.valueOf(mainDeptId),qwDTO.getUrlHost());
if (CollectionUtils.isEmpty(departments)) { if (CollectionUtils.isEmpty(departments)) {
log.info("通过主部门查询部门列表为空 mainDeptId:{}", mainDeptId); log.info("通过主部门查询部门列表为空 mainDeptId:{}", mainDeptId);
return; return;
...@@ -237,14 +236,14 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -237,14 +236,14 @@ public class MessageApiServiceImpl implements MessageApiService {
return; return;
} }
String corpId = qywxCallBackDTO.getAuthCorpId(); String corpId = qywxCallBackDTO.getAuthCorpId();
TabHaobanWxApplication wxApplication = wxApplicationService.selectByCorpId(corpId); TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
if (Objects.isNull(wxApplication)) { if (Objects.isNull(wxEnterprise)) {
log.info("授权企业不存在,{}", corpId); log.info("授权企业不存在,{}", corpId);
return; return;
} }
String wxEnterpriseId = wxApplication.getWxEnterpriseId(); String wxEnterpriseId = wxEnterprise.getWxEnterpriseId();
String changeType = qywxCallBackDTO.getChangeType(); String changeType = qywxCallBackDTO.getChangeType();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (changeType.equals(WxEditType.ADD_USER.getCode())) { if (changeType.equals(WxEditType.ADD_USER.getCode())) {
log.info("成员同步新增,userid:{}", userid); log.info("成员同步新增,userid:{}", userid);
// 新增 // 新增
...@@ -254,7 +253,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -254,7 +253,7 @@ public class MessageApiServiceImpl implements MessageApiService {
if (suitWxEnterpriseIid) { if (suitWxEnterpriseIid) {
String staffName = Convert.toStr(serviceResponse.getResult()); String staffName = Convert.toStr(serviceResponse.getResult());
// 鸿星尔克定制 // 鸿星尔克定制
dealErKe(qywxCallBackDTO, wxEnterpriseId, staffName); dealErKe(qywxCallBackDTO, wxEnterpriseId, staffName,qwDTO);
} }
} else if (changeType.equals(WxEditType.UPDATE_USER.getCode())) { } else if (changeType.equals(WxEditType.UPDATE_USER.getCode())) {
log.info("成员同步修改,userid:{}", userid); log.info("成员同步修改,userid:{}", userid);
...@@ -262,7 +261,6 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -262,7 +261,6 @@ public class MessageApiServiceImpl implements MessageApiService {
TabHaobanStaff oldStaff = this.staffService.selectByUserIdAndEnterpriseId(userid, wxEnterpriseId); TabHaobanStaff oldStaff = this.staffService.selectByUserIdAndEnterpriseId(userid, wxEnterpriseId);
if (oldStaff == null) { if (oldStaff == null) {
//员工可能修改userId,需要拿到openUserId再去查询一次 //员工可能修改userId,需要拿到openUserId再去查询一次
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
if (qwDTO != null && (qwDTO.getWxSecurityType() == 1 || qwDTO.getWxSecurityType() == 3)){ if (qwDTO != null && (qwDTO.getWxSecurityType() == 1 || qwDTO.getWxSecurityType() == 3)){
String openUserid = getOpenUserid(userid, qwDTO); String openUserid = getOpenUserid(userid, qwDTO);
if (StringUtils.isNotBlank(openUserid)){ if (StringUtils.isNotBlank(openUserid)){
...@@ -337,8 +335,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -337,8 +335,7 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId); log.info("没有配置secret,wxEnterpriseId:{}", wxEnterpriseId);
return; return;
} }
UserDTO user = qywxUserApiService.getSelfWorkWxUser(corpId, secretSetting.getSecretVal(), userid ,qwDTO.getUrlHost());
UserDTO user = qywxUserApiService.getSelfWorkWxUser(corpId, secretSetting.getSecretVal(), userid);
if (null != user) { if (null != user) {
Integer status = user.getStatus(); Integer status = user.getStatus();
// 1=已激活,2=已禁用,4=未激活,5=退出企业。 // 1=已激活,2=已禁用,4=未激活,5=退出企业。
...@@ -405,6 +402,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -405,6 +402,7 @@ public class MessageApiServiceImpl implements MessageApiService {
return; return;
} }
String wxEnterpriseId = wxApplication.getWxEnterpriseId(); String wxEnterpriseId = wxApplication.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId,
SecretTypeEnum.CUSTOMIZED_APP.getVal()); SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) { if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
...@@ -428,7 +426,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -428,7 +426,7 @@ public class MessageApiServiceImpl implements MessageApiService {
return; return;
} }
com.gic.wechat.api.dto.qywx.DepartmentDTO deptDetail = qywxDepartmentApiService com.gic.wechat.api.dto.qywx.DepartmentDTO deptDetail = qywxDepartmentApiService
.getSelfDepartmentById(authCorpId, secret, wxDeptId); .getSelfDepartmentById(authCorpId, secret, wxDeptId , qwDTO.getUrlHost());
departmentDTO.setDepartmentName(deptDetail.getName()); departmentDTO.setDepartmentName(deptDetail.getName());
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId()); departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId( departmentDTO.setChainId(
...@@ -440,7 +438,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -440,7 +438,7 @@ public class MessageApiServiceImpl implements MessageApiService {
departmentDTO.setWxDepartmentId(wxDeptId + ""); departmentDTO.setWxDepartmentId(wxDeptId + "");
if (qywxCallBackDTO.getParentId() != null) { if (qywxCallBackDTO.getParentId() != null) {
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService
.listSelfDepartment(authCorpId, secret, qywxCallBackDTO.getParentId()); .listSelfDepartment(authCorpId, secret, qywxCallBackDTO.getParentId(),qwDTO.getUrlHost());
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
for (com.gic.wechat.api.dto.qywx.DepartmentDTO wxDepartmentDTO : list) { for (com.gic.wechat.api.dto.qywx.DepartmentDTO wxDepartmentDTO : list) {
if (Convert.toStr(wxDepartmentDTO.getId()).equals(departmentDTO.getDepartmentId())) { if (Convert.toStr(wxDepartmentDTO.getId()).equals(departmentDTO.getDepartmentId())) {
...@@ -491,7 +489,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -491,7 +489,7 @@ public class MessageApiServiceImpl implements MessageApiService {
* @param qywxCallBackDTO * @param qywxCallBackDTO
* @param wxEnterpriseId * @param wxEnterpriseId
*/ */
private void dealErKe(QywxCallBackDTO qywxCallBackDTO, String wxEnterpriseId, String staffName) { private void dealErKe(QywxCallBackDTO qywxCallBackDTO, String wxEnterpriseId, String staffName , WxEnterpriseQwDTO qwDTO) {
log.info("成员同步定制化开始"); log.info("成员同步定制化开始");
// 处理定制-目前鸿星尔克用 // 处理定制-目前鸿星尔克用
boolean checkErkeDeal = checkErkeDeal(qywxCallBackDTO); boolean checkErkeDeal = checkErkeDeal(qywxCallBackDTO);
...@@ -510,7 +508,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -510,7 +508,7 @@ public class MessageApiServiceImpl implements MessageApiService {
log.info("没有配置secret:{}", wxEnterpriseId); log.info("没有配置secret:{}", wxEnterpriseId);
return; return;
} }
dealClerkUser(qywxCallBackDTO, relatedList.get(0).getEnterpriseId(), secretSetting.getSecretVal(), staffName); dealClerkUser(qywxCallBackDTO, relatedList.get(0).getEnterpriseId(), secretSetting.getSecretVal(), staffName,qwDTO);
log.info("成员同步定制化结束"); log.info("成员同步定制化结束");
} }
...@@ -597,7 +595,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -597,7 +595,7 @@ public class MessageApiServiceImpl implements MessageApiService {
if (qwDTO.needOpenUserId3th()) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staff.getWxOpenUseId(); wxUserId = staff.getWxOpenUseId();
} }
messageDTO.setAppid(config.getAppid()); messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(Arrays.asList(wxUserId)); messageDTO.setUserIds(Arrays.asList(wxUserId));
messageDTO.setPage( messageDTO.setPage(
NoticeMessageTypeEnum.OFFLINE_PRE.getPageUrl() + NoticeMessageTypeEnum.OFFLINE_PRE.getPageType()); NoticeMessageTypeEnum.OFFLINE_PRE.getPageUrl() + NoticeMessageTypeEnum.OFFLINE_PRE.getPageType());
...@@ -606,7 +604,7 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -606,7 +604,7 @@ public class MessageApiServiceImpl implements MessageApiService {
map.put("事件", message); map.put("事件", message);
List<ItemDTO> items = getItemsList(map); List<ItemDTO> items = getItemsList(map);
messageDTO.setItems(items); messageDTO.setItems(items);
qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(), messageDTO); qywxSuiteApiService.sendMessage(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
return com.gic.api.base.commons.ServiceResponse.success(); return com.gic.api.base.commons.ServiceResponse.success();
} }
......
...@@ -62,7 +62,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService ...@@ -62,7 +62,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
} }
String[] arr = miniprogramSetting.getImageUrl().split("/"); String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(miniprogramSetting.getWxEnterpriseId()) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(miniprogramSetting.getWxEnterpriseId()) ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode()); boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), miniprogramSetting.getImageUrl(), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date); miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString()); miniprogramSetting.setMediaId(jp.getResult().toString());
...@@ -116,7 +117,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService ...@@ -116,7 +117,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
} }
String[] arr = miniprogramSetting.getImageUrl().split("/"); String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), config.getWxSuiteid(), CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode()); boolean selfFlag = qwDTO.isSelf() ;
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), miniprogramSetting.getImageUrl(), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) { if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date); miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString()); miniprogramSetting.setMediaId(jp.getResult().toString());
......
...@@ -196,14 +196,14 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -196,14 +196,14 @@ public class StaffApiServiceImpl implements StaffApiService {
if (qwDTO.getWxSecurityType() == 4) { if (qwDTO.getWxSecurityType() == 4) {
user = qywxUserApiService.getWorkWxUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId); user = qywxUserApiService.getWorkWxUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId);
logger.info("成员详情(第三方)={}", JSON.toJSONString(user)); logger.info("成员详情(第三方)={}", JSON.toJSONString(user));
UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), user.getOpen_userid()); UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), user.getOpen_userid() , qwDTO.getUrlHost());
logger.info("成员详情(代开)={}", JSON.toJSONString(user)); logger.info("成员详情(代开)={}", JSON.toJSONString(user));
if (user != null && userSelf != null) { if (user != null && userSelf != null) {
user.setName(userSelf.getName()); user.setName(userSelf.getName());
user.setPosition(userSelf.getPosition()); user.setPosition(userSelf.getPosition());
} }
} else { } else {
user = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), wxUserId); user = qywxUserApiService.getSelfWorkWxUser(dkCorpid, secretSetting.getSecretVal(), wxUserId , qwDTO.getUrlHost());
logger.info("成员详情(代开)={}", JSON.toJSONString(user)); logger.info("成员详情(代开)={}", JSON.toJSONString(user));
} }
if (null == user) { if (null == user) {
...@@ -255,6 +255,11 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -255,6 +255,11 @@ public class StaffApiServiceImpl implements StaffApiService {
if (StringUtils.isNotBlank(qr_code)) { if (StringUtils.isNotBlank(qr_code)) {
staff.setQrCode(qr_code); staff.setQrCode(qr_code);
} }
//判断成员是否开启联系我
if (this.openConcatFlag(wxEnterpriseId,wxUserId)) {
logger.info("成员开启联系我");
staff.setOpenConcatFlag(1);
}
//成员更改或更新 //成员更改或更新
if (StringUtils.isBlank(staff.getStaffId())) { if (StringUtils.isBlank(staff.getStaffId())) {
logger.info("新增成员"); logger.info("新增成员");
...@@ -270,6 +275,22 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -270,6 +275,22 @@ public class StaffApiServiceImpl implements StaffApiService {
res.setResult(staff.getStaffName()); res.setResult(staff.getStaffName());
return res; return res;
} }
private Boolean openConcatFlag(String wxEnterpriseId,String userId){
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//企微已经开启联系我
List<String> wxUserIdsList = null ;
Boolean flag = false;
if(qwDTO.isSelf()) {
wxUserIdsList = qywxUserApiService.listCorpExternalUserSelf(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(),qwDTO.getUrlHost());
}else {
wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
}
if (CollUtil.isNotEmpty(wxUserIdsList) && wxUserIdsList.contains(userId)) {
logger.info("成员开启联系我");
flag = true;
}
return flag;
}
/** /**
* 获取wxopenuserid * 获取wxopenuserid
...@@ -489,7 +510,8 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -489,7 +510,8 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override @Override
public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId, String taskId) { public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId, String taskId) {
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0 , qwDTO.getUrlHost());
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
for (UserDTO dto : list) { for (UserDTO dto : list) {
try { try {
......
...@@ -444,7 +444,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe ...@@ -444,7 +444,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
} else { } else {
userIds.add(relationDTO.getQwUserId()); userIds.add(relationDTO.getQwUserId());
} }
QywxExternalcontactResultDTO configResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), send); QywxExternalcontactResultDTO configResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), send,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("configId:{}", JSON.toJSONString(configResp)); logger.info("configId:{}", JSON.toJSONString(configResp));
String configId = configResp.getConfig_id(); String configId = configResp.getConfig_id();
if (StringUtils.isBlank(configId)) { if (StringUtils.isBlank(configId)) {
......
...@@ -34,6 +34,7 @@ import com.gic.haoban.manage.service.config.Config; ...@@ -34,6 +34,7 @@ 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;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper; import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
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.service.StaffDepartmentRelatedService; import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.ItemDTO; import com.gic.wechat.api.dto.qywx.ItemDTO;
...@@ -248,15 +249,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -248,15 +249,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
items.add(dto2); items.add(dto2);
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
list.add(wxUserId); list.add(wxUserId);
messageDTO.setAppid(config.getAppid()); TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
WxEnterpriseQwDTO qwDTO =this.wxEnterpriseService.getQwInfo(wxEnterprise.getWxEnterpriseId()) ;
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(list); messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl); messageDTO.setPage(pageUrl);
messageDTO.setTitle(title); messageDTO.setTitle(title);
messageDTO.setItems(items); messageDTO.setItems(items);
logger.info("发送参数为corpId============:{},suitId============:{},messageDTO============:{},", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO)); logger.info("发送参数为corpId============:{},suitId============:{},messageDTO============:{},", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO));
boolean b = qywxSuiteApiService.sendMessage(corpId, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
boolean b = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO);
logger.info("发送===============》{}", b); logger.info("发送===============》{}", b);
return b; return b;
} }
...@@ -303,13 +305,15 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -303,13 +305,15 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
contentList.add(itemDTO); contentList.add(itemDTO);
}); });
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO(); QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
messageDTO.setAppid(this.config.getAppid()); TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
WxEnterpriseQwDTO qwDTO =this.wxEnterpriseService.getQwInfo(wxEnterprise.getWxEnterpriseId()) ;
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(Collections.singletonList(wxUserId)); messageDTO.setUserIds(Collections.singletonList(wxUserId));
messageDTO.setTitle(title); messageDTO.setTitle(title);
messageDTO.setItems(contentList); messageDTO.setItems(contentList);
messageDTO.setPage(pageUrl); messageDTO.setPage(pageUrl);
logger.info("消息发送, corpId : {}, suitId : {}, messageDTO : {}", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO)); logger.info("消息发送, corpId : {}, suitId : {}, messageDTO : {}", corpId, config.getWxSuiteid(), JSONObject.toJSONString(messageDTO));
boolean sendResult = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO); boolean sendResult = qywxSuiteApiService.sendMessage(corpId, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("消息发送结果, sendResult : {}", sendResult); logger.info("消息发送结果, sendResult : {}", sendResult);
return sendResult; return sendResult;
} }
...@@ -354,14 +358,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela ...@@ -354,14 +358,16 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
} }
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
list.add(wxUserId); list.add(wxUserId);
messageDTO.setAppid(config.getAppid()); TabHaobanWxEnterprise wxEnterprise = this.wxEnterpriseService.getEnterpriseBycorpId(corpId);
WxEnterpriseQwDTO qwDTO =this.wxEnterpriseService.getQwInfo(wxEnterprise.getWxEnterpriseId()) ;
messageDTO.setAppid(qwDTO.getHbWxaAppid());
messageDTO.setUserIds(list); messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl); messageDTO.setPage(pageUrl);
messageDTO.setTitle(title); messageDTO.setTitle(title);
messageDTO.setItems(items); messageDTO.setItems(items);
logger.info("发送消息参数为corpId={},messageDTO={},", corpId, JSONObject.toJSONString(messageDTO)); logger.info("发送消息参数为corpId={},messageDTO={},", corpId, JSONObject.toJSONString(messageDTO));
boolean b = qywxSuiteApiService.sendMessage(corpId, config.getWxSuiteid(), messageDTO); boolean b = qywxSuiteApiService.sendMessage(corpId, qwDTO.getSelf3thSecret(), messageDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("发送消息返回={}", b); logger.info("发送消息返回={}", b);
return b; return b;
} }
......
...@@ -49,27 +49,11 @@ public class TestServiceImpl implements TestApiService { ...@@ -49,27 +49,11 @@ public class TestServiceImpl implements TestApiService {
@Override @Override
public String listSelfQywxUser(String corpid, String secretVal, String dataId) { public String listSelfQywxUser(String corpid, String secretVal, String dataId) {
long t = System.currentTimeMillis();
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, secretVal, dataId, 0);
logger.info("耗时为===============>{}毫秒", (System.currentTimeMillis() - t));
if (null != list) {
logger.info("微信获取部门成员数量为:{}", list.size());
} else {
logger.info("微信获取部门成员数量异常");
}
return ""; return "";
} }
@Override @Override
public String listAllQywxUser(String corpid, String secretVal, String dataId) { public String listAllQywxUser(String corpid, String secretVal, String dataId) {
long t = System.currentTimeMillis();
List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, secretVal, dataId, 1);
logger.info("耗时为===============>{}毫秒", (System.currentTimeMillis() - t));
if (null != list) {
logger.info("微信获取部门成员数量为:{}", list.size());
} else {
logger.info("微信获取部门成员数量异常");
}
return ""; return "";
} }
......
...@@ -249,6 +249,13 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -249,6 +249,13 @@ 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 WxEnterpriseDTO selectByWxaAppid(String appid) {
TabHaobanWxEnterprise tab = wxEnterpriseMapper.selectByWxaAppid(appid);
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, tab);
return wxDTO;
}
@Override @Override
public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) { public WxEnterpriseQwDTO getQwInfo(String wxEnterpriseId) {
......
package com.gic.haoban.manage.service.service.out.impl.hm; package com.gic.haoban.manage.service.service.out.impl.hm;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page; 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.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon; import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.common.utils.EntityUtil; import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
......
...@@ -540,8 +540,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService { ...@@ -540,8 +540,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
paramsDTO.setUser(Arrays.asList(tabHaobanStaff.getWxUserId())); paramsDTO.setUser(Arrays.asList(tabHaobanStaff.getWxUserId()));
} }
} }
QywxExternalcontactResultDTO wxResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), QywxExternalcontactResultDTO wxResp = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), paramsDTO , qwDTO.isSelf(),qwDTO.getUrlHost());
config.getWxSuiteid(), paramsDTO);
log.info("创建动态活码参数corpid={},app={},param={},返回={}", qwDTO.getThirdCorpid(), config.getWxSuiteid(), log.info("创建动态活码参数corpid={},app={},param={},返回={}", qwDTO.getThirdCorpid(), config.getWxSuiteid(),
JSON.toJSONString(paramsDTO), JSON.toJSONString(wxResp)); JSON.toJSONString(paramsDTO), JSON.toJSONString(wxResp));
if (null != wxResp && 0 == wxResp.getErrcode()) { if (null != wxResp && 0 == wxResp.getErrcode()) {
......
...@@ -151,14 +151,13 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -151,14 +151,13 @@ 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 = 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()), "导购未关联好办");
} }
qywxExternalcontactDTO.setUser(userIds); qywxExternalcontactDTO.setUser(userIds);
logger.info("新增活码参数:{}", JSON.toJSONString(qywxExternalcontactDTO)); logger.info("新增活码参数:{}", JSON.toJSONString(qywxExternalcontactDTO));
QywxExternalcontactResultDTO qywxExternalcontactResultDTO = qywxUserApiService.addContactWay(corpid, config.getWxSuiteid(), qywxExternalcontactDTO); QywxExternalcontactResultDTO qywxExternalcontactResultDTO = qywxUserApiService.addContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), qywxExternalcontactDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
if (qywxExternalcontactResultDTO.getErrcode() != 0) { if (qywxExternalcontactResultDTO.getErrcode() != 0) {
GicLogRecordEvaluationContext.noWriteLog(); GicLogRecordEvaluationContext.noWriteLog();
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), "创建企微活码失败,具体失败原因请参考企微报错http链接:" + qywxExternalcontactResultDTO.getErrmsg()); return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), "创建企微活码失败,具体失败原因请参考企微报错http链接:" + qywxExternalcontactResultDTO.getErrmsg());
...@@ -341,7 +340,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -341,7 +340,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(qwDTO.getThirdCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO); QywxResponseDTO qywxResponseDTO = qywxUserApiService.updateContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), qywxExternalcontactDTO,qwDTO.isSelf(),qwDTO.getUrlHost());
if (qywxResponseDTO.getErrcode() != 0) { if (qywxResponseDTO.getErrcode() != 0) {
logger.error("更新企微活码失败"); logger.error("更新企微活码失败");
GicLogRecordEvaluationContext.noWriteLog(); GicLogRecordEvaluationContext.noWriteLog();
...@@ -691,7 +690,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -691,7 +690,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String wxConfigId = hmQrcodeBO.getWxConfigId(); String wxConfigId = hmQrcodeBO.getWxConfigId();
if (StringUtils.isNotBlank(wxConfigId)) { if (StringUtils.isNotBlank(wxConfigId)) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(hmQrcodeBO.getWxEnterpriseId()); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(hmQrcodeBO.getWxEnterpriseId());
QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxConfigId); QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), wxConfigId,qwDTO.isSelf(),qwDTO.getUrlHost());
int errcode = qywxResponseDTO.getErrcode(); int errcode = qywxResponseDTO.getErrcode();
//https://open.work.weixin.qq.com/devtool/query?e=41044 //https://open.work.weixin.qq.com/devtool/query?e=41044
if (errcode != 0) { if (errcode != 0) {
...@@ -816,7 +815,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService { ...@@ -816,7 +815,12 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId);
//查询出所有正常的导购 //查询出所有正常的导购
//企微已经开启联系我 //企微已经开启联系我
List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid()); List<String> wxUserIdsList = null ;
if(qwDTO.isSelf()) {
wxUserIdsList = qywxUserApiService.listCorpExternalUserSelf(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(),qwDTO.getUrlHost());
}else {
wxUserIdsList = qywxUserApiService.listCorpExternalUser(qwDTO.getThirdCorpid(), config.getWxSuiteid());
}
this.staffService.updateOpenConcatFlag(wxUserIdsList,qwDTO.needOpenUserId3th()?1:0) ; this.staffService.updateOpenConcatFlag(wxUserIdsList,qwDTO.needOpenUserId3th()?1:0) ;
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId); List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) { if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) {
......
...@@ -13,6 +13,7 @@ import com.gic.enterprise.api.dto.EnterpriseDTO; ...@@ -13,6 +13,7 @@ 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.manage.api.dto.StaffActiveDataDTO; import com.gic.haoban.manage.api.dto.StaffActiveDataDTO;
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.licence.LicenceOrderDTO; import com.gic.haoban.manage.api.dto.licence.LicenceOrderDTO;
import com.gic.haoban.manage.api.dto.licence.LicenceOrderPageDTO; import com.gic.haoban.manage.api.dto.licence.LicenceOrderPageDTO;
import com.gic.haoban.manage.api.dto.licence.LicenceOrderProgressDTO; import com.gic.haoban.manage.api.dto.licence.LicenceOrderProgressDTO;
...@@ -490,9 +491,13 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService { ...@@ -490,9 +491,13 @@ public class LicenceOrderApiServiceImpl implements LicenceOrderApiService {
@Override @Override
public ServiceResponse<HashMap<String, Integer>> hasPopup(String wxEnterpriseId) { public ServiceResponse<HashMap<String, Integer>> hasPopup(String wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
HashMap<String, Integer> map = new HashMap<>(); HashMap<String, Integer> map = new HashMap<>();
map.put("hasPopup",0); map.put("hasPopup",0);
map.put("count",0); map.put("count",0);
if(qwDTO.isSelf()) {
return ServiceResponse.success(map);
}
List<String> list = staffClerkRelationService.listByWxEnterpriseId(wxEnterpriseId); List<String> list = staffClerkRelationService.listByWxEnterpriseId(wxEnterpriseId);
if (CollUtil.isEmpty(list)){ if (CollUtil.isEmpty(list)){
return ServiceResponse.success(map); return ServiceResponse.success(map);
......
...@@ -170,12 +170,12 @@ public class QywxDeptSyncOperation implements BaseSyncOperation { ...@@ -170,12 +170,12 @@ public class QywxDeptSyncOperation implements BaseSyncOperation {
if ("0".equals(pDataId)) { if ("0".equals(pDataId)) {
//根级部门 //根级部门
List<UserDTO> list = null ; List<UserDTO> list = null ;
WxEnterpriseQwDTO wxInfo = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(wxInfo.getWxSecurityType()==4) { if(qwDTO.getWxSecurityType()==4) {
list = this.qywxUserApiService.listDepartmentUser(wxInfo.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ; list = this.qywxUserApiService.listDepartmentUser(qwDTO.getThirdCorpid(), config.getWxSuiteid(), dataId, 1) ;
logger.info("从(第三方)获取通讯录={}",JSON.toJSONString(list)) ; logger.info("从(第三方)获取通讯录={}",JSON.toJSONString(list)) ;
}else { }else {
list = this.qywxUserApiService.listSelfDepartmentUser(wxInfo.getDkCorpid(), secretSetting.getSecretVal(), dataId, 1); list = this.qywxUserApiService.listSelfDepartmentUser(qwDTO.getDkCorpid(), secretSetting.getSecretVal(), dataId, 1,qwDTO.getUrlHost());
logger.info("从(代开)获取通讯录={}",JSON.toJSONString(list)) ; logger.info("从(代开)获取通讯录={}",JSON.toJSONString(list)) ;
} }
if (null == list) { if (null == list) {
......
...@@ -74,6 +74,7 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation { ...@@ -74,6 +74,7 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
dkWxUserId = staff.getWxOpenUseId(); dkWxUserId = staff.getWxOpenUseId();
} }
List<String> selfUserIdList = memberUnionidRelatedApiService.listSelfExterialList(wxEnterpriseId, dkWxUserId); List<String> selfUserIdList = memberUnionidRelatedApiService.listSelfExterialList(wxEnterpriseId, dkWxUserId);
List<String> delUserIdList = selfUserIdList ;
logger.info("selfUserIdList={}", JSONObject.toJSONString(selfUserIdList)); logger.info("selfUserIdList={}", JSONObject.toJSONString(selfUserIdList));
if (CollectionUtils.isEmpty(selfUserIdList)) { if (CollectionUtils.isEmpty(selfUserIdList)) {
logger.info("自建应用调用第三方接口进入重试"); logger.info("自建应用调用第三方接口进入重试");
...@@ -87,26 +88,30 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation { ...@@ -87,26 +88,30 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
reason = "该用户没有外部联系人"; reason = "该用户没有外部联系人";
return; return;
} }
//第三方服务商的外部联系人
String wxUserId3th = staff.getWxUserId() ; String wxUserId3th = staff.getWxUserId() ;
if(qwDTO.needOpenUserId3th()) { if(qwDTO.needOpenUserId3th()) {
wxUserId3th = staff.getWxOpenUseId() ; wxUserId3th = staff.getWxOpenUseId() ;
} }
List<String> userIdList = memberUnionidRelatedApiService.listExterialList(wxEnterpriseId, wxUserId3th); List<String> userIdList = null ;
if (CollectionUtils.isEmpty(selfUserIdList)) { if(!qwDTO.isSelf()) {
dealFlag = tryAgainToMq(dataPre); //第三方服务商的外部联系人
reason = "重试次数过多"; userIdList = memberUnionidRelatedApiService.listExterialList(wxEnterpriseId, wxUserId3th);
logger.info("第三方服务商外部联系人调用失败进入重试:{}", dataPre.getDataId()); delUserIdList = userIdList ;
return; if (CollectionUtils.isEmpty(selfUserIdList)) {
} dealFlag = tryAgainToMq(dataPre);
if (CollectionUtils.isEmpty(userIdList)) { reason = "重试次数过多";
logger.info("该用户无第三方外部联系人:{}", JSONObject.toJSONString(dataPre)); logger.info("第三方服务商外部联系人调用失败进入重试:{}", dataPre.getDataId());
dealFlag = false; return;
reason = "该用户没有外部联系人"; }
return; if (CollectionUtils.isEmpty(userIdList)) {
logger.info("该用户无第三方外部联系人:{}", JSONObject.toJSONString(dataPre));
dealFlag = false;
reason = "该用户没有外部联系人";
return;
}
} }
//清理外部联系人 //清理外部联系人
memberUnionidRelatedApiService.cleanNoExsitFriendNew(wxEnterpriseId, staffId, userIdList); memberUnionidRelatedApiService.cleanNoExsitFriendNew(wxEnterpriseId, staffId, delUserIdList);
//写入外部联系人的处理队列 //写入外部联系人的处理队列
List<TabHaobanPreDealLog> dealLogList = new ArrayList<>(); List<TabHaobanPreDealLog> dealLogList = new ArrayList<>();
for (String externalUserId : selfUserIdList) { for (String externalUserId : selfUserIdList) {
...@@ -122,21 +127,23 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation { ...@@ -122,21 +127,23 @@ public class FriendClerkSyncNewOperation implements BaseSyncOperation {
} }
preDealService.insert(dealLogList); preDealService.insert(dealLogList);
//写入外部联系人的处理队列 if(!qwDTO.isSelf()) {
List<TabHaobanPreDealLog> thirddealLogList = new ArrayList<>(); //写入外部联系人的处理队列
for (String externalUserId : userIdList) { List<TabHaobanPreDealLog> thirddealLogList = new ArrayList<>();
TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog(); for (String externalUserId : userIdList) {
dealLog.setDataId(externalUserId + "###" + wxUserId3th); TabHaobanPreDealLog dealLog = new TabHaobanPreDealLog();
dealLog.setpDataId(staffId); dealLog.setDataId(externalUserId + "###" + wxUserId3th);
dealLog.setDataType(PreDealTypeEnum.friend.getVal()); dealLog.setpDataId(staffId);
dealLog.setStatusFlag(0); dealLog.setDataType(PreDealTypeEnum.friend.getVal());
dealLog.setTaskId(dataPre.getTaskId()); dealLog.setStatusFlag(0);
dealLog.setDataContent(externalUserId); dealLog.setTaskId(dataPre.getTaskId());
dealLog.setWxEnterpriseId(wxEnterpriseId); dealLog.setDataContent(externalUserId);
thirddealLogList.add(dealLog); dealLog.setWxEnterpriseId(wxEnterpriseId);
thirddealLogList.add(dealLog);
}
preDealService.insert(thirddealLogList);
} }
preDealService.insert(thirddealLogList);
//成功更新状态 //成功更新状态
dealSuccess(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), dataPre.getWxEnterpriseId()); dealSuccess(dealParamMqDTO.getTaskId(), dealParamMqDTO.getData(), dataPre.getEnterpriseId(), dataPre.getWxEnterpriseId());
} catch (Exception e) { } catch (Exception e) {
......
...@@ -8,6 +8,7 @@ import com.esotericsoftware.minlog.Log; ...@@ -8,6 +8,7 @@ import com.esotericsoftware.minlog.Log;
import com.gic.commons.util.GICMQClientUtil; import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.manage.api.dto.DealParamMqDTO; import com.gic.haoban.manage.api.dto.DealParamMqDTO;
import com.gic.haoban.manage.api.dto.ExternalUserDTO; import com.gic.haoban.manage.api.dto.ExternalUserDTO;
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;
...@@ -16,10 +17,12 @@ import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog; ...@@ -16,10 +17,12 @@ import com.gic.haoban.manage.service.entity.TabHaobanPreDealLog;
import com.gic.haoban.manage.service.exception.WxApiLimitException; import com.gic.haoban.manage.service.exception.WxApiLimitException;
import com.gic.haoban.manage.service.service.PreDealService; import com.gic.haoban.manage.service.service.PreDealService;
import com.gic.haoban.manage.service.service.SyncTaskService; import com.gic.haoban.manage.service.service.SyncTaskService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.task.BaseSyncOperation; import com.gic.haoban.manage.service.task.BaseSyncOperation;
import com.gic.mq.sdk.GicMQClient; import com.gic.mq.sdk.GicMQClient;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -46,6 +49,8 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation { ...@@ -46,6 +49,8 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
private SyncTaskService syncTaskService; private SyncTaskService syncTaskService;
@Autowired @Autowired
private FriendClerkSyncNewOperation friendClerkSyncNewOperation; private FriendClerkSyncNewOperation friendClerkSyncNewOperation;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
private static final String TRY_AGAIN = "haoban_fresh_wx_friend_again_"; private static final String TRY_AGAIN = "haoban_fresh_wx_friend_again_";
...@@ -77,6 +82,17 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation { ...@@ -77,6 +82,17 @@ public class SelfFriendSyncNewOperation implements BaseSyncOperation {
String str = staffId + "_" + externalUserDTO.getName() + "_" + externalUserDTO.getAddCreateTime() ; String str = staffId + "_" + externalUserDTO.getName() + "_" + externalUserDTO.getAddCreateTime() ;
String relationKey = SecureUtil.md5(str); String relationKey = SecureUtil.md5(str);
logger.info("生成代开发relationKey={},staff={},{}",relationKey,staffId,str); logger.info("生成代开发relationKey={},staff={},{}",relationKey,staffId,str);
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
externalUserDTO.setSelfExternalUserId(externalUserDTO.getExternalUserId());
String ret = this.memberUnionidRelatedApiService.dealMergeForReflsh(externalUserDTO, wxEnterpriseId, staffId) ;
if (StringUtils.isNotBlank(ret)) {
logger.info("好友创建失败:{},{}", ret, JSONObject.toJSONString(externalUserDTO));
dealFlag = false;
reason = ret + ":" + relationKey;
return;
}
}
//更新状态 //更新状态
this.preDealService.updateFriendStatusByDataId(taskId, dataPre.getDataId(), PreDealStatusEnum.computed.getVal(), reason, json.toJSONString(), relationKey , PreDealTypeEnum.self_friend.getVal()); this.preDealService.updateFriendStatusByDataId(taskId, dataPre.getDataId(), PreDealStatusEnum.computed.getVal(), reason, json.toJSONString(), relationKey , PreDealTypeEnum.self_friend.getVal());
dealSuccess(taskId, dataPre.getDataId(), null, wxEnterpriseId); dealSuccess(taskId, dataPre.getDataId(), null, wxEnterpriseId);
......
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
<result column="status_flag" jdbcType="INTEGER" property="statusFlag" /> <result column="status_flag" jdbcType="INTEGER" property="statusFlag" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="agent_name" property="agentName" />
<result column="agent_id" property="agentId" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
secret_id, wx_enterprise_id, secret_name, secret_val, enterprise_id, secret_type, secret_id, wx_enterprise_id, secret_name, secret_val, enterprise_id, secret_type,
check_flag, status_flag, create_time, update_time check_flag, status_flag, create_time, update_time,agent_name,agent_id
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select select
...@@ -28,11 +30,11 @@ ...@@ -28,11 +30,11 @@
insert into tab_haoban_secret_setting (secret_id, wx_enterprise_id, secret_name, insert into tab_haoban_secret_setting (secret_id, wx_enterprise_id, secret_name,
secret_val, enterprise_id, secret_type, secret_val, enterprise_id, secret_type,
check_flag, status_flag, create_time, check_flag, status_flag, create_time,
update_time) update_time,agent_name,agent_id)
values (#{secretId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{secretName,jdbcType=VARCHAR}, values (#{secretId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{secretName,jdbcType=VARCHAR},
#{secretVal,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, #{secretType,jdbcType=INTEGER}, #{secretVal,jdbcType=VARCHAR}, #{enterpriseId,jdbcType=VARCHAR}, #{secretType,jdbcType=INTEGER},
#{checkFlag,jdbcType=INTEGER}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{checkFlag,jdbcType=INTEGER}, #{statusFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}) #{updateTime,jdbcType=TIMESTAMP}),#{agentName} , #{agentId}
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabSecretSetting"> <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabSecretSetting">
...@@ -65,6 +67,12 @@ ...@@ -65,6 +67,12 @@
<if test="updateTime != null"> <if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
</if> </if>
<if test="agentName != null">
agent_name = #{agentName},
</if>
<if test="agentId != null">
agent_id = #{agentId},
</if>
</set> </set>
where secret_id = #{secretId,jdbcType=VARCHAR} where secret_id = #{secretId,jdbcType=VARCHAR}
</update> </update>
......
...@@ -120,6 +120,9 @@ ...@@ -120,6 +120,9 @@
<if test="qrCode != null"> <if test="qrCode != null">
qr_code, qr_code,
</if> </if>
<if test="openConcatFlag != null">
open_concat_flag,
</if>
<if test="addNum != null"> <if test="addNum != null">
add_num, add_num,
</if> </if>
...@@ -188,6 +191,9 @@ ...@@ -188,6 +191,9 @@
<if test="qrCode != null"> <if test="qrCode != null">
#{qrCode}, #{qrCode},
</if> </if>
<if test="openConcatFlag != null">
#{openConcatFlag},
</if>
<if test="addNum != null"> <if test="addNum != null">
#{addNum} #{addNum}
</if> </if>
......
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
<result column="auto_active_flag" property="autoActiveFlag" jdbcType="INTEGER"/> <result column="auto_active_flag" property="autoActiveFlag" jdbcType="INTEGER"/>
<result column="wx_corpid" property="wxCorpid"/> <result column="wx_corpid" property="wxCorpid"/>
<result column="open_corpid" property="openCorpid"/> <result column="open_corpid" property="openCorpid"/>
<result column="wxa_appid" property="wxaAppid" />
<result column="url_host" property="urlHost"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -50,7 +52,7 @@ ...@@ -50,7 +52,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 , wx_corpid , open_corpid , auto_active_flag ,member_secret,contact_secret,agree_external_userid_flag,agree_external_userid_time,external_flag,userid_flag ,wx_security_type , wx_corpid , open_corpid , auto_active_flag , wxa_appid , url_host
</sql> </sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
...@@ -58,7 +60,14 @@ ...@@ -58,7 +60,14 @@
from tab_haoban_wx_enterprise from tab_haoban_wx_enterprise
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR} where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</select> </select>
<select id="selectByWxaAppid" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_wx_enterprise
where wxa_appid = #{appid} and wx_security_type = 5
</select>
<insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise"> <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise">
insert into tab_haoban_wx_enterprise insert into tab_haoban_wx_enterprise
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
...@@ -503,7 +512,6 @@ ...@@ -503,7 +512,6 @@
from tab_haoban_wx_enterprise_related a from tab_haoban_wx_enterprise_related a
left join tab_haoban_wx_enterprise b on a.wx_enterprise_id = b.wx_enterprise_id left join tab_haoban_wx_enterprise b on a.wx_enterprise_id = b.wx_enterprise_id
where a.status_flag = 1 and b.status_flag = 1 where a.status_flag = 1 and b.status_flag = 1
group by a.enterprise_id
</select> </select>
<select id="queryWxEnterpriseByEnterpriseId" resultType="java.lang.String"> <select id="queryWxEnterpriseByEnterpriseId" resultType="java.lang.String">
......
...@@ -85,12 +85,6 @@ public class DealSyncTest { ...@@ -85,12 +85,6 @@ public class DealSyncTest {
@Test @Test
public void test3() {
List<DepartmentDTO> department = qywxDepartmentApiService.listSelfDepartment("wweac4ef962720aa12", "GFu4FwkfcGFPue-qinB7ThEU4wR2SadbBH1yT5sLDzs", null);
System.out.println(JSONObject.toJSONString(department));
}
@Test
public void test4() { public void test4() {
String s = ""; String s = "";
memberUnionidRelatedApiService.dealQywxExternalUser(s); memberUnionidRelatedApiService.dealQywxExternalUser(s);
......
...@@ -43,6 +43,7 @@ import com.gic.haoban.manage.api.dto.HaobanUserDTO; ...@@ -43,6 +43,7 @@ import com.gic.haoban.manage.api.dto.HaobanUserDTO;
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.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.service.HaobanUserApiService; import com.gic.haoban.manage.api.service.HaobanUserApiService;
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;
...@@ -330,7 +331,10 @@ public class LoginController extends WebBaseController { ...@@ -330,7 +331,10 @@ public class LoginController extends WebBaseController {
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,2); WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,2);
if (null == application) { if (null == application) {
logger.info("登录企业应用 没授权!gicEnterpriseId:{}", gicEnterpriseId); logger.info("登录企业应用 没授权!gicEnterpriseId:{}", gicEnterpriseId);
return "1004"; WxEnterpriseQwDTO qw = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(!qw.isSelf()) {
return "1004";
}
} }
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (null == enterprise) { if (null == enterprise) {
......
...@@ -94,22 +94,6 @@ public class TestController extends WebBaseController { ...@@ -94,22 +94,6 @@ public class TestController extends WebBaseController {
return this.resultResponse(HaoBanErrCode.ERR_0,this.qwFriendApiService.getCallTimes(wxEnterpriseId)); return this.resultResponse(HaoBanErrCode.ERR_0,this.qwFriendApiService.getCallTimes(wxEnterpriseId));
} }
@RequestMapping("/send-message-test")
public HaobanResponse testSendMessage(QywxXcxSendMessageQo qo) {
QywxXcxSendMessageDTO messageDTO = EntityUtil.changeEntityByOrika(QywxXcxSendMessageDTO.class, qo);
ArrayList<String> list = new ArrayList<>();
list.add(qo.getUserId());
messageDTO.setUserIds(list);
boolean b = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
"ww2c34dc56739bb105", messageDTO);
if (b) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
return resultResponse(HaoBanErrCode.ERR_0);
}
}
@RequestMapping("/test-dubbo") @RequestMapping("/test-dubbo")
public HaobanResponse dubbo(@RequestParam(defaultValue = "2000") Integer n, @RequestParam(defaultValue = "100") String t) { public HaobanResponse dubbo(@RequestParam(defaultValue = "2000") Integer n, @RequestParam(defaultValue = "100") String t) {
......
...@@ -163,6 +163,9 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -163,6 +163,9 @@ public class WxEnterpriseController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_10012); return resultResponse(HaoBanErrCode.ERR_10012);
} }
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ; WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
if(qwDTO.isSelf()) {
return this.fail("自建应用不能刷新");
}
QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(qwDTO.getThirdCorpid(), config.getWxSuiteid()); QywxCorpInfoDTO dto = qywxTokenManageService.getCorpInfo(qwDTO.getThirdCorpid(), config.getWxSuiteid());
if (dto == null) { if (dto == null) {
return resultResponse(HaoBanErrCode.ERR_10012); return resultResponse(HaoBanErrCode.ERR_10012);
...@@ -205,9 +208,12 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -205,9 +208,12 @@ public class WxEnterpriseController extends WebBaseController {
if(wxType==4) { if(wxType==4) {
desc = "(第三方明文,代开密文)" ; desc = "(第三方明文,代开密文)" ;
} }
if(wxType==5) {
desc = " (自建) " ;
}
int newType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ; int newType = this.wxEnterpriseApiService.calcSecretType(wxEnterpriseId) ;
String diff = ""; String diff = "";
if(null != wxType && wxType.intValue() != newType) { if(null != wxType && wxType.intValue() != newType && wxType != 5) {
diff = "*"; diff = "*";
} }
return Arrays.asList(wxEnterpriseDTO.getWxCorpid(),wxEnterpriseDTO.getOpenCorpid()).stream().filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.joining(" / ")) + desc + diff; return Arrays.asList(wxEnterpriseDTO.getWxCorpid(),wxEnterpriseDTO.getOpenCorpid()).stream().filter(str -> StringUtils.isNotBlank(str)).collect(Collectors.joining(" / ")) + desc + diff;
...@@ -314,11 +320,18 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -314,11 +320,18 @@ 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.CUSTOMIZED_APP.getVal()))) { // 如果是第三方校验待开发
return resultResponse(HaoBanErrCode.ERR_1, true); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
} else { if(qwDTO.isSelf()) {
return resultResponse(HaoBanErrCode.ERR_1, false); if ((secretTypeList.contains(SecretTypeEnum.SELF_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
}else {
if ((secretTypeList.contains(SecretTypeEnum.CUSTOMIZED_APP.getVal()))) {
return resultResponse(HaoBanErrCode.ERR_1, true);
}
} }
return resultResponse(HaoBanErrCode.ERR_1, false);
} }
/** /**
...@@ -340,16 +353,16 @@ public class WxEnterpriseController extends WebBaseController { ...@@ -340,16 +353,16 @@ public class WxEnterpriseController extends WebBaseController {
} }
wxSecretKey = wxSecretKey.trim(); wxSecretKey = wxSecretKey.trim();
String token = this.qywxCorpApiService.getToken(qwDTO.getDkCorpid(), wxSecretKey); String token = this.qywxCorpApiService.getToken(qwDTO.getDkCorpid(), wxSecretKey);
logger.info("查询token", token) ; logger.info("查询token={}", token) ;
if(StringUtils.isEmpty(token) || token.length() < 10) { if(StringUtils.isEmpty(token) || token.length() < 10) {
return this.fail("请确认secret是否正确") ; return this.fail("请确认secret是否正确") ;
} }
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CONTACT_CUSTOMER.getVal(), null); SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.SELF_APP.getVal(), null);
if (null == secretSetting) { if (null == secretSetting) {
secretSetting = new SecretSettingDTO(); secretSetting = new SecretSettingDTO();
} }
secretSetting.setSecretType(SecretTypeEnum.CONTACT_CUSTOMER.getVal()); secretSetting.setSecretType(SecretTypeEnum.SELF_APP.getVal());
secretSetting.setSecretName(SecretTypeEnum.CONTACT_CUSTOMER.getName()); secretSetting.setSecretName(SecretTypeEnum.SELF_APP.getName());
secretSetting.setWxEnterpriseId(wxEnterpriseId); secretSetting.setWxEnterpriseId(wxEnterpriseId);
secretSetting.setEnterpriseId("-1"); secretSetting.setEnterpriseId("-1");
secretSetting.setSecretVal(wxSecretKey); secretSetting.setSecretVal(wxSecretKey);
......
...@@ -144,9 +144,22 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -144,9 +144,22 @@ public class WxEnterpriseInfoController extends WebBaseController {
*/ */
@RequestMapping(value = "get-info-by-code", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "get-info-by-code", method = {RequestMethod.GET, RequestMethod.POST})
@IgnoreLogin @IgnoreLogin
public HaobanResponse getInfoByCode(String code) { public HaobanResponse getInfoByCode(String code , String appid) {
logger.info("code:{}", code); logger.info("code:{}", code);
String userDTOJson = qywxCorpApiService.getCodeSession(config.getWxSuiteid(), code); String userDTOJson = null ;
String wxEnterpriseId = null ;
if(StringUtils.isNotEmpty(appid)) {
WxEnterpriseDTO wxEnterprise = this.wxEnterpriseApiService.selectByWxaAppid(appid) ;
if(null != wxEnterprise) {
wxEnterpriseId = wxEnterprise.getWxEnterpriseId() ;
}
}
if(null != wxEnterpriseId) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId) ;
userDTOJson = qywxUserApiService.getUserByCode(qwDTO.getDkCorpid(), qwDTO.getSelfSecret(), code , qwDTO.getUrlHost());
}else {
userDTOJson = qywxCorpApiService.getCodeSession(config.getWxSuiteid(), code);
}
// {"errcode":0,"corpid":"wweac4ef962720aa12","session_key":"oNKOu4tDcnTWdj4wOg75YQ==","errmsg":"ok", // {"errcode":0,"corpid":"wweac4ef962720aa12","session_key":"oNKOu4tDcnTWdj4wOg75YQ==","errmsg":"ok",
// "open_userid":"wo59NLDQAAxeJ-Nr7_vwkZVc7QOG73PQ","userid":"xugaohua","deviceid":"0BB1D1FA-C5A2-4BDD-80A2-33B6BB230F8A"} // "open_userid":"wo59NLDQAAxeJ-Nr7_vwkZVc7QOG73PQ","userid":"xugaohua","deviceid":"0BB1D1FA-C5A2-4BDD-80A2-33B6BB230F8A"}
logger.info("好办登录={}", userDTOJson); logger.info("好办登录={}", userDTOJson);
...@@ -241,9 +254,14 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -241,9 +254,14 @@ public class WxEnterpriseInfoController extends WebBaseController {
staffApiService.activeStaff(staffId); staffApiService.activeStaff(staffId);
} }
String wxEnterpriseId = loginStaff.getWxEnterpriseId(); wxEnterpriseId = loginStaff.getWxEnterpriseId();
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId); WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId);
String accesstoken = qywxCorpApiService.getCorpAccessToken(qwDTO.getThirdCorpid(), config.getWxSuiteid()); String accesstoken = null ;
if(qwDTO.isSelf()) {
accesstoken = qywxCorpApiService.getCorpAccessToken(qwDTO.getThirdCorpid(), config.getWxSuiteid());
}else {
accesstoken = qywxCorpApiService.getToken(qwDTO.getThirdCorpid(), qwDTO.getSelfSecret()) ;
}
WellDoneLoginInfoVO wellDoneLoginInfoVo = new WellDoneLoginInfoVO(); WellDoneLoginInfoVO wellDoneLoginInfoVo = new WellDoneLoginInfoVO();
wellDoneLoginInfoVo.setAccessToken(accesstoken); wellDoneLoginInfoVo.setAccessToken(accesstoken);
wellDoneLoginInfoVo.setStaffId(staffId); wellDoneLoginInfoVo.setStaffId(staffId);
...@@ -381,7 +399,7 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -381,7 +399,7 @@ public class WxEnterpriseInfoController extends WebBaseController {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseApiService.getQwInfo(wxEnterpriseId); 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(wxEnterpriseId, qwDTO.getMemberCorpid(), qo.getCode(), qo.getGicEnterpriseId()); user = getUserByCode(wxEnterpriseId, qwDTO.getMemberCorpid(), qo.getCode(), qo.getGicEnterpriseId(),qwDTO);
if (user == null) { if (user == null) {
logger.info("登录失败,从微信获取用户信息失败"); logger.info("登录失败,从微信获取用户信息失败");
return resultResponse(HaoBanErrCode.ERR_6); return resultResponse(HaoBanErrCode.ERR_6);
...@@ -450,13 +468,13 @@ public class WxEnterpriseInfoController extends WebBaseController { ...@@ -450,13 +468,13 @@ public class WxEnterpriseInfoController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, user); return resultResponse(HaoBanErrCode.ERR_1, user);
} }
private MemberLoginQo getUserByCode(String wxEnterpriseId, String corpid, String code, String enterpriseId) { private MemberLoginQo getUserByCode(String wxEnterpriseId, String corpid, String code, String enterpriseId,WxEnterpriseQwDTO qwDTO) {
SecretSettingDTO secretSetting = wxEnterpriseApiService.getSecretSetting(wxEnterpriseId, 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没有配置{},{}", wxEnterpriseId, enterpriseId); logger.info("MEMBER_WAPPsecret没有配置{},{}", wxEnterpriseId, enterpriseId);
return null; return null;
} }
String userDTOJson = qywxUserApiService.getUserByCode(corpid, secretSetting.getSecretVal(), code); String userDTOJson = qywxUserApiService.getUserByCode(corpid, secretSetting.getSecretVal(), code ,qwDTO.getUrlHost());
logger.info("会员微信登录信息=============>{}", userDTOJson); logger.info("会员微信登录信息=============>{}", userDTOJson);
return JSON.parseObject(userDTOJson, MemberLoginQo.class); return JSON.parseObject(userDTOJson, MemberLoginQo.class);
} }
......
...@@ -43,7 +43,6 @@ import com.gic.commons.util.EntityUtil; ...@@ -43,7 +43,6 @@ import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum; import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.EnterpriseUsingPermissionDto;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreSearchDTO; import com.gic.enterprise.api.dto.StoreSearchDTO;
import com.gic.enterprise.api.dto.enterprise.EnterpriseUsingStatusDTO; import com.gic.enterprise.api.dto.enterprise.EnterpriseUsingStatusDTO;
...@@ -112,8 +111,6 @@ import com.gic.haoban.manage.web.vo.notify.CustomerFriendMemberVO; ...@@ -112,8 +111,6 @@ import com.gic.haoban.manage.web.vo.notify.CustomerFriendMemberVO;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
@RestController @RestController
public class WxStaffController extends WebBaseController { public class WxStaffController extends WebBaseController {
...@@ -858,7 +855,7 @@ public class WxStaffController extends WebBaseController { ...@@ -858,7 +855,7 @@ public class WxStaffController extends WebBaseController {
if (staffDTO != null) { if (staffDTO != null) {
String phoneNumber = staffDTO.getPhoneNumber(); String phoneNumber = staffDTO.getPhoneNumber();
if (StringUtils.isBlank(phoneNumber)) { if (StringUtils.isBlank(phoneNumber)) {
logger.error("手机号为空,不进行查询,staffId:{}", staffId); logger.error("成员表手机号为空,不进行查询,staffId:{}", staffId);
return ret; return ret;
} }
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList,
...@@ -1435,8 +1432,12 @@ public class WxStaffController extends WebBaseController { ...@@ -1435,8 +1432,12 @@ public class WxStaffController extends WebBaseController {
if (qwDTO.needOpenUserId3th()) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId(); wxUserId = staffDTO.getWxOpenUseId();
} }
String openid = qywxUserApiService.getSelfOpenIdByUserId(qwDTO.getThirdCorpid(), config.getWxSuiteid(), String secret = config.getWxSuiteid();
wxUserId); if (qwDTO.isSelf()) {
secret = qwDTO.getSelfSecret();
}
String openid = qywxUserApiService.getSelfOpenIdByUserId(qwDTO.getThirdCorpid(), secret,
wxUserId,qwDTO.isSelf(),qwDTO.getUrlHost());
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());
......
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