fix 登录就绑定微信,并解绑之前的

This commit is contained in:
lijiarao
2021-11-02 17:55:39 +08:00
parent bab223cecc
commit 9a37bd771f
@@ -259,14 +259,15 @@ public class CompanyLoginController {
LambdaQueryWrapper<PayContactsManagement> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PayContactsManagement::getOpenId, PasswordUtil.encrypt(openId));
PayContactsManagement contactsManagement1 = payContactsManagementService.getOne(queryWrapper1);
//没有绑定过就绑定
if (contactsManagement1 == null){
contactsManagement.setOpenId(PasswordUtil.encrypt(openId));
//绑定过就解绑重新绑定
if (contactsManagement1 != null){
contactsManagement1.setOpenId(null);
payContactsManagementService.updateById(contactsManagement);
//绑定过就判断是否是当前用户,如果不是就报错
}else if (!Objects.equals(contactsManagement1.getPhone(),contactsManagement.getPhone())){
throw new JeroBootException("微信已经绑定过其他账号");
}
//绑定微信
contactsManagement.setOpenId(PasswordUtil.encrypt(openId));
payContactsManagementService.updateById(contactsManagement);
baseCommonService.addLog("手机号: " + PasswordUtil.decrypt(contactsManagement.getPhone()) + ",绑定微信成功!", CommonConstant.LOG_TYPE_2, CommonConstant.OPERATE_TYPE_3, loginUser);
//update-end--Author:wangshuai Date:20200714 for:登录日志没有记录人员
return Result.OK("绑定微信成功");