Selaa lähdekoodia

fix 微信登录

he2802 3 vuotta sitten
vanhempi
commit
82b882fc27

+ 8 - 5
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/WxLoginService.java

@@ -104,7 +104,7 @@ public class WxLoginService
         loginUser.setUser(user);
         Map<String,Object> map = new HashMap<>();
         map.put(Constants.TOKEN,wxTokenService.createToken(loginUser));
-        map.put("union_id",loginUser.getUser().getUnionId());
+        map.put("user_account",loginUser.getUser().getUserAccount());
         map.put("full_info",Validator.isEmpty(user.getIdCard())?false:true); //是否完善身份信息
         return map;
     }
@@ -215,10 +215,13 @@ public class WxLoginService
         JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
         String session_key = String.valueOf(jsonObject.get("session_key"));
         String openId = String.valueOf(jsonObject.get("openid"));
-        String unionId = String.valueOf(jsonObject.get("unionid"));
+        String unionId = null;
+        if(jsonObject.containsKey("unionid")){ //当没绑定开放平台
+            unionId = String.valueOf(jsonObject.get("unionid"));
+        }
         String phoneNumber = obtainWxPhone(loginBody.getIv(),loginBody.getEncryptedData(),session_key);
         if(Validator.isEmpty(phoneNumber)){
-            throw new CustomException("该微信没有绑定手机号码");
+            throw new CustomException("该微信没有绑定手机号码"+resultString);
         }
         User user = iUserService.getOne(new LambdaQueryWrapper<User>()
                 .eq(User::getTelphone,phoneNumber).last("limit 1"));
@@ -227,7 +230,7 @@ public class WxLoginService
             user.setUnionId(unionId);
             user.setLastLoginTime(DateUtils.getNowTime());
             user.setUpdateTime(DateUtils.getNowTime());
-            iUserService.save(user);
+            iUserService.updateById(user);
         }else{
             //手机匹配不上再匹配openid
             user = iUserService.getOne(new LambdaQueryWrapper<User>()
@@ -236,7 +239,7 @@ public class WxLoginService
             user.setUnionId(unionId);
             user.setUpdateTime(DateUtils.getNowTime());
             user.setLastLoginTime(DateUtils.getNowTime());
-            iUserService.save(user);
+            iUserService.updateById(user);
         }
         if(user==null){
             if(!register_small(openId,unionId,phoneNumber,loginBody.getInviteCode())){

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeServiceImpl.java

@@ -228,7 +228,7 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
         }
         if (bo.getStatus() == 0) {  //更新为无效
            ClassGradeVo oldGrade =  this.queryById(bo.getGradeId());
-           if(oldGrade.getStatus()==1){ 
+           if(oldGrade.getStatus()==1){
                ClassGradeUserQueryBo classGradeUserQueryBo = new ClassGradeUserQueryBo();
                classGradeUserQueryBo.setGradeId(bo.getGradeId());
                List<ClassGradeStudentVo> list = this.listGrade(classGradeUserQueryBo);