|
@ -84,6 +84,25 @@ public class OfficialAccountMessageUtil { |
|
|
//判断是否有openId
|
|
|
//判断是否有openId
|
|
|
if (CollectionUtil.isNotEmpty(openIdList)) { |
|
|
if (CollectionUtil.isNotEmpty(openIdList)) { |
|
|
openIdList.forEach(openid -> { |
|
|
openIdList.forEach(openid -> { |
|
|
|
|
|
//拼接访问路径
|
|
|
|
|
|
sendMsg(appId, secret, templateMessage); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 公众号发送订阅消息(传入openId) |
|
|
|
|
|
* @param templateMessages 消息 |
|
|
|
|
|
*/ |
|
|
|
|
|
public static void officialMessage(List<WxTemplateMessage> templateMessages, String appId, String secret) { |
|
|
|
|
|
//判断是否有openId
|
|
|
|
|
|
if (CollectionUtil.isEmpty(templateMessages)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
templateMessages.forEach(templateMessage -> sendMsg(appId, secret, templateMessage)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void sendMsg(String appId, String secret, WxTemplateMessage templateMessage) { |
|
|
//拼接访问路径
|
|
|
//拼接访问路径
|
|
|
String url = String.format(WxConstant.MESSAGE_TEMPLATE_SEND, WxCommonUtil.getAccessToken(appId, secret)); |
|
|
String url = String.format(WxConstant.MESSAGE_TEMPLATE_SEND, WxCommonUtil.getAccessToken(appId, secret)); |
|
|
//调用微信接口
|
|
|
//调用微信接口
|
|
@ -100,7 +119,5 @@ public class OfficialAccountMessageUtil { |
|
|
if (null != wxBaseEntity.getErrcode()) { |
|
|
if (null != wxBaseEntity.getErrcode()) { |
|
|
throw new BaseException(wxBaseEntity.getErrcode(), wxBaseEntity.getErrmsg()); |
|
|
throw new BaseException(wxBaseEntity.getErrcode(), wxBaseEntity.getErrmsg()); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|