Kaynağa Gözat

Merge branch 'dev3.5' of http://192.168.3.207:10080/qmx/jy into dev3.5

wangshan 4 yıl önce
ebeveyn
işleme
d1d25c3ed5

+ 14 - 5
src/jfw/modules/app/src/web/staticres/jyapp/me/js/association.js

@@ -5,12 +5,12 @@ var company = {
     importText: $('.import_text'), // 联想公司输入框
     assoList: $('.assoList'), // 联想出的公司列表
     assoUl: $('.asso_ul'),
+    isregister:true,
     init: function () {
         this.addEventKeys();
         this.addEventLister();
         this.iosBackInvoke();
         $(comname).on('click', this.setCompanyName)
-        // $(company.importCancel[0]).on('click', this.setCancel)
         $(company.importText[0]).on('input', this.getCompanyList)
         $(company.importText[0]).on('blur', this.inputLoseFocus)
     },
@@ -30,11 +30,19 @@ var company = {
                 } else {
                     // 键盘收起事件处理
                     // alert("android 键盘收起事件处理")
-                    company.setCancel()
+                    var params = window.location.search.substring(1)
+                    if(params == '') {
+                        company.association.fadeOut()
+                    }else{
+                        company.isregister = false
+                        company.setCancel()
+                    }
                 }
-            });
+            },false);
         }
     },
