|
@@ -175,21 +175,20 @@ public class WxServiceImpl implements WxService {
|
|
|
Set<String> openIdSet = new HashSet<>();
|
|
|
for(Long userId:list) {
|
|
|
try {
|
|
|
- String openId = wxMapper
|
|
|
- .selectOne(Wrappers.<UsUserWechat>lambdaQuery().eq(UsUserWechat::getUserId, userId))
|
|
|
- .getOpenid();
|
|
|
- if(!openIdSet.add(openId)) {
|
|
|
- log.warn("下发微信消息,接收人userId:{}的openId重复",sendMsgReq.getToUserId());
|
|
|
+ UsUserWechat uUsUserWechat = wxMapper
|
|
|
+ .selectOne(Wrappers.<UsUserWechat>lambdaQuery().eq(UsUserWechat::getUserId, userId));
|
|
|
+ if(uUsUserWechat==null||uUsUserWechat.getOpenid()==null) {
|
|
|
+ log.warn("下发微信消息,接收人userId:{}的openId为空", sendMsgReq.getToUserId());
|
|
|
continue;
|
|
|
}
|
|
|
- if (null != openId && !openId.isEmpty()) {
|
|
|
- AppEntry appEntry = AppEntry.builder().appId(appid).secret(appsecret).build();
|
|
|
- TemplateEntry tpl = TemplateEntry.builder().template_id(templateId).touser(openId).page(page)
|
|
|
- .miniprogram_state(miniprogramState).data(dataMap).build();
|
|
|
- PushWxMessage.sendMessage(appEntry, tpl);
|
|
|
- } else {
|
|
|
- log.error("下发微信消息,接收人userId:{}的openId为空", sendMsgReq.getToUserId());
|
|
|
+ if(!openIdSet.add(uUsUserWechat.getOpenid())) {
|
|
|
+ log.warn("下发微信消息,接收人userId:{}的openId重复",sendMsgReq.getToUserId());
|
|
|
+ continue;
|
|
|
}
|
|
|
+ AppEntry appEntry = AppEntry.builder().appId(appid).secret(appsecret).build();
|
|
|
+ TemplateEntry tpl = TemplateEntry.builder().template_id(templateId).touser(uUsUserWechat.getOpenid()).page(page)
|
|
|
+ .miniprogram_state(miniprogramState).data(dataMap).build();
|
|
|
+ PushWxMessage.sendMessage(appEntry, tpl);
|
|
|
} catch (Exception e) {
|
|
|
log.error("下发微信消息异常",e);
|
|
|
}
|