wangchuanjin 2 лет назад
Родитель
Сommit
f77694cdb4
2 измененных файлов с 24 добавлено и 15 удалено
  1. 24 15
      p/public.go
  2. BIN
      test

+ 24 - 15
p/public.go

@@ -713,46 +713,46 @@ func GetPhone(u map[string]interface{}) string {
 }
 
 //
-func GetAllByEntUserId(mgo *MongodbSim, msl *Mysql, entUserId, tp int) (*map[string]interface{}, *map[string]interface{}) {
+func GetAllByEntUserId(mgo *MongodbSim, msl *Mysql, entUserId, tp int) *map[string]interface{} {
 	entUsers := msl.SelectBySql(`select phone from entniche_user where id=?`, entUserId)
 	if entUsers == nil || len(*entUsers) == 0 {
 		logger.Info("entniche_user表中没有找到该企业用户", entUserId)
-		return nil, nil
+		return nil
 	}
 	phone, _ := (*entUsers)[0]["phone"].(string)
 	if phone == "" {
-		return nil, nil
+		return nil
 	}
 	return getEntPushSet(mgo, msl, entUserId, tp, phone)
 }
 
 //
-func GetAllByEntPositionId(mgo *MongodbSim, tidb, msl *Mysql, positionId, tp int) (*map[string]interface{}, *map[string]interface{}) {
+func GetAllByEntPositionId(mgo *MongodbSim, tidb, msl *Mysql, positionId, tp int) *map[string]interface{} {
 	position := tidb.SelectBySql(`select a.ent_id,b.phone from base_position a inner join base_user b on (a.id=? and a.user_id=b.id)`, positionId)
 	if position == nil || len(*position) == 0 {
 		logger.Info("无效的职位id", position)
-		return nil, nil
+		return nil
 	}
 	entId := util.Int64All((*position)[0]["ent_id"])
 	if entId == 0 {
 		logger.Info("该职位id没有找到对应的企业id", position)
-		return nil, nil
+		return nil
 	}
 	phone, _ := (*position)[0]["phone"].(string)
 	if phone == "" {
 		logger.Info("该职位id没有找到对应的手机号", position)
-		return nil, nil
+		return nil
 	}
 	entUsers := msl.SelectBySql(`select id from entniche_user where phone=? and ent_id=?`, phone, entId)
 	if entUsers == nil || len(*entUsers) == 0 {
 		logger.Info("entniche_user表中没有找到该企业用户", phone, entId)
-		return nil, nil
+		return nil
 	}
 	return getEntPushSet(mgo, msl, util.IntAll((*entUsers)[0]["id"]), tp, phone)
 }
 
 //
-func getEntPushSet(mgo *MongodbSim, msl *Mysql, entUserId, tp int, phone string) (*map[string]interface{}, *map[string]interface{}) {
+func getEntPushSet(mgo *MongodbSim, msl *Mysql, entUserId, tp int, phone string) *map[string]interface{} {
 	users, ok := mgo.Find(Mgo_User, map[string]interface{}{
 		"$or": []map[string]interface{}{
 			map[string]interface{}{
@@ -772,7 +772,7 @@ func getEntPushSet(mgo *MongodbSim, msl *Mysql, entUserId, tp int, phone string)
 	}, `{"s_phone":-1}`, false, -1, -1)
 	if !ok || users == nil || len(*users) == 0 {
 		logger.Info("user表中没有找到该企业用户", entUserId)
-		return nil, nil
+		return nil
 	}
 	user := map[string]interface{}{}
 	for _, v := range *users {
@@ -791,13 +791,22 @@ func getEntPushSet(mgo *MongodbSim, msl *Mysql, entUserId, tp int, phone string)
 			user["s_appponetype"] = s_appponetype
 		}
 	}
+	entniche_user, ok := mgo.FindOneByField("entniche_user", map[string]interface{}{
+		"i_userid": entUserId,
+	}, `{"_id":0,"i_member_status":1,"l_member_endtime":1,"l_vip_endtime":1,"i_vip_status":1}`)
+	if ok && entniche_user != nil && len(*entniche_user) > 0 {
+		for k, v := range *entniche_user {
+			user[k] = v
+		}
+	}
 	entniche_rule, ok := mgo.FindOneByField("entniche_rule", map[string]interface{}{
 		"i_userid": entUserId,
 		"i_type":   tp,
-	}, `{"o_entniche":1,"l_endtime":1,"i_status":1}`)
-	if !ok || entniche_rule == nil || len(*entniche_rule) == 0 {
-		logger.Info("没有找到该企业用户的订阅设置", entUserId)
-		return nil, nil
+	}, `{"_id":0,"o_entniche":1}`)
+	if ok && entniche_rule != nil && len(*entniche_rule) > 0 {
+		for k, v := range *entniche_user {
+			user[k] = v
+		}
 	}
-	return &user, entniche_rule
+	return &user
 }