publicScreenMsg.go 2.39 KB
Newer Older
chenweijian's avatar
chenweijian committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
package group_m

import (
	"encoding/json"
	"hilo-user/_const/enum/group_e"
	"hilo-user/domain"
	"hilo-user/domain/model/noble_m"
	"hilo-user/domain/model/user_m"
	"hilo-user/rpc"
)

// 信令消息
type GroupSystemMsg struct {
	MsgId   group_e.TypeSignalMsg `json:"msgId"`
	Source  string                `json:"source"`
	Target  string                `json:"target"`
	Content string                `json:"content"`
}

type HiloUserInfo struct {
	WealthGrade uint32   `json:"wealthGrade"`
	CharmGrade  uint32   `json:"charmGrade"`
	IsVip       bool     `json:"isVip"`
	IsPretty    bool     `json:"isPretty"`
	Medals      []uint32 `json:"medals"`
	PowerName   string   `json:"powerName"` // 用户加入的国家势力的绑定群组的名称
	NobleLevel  uint16   `json:"nobleLevel"`
	SvipLevel   int      `json:"svipLevel"`
}

var GetGroupPowerNameByUserId func(model *domain.Model, userId uint64) (uint64, string, error)

//不用返回错误
func GetHiloUserInfo(model *domain.Model, extId string) string {
	user, err := user_m.GetUserByExtId(model, extId)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%+v", extId, err)
		return ""
	}

	wealthGrade, _, err := user_m.GetWealthGrade(model, user.ID)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%v", extId, err)
		return ""
	}
	charmGrade, _, err := user_m.GetCharmGrade(model, user.ID)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%v", extId, err)
		return ""
	}
	isVip, _, err := user_m.IsVip(user.ID)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%v", extId, err)
		return ""
	}
	//

	isPretty := user.IsPrettyCode()
	//
	medals, err := user_m.GetUserMedalMerge(model.Log, model.Db, user.ID)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%v", extId, err)
		return ""
	}

	_, powerName, err := GetGroupPowerNameByUserId(model, user.ID)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%v", extId, err)
		return ""
	}

	nobleLevel, err := noble_m.GetNobleLevel(model.Db, user.ID)
	if err != nil {
		model.Log.Errorf("extId:%v, err:%v", extId, err)
		return ""
	}
	svip, _ := rpc.GetUserSvip(model, user.ID)

	hilo := HiloUserInfo{
		WealthGrade: wealthGrade,
		CharmGrade:  charmGrade,
		IsVip:       isVip,
		IsPretty:    isPretty,
		Medals:      medals,
		PowerName:   powerName,
		NobleLevel:  nobleLevel,
		SvipLevel:   svip.SvipLevel,
	}
	buf, err := json.Marshal(hilo)
	if err != nil {
		model.Log.Errorf("hilo:%+v, err:%v", hilo, err)
	}
	return string(buf)
}