增加限制条件

This commit is contained in:
hoteas
2022-05-06 11:35:40 +08:00
parent aea2e0241d
commit 4cbc84063a
7 changed files with 87 additions and 48 deletions
+9 -6
View File
@@ -47,15 +47,18 @@ func getCode() string {
}
//认证公共方案
func auth(that *Context, phone, companyName string) error {
func auth(that *Context, phone, companyName, userName string) error {
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id", Map{"id": that.Session("user_id").ToCeilInt()})
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id,name", Map{"id": that.Session("user_id").ToCeilInt()})
if user == nil {
return errors.New("找不到用户")
}
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
if company == nil {
return errors.New("找不到企业")
}
//手机号与原来的不同则进行绑定
if phone != user.GetString("phone") {
if phone != user.GetString("phone") || companyName != company.GetString("name") || user.GetString("name") != userName {
//微信验证成功
if that.Session("wechat_phone").ToStr() == phone {
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
@@ -67,7 +70,7 @@ func auth(that *Context, phone, companyName string) error {
return errors.New("验证码错误")
} else {
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
that.Db.Update("user", Map{"phone": phone, "name": userName}, Map{"id": user.GetCeilInt("id")})
if user.GetCeilInt("company_id") != 0 {
that.Db.Update("company", Map{"phone": phone}, Map{"id": user.GetCeilInt("company_id")})
}
@@ -76,7 +79,7 @@ func auth(that *Context, phone, companyName string) error {
}
//
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
//company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
if company != nil {
that.Db.Update("company", Map{"name": companyName}, Map{"id": company.GetCeilInt64("id")})
if user.GetCeilInt64("salesman_id") != 0 {