Browse Source

Merge branch 'dev_v1.0.3_wh' of moapp/jypkg into feature/v1.0.3

王浩 1 year ago
parent
commit
5d628943db
1 changed files with 28 additions and 0 deletions
  1. 28 0
      ent/entity/user.go

+ 28 - 0
ent/entity/user.go

@@ -134,6 +134,11 @@ func (u *User) Del(entId int, ids string) bool {
 
 //新增员工
 func (u *User) Add(tx *sql.Tx, entId int, user *User, paymentAddress, source, nsq, nsq_Topic string) (int64, bool) {
+	if user.User_name != "" && len(user.User_name) > 0 {
+		if !u.UserNameExist(user.User_name, user.Phone) {
+			return 0, false
+		}
+	}
 	nowFormat := NowFormat(Date_Full_Layout)
 	user_id := Mysql.InsertByTx(tx, Entniche_user, map[string]interface{}{
 		"name":       user.Name,
@@ -307,6 +312,29 @@ func (u *User) ResetPasswords(power_virtual_account int, virtual_account_rule, p
 func (u *User) PhoneExist(phone string, entId int) *[]map[string]interface{} {
 	return Mysql.SelectBySql("select id from entniche_user where phone=? and ent_id=?", phone, entId)
 }
+func (u *User) UserNameExist(userName, phone string) bool {
+	user, ok := MQFW.FindOne("user", map[string]interface{}{
+		"i_appid":   2,
+		"user_name": userName,
+	})
+	if ok && user != nil && len(*user) > 0 {
+		s_phone := qutil.InterfaceToStr((*user)["s_phone"])
+		s_m_phone := qutil.InterfaceToStr((*user)["s_m_phone"])
+		if s_phone != "" {
+			if s_phone == phone {
+				return true
+			}
+			return false
+		}
+		if s_m_phone != "" {
+			if s_phone == phone {
+				return true
+			}
+			return false
+		}
+	}
+	return true
+}
 
 func (u *User) UpdateUserName(tx *sql.Tx, entId, userId int, user_name string) {
 	//entniche_user表,用户名字段 user_name