wangchuanjin преди 2 години
родител
ревизия
c0fec8a6ed
променени са 1 файла, в които са добавени 30 реда и са изтрити 0 реда
  1. 30 0
      p/public.go

+ 30 - 0
p/public.go

@@ -723,6 +723,36 @@ func GetAllByEntUserId(mgo *MongodbSim, msl *Mysql, entUserId, tp int) (*map[str
 	if phone == "" {
 		return nil, nil
 	}
+	return getEntPushSet(mgo, msl, entUserId, tp, phone)
+}
+
+//
+func GetAllByEntPositionId(mgo *MongodbSim, tidb, msl *Mysql, positionId, tp int) (*map[string]interface{}, *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
+	}
+	entId := util.Int64All((*position)[0]["ent_id"])
+	if entId == 0 {
+		logger.Info("该职位id没有找到对应的企业id", position)
+		return nil, nil
+	}
+	phone, _ := (*position)[0]["phone"].(string)
+	if phone == "" {
+		logger.Info("该职位id没有找到对应的手机号", position)
+		return nil, 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 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{}) {
 	users, ok := mgo.Find(Mgo_User, map[string]interface{}{
 		"$or": []map[string]interface{}{
 			map[string]interface{}{