客户修改和删除BUG修改

This commit is contained in:
秦鸿展
2026-05-27 14:08:36 +08:00
parent 1cca869a30
commit 1679403f56
3 changed files with 79 additions and 26 deletions
@@ -2112,13 +2112,22 @@ public class UserApplicationService {
}
}
UserEntity userEntity = userDomainService.updateUser(userDO);
//同步网货平台员工信息
wlhyDomainService.addOrEditPlatformUser(userEntity);
Long organizationId = loginUser.getUserPo().getOrganizationId();
Integer ordIsQueue = userMapper.getOrdIsQueue(organizationId);
if (userEntity.getUserAccount()!=null&&ordIsQueue==1){
//同步yms员工信息
ymsDomainService.addOrEditYmsUser(userEntity);
// 客户/供应商为 WMS 客户管理用户,不同步网货/YMS 平台员工
if (!isCustomerManagementPresetRole(userEntity.getRoleCode())) {
try {
wlhyDomainService.addOrEditPlatformUser(userEntity);
} catch (Exception e) {
log.warn("同步网货平台员工信息失败,但不影响用户保存: {}", e.getMessage());
}
Long organizationId = loginUser.getUserPo().getOrganizationId();
Integer ordIsQueue = userMapper.getOrdIsQueue(organizationId);
if (userEntity.getUserAccount() != null && ordIsQueue == 1) {
try {
ymsDomainService.addOrEditYmsUser(userEntity);
} catch (Exception e) {
log.warn("同步YMS平台员工信息失败,但不影响用户保存: {}", e.getMessage());
}
}
}
BeanUtils.copyProperties(userPo, userEntity);
@@ -2275,6 +2284,7 @@ public class UserApplicationService {
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
List<Long> wlhySyncIds = new ArrayList<>();
for (Long userId : ids) {
UserPo userPo = userDomainService.selectByUserId(userId);
UserDO userDO = new UserDO();
@@ -2288,11 +2298,17 @@ public class UserApplicationService {
userDO.setDelFlag(2);
userDO.setUpdateTime(new Date());
userDomainService.updateUser(userDO);
if (!isCustomerManagementPresetRole(userPo.getRoleCode())) {
wlhySyncIds.add(userId);
}
}
}
//同步删除网货的员工信息(只有当ids不为空时才调用)
if (!ids.isEmpty()) {
wlhyDomainService.deleteBatchPlatformUser(ids);
if (!wlhySyncIds.isEmpty()) {
try {
wlhyDomainService.deleteBatchPlatformUser(wlhySyncIds);
} catch (Exception e) {
log.warn("同步删除网货用户失败,但不影响本地删除: {}", e.getMessage());
}
}
return ids.size();
}
@@ -5089,10 +5105,33 @@ public class UserApplicationService {
if (customerDO.getUserId() == null){
throw new ServiceException("用户id不能为空");
}
UserPo userPo = userDomainService.selectByUserId(customerDO.getUserId());
if (ObjectUtil.isNull(userPo)) {
throw new ServiceException("用户不存在");
}
UserDO userDO = new UserDO();
BeanUtils.copyProperties(customerDO, userDO);
userDO.setUserPhone(customerDO.getEmergencyContactPhone());
userDO.setBusinessType(1);
// CustomerDTO 修改场景通常不传 roleCode/组织/账号,须沿用库中值,避免同步 YMS/网货时角色为空触发 selectOne 返回多条
if (StringUtils.isEmpty(userDO.getRoleCode())) {
userDO.setRoleCode(userPo.getRoleCode());
userDO.setRoleName(userPo.getRoleName());
userDO.setRoleId(userPo.getRoleId());
}
if (userDO.getOrganizationId() == null) {
userDO.setOrganizationId(userPo.getOrganizationId());
userDO.setOrganizationName(userPo.getOrganizationName());
}
if (userDO.getTopOrganizationId() == null) {
userDO.setTopOrganizationId(userPo.getTopOrganizationId());
}
if (StringUtils.isEmpty(userDO.getUserAccount())) {
userDO.setUserAccount(userPo.getUserAccount());
}
if (StringUtils.isEmpty(userDO.getUserMemberCode())) {
userDO.setUserMemberCode(userPo.getUserMemberCode());
}
updateUser(userDO);
if (isWT()){
//开启仓配一体 同步托运人信息
@@ -539,17 +539,17 @@ public class UserWlhyDomainService {
roleDo.setOrganizationId(userEntity.getOrganizationId());
RoleEntity roleEntity = roleDomainService.selectByOrganizationIdAndRoleCode(roleDo);
if (roleEntity != null) {
UserRoleDo userRoleDo = new UserRoleDo();
userRoleDo.setUserId(userEntity.getUserId());
userRoleDo.setRoleId(roleEntity.getRoleId());
userRoleIds.add(String.valueOf(roleEntity.getRoleId()));
userRoleNames.add(userEntity.getRoleName());
userRoleCodes.add(userEntity.getRoleCode());
userRoleNames.add(roleEntity.getRoleName());
userRoleCodes.add(roleEntity.getRoleCode());
}
}
platformUserDTO.setRoleIds(userRoleIds);
platformUserDTO.setRoleNames(userRoleNames);
platformUserDTO.setRoleCodes(userRoleCodes);
// 本组织无 must 角色时勿用空列表覆盖 addPlatformUser 已设置的角色否则网货侧 selectOne 会命中全表
if (!userRoleIds.isEmpty()) {
platformUserDTO.setRoleIds(userRoleIds);
platformUserDTO.setRoleNames(userRoleNames);
platformUserDTO.setRoleCodes(userRoleCodes);
}
}
/**
@@ -609,17 +609,29 @@ public class UserWlhyDomainService {
* @return boolean
*/
public boolean deleteBatchPlatformUser(List<Long> szwlUserIds){
// 检查ids是否为空
if (szwlUserIds == null || szwlUserIds.isEmpty()) {
return true; // 如果列表为空直接返回成功避免SQL语法错误
}
//检查是否开启网货
boolean flag = checkSwitch();
if(!flag){
//如果配置网货产品,返回跳过
return true;
}
R<Boolean> result = wlhyServiceFeign.deleteBatchPlatformUser(szwlUserIds);
boolean flag = checkSwitch();
if (!flag) {
return true;
}
// 仅删除网货中已存在的用户避免远程生成 WHERE id IN () 导致语法错误
List<Long> existInWlhyIds = new ArrayList<>();
for (Long szwlUserId : szwlUserIds) {
R<Long> wlhyUser = wlhyServiceFeign.getUserInfoBySzwlUserId(szwlUserId);
if (R.FAIL == wlhyUser.getCode()) {
log.warn("查询网货用户失败,跳过同步删除 szwlUserId={}: {}", szwlUserId, wlhyUser.getMsg());
continue;
}
if (wlhyUser.getData() != null) {
existInWlhyIds.add(szwlUserId);
}
}
if (existInWlhyIds.isEmpty()) {
return true;
}
R<Boolean> result = wlhyServiceFeign.deleteBatchPlatformUser(existInWlhyIds);
if (R.FAIL == result.getCode()) {
throw new ServiceException(result.getMsg());
}
@@ -793,6 +793,8 @@
</select>
<select id="selectYmsByUserId" resultType="com.mhd.common.core.domain.dto.YmsSysUserDTO">
select * from NGWL_TEST_YMS.SYS_USER where SZWL_USER_ID = #{userId}
ORDER BY USER_ID DESC
limit 1
</select>
<select id="getOrdIsQueue" resultType="java.lang.Integer">
SELECT is_queue from NGWL_TEST_PRODUCT.SYS_ORGANIZATION where ORGANIZATION_ID = #{organizationId}