From 1496a2640408f000f31e01ebe90b5ef97237f5a1 Mon Sep 17 00:00:00 2001
From: zqy <2522236926@qq.com>
Date: 星期二, 19 八月 2025 19:42:46 +0800
Subject: [PATCH] 修改婚姻bug && 管理员修改用户信息时 同步修改用户姓名、性别、婚姻状态

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
index d6b2651..447c550 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
@@ -223,6 +223,18 @@
             // 浼樺厛鑾峰彇褰撳墠鏁版嵁搴撹褰�
             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);
+                    });
+
             // 淇濈暀鍘熷搴璉D锛堢‘淇濇暟鎹繛缁�э級
             if (myFamily != null) infoUser.setFamilyId(myFamily);
 
@@ -243,6 +255,8 @@
             }
             // 2.2.3 閰嶅伓瀹舵棌缁ф壙锛堟渶楂樹紭鍏堢骇锛�
             if (user.getSpouseId() != null ){
+                //灏嗕慨鏀圭殑瀵瑰簲鐢ㄦ埛鍘熸湰id娓呯┖
+                zInfoUserService.setSpouseOnly(user.getUserId());
                 // 浠呭綋鐢ㄦ埛棣栨鎴愪负瀹跺涵鎴愬憳鏃剁户鎵块厤鍋跺鏃�
                 if (zInfoUserService.getById(user.getUserId()) == null ||
                         zInfoUserService.getById(user.getUserId()).getIsMyFamily() == 0) {
@@ -288,7 +302,6 @@
             }
 
             // ===== 3. 濠氬Щ鐘舵�佷笓椤瑰鐞� =====
-            if(infoUser.getMaritalStatus() != null) {
                 // 3.1 鏋勫缓鏈汉濠氬Щ淇℃伅
                 MarryInfoDto marrySelf = new MarryInfoDto();
                 marrySelf.setUid(user.getSysId()); // 绯荤粺ID
@@ -317,7 +330,10 @@
                     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();
@@ -345,7 +361,7 @@
                     exSpouseRecord.setMarryStatus(2);          // 绂诲鐘舵��
                     marryUserService.save(exSpouseRecord);     // 鍐欏叆鍘嗗彶琛�
                 }
-            }
+
             return AjaxResult.success(); // 鎿嶄綔鎴愬姛
         } else {
             // 鈿狅笍 闈炲搴垚鍛樼洿鎺ラ樆鏂�

--
Gitblit v1.9.1