WH01243 1 anno fa
parent
commit
01fc36fa72
1 ha cambiato i file con 6 aggiunte e 7 eliminazioni
  1. 6 7
      ent/entity/user.go

+ 6 - 7
ent/entity/user.go

@@ -331,18 +331,17 @@ func (u *User) UserNameExist(userName, phone string) bool {
 	return true
 }
 
-func (u *User) UpdateUserName(tx *sql.Tx, entId, userId int, user_name string) {
+func (u *User) UpdateUserName(tx *sql.Tx, entId, userId int, user_name, phone string) {
 	//entniche_user表,用户名字段 user_name
 	//base_user表,用户名字段 user_name
 	//mog库user表,用户名字段 user_name
 	if user_name != "" && len(user_name) > 0 {
-		user := u.GetById(entId, userId)
-		Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set user_name=? where phone=? and  ent_id!=?`, user.User_name, user.Phone, entId)
+		Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set user_name=? where phone=? and  ent_id!=?`, user_name, phone, entId)
 		data, _ := MQFW.Find("user", map[string]interface{}{
 			"i_appid": 2,
 			"$or": []map[string]interface{}{
-				{"s_phone": user.Phone},
-				{"s_m_phone": user.Phone},
+				{"s_phone": phone},
+				{"s_m_phone": phone},
 			},
 		}, `{"s_phone":-1}`, `{"_id":1,"base_user_id":1}`, false, 0, 1)
 		if data != nil && len(*data) > 0 {
@@ -376,7 +375,7 @@ func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId
 			}, true, false)
 			ok_2 := Mysql.UpdateOrDeleteBySqlByTx(tx, "update entniche_info set admin=?,phone=? where id=?", name, phone, entId)
 			ok_3 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
-			u.UpdateUserName(tx, entId, userId, user_name)
+			u.UpdateUserName(tx, entId, userId, user_name, phone)
 			return ok_1 != -1 && ok_3 && ok_2 != -1
 		})
 		if ok {
@@ -398,7 +397,7 @@ func (u *User) UpdateInfo(mail string, phone string, name string, userId, deptId
 				},
 			}, true, false)
 			ok_2 := VarUser.Move(tx, entId, deptId, fmt.Sprint(userId))
-			u.UpdateUserName(tx, entId, userId, user_name)
+			u.UpdateUserName(tx, entId, userId, user_name, phone)
 			return ok_1 == 1 && ok_2
 		})
 	}