| | |
| | | // 优先获取当前数据库记录 |
| | | ZInfoUser byId = zInfoUserService.getById(user); |
| | | Long myFamily = byId.getFamilyId(); |
| | | |
| | | //获取同一用户的信息 并对其进行修改 |
| | | zInfoUserService.findByUaidToFaid(byId.getUaid()) |
| | | .stream() |
| | | .filter(infoUser1 -> !infoUser1.getUserId().equals(infoUser.getUserId())) |
| | | .forEach(infoUser1 -> { |
| | | infoUser1.setOldName(infoUser.getOldName()); |
| | | infoUser1.setMaritalStatus(infoUser.getMaritalStatus()); |
| | | infoUser1.setSex(infoUser.getSex()); |
| | | zInfoUserService.updateById(infoUser1); |
| | | }); |
| | | |
| | | // 保留原家庭ID(确保数据连续性) |
| | | if (myFamily != null) infoUser.setFamilyId(myFamily); |
| | | |
| | |
| | | } |
| | | // 2.2.3 配偶家族继承(最高优先级) |
| | | if (user.getSpouseId() != null ){ |
| | | //将修改的对应用户原本id清空 |
| | | zInfoUserService.setSpouseOnly(user.getUserId()); |
| | | // 仅当用户首次成为家庭成员时继承配偶家族 |
| | | if (zInfoUserService.getById(user.getUserId()) == null || |
| | | zInfoUserService.getById(user.getUserId()).getIsMyFamily() == 0) { |
| | |
| | | } |
| | | |
| | | // ===== 3. 婚姻状态专项处理 ===== |
| | | if(infoUser.getMaritalStatus() != null) { |
| | | // 3.1 构建本人婚姻信息 |
| | | MarryInfoDto marrySelf = new MarryInfoDto(); |
| | | marrySelf.setUid(user.getSysId()); // 系统ID |
| | |
| | | marrySelfService.updateData(spouse); // 持久化 |
| | | } |
| | | |
| | | // 3.4 离婚特殊处理(状态码=2) |
| | | |
| | | |
| | | |
| | | // 3.4 离婚特殊处理(状态码=2) |
| | | if(user.getMaritalStatus() != null && user.getMaritalStatus() == 2) { |
| | | // 3.4.1 获取配偶信息 |
| | | Long spouseId = zInfoUserService.getById(user.getUserId()).getSpouseId(); |
| | |
| | | exSpouseRecord.setMarryStatus(2); // 离婚状态 |
| | | marryUserService.save(exSpouseRecord); // 写入历史表 |
| | | } |
| | | } |
| | | |
| | | return AjaxResult.success(); // 操作成功 |
| | | } else { |
| | | // ⚠️ 非家庭成员直接阻断 |