Просмотр исходного кода

登录后获取用户信息的时候返回用户是否关注公众号

Yangzw 3 месяцев назад
Родитель
Сommit
2fadc6b252

+ 10 - 1
feifan-module-member/feifan-module-member-biz/src/main/java/cn/newfeifan/mall/module/member/service/user/MemberUserServiceImpl.java

@@ -25,7 +25,9 @@ import cn.newfeifan.mall.module.system.api.sms.SmsCodeApi;
 import cn.newfeifan.mall.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
 import cn.newfeifan.mall.module.system.api.social.SocialClientApi;
 import cn.newfeifan.mall.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO;
+import cn.newfeifan.mall.module.system.dal.dataobject.social.SocialUserBindDO;
 import cn.newfeifan.mall.module.system.dal.dataobject.social.SocialUserDO;
+import cn.newfeifan.mall.module.system.dal.mysql.social.SocialUserBindMapper;
 import cn.newfeifan.mall.module.system.dal.mysql.social.SocialUserMapper;
 import cn.newfeifan.mall.module.system.enums.sms.SmsSceneEnum;
 import cn.newfeifan.mall.module.system.service.user.AdminUserService;
@@ -86,6 +88,8 @@ public class MemberUserServiceImpl implements MemberUserService {
     @Resource
     private SocialUserMapper socialUserMapper;
     @Resource
+    private SocialUserBindMapper socialUserBindMapper;
+    @Resource
     private StringRedisTemplate stringRedisTemplate;
     @Value("${wx.mp.app-id}")
     private String appid;
@@ -474,7 +478,12 @@ public class MemberUserServiceImpl implements MemberUserService {
 
     @Override
     public Boolean getUserIsSubscribe(Long userId) {
-        SocialUserDO socialUserDO = socialUserMapper.selectOne(SocialUserDO::getCreator, getLoginUserId());
+        SocialUserBindDO socialUserBindDO = socialUserBindMapper.selectOne(SocialUserBindDO::getUserId, getLoginUserId());
+        // 如果没有存储用户的openid就直接返回false
+        if(socialUserBindDO == null){
+            return false;
+        }
+        SocialUserDO socialUserDO = socialUserMapper.selectOne(SocialUserDO::getId, socialUserBindDO.getSocialUserId());
         // 如果没有存储用户的openid就直接返回false
         if(socialUserDO == null){
             return false;