正在显示
1 个修改的文件
包含
11 行增加
和
0 行删除
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "oppmg/common/log" | 7 | "oppmg/common/log" |
8 | "oppmg/models" | 8 | "oppmg/models" |
9 | "oppmg/protocol" | 9 | "oppmg/protocol" |
10 | + "oppmg/services/ucenter" | ||
10 | "oppmg/utils" | 11 | "oppmg/utils" |
11 | "time" | 12 | "time" |
12 | 13 | ||
@@ -170,17 +171,27 @@ func AddEmployeeData(data []ModuleEmployee) error { | @@ -170,17 +171,27 @@ func AddEmployeeData(data []ModuleEmployee) error { | ||
170 | var ( | 171 | var ( |
171 | userdata *models.User | 172 | userdata *models.User |
172 | ) | 173 | ) |
174 | + ucenterReturn, err := ucenter.RequestUCenterAddUser(v.Phone, v.Name, "") | ||
175 | + if err != nil { | ||
176 | + log.Error("请求统一用户中心数据失败:%s", err) | ||
177 | + continue | ||
178 | + } | ||
179 | + v.OpenId = ucenterReturn.Data.Id | ||
173 | userdata, err = models.GetUserByUCenter(v.OpenId) | 180 | userdata, err = models.GetUserByUCenter(v.OpenId) |
174 | if err != nil && err != orm.ErrNoRows { | 181 | if err != nil && err != orm.ErrNoRows { |
175 | log.Error("获取用户数据失败,err:%s", err) | 182 | log.Error("获取用户数据失败,err:%s", err) |
176 | return errors.New("获取用户数据失败") | 183 | return errors.New("获取用户数据失败") |
177 | } | 184 | } |
185 | + | ||
178 | if err == orm.ErrNoRows { | 186 | if err == orm.ErrNoRows { |
179 | //添加用户 | 187 | //添加用户 |
180 | userdata = &models.User{ | 188 | userdata = &models.User{ |
181 | UserCenterId: v.OpenId, | 189 | UserCenterId: v.OpenId, |
182 | NickName: v.Name, | 190 | NickName: v.Name, |
183 | Phone: v.Phone, | 191 | Phone: v.Phone, |
192 | + Accid: ucenterReturn.Data.Accid, | ||
193 | + Icon: ucenterReturn.Data.Avatar, | ||
194 | + CsAccount: ucenterReturn.Data.CustomerAccount, | ||
184 | } | 195 | } |
185 | _, err = models.AddUser(userdata) | 196 | _, err = models.AddUser(userdata) |
186 | if err != nil { | 197 | if err != nil { |
-
请 注册 或 登录 后发表评论