🩹 code-review 修订:改号同步日志手机号脱敏、统一 feign 契约注释
This commit is contained in:
@@ -89,7 +89,7 @@ public class MpLoginSupport {
|
||||
// ③ 身份含 driver 才建档;纯 admin 不建
|
||||
String loginNotice = ensureProfile(account, phone, tenantId);
|
||||
// ④ 微信登录把 openid 覆盖写为本次值留痕;失败只 WARN
|
||||
bindOpenid(account, openid);
|
||||
bindOpenId(account, openid);
|
||||
MpUserInfo userInfo = loadUserInfo(account);
|
||||
attachNotice(userInfo, loginNotice);
|
||||
return TokenUtil.convertMpUser(userInfo);
|
||||
@@ -187,7 +187,7 @@ public class MpLoginSupport {
|
||||
/**
|
||||
* ④ 微信登录把 openid 覆盖写为本次值:「该账号最近一次登录用的微信」,不参与识别;失败只 WARN
|
||||
*/
|
||||
private void bindOpenid(MpUser account, String openid) {
|
||||
private void bindOpenId(MpUser account, String openid) {
|
||||
if (account == null || StringUtil.isBlank(openid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-1
@@ -63,7 +63,8 @@ public interface IDriverClient {
|
||||
* <p>
|
||||
* 幂等入口:档案 mobile 已是新号时返回成功且不写库。只在档案属于该账号
|
||||
* (user_id + tenant_id 命中)且档案 mobile 等于 oldPhone 时改这一列;
|
||||
* 不满足时不动档案,通过返回值的 message 说明原因,不抛异常给调用方的账号更新。
|
||||
* 不满足时不动档案,通过返回值的 message 说明原因。入参不合法时服务端抛 ServiceException,
|
||||
* feign 以调用异常返回,调用方按失败处理并自行决定是否影响账号更新。
|
||||
*
|
||||
* @param param 租户、小程序账号、账号旧号与新号
|
||||
* @return 档案ID与本次是否同步
|
||||
|
||||
+1
-7
@@ -97,13 +97,7 @@ public final class MpPhoneChangePlan {
|
||||
&& !submittedAccount.equals(oldAccount) && !isMasked(submittedAccount)) {
|
||||
return submittedAccount;
|
||||
}
|
||||
if (oldAccount == null) {
|
||||
return newPhone;
|
||||
}
|
||||
if (oldAccount.equals(oldPhone)) {
|
||||
return newPhone;
|
||||
}
|
||||
return oldAccount;
|
||||
return shouldSyncAccount() ? newPhone : oldAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+12
-9
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
package org.springblade.system.support;
|
||||
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springblade.core.tool.api.R;
|
||||
@@ -34,12 +35,12 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* 改号后同步司机档案手机号
|
||||
* <p>
|
||||
* 只在后台编辑与 App 内改号两个入口调用:登录链路上 transport 会回调本服务的 updateUser,
|
||||
* 若那里再回调用 transport,会形成 transport(持 driver 行锁) → system → transport 的嵌套更新,
|
||||
* 内层等同一行的锁直到超时。
|
||||
* 只在后台编辑与 App 内改号两个入口调用。登录链路的账号更新不得回调 transport:
|
||||
* transport 的司机档案编辑会回调本服务的 updateUser,互相回调会形成 transport(持 driver 行锁)
|
||||
* → system → transport 的嵌套更新,内层等同一行的锁直到超时。
|
||||
* <p>
|
||||
* 档案同步是账号更新之后的补偿动作:任何失败只记日志、不抛异常,账号更新照常提交。
|
||||
* 调用方据此能看出「账号改了、档案没改」。
|
||||
* 档案同步在账号更新之后执行:任何失败只记日志、不抛异常,账号更新照常提交。
|
||||
* 日志里的手机号一律脱敏;tenantId / mpUserId / driverId 保持原值用于定位。
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@@ -63,6 +64,8 @@ public class MpUserPhoneChangeSupport {
|
||||
|| oldMobile.contains("*") || newMobile.contains("*") || oldMobile.equals(newMobile)) {
|
||||
return false;
|
||||
}
|
||||
String maskedOldPhone = DesensitizedUtil.mobilePhone(oldMobile);
|
||||
String maskedNewPhone = DesensitizedUtil.mobilePhone(newMobile);
|
||||
DriverSyncMobileDTO param = new DriverSyncMobileDTO();
|
||||
param.setTenantId(tenant);
|
||||
param.setMpUserId(userId);
|
||||
@@ -72,24 +75,24 @@ public class MpUserPhoneChangeSupport {
|
||||
R<DriverSyncMobileVO> result = driverClient.syncMobile(param);
|
||||
if (result == null || !result.isSuccess()) {
|
||||
log.error("小程序用户改号:账号已更新,司机档案同步调用失败。tenantId={} mpUserId={} oldPhone={} newPhone={} reason={}",
|
||||
tenant, userId, oldMobile, newMobile, result == null ? "无响应" : result.getMsg());
|
||||
tenant, userId, maskedOldPhone, maskedNewPhone, result == null ? "无响应" : result.getMsg());
|
||||
return false;
|
||||
}
|
||||
DriverSyncMobileVO data = result.getData();
|
||||
if (data == null) {
|
||||
log.error("小程序用户改号:账号已更新,司机档案同步无返回数据。tenantId={} mpUserId={} oldPhone={} newPhone={}",
|
||||
tenant, userId, oldMobile, newMobile);
|
||||
tenant, userId, maskedOldPhone, maskedNewPhone);
|
||||
return false;
|
||||
}
|
||||
if (!Boolean.TRUE.equals(data.getSynced())) {
|
||||
log.warn("小程序用户改号:账号已更新,司机档案未同步。tenantId={} mpUserId={} oldPhone={} newPhone={} driverId={} reason={}",
|
||||
tenant, userId, oldMobile, newMobile, data.getDriverId(), data.getMessage());
|
||||
tenant, userId, maskedOldPhone, maskedNewPhone, data.getDriverId(), data.getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
log.error("小程序用户改号:账号已更新,司机档案同步异常。tenantId={} mpUserId={} oldPhone={} newPhone={}",
|
||||
tenant, userId, oldMobile, newMobile, exception);
|
||||
tenant, userId, maskedOldPhone, maskedNewPhone, exception);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ class MpUserServiceImplTest {
|
||||
assertTrue(scope.isAllDept());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------ 改号三处一致(票 05 场景 6)
|
||||
// ------------------------------------------------------------ 改号三处一致
|
||||
|
||||
@Test
|
||||
@DisplayName("后台改号(account 就是旧号):手机号、登录账号、司机档案电话三处一致")
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* App 内改号(票 05 场景 6 的小程序侧入口)。
|
||||
* App 内改号(小程序侧改号入口)。
|
||||
* <p>
|
||||
* 只验证「交给 updateUser 之前」的三处一致性判据:手机号是新号、账号是否跟随取库里的旧号、
|
||||
* 以及必须走带司机档案同步的更新入口(否则档案电话会停在旧号)。
|
||||
|
||||
Reference in New Issue
Block a user