From 6015dc6c90f0310fb92652781f6f58bbc8bafa07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?niohe=C2=B7erbao?= Date: Tue, 4 Apr 2023 10:52:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=BC=96=E8=BE=91=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E5=8F=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/user/manage/UserInfoManage.java | 54 +++++++++++++++------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java index eb633da..22a3070 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java @@ -74,6 +74,7 @@ public class UserInfoManage { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class) .eq(DingEmployeeInfo::getMainJob, "true") + .eq(DingEmployeeInfo::getStatus, "A") .eq(StringUtils.isNotBlank(orgCode), DingEmployeeInfo::getOrganizationCode, orgCode) .like(StringUtils.isNotBlank(phoneNo), DingEmployeeInfo::getBindUserMobile, phoneNo) .like(StringUtils.isNotBlank(name), DingEmployeeInfo::getEmployeeName, name) @@ -91,7 +92,7 @@ public class UserInfoManage { Map employeeCodeAvailableMap = new HashMap<>(16); if (CollUtil.isNotEmpty(employeeCodeList)) { employeeCodeAvailableMap = iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getEmployeeCode, employeeCodeList)) + .in(UserInfo::getEmployeeCode, employeeCodeList)) .stream().collect(Collectors.toMap(UserInfo::getEmployeeCode, Function.identity())); } List orgCodeList = records.stream() @@ -168,7 +169,7 @@ public class UserInfoManage { // TODO 这里过滤的非浙政钉用户的专家 后续需要增加补充逻辑 return iUserInfoService.list(Wrappers.lambdaQuery(UserInfo.class) - .in(UserInfo::getId, compliantUserIdList)) + .in(UserInfo::getId, compliantUserIdList)) .stream().map(UserInfo::getEmployeeCode) .filter(StringUtils::isNotBlank).collect(Collectors.toList()); @@ -256,23 +257,11 @@ public class UserInfoManage { @Transactional(rollbackFor = Exception.class) public void userInfoDetailEdit(ReqUserDetailEditPO reqUserDetailEditPO) { - String employeeCode = reqUserDetailEditPO.getEmployeeCode(); Long userId = generateUserId(reqUserDetailEditPO.getEmployeeCode()); UserInfo userInfo = iUserInfoService.getById(userId); + // 绑定用户手机号 + bandUserMobile(userInfo, reqUserDetailEditPO); - String mobile = userInfo.getMobile(); - if (StringUtils.isBlank(mobile)) { - String phoneNo = reqUserDetailEditPO.getPhoneNo(); - userInfo.setMobile(phoneNo); - // 更新浙政钉相关数据 - if (StringUtils.isNotBlank(phoneNo)) { - iDingEmployeeInfoService - .update(Wrappers.lambdaUpdate(DingEmployeeInfo.class) - .eq(DingEmployeeInfo::getMainJob, "true") - .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) - .set(DingEmployeeInfo::getBindUserMobile, phoneNo)); - } - } userInfo.setAvailable(reqUserDetailEditPO.getStatus()); userInfo.setUpdateOn(LocalDateTime.now()); userInfo.setUpdateBy(LoginUserUtil.getUserId()); @@ -291,6 +280,39 @@ public class UserInfoManage { } } + /** + * 绑定用户手机号 + * + * @param userInfo + * @param reqUserDetailEditPO + */ + @Transactional(rollbackFor = Exception.class) + public void bandUserMobile(UserInfo userInfo, ReqUserDetailEditPO reqUserDetailEditPO) { + String employeeCode = reqUserDetailEditPO.getEmployeeCode(); + String mobile = userInfo.getMobile(); + Long userId = userInfo.getId(); + if (StringUtils.isBlank(mobile)) { + // 校验手机号是否重复 + UserInfo repeatMobileUserInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class) + .eq(UserInfo::getMobile, mobile).ne(UserInfo::getId, userId)); + if (Objects.nonNull(repeatMobileUserInfo)) { + throw new BizException("该手机号码已被绑定,请问重复绑定"); + } + + String phoneNo = reqUserDetailEditPO.getPhoneNo(); + userInfo.setMobile(phoneNo); + // 更新浙政钉相关数据 + if (StringUtils.isNotBlank(phoneNo)) { + iDingEmployeeInfoService + .update(Wrappers.lambdaUpdate(DingEmployeeInfo.class) + .eq(DingEmployeeInfo::getMainJob, "true") + .eq(DingEmployeeInfo::getEmployeeCode, employeeCode) + .set(DingEmployeeInfo::getBindUserMobile, phoneNo)); + } + } + + } + @Transactional(rollbackFor = Exception.class) public Long generateUserId(String employeeCode) { UserInfo userInfo = iUserInfoService.getOne(Wrappers.lambdaQuery(UserInfo.class)