Commit b5558721 by 徐高华

pendingid

parent b603ed9f
package com.gic.haoban.manage.api.service; package com.gic.haoban.manage.api.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.QwPendingIdDTO; import com.gic.haoban.manage.api.dto.QwPendingIdDTO;
...@@ -17,6 +18,20 @@ public interface QwFriendApiService { ...@@ -17,6 +18,20 @@ public interface QwFriendApiService {
/** /**
* *
* @Title: pendingCheck
* @Description: 校验商户能否获取pending
* @author xugh
* @param enterpriseId
* @param unionid
* @param openid
* @param wxaOpenid
* @return
* @throws
*/
public ServiceResponse<Map<String,String>> pendingIdCheck(String enterpriseId, String unionid, String openid, String wxaOpenid);
/**
*
* @Title: getPendingIdByUnionid * @Title: getPendingIdByUnionid
* @Description: 通过uniond获取好友id/pendingid * @Description: 通过uniond获取好友id/pendingid
* @author xugh * @author xugh
......
...@@ -2,7 +2,9 @@ package com.gic.haoban.manage.service.service.out.impl; ...@@ -2,7 +2,9 @@ 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.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -44,24 +46,63 @@ public class QwFriendApiServiceImpl implements QwFriendApiService { ...@@ -44,24 +46,63 @@ public class QwFriendApiServiceImpl implements QwFriendApiService {
private Config config; private Config config;
@Override @Override
public ServiceResponse<QwPendingIdDTO> getPendingIdByUnionid(String enterpriseId, String unionid, String openid) { public ServiceResponse<Map<String, String>> pendingIdCheck(String enterpriseId, String unionid, String openid,
String wxaOpenid) {
ServiceResponse<WxEnterpriseQwDTO> corpidResp = this.checkAndGetCorpid(enterpriseId);
if (!corpidResp.isSuccess()) {
return ServiceResponse.failure(corpidResp.getCode(), corpidResp.getMessage());
}
String suiteid = config.getWxSuiteid(); String suiteid = config.getWxSuiteid();
WxEnterpriseQwDTO qwDTO = corpidResp.getResult();
String corpid = qwDTO.getThirdCorpid();
ServiceResponse<PendingIdDTO> wxResp = this.qywxExternalUserService.unionidToExternalUserid(corpid, suiteid,
unionid, openid, 0);
Map<String, String> retMap = new HashMap<>();
StringBuilder sb = new StringBuilder();
String result = "";
String wxCode = "0";
String wxaCode = "0";
if (wxResp.isSuccess()) {
result = "ok";
} else {
result = wxResp.getCode();
wxCode = result;
}
retMap.put("wxCode", wxCode);
sb.append("服务号-").append(result).append(",");
ServiceResponse<PendingIdDTO> wxaResp = this.qywxExternalUserService.unionidToExternalUserid(corpid, suiteid,
unionid, wxaOpenid, 0);
if (wxaResp.isSuccess()) {
result = "ok";
} else {
result = wxResp.getCode();
wxaCode = result;
}
sb.append("小程序-").append(result);
retMap.put("remark", sb.toString());
retMap.put("wxaCode", wxaCode);
return ServiceResponse.success(retMap);
}
@Override
public ServiceResponse<QwPendingIdDTO> getPendingIdByUnionid(String enterpriseId, String unionid, String openid) {
ServiceResponse<WxEnterpriseQwDTO> corpidResp = this.checkAndGetCorpid(enterpriseId); ServiceResponse<WxEnterpriseQwDTO> corpidResp = this.checkAndGetCorpid(enterpriseId);
if (!corpidResp.isSuccess()) { if (!corpidResp.isSuccess()) {
return ServiceResponse.failure(corpidResp.getCode(), corpidResp.getMessage()); return ServiceResponse.failure(corpidResp.getCode(), corpidResp.getMessage());
} }
String suiteid = config.getWxSuiteid();
WxEnterpriseQwDTO qwDTO = corpidResp.getResult(); WxEnterpriseQwDTO qwDTO = corpidResp.getResult();
String wxEnterpriseId = qwDTO.getWxEnterpriseId(); String wxEnterpriseId = qwDTO.getWxEnterpriseId();
boolean isLimit = QwTimesUtils.isLimit(wxEnterpriseId, enterpriseId,QwInterfaceLimitEnum.GET_PENDING_ID); boolean isLimit = QwTimesUtils.isLimit(wxEnterpriseId, enterpriseId, QwInterfaceLimitEnum.GET_PENDING_ID);
if (isLimit) { if (isLimit) {
return ServiceResponse.failure(HaoBanErrCode.ERR_2000.getCode(), HaoBanErrCode.ERR_2000.getMsg()); return ServiceResponse.failure(HaoBanErrCode.ERR_2000.getCode(), HaoBanErrCode.ERR_2000.getMsg());
} }
String corpid = qwDTO.getThirdCorpid(); String corpid = qwDTO.getThirdCorpid();
ServiceResponse<PendingIdDTO> qwResp = this.qywxExternalUserService.unionidToExternalUserid(corpid, suiteid, ServiceResponse<PendingIdDTO> qwResp = this.qywxExternalUserService.unionidToExternalUserid(corpid, suiteid,
unionid, openid, 1); unionid, openid, 0);
QwTimesUtils.addTimes(wxEnterpriseId, QwInterfaceLimitEnum.GET_PENDING_ID); QwTimesUtils.addTimes(wxEnterpriseId, QwInterfaceLimitEnum.GET_PENDING_ID);
log.info("获取pendingid,参数={},返回={}", unionid, JSON.toJSONString(qwResp)); log.info("获取pendingid,参数={},{},返回={}", unionid, openid, JSON.toJSONString(qwResp));
if (!qwResp.isSuccess()) { if (!qwResp.isSuccess()) {
return ServiceResponse.failure(qwResp.getCode(), qwResp.getMessage()); return ServiceResponse.failure(qwResp.getCode(), qwResp.getMessage());
} }
......
...@@ -72,8 +72,8 @@ public class QwTimesUtils { ...@@ -72,8 +72,8 @@ public class QwTimesUtils {
private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum qwInterface, private static boolean timesCheck(int type, String cacheKey, QwInterfaceLimitEnum qwInterface,
String wxEnterpriseId, String enterpriseId, Date now, QwLimitTimesBO setTimeBO) { String wxEnterpriseId, String enterpriseId, Date now, QwLimitTimesBO setTimeBO) {
Integer doneTimes = RedisUtil.getCache(cacheKey, Integer.class); Integer doneTimes = RedisUtil.getCache(cacheKey, Integer.class);
logger.info("获取已调次数={},cacheKey={}", doneTimes, cacheKey); logger.info("type{}获取已调次数={},cacheKey={}", type, doneTimes == null ? 0 : doneTimes, cacheKey);
if (null == doneTimes) { if (null == doneTimes || doneTimes == 0) {
return false; return false;
} }
int setTimes = 0; int setTimes = 0;
......
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