|
@@ -861,3 +861,34 @@ func GetEntUserSubset(mgo *MongodbSim, entUserId, tp int) map[string]interface{}
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+//根据企业员工id获取身份信息
|
|
|
+func IdentityByEntUserId(base, main *Mysql, entUserId int64) *IdentityInfo {
|
|
|
+ ents := main.SelectBySql(`SELECT a.id,a.name,a.phone,a.ent_id,b.name as ent_name from entniche_user a inner join entniche_info b on (a.id=? and a.ent_id=b.id) limit 1`, entUserId)
|
|
|
+ if ents == nil || len(*ents) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ if entId := Int64All((*ents)[0]["ent_id"]); entId > 0 {
|
|
|
+ list := base.SelectBySql(`SELECT a.id as position_id,c.person_id,a.person_name,a.account_id,a.type as position_type,d.id as user_id,b.id as ent_account_id from base_user d
|
|
|
+ inner join base_position a on (d.phone=? and a.ent_id=? and a.type=1 and d.id=a.user_id)
|
|
|
+ inner join base_account c on (c.ent_id=? and c.type=1 and a.account_id=c.id)
|
|
|
+ inner join base_account b on (b.type=1 and b.person_id=0 and b.ent_id=?) limit 1`, ObjToString((*ents)[0]["phone"]), entId, entId, entId)
|
|
|
+ if list != nil && len(*list) == 1 {
|
|
|
+ identity := &IdentityInfo{
|
|
|
+ PersonId: Int64All((*list)[0]["person_id"]),
|
|
|
+ UserName: ObjToString((*list)[0]["person_name"]),
|
|
|
+ AccountId: Int64All((*list)[0]["account_id"]),
|
|
|
+ EntAccountId: Int64All((*list)[0]["ent_account_id"]),
|
|
|
+ PositionId: Int64All((*list)[0]["position_id"]),
|
|
|
+ PositionType: Int64All((*list)[0]["position_type"]),
|
|
|
+ UserId: Int64All((*list)[0]["user_id"]),
|
|
|
+ EntId: entId,
|
|
|
+ EntUserId: Int64All((*ents)[0]["id"]),
|
|
|
+ EntUserName: ObjToString((*ents)[0]["name"]),
|
|
|
+ Name: ObjToString((*ents)[0]["ent_name"]),
|
|
|
+ }
|
|
|
+ return identity
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|