From 437d6b92859156411808accec38c2e51c383610b Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Wed, 17 Nov 2021 14:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/WechatController.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index e61fe8a3..067bf234 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -158,23 +158,31 @@ public class WechatController { highUserService.updateUser(user); } } else { - if (highUserService.findByPhone(phoneNoInfo.getPurePhoneNumber()) != null) { - throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.COMMON_ERROR, "手机号已被绑定,请更换后重新授权"); + // 根据手机号查询用户 + user = highUserService.findByPhone(phoneNoInfo.getPurePhoneNumber()); + if (user == null) { + user = new HighUser(); + user.setName("用户" + IDGenerator.nextId(5)); + user.setPhone(phoneNoInfo.getPurePhoneNumber()); + user.setRegTime(new Date()); + user.setGold(0); + user.setOpenId(session.getOpenid()); + user.setUnionId(session.getUnionid()); + user.setStatus(1); + // 用户信息完整状态 + // 0:完整 + // 1:需要填写用户信息 + // 2:需要填写手机号 + user.setInfoCompleteStatus(1); + highUserService.insertUser(user); + } else { + if (StringUtils.isBlank(user.getName())) { + user.setName("用户" + IDGenerator.nextId(5)); + } + user.setOpenId(session.getOpenid()); + user.setUnionId(session.getUnionid()); + highUserService.updateUser(user); } - user = new HighUser(); - user.setName("用户" + IDGenerator.nextId(5)); - user.setPhone(phoneNoInfo.getPurePhoneNumber()); - user.setRegTime(new Date()); - user.setGold(0); - user.setOpenId(session.getOpenid()); - user.setUnionId(session.getUnionid()); - user.setStatus(1); - // 用户信息完整状态 - // 0:完整 - // 1:需要填写用户信息 - // 2:需要填写手机号 - user.setInfoCompleteStatus(1); - highUserService.insertUser(user); } // 定义个人所有数据