+    // 解绑输入框失去焦点事件
+
     isAndroid: function (_isAndroid,ua) {
         if (_isAndroid === -1) {
             _isAndroid = /Android/i.test(ua) ? 1 : 0;
@@ -53,7 +61,9 @@ var company = {
     // 输入框失去焦点触发事件
     inputLoseFocus: function () {
         company.association.fadeOut()
-        company.setCancel()
+        if(company.isregister){
+            company.setCancel()
+        }
     },
     // ios返回刷新问题
     iosBackInvoke: function () {
@@ -74,7 +84,6 @@ var company = {
         for (var i=0; i<assoLiAll.length; i++) {
             $(assoLiAll[i]).on('click', function(){
                 $(comname).val($(this).find('.asso_res').text())
-                // company.setCancel()
             })
         }
     },

+ 0 - 1
src/jfw/modules/app/src/web/templates/me/register.html

@@ -294,7 +294,6 @@
 				return _isAndroid === 1;                
 			}
 			if (isAndroid()) {
-				console.log('123')
 				const innerHeight = window.innerHeight;
 				window.addEventListener('resize', () => {
 					const newInnerHeight = window.innerHeight;

+ 142 - 0
src/jfw/modules/common/src/qfw/util/jy/userPhoneUtil.go

@@ -0,0 +1,142 @@
+package jy
+
+import (
+	mg "mongodb"
+)
+
+type PhoneUtil struct {
+	UserMgoDB mg.MongodbSim
+}
+
+func NewPhoneUtil(db mg.MongodbSim) *PhoneUtil {
+	return &PhoneUtil{db}
+}
+
+/*
+微信账号绑定手机号
+param  unionId:当前微信的s_unionid
+		 phone:要绑定的手机号
+return exists:是否存在
+       needRelation:是否需要建立关联关系
+*/
+func (this *PhoneUtil) BindPhoneIsOccupy(unionId, phone string) (exists, needRelation bool) {
+	//已经有微信账户绑定过
+	if this.UserMgoDB.Count("user", map[string]interface{}{"i_appid": 2, "s_m_phone": phone, "s_phone": map[string]interface{}{"$exists": 0}}) > 0 {
+		return true, false
+	}
+	//是否存在手机号用户
+	if pUserNum := this.UserMgoDB.Count("user", map[string]interface{}{
+		"i_appid": 2,
+		"s_phone": phone,
+	}); pUserNum > 0 {
+		//存在手机号用户,但此手机号未绑定微信,或绑定微信和当前账户绑定微信一致
+		if pUserNum == 1 && pUserNum == this.UserMgoDB.Count("user", map[string]interface{}{
+			"i_appid": 2,
+			"s_phone": phone,
+			"$or": []map[string]interface{}{
+				map[string]interface{}{
+					"s_m_openid": map[string]interface{}{"$exists": 0},
+					"a_m_openid": map[string]interface{}{"$exists": 0},
+				},
+				map[string]interface{}{
+					"s_unionid": unionId,
+				},
+			},
+		}) {
+			return false, true
+		}
+		return true, false
+	}
+	//纯新手机号
+	return false, false
+}
+
+/*
+更改手机号
+param phone要更改的手机号
+    needMerge:当前账户是否需要合并
+return exists:是否存在
+       needRelation:是否需要建立关联关系
+备注:在合并状态的微信账户,可以更换存在但未绑定微信的手机号;其他情况只能更换新手机号
+*/
+func (this *PhoneUtil) ChangePhoneIsOccupy(phone string, isWxAndNeedMerge bool) (exists, needRelation bool) {
+	if isWxAndNeedMerge {
+		//if this.UserMgoDB.Count("user", map[string]interface{}{
+		//	"i_appid": 2,
+		//	"$or": []map[string]interface{}{
+		//		map[string]interface{}{ //存在手机号未绑定微信的用户
+		//			"s_unionid": map[string]interface{}{"$exists": 1},
+		//			"s_phone":   phone,
+		//		},
+		//		map[string]interface{}{ //手机号已绑定
+		//			"s_m_phone": phone,
+		//		},
+		//	},
+		//}) > 0 {
+		//	return true, false
+		//}
+
+		//手机号已绑定
+		if this.UserMgoDB.Count("user", map[string]interface{}{
+			"i_appid":   2,
+			"s_m_phone": phone,
+		}) > 0 {
+			return true, false
+		}
+		//存在手机号未绑定微信的用户
+		if this.UserMgoDB.Count("user", map[string]interface{}{
+			"i_appid":   2,
+			"s_phone":   phone,
+			"s_unionid": map[string]interface{}{"$exists": 0},
+		}) > 0 {
+			return false, true
+		}
+	} else {
+		if this.UserMgoDB.Count("user", map[string]interface{}{
+			"i_appid": 2,
+			"$or": []map[string]interface{}{
+				map[string]interface{}{ //手机号用户
+					"s_m_phone": phone,
+				},
+				map[string]interface{}{ //手机号已被绑定的用户
+					"s_phone": phone,
+				},
+			},
+		}) > 0 {
+			return true, false
+		}
+	}
+	return false, false
+}
+
+/*
+手机号账号绑定微信
+param   phone:当前手机号
+		unionId:要绑定的微信s_unionid
+return exists:是否存在
+       needRelation:是否需要建立关联关系
+*/
+func (this *PhoneUtil) BindWeixinIsOccupy(phone, unionId string) (exists, needRelation bool) {
+	//存在对应的微信 1.未绑定手机号 2.绑定手机号为当前账户手机号
+	if wxBindNum := this.UserMgoDB.Count("user", map[string]interface{}{"i_appid": 2, "s_unionid": unionId}); wxBindNum > 0 {
+		if wxBindNum != 1 || this.UserMgoDB.Count("user", map[string]interface{}{
+			"i_appid":   2,
+			"s_unionid": unionId,
+			"s_phone":   map[string]interface{}{"$exists": 0},
+			"$or": []map[string]interface{}{
+				map[string]interface{}{
+					"s_m_phone": map[string]interface{}{"$exists": 0},
+				},
+				map[string]interface{}{
+					"s_m_phone": phone,
+				},
+			},
+		}) != wxBindNum {
+			return true, false
+		}
+		//建立旧微信绑定手机号(建立双向绑定)
+		return false, true
+	}
+	//全新微信账户
+	return false, false
+}

+ 187 - 249
src/jfw/modules/subscribepay/src/service/userAccountInfo.go

@@ -135,6 +135,87 @@ func (this *UserAccount) Interested(doType string) {
 	this.ServeJson(NewResult(rData, errMsg))
 }
 
+//绑定邮箱&更改邮箱【绑定邮箱和更改邮箱流程一样】
+func (this *UserAccount) MailSet(doType string) {
+	userId, _ := this.GetSession("userId").(string)
+	rData, errMsg := func() (interface{}, error) {
+		step, _ := this.GetInteger("step")
+		mail := this.GetString("mail")
+		code := this.GetString("code")
+		if doType == "change" && step == 1 { //仅发送验证码 校验是否通过身份验证
+			if pass, data := authenticationCheck(this.GetSession(mailAuthPassSessionKey)); !pass {
+				return data, nil
+			}
+		}
+		mailVerify, err := mailStep(this.Session(), step, mail, code, "bind")
+		if err != nil {
+			return nil, err
+		}
+		//校验验证码成功【校验是否需要合并】
+		if step == 2 {
+			if !util.MQFW.UpdateById("user", userId, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"s_myemail": mailVerify,
+				},
+			}) {
+				return nil, DBUPDATE_ERROR
+			}
+			this.Session().Del(mailAuthPassSessionKey)
+		}
+		return map[string]interface{}{
+			"state": 1,
+		}, nil
+	}()
+	if errMsg != nil {
+		log.Printf("%s UserAccount MailSet %s 邮箱异常:%s\n", userId, doType, errMsg.Error())
+	}
+	this.ServeJson(NewResult(rData, errMsg))
+}
+
+//公司名称联想
+func (this *UserAccount) CompanyAssociation() {
+	rData, errMsg := func() (interface{}, error) {
+		name := this.GetString("name")
+		list := []string{}
+		if len([]rune(name)) > 2 {
+			query := fmt.Sprintf(`{"query": {"match_phrase": {"name": "%s"}},"_source": ["name"],"size": %d}`, name, 5)
+			r := elastic.Get("qyxy", "qyxy", query)
+			if r != nil {
+				for _, v := range *r {
+					list = append(list, qutil.ObjToString(v["name"]))
+				}
+			}
+		}
+		return list, nil
+	}()
+	this.ServeJson(NewResult(rData, errMsg))
+}
+
+//设置公司名称
+func (this *UserAccount) SetCompany() {
+	userId, _ := this.GetSession("userId").(string)
+	rData, errMsg := func() (interface{}, error) {
+		companyName := strings.TrimSpace(this.GetString("name"))
+		if companyName == "" {
+			return nil, fmt.Errorf("公司名称不能为空")
+		}
+		if !util.MQFW.UpdateById("user", userId, map[string]interface{}{
+			"$set": map[string]interface{}{
+				"s_company": companyName,
+			},
+		}) {
+			return nil, DBUPDATE_ERROR
+		}
+		return map[string]interface{}{
+			"state": 1,
+		}, nil
+	}()
+	if errMsg != nil {
+		log.Printf("%s UserAccount ChangeCompany 设置公司名称:%s\n", userId, errMsg.Error())
+	}
+	this.ServeJson(NewResult(rData, errMsg))
+}
+
 //获取图形验证码
 func (this *UserAccount) PhoneCaptcha() {
 	userId, _ := this.GetSession("userId").(string)
@@ -248,7 +329,7 @@ func (this *UserAccount) PhoneBind() {
 		}
 		//校验验证码成功【校验是否需要合并】
 		if step == 2 {
-			uData, _ := util.MQFW.FindById("user", userId, `{"s_unionid":1,"s_name":1,"s_nickname":1,"i_sex":1,"s_country":1,"s_province":1,"s_city":1,"s_headimageurl":1,"s_m_openid":1,"a_m_openid":1}`)
+			uData, _ := util.MQFW.FindById("user", userId, `{"s_unionid":1,"s_name":1,"s_nickname":1,"s_headimageurl":1}`)
 			if uData == nil && len(*uData) == 0 {
 				return nil, DBQUERY_ERROR
 			}
@@ -256,33 +337,23 @@ func (this *UserAccount) PhoneBind() {
 			if unionid == "" {
 				return "", fmt.Errorf("获取账户信息异常")
 			}
-			exists, needRelation := bindPhoneIsOccupy(phoneVerify, unionid)
+			exists, needRelation := jy.NewPhoneUtil(util.MQFW).BindPhoneIsOccupy(unionid, phoneVerify)
 			if exists { //再次校验是否使用
 				return nil, fmt.Errorf("手机号已被绑定")
 			} else {
 				//建立关联关系
 				if needRelation {
-					upsetMap := map[string]interface{}{
+					relationMap := map[string]interface{}{
 						"s_unionid":      (*uData)["s_unionid"],
 						"s_name":         (*uData)["s_name"],
 						"s_nickname":     (*uData)["s_nickname"],
-						"i_sex":          (*uData)["i_sex"],
-						"s_country":      (*uData)["s_country"],
-						"s_province":     (*uData)["s_province"],
-						"s_city":         (*uData)["s_city"],
 						"s_headimageurl": (*uData)["s_headimageurl"],
 					}
-					if (*uData)["s_m_openid"] != nil {
-						upsetMap["s_m_openid"] = (*uData)["s_m_openid"]
-					}
-					if (*uData)["a_m_openid"] != nil {
-						upsetMap["a_m_openid"] = (*uData)["a_m_openid"]
-					}
 					if !util.MQFW.Update("user", map[string]interface{}{
 						"i_appid": 2,
 						"s_phone": phoneVerify,
 					}, map[string]interface{}{
-						"$set": upsetMap,
+						"$set": relationMap,
 					}, false, false) {
 						return nil, fmt.Errorf("建立绑定异常")
 					}
@@ -326,6 +397,14 @@ func (this *UserAccount) PhoneChange() {
 			if pass, err := imgCaptchaCheck(this.Session(), userId, code); !pass || err != nil {
 				return nil, err
 			}
+			//发送短信验证码前,校验手机号是否存在
+			wId, _, _, _, _, err := jy.CreateUserMerge(util.MQFW, util.Mysql, this.Session()).MergeQuery()
+			if err != nil {
+				return nil, err
+			}
+			if exists, _ := jy.NewPhoneUtil(util.MQFW).ChangePhoneIsOccupy(phone, wId != "" && userId == wId); exists {
+				return nil, fmt.Errorf("手机号已被使用")
+			}
 		}
 		//发送验证码&校验验证码逻辑
 		phoneVerify, err := phoneStep(this.Session(), step, phone, code, "change")
@@ -334,119 +413,104 @@ func (this *UserAccount) PhoneChange() {
 		}
 		//校验验证码成功绑定手机号
 		if step == 2 {
-			if changePhoneIsOccupy(phoneVerify) { //再次校验是否使用
-				return nil, fmt.Errorf("手机号已被绑定")
-			} else {
-				uData, ok := util.MQFW.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
-				if !ok || uData == nil || len(*uData) == 0 {
-					return nil, DBQUERY_ERROR
+			//更换手机号前,再次校验是否存在手机号
+			wId, _, _, _, _, err := jy.CreateUserMerge(util.MQFW, util.Mysql, this.Session()).MergeQuery()
+			if err != nil {
+				return nil, err
+			}
+			exists, needRelation := jy.NewPhoneUtil(util.MQFW).ChangePhoneIsOccupy(phoneVerify, wId != "" && userId == wId)
+			if exists {
+				return nil, fmt.Errorf("手机号已被使用")
+			}
+			uData, ok := util.MQFW.FindById("user", userId, `{"s_phone":1,"s_m_phone":1,"s_unionid":1,"s_name":1,"s_nickname":1,"s_headimageurl":1}`)
+			if !ok || uData == nil || len(*uData) == 0 {
+				return nil, DBQUERY_ERROR
+			}
+			beforePhone, _ := qutil.If((*uData)["s_phone"] != nil, (*uData)["s_phone"], (*uData)["s_m_phone"]).(string)
+			if beforePhone == "" {
+				return nil, fmt.Errorf("获取手机号异常")
+			}
+			//商机管理更改手机号逻辑entniche
+			if !util.Mysql.ExecTx("更换管理员老手机号", func(tx *sql.Tx) bool {
+				update_1, update_2, update_3 := true, true, false
+				if util.Mysql.CountBySql("select id from entniche_user where phone=? ", beforePhone) > 0 {
+					update_1 = util.Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set phone=? where phone=? `, phoneVerify, beforePhone) > -1
 				}
-				beforePhone, _ := qutil.If((*uData)["s_phone"] != nil, (*uData)["s_phone"], (*uData)["s_m_phone"]).(string)
-				if beforePhone == "" {
-					return nil, fmt.Errorf("获取手机号异常")
+				if util.Mysql.CountBySql("select id from entniche_info where phone=? ", beforePhone) > 0 {
+					update_2 = util.Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_info set phone=? where phone=?`, phoneVerify, beforePhone) > -1
 				}
-				//商机管理更改手机号逻辑entniche
-				if !util.Mysql.ExecTx("更换管理员老手机号", func(tx *sql.Tx) bool {
-					update_1, update_2, update_3 := true, true, false
-					if util.Mysql.CountBySql("select id from entniche_user where phone=? ", beforePhone) > 0 {
-						update_1 = util.Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_user set phone=? where phone=? `, phoneVerify, beforePhone) > -1
-					}
-					if util.Mysql.CountBySql("select id from entniche_info where phone=? ", beforePhone) > 0 {
-						update_2 = util.Mysql.UpdateOrDeleteBySqlByTx(tx, `update entniche_info set phone=? where phone=?`, phoneVerify, beforePhone) > -1
-					}
-					updateMap := map[string]interface{}{}
-					changePhone := map[string]interface{}{}
-					if (*uData)["s_phone"] != nil {
-						changePhone["s_phone"] = phoneVerify
+				updateMap := map[string]interface{}{}
+				changePhone := map[string]interface{}{}
+				if (*uData)["s_phone"] != nil {
+					changePhone["s_phone"] = phoneVerify
+				}
+				if (*uData)["s_m_phone"] != nil {
+					changePhone["s_m_phone"] = phoneVerify
+				}
+				updateMap["$set"] = changePhone //更改手机号字段
+
+				//解除关联关系
+				//手机号端
+				//   删除微信相关字段
+				//微信端(不查询)
+				//   不做更改
+				unbind2Query := map[string]interface{}{
+					"i_appid": 2,
+					"$or": []map[string]interface{}{
+						map[string]interface{}{"s_phone": beforePhone},
+						map[string]interface{}{"s_m_phone": beforePhone},
+					},
+					"_id": map[string]interface{}{"$ne": (*uData)["_id"]},
+				}
+				phoneUnset := map[string]interface{}{
+					"s_unionid": 1, "s_name": 1, "s_nickname": 1, "s_headimageurl": 1,
+				}
+				if util.MQFW.Count("user", unbind2Query) > 0 { //查询是否存在相关联账号
+					if (*uData)["s_m_phone"] != nil { //当前为微信账户
+						if !util.MQFW.Update("user", map[string]interface{}{
+							"i_appid": 2,
+							"s_phone": beforePhone,
+							"_id":     map[string]interface{}{"$ne": (*uData)["_id"]},
+						}, map[string]interface{}{
+							"$unset": phoneUnset,
+						}, false, false) {
+							return false
+						}
+					} else { //当前为手机号账户
+						updateMap["$unset"] = phoneUnset
 					}
-					if (*uData)["s_m_phone"] != nil {
-						changePhone["s_m_phone"] = phoneVerify
+				}
+				//设置新号关联关系
+				if needRelation {
+					upsetMap := map[string]interface{}{
+						"s_unionid":      (*uData)["s_unionid"],
+						"s_name":         (*uData)["s_name"],
+						"s_nickname":     (*uData)["s_nickname"],
+						"s_headimageurl": (*uData)["s_headimageurl"],
 					}
-					updateMap["$set"] = changePhone //更改手机号字段
-
-					//解除绑定关系
-					//手机号端
-					//   删除微信相关字段
-					//微信端(不查询)
-					//   不做更改
-					unbind2Query := map[string]interface{}{
+					if !util.MQFW.Update("user", map[string]interface{}{
 						"i_appid": 2,
-						"$or": []map[string]interface{}{
-							map[string]interface{}{"s_phone": beforePhone},
-							map[string]interface{}{"s_m_phone": beforePhone},
-						},
-						"_id": map[string]interface{}{"$ne": (*uData)["_id"]},
-					}
-					phoneUnset := map[string]interface{}{
-						"s_unionid": 1, "s_name": 1, "s_nickname": 1, "i_sex": 1, "s_country": 1, "s_province": 1, "s_city": 1, "s_headimageurl": 1, "s_m_openid": 1, "a_m_openid": 1,
-					}
-					if util.MQFW.Count("user", unbind2Query) > 0 { //查询是否存在相关联账号
-						if (*uData)["s_m_phone"] != nil { //当前为微信账户
-							if !util.MQFW.Update("user", map[string]interface{}{
-								"i_appid": 2,
-								"s_phone": beforePhone,
-								"_id":     map[string]interface{}{"$ne": (*uData)["_id"]},
-							}, map[string]interface{}{
-								"$unset": phoneUnset,
-							}, false, false) {
-								return false
-							}
-						} else { //当前为手机号账户
-							updateMap["$unset"] = phoneUnset
-						}
+						"s_phone": phoneVerify,
+					}, map[string]interface{}{
+						"$set": upsetMap,
+					}, false, false) {
+						return false
 					}
-					update_3 = util.MQFW.UpdateById("user", userId, updateMap)
-					return update_1 && update_2 && update_3
-				}) {
-					return nil, fmt.Errorf("商机管理手机号更改出错")
 				}
-				this.Session().Del(phoneAuthPassSessionKey)
-				jy.CreateUserMerge(util.MQFW, util.Mysql, this.Session()).FlushSession(nil, userId) //刷新session
-			}
-		}
-		return map[string]interface{}{
-			"state": 1,
-		}, nil
-	}()
-	if errMsg != nil {
-		log.Printf("%s UserAccount ChangePhone 更改手机号异常:%s\n", userId, errMsg.Error())
-	}
-	this.ServeJson(NewResult(rData, errMsg))
-}
-
-//绑定邮箱&更改邮箱【绑定邮箱和更改邮箱流程一样】
-func (this *UserAccount) MailSet(doType string) {
-	userId, _ := this.GetSession("userId").(string)
-	rData, errMsg := func() (interface{}, error) {
-		step, _ := this.GetInteger("step")
-		mail := this.GetString("mail")
-		code := this.GetString("code")
-		if doType == "change" && step == 1 { //仅发送验证码 校验是否通过身份验证
-			if pass, data := authenticationCheck(this.GetSession(mailAuthPassSessionKey)); !pass {
-				return data, nil
-			}
-		}
-		mailVerify, err := mailStep(this.Session(), step, mail, code, "bind")
-		if err != nil {
-			return nil, err
-		}
-		//校验验证码成功【校验是否需要合并】
-		if step == 2 {
-			if !util.MQFW.UpdateById("user", userId, map[string]interface{}{
-				"$set": map[string]interface{}{
-					"s_myemail": mailVerify,
-				},
+				update_3 = util.MQFW.UpdateById("user", userId, updateMap)
+				return update_1 && update_2 && update_3
 			}) {
-				return nil, DBUPDATE_ERROR
+				return nil, fmt.Errorf("商机管理手机号更改出错")
 			}
-			this.Session().Del(mailAuthPassSessionKey)
+			this.Session().Del(phoneAuthPassSessionKey)
+			jy.CreateUserMerge(util.MQFW, util.Mysql, this.Session()).FlushSession(nil, userId) //刷新session
 		}
 		return map[string]interface{}{
 			"state": 1,
 		}, nil
 	}()
 	if errMsg != nil {
-		log.Printf("%s UserAccount MailSet %s 邮箱异常:%s\n", userId, doType, errMsg.Error())
+		log.Printf("%s UserAccount ChangePhone 更改手机号异常:%s\n", userId, errMsg.Error())
 	}
 	this.ServeJson(NewResult(rData, errMsg))
 }
@@ -497,8 +561,7 @@ func (this *UserAccount) WxBind() {
 		if err != nil {
 			return nil, PARAM_ERROR
 		}
-
-		thisUser, ok := util.MQFW.FindById("user", userId, `{s_unionid:1}`)
+		thisUser, ok := util.MQFW.FindById("user", userId, `{"s_unionid":1,"s_phone":1}`)
 		if !ok || thisUser == nil || len(*thisUser) == 0 {
 			return false, DBQUERY_ERROR
 		}
@@ -517,29 +580,11 @@ func (this *UserAccount) WxBind() {
 		//绑定微信条件
 		//1.全新微信
 		//2.非全新微信。此号无绑定手机号,或者绑定手机号和当前手机号一致(绑定后此非全新微信,也需要添加手机号字段;建立双向关联关系)
-		if wxBindNum := util.MQFW.Count("user", map[string]interface{}{"i_appid": 2, "s_unionid": uBind.UnionId}); wxBindNum > 0 {
-			if wxBindNum != 1 || util.MQFW.Count("user", map[string]interface{}{
-				"i_appid":   2,
-				"s_unionid": uBind.UnionId,
-				"$or": []map[string]interface{}{
-					map[string]interface{}{
-						"s_phone":   map[string]interface{}{"$exists": 0},
-						"s_m_phone": map[string]interface{}{"$exists": 0},
-					},
-					map[string]interface{}{
-						"$or": []map[string]interface{}{
-							map[string]interface{}{
-								"s_phone": thisPhone,
-							},
-							map[string]interface{}{
-								"s_m_phone": thisPhone,
-							},
-						},
-					},
-				},
-			}) != wxBindNum {
-				return nil, fmt.Errorf("微信被已绑定")
-			}
+		exists, needRelation := jy.NewPhoneUtil(util.MQFW).BindWeixinIsOccupy(thisPhone, uBind.UnionId)
+		if exists {
+			return nil, fmt.Errorf("微信被已绑定")
+		}
+		if needRelation {
 			//建立旧微信绑定手机号(建立双向绑定)
 			if !util.MQFW.Update("user", map[string]interface{}{
 				"i_appid": 2, "s_unionid": uBind.UnionId,
@@ -550,18 +595,10 @@ func (this *UserAccount) WxBind() {
 			}
 		}
 		//微信绑定校验通过
-		rData := map[string]interface{}{
-			"state": 1,
-		}
 		upDate := map[string]interface{}{
 			"s_name":         uBind.Nickname,
 			"s_nickname":     uBind.Nickname,
-			"i_sex":          uBind.Sex,
-			"s_country":      uBind.Country,
-			"s_province":     uBind.Province,
-			"s_city":         uBind.City,
 			"s_headimageurl": uBind.HeadImageUrl,
-			"a_m_openid":     uBind.OpenId,
 			"s_unionid":      uBind.UnionId,
 		}
 		if !util.MQFW.UpdateById("user", userId, map[string]interface{}{
@@ -570,7 +607,9 @@ func (this *UserAccount) WxBind() {
 			return -1, DBUPDATE_ERROR
 		}
 		jy.CreateUserMerge(util.MQFW, util.Mysql, this.Session()).FlushSession(&upDate, userId)
-		return rData, nil
+		return map[string]interface{}{
+			"state": 1,
+		}, nil
 	}()
 	if errMsg != nil {
 		log.Printf("%s UserAccount WxBind 微信绑定出错:%s\n", userId, errMsg.Error())
@@ -597,10 +636,7 @@ func (this *UserAccount) WxUnBind() {
 		if unionid == "" {
 			return nil, fmt.Errorf("未查询到绑定信息")
 		}
-		if phone, ok := (*unsetMap)["s_phone"].(string); !ok || phone == "" { //仅手机号登录
-			return nil, fmt.Errorf("解绑操作异常")
-		}
-		//解绑微信必须先绑定手机号
+		//解绑微信必须 仅手机号登录
 		phone, _ := (*unsetMap)["s_phone"].(string)
 		if phone == "" {
 			return nil, fmt.Errorf("非法操作")
@@ -658,50 +694,6 @@ func (this *UserAccount) WxUnBind() {
 	this.ServeJson(NewResult(rData, errMsg))
 }
 
-//公司名称联想
-func (this *UserAccount) CompanyAssociation() {
-	rData, errMsg := func() (interface{}, error) {
-		name := this.GetString("name")
-		list := []string{}
-		if len([]rune(name)) > 2 {
-			query := fmt.Sprintf(`{"query": {"match_phrase": {"name": "%s"}},"_source": ["name"],"size": %d}`, name, 5)
-			r := elastic.Get("qyxy", "qyxy", query)
-			if r != nil {
-				for _, v := range *r {
-					list = append(list, qutil.ObjToString(v["name"]))
-				}
-			}
-		}
-		return list, nil
-	}()
-	this.ServeJson(NewResult(rData, errMsg))
-}
-
-//设置公司名称
-func (this *UserAccount) SetCompany() {
-	userId, _ := this.GetSession("userId").(string)
-	rData, errMsg := func() (interface{}, error) {
-		companyName := strings.TrimSpace(this.GetString("name"))
-		if companyName == "" {
-			return nil, fmt.Errorf("公司名称不能为空")
-		}
-		if !util.MQFW.UpdateById("user", userId, map[string]interface{}{
-			"$set": map[string]interface{}{
-				"s_company": companyName,
-			},
-		}) {
-			return nil, DBUPDATE_ERROR
-		}
-		return map[string]interface{}{
-			"state": 1,
-		}, nil
-	}()
-	if errMsg != nil {
-		log.Printf("%s UserAccount ChangeCompany 设置公司名称:%s\n", userId, errMsg.Error())
-	}
-	this.ServeJson(NewResult(rData, errMsg))
-}
-
 //util---------------------------------
 
 //图形验证码校验
@@ -742,11 +734,7 @@ func phoneStep(sess *httpsession.Session, step int, phone, code, sign string) (s
 			if unionid == "" {
 				return "", fmt.Errorf("获取账户信息异常")
 			}
-			if exists, _ := bindPhoneIsOccupy(phone, unionid); exists {
-				return "", fmt.Errorf("手机号已被使用")
-			}
-		} else if sign == "change" {
-			if changePhoneIsOccupy(phone) {
+			if exists, _ := jy.NewPhoneUtil(util.MQFW).BindPhoneIsOccupy(unionid, phone); exists {
 				return "", fmt.Errorf("手机号已被使用")
 			}
 		}
@@ -832,56 +820,6 @@ func mailStep(sess *httpsession.Session, step int, mail, code, doType string) (s
 	return "", OPERATION_ERROR
 }
 
-//手机号占用查询(绑定)
-func bindPhoneIsOccupy(phone, unionid string) (exists, needRelation bool) {
-	//已经有微信账户绑定过
-	if util.MQFW.Count("user", map[string]interface{}{"i_appid": 2, "s_m_phone": phone, "s_phone": map[string]interface{}{"$exists": 0}}) > 0 {
-		return true, false
-	}
-	//是否存在手机号用户
-	if pUserNum := util.MQFW.Count("user", map[string]interface{}{
-		"i_appid": 2,
-		"s_phone": phone,
-	}); pUserNum > 0 {
-		//存在手机号用户,但此手机号未绑定微信,或绑定微信和当前账户绑定微信一致
-		if pUserNum == 1 && pUserNum == util.MQFW.Count("user", map[string]interface{}{
-			"i_appid": 2,
-			"s_phone": phone,
-			"$or": []map[string]interface{}{
-				map[string]interface{}{
-					"s_m_openid": map[string]interface{}{"$exists": 0},
-					"a_m_openid": map[string]interface{}{"$exists": 0},
-				},
-				map[string]interface{}{
-					"s_unionid": unionid,
-				},
-			},
-		}) {
-			return false, true
-		}
-		return true, false
-	}
-	return false, false
-}
-
-//手机号占用查询(更改)
-func changePhoneIsOccupy(phone string) bool {
-	if util.MQFW.Count("user", map[string]interface{}{
-		"i_appid": 2,
-		"$or": []map[string]interface{}{
-			map[string]interface{}{
-				"s_m_phone": phone,
-			},
-			map[string]interface{}{
-				"s_phone": phone,
-			},
-		},
-	}) > 0 {
-		return true
-	}
-	return false
-}
-
 //通过用户id获取手机号
 func getPhoneByUserId(userId string) (phone string) {
 	uData, _ := util.MQFW.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)