mirror of
https://gitee.com/myxzgzs/boyue-vue-pro.git
synced 2025-08-08 00:12:46 +08:00
feat:【MP 公众号】兼容无 API 权限的个人公众号场景
This commit is contained in:
parent
d8e1610495
commit
563985dcfc
@ -1,10 +1,13 @@
|
||||
package cn.iocoder.yudao.module.mp.service.handler.user;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.module.mp.framework.mp.core.context.MpContextHolder;
|
||||
import cn.iocoder.yudao.module.mp.service.message.MpAutoReplyService;
|
||||
import cn.iocoder.yudao.module.mp.service.user.MpUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
@ -13,7 +16,6 @@ import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -40,6 +42,13 @@ public class SubscribeHandler implements WxMpMessageHandler {
|
||||
wxMpUser = weixinService.getUserService().userInfo(wxMessage.getFromUser());
|
||||
} catch (WxErrorException e) {
|
||||
log.error("[handle][粉丝({})] 获取粉丝信息失败!", wxMessage.getFromUser(), e);
|
||||
// 特殊情况(个人账号,无接口权限):https://t.zsxq.com/cLFq5
|
||||
if (ObjUtil.equal(e.getError().getErrorCode(), WxMpErrorMsgEnum.CODE_48001)) {
|
||||
wxMpUser = new WxMpUser();
|
||||
wxMpUser.setOpenId(wxMessage.getFromUser());
|
||||
wxMpUser.setSubscribe(true);
|
||||
wxMpUser.setSubscribeTime(System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
// 第二步,保存粉丝信息
|
||||
|
Loading…
x
Reference in New Issue
Block a user