Parcourir la source

🐛 #1426 修复多公众号管理的两个问题

1、允许动态更新公众号的配置,原有逻辑:更新配置时会报“该公众号标识已存在,请更换其他标识!”;
2、多公众号的消息路由,原有逻辑问题:handler里WxMpConfigStorageHolder不能获取到appid,意味着用的wxmpservice不对,只会走默认的,已测试存在该问题
dev1
S il y a 5 ans
committed by GitHub
Parent
révision
0a99706b74
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: 4AEE18F83AFDEB23
2 fichiers modifiés avec 11 ajouts et 3 suppressions
  1. +11
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java
  2. +0
    -3
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java

+ 11
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpMessageRouter.java Voir le fichier

@@ -152,6 +152,13 @@ public class WxMpMessageRouter {
return route(wxMessage, context, null);
}

/**
* 处理不同appid微信消息
*/
public WxMpXmlOutMessage route(final String appid, final WxMpXmlMessage wxMessage, final Map<String, Object> context) {
return route(wxMessage, context, this.wxMpService.switchoverTo(appid));
}

/**
* 处理微信消息.
*/
@@ -228,6 +235,10 @@ public class WxMpMessageRouter {
return this.route(wxMessage, new HashMap<String, Object>(2));
}

public WxMpXmlOutMessage route(String appid, final WxMpXmlMessage wxMessage) {
return this.route(appid, wxMessage, new HashMap<String, Object>(2));
}

private boolean isMsgDuplicated(WxMpXmlMessage wxMessage) {
StringBuilder messageId = new StringBuilder();
if (wxMessage.getMsgId() == null) {


+ 0
- 3
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java Voir le fichier

@@ -399,9 +399,6 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
@Override
public void addConfigStorage(String mpId, WxMpConfigStorage configStorages) {
synchronized (this) {
if (this.configStorageMap.containsKey(mpId)) {
throw new RuntimeException("该公众号标识已存在,请更换其他标识!");
}
this.configStorageMap.put(mpId, configStorages);
}
}


Chargement…
Annuler
Enregistrer