|
@@ -17,8 +17,9 @@ var (
|
|
|
ctx = context.Background()
|
|
|
)
|
|
|
|
|
|
-// GetCreateUserData 查询用户 不存在注册用户
|
|
|
-func GetCreateUserData(phone string) map[string]interface{} {
|
|
|
+// GetCreateUserData 查询用户 不存在注册用户 isEntSign 是否需要注册企业信息(避免校验调用) 如entId不为0代办已注册企业信息
|
|
|
+func GetCreateUserData(phone, companyName, orderCode string, entId int, isEntSign bool) map[string]interface{} {
|
|
|
+ data := make(map[string]interface{})
|
|
|
userData, ok := MG.DB().FindOne("user", map[string]interface{}{
|
|
|
"$or": []map[string]interface{}{
|
|
|
{"s_phone": phone},
|
|
@@ -26,7 +27,7 @@ func GetCreateUserData(phone string) map[string]interface{} {
|
|
|
},
|
|
|
})
|
|
|
if ok && userData != nil && len(*userData) > 0 {
|
|
|
- return *userData
|
|
|
+ data = *userData
|
|
|
} else {
|
|
|
id := MG.DB().Save("user", map[string]interface{}{
|
|
|
"i_appid": 2,
|
|
@@ -51,11 +52,24 @@ func GetCreateUserData(phone string) map[string]interface{} {
|
|
|
ck := &http.Cookie{}
|
|
|
usercenter.AddBaseUser(*MG.DB(), g.Cfg().MustGet(ctx, "userCenterUrl").String(), id, formdata, ck)
|
|
|
SaveUserLog(id, phone)
|
|
|
- data, _ := MG.DB().FindById("user", id, "")
|
|
|
- return *data
|
|
|
+ uData, _ := MG.DB().FindById("user", id, "")
|
|
|
+ data = *uData
|
|
|
}
|
|
|
}
|
|
|
- return nil
|
|
|
+ var userPositionId string
|
|
|
+ //查找baseUserId
|
|
|
+ baseUserId := common.Int64All(data["base_user_id"])
|
|
|
+ positionData, _ := g.DB().Ctx(ctx).GetOne(ctx, fmt.Sprintf(`SELECT s_name FROM base_position WHERE type=1 and user_id='%d' and ent_id=%d`, baseUserId, entId))
|
|
|
+ if !positionData.IsEmpty() {
|
|
|
+ userPositionId = gconv.String(positionData.Map()["id"])
|
|
|
+ }
|
|
|
+ //校验企业用户是否创建
|
|
|
+ if entId == 0 && isEntSign {
|
|
|
+ entId, _, userPositionId = AutomaticallyCreatingEnt(companyName, phone, orderCode, common.InterfaceToStr(data["_id"]))
|
|
|
+ }
|
|
|
+ data["entId"] = entId
|
|
|
+ data["userPositionId"] = userPositionId
|
|
|
+ return data
|
|
|
}
|
|
|
|
|
|
// 用户注册日志保存
|