Yangzw 10 ماه پیش
والد
کامیت
6439492eae

+ 1 - 0
feifan-module-system/feifan-module-system-api/src/main/java/cn/newfeifan/mall/module/system/enums/ErrorCodeConstants.java

@@ -176,5 +176,6 @@ public interface ErrorCodeConstants {
     ErrorCode WECHAT_MSG_TEMPLATE_REDIS_NOT_EXISTS = new ErrorCode(1_002_028_002, "我想消息模板缓存异常");
     ErrorCode CONFIG_NOT_EXISTS = new ErrorCode(1_002_028_003, "系统配置不存在");
     ErrorCode CONFIG_REDIS_NOT_EXISTS = new ErrorCode(1_002_028_004, "系统配置不存在");
+    ErrorCode AUTH_SOCIAL_USER_BIND_MAX = new ErrorCode(1_004_012_004, "此微信号已经到达绑定的上限了");
 
 }

+ 11 - 0
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/service/social/SocialUserServiceImpl.java

@@ -6,6 +6,7 @@ import cn.newfeifan.mall.framework.common.exception.ServiceException;
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
 import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.system.api.social.SocialUserApi;
 import cn.newfeifan.mall.module.system.api.social.dto.SocialUserBindReqDTO;
 import cn.newfeifan.mall.module.system.api.social.dto.SocialUserRespDTO;
 import cn.newfeifan.mall.module.system.controller.admin.socail.vo.user.SocialUserPageReqVO;
@@ -17,6 +18,7 @@ import cn.newfeifan.mall.module.system.enums.social.SocialTypeEnum;
 import com.alibaba.fastjson.JSONObject;
 import com.xingyuv.jushauth.model.AuthUser;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -55,6 +57,10 @@ public class SocialUserServiceImpl implements SocialUserService {
     @Resource
     private StringRedisTemplate stringRedisTemplate;
 
+    @Resource
+    @Lazy
+    private SocialUserApi socialUserApi;
+
     @Override
     public List<SocialUserDO> getSocialUserList(Long userId, Integer userType) {
         // 获得绑定
@@ -74,6 +80,11 @@ public class SocialUserServiceImpl implements SocialUserService {
                 reqDTO.getCode(), reqDTO.getState());
         Assert.notNull(socialUser, "社交用户不能为空");
 
+        //微信能绑定的账号上限校验
+        if(socialUserApi.wxBindIsMax(socialUser.getId())){
+            throw exception(AUTH_SOCIAL_USER_BIND_MAX);
+        }
+
         // 社交用户可能之前绑定过别的用户,需要进行解绑
 //        socialUserBindMapper.deleteByUserTypeAndSocialUserId(reqDTO.getUserType(), socialUser.getId());