43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
|
package logic
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"fonchain-fiee/api/accountFiee"
|
||
|
"fonchain-fiee/pkg/service"
|
||
|
"fonchain-fiee/pkg/utils"
|
||
|
)
|
||
|
|
||
|
// 对没有名字的name进行优化
|
||
|
func beautifulZeroName(name string, userId int64) string {
|
||
|
return utils.IfGec(name == "", fmt.Sprintf("未实名用户:%d", userId), name)
|
||
|
}
|
||
|
|
||
|
var userIdMapPhone = make(map[int64]string)
|
||
|
|
||
|
func BeautifulZeroNameWithPhone(name string, userId int64) string {
|
||
|
var ctx = context.Background()
|
||
|
if name == "" {
|
||
|
telNum, ok := userIdMapPhone[userId]
|
||
|
if ok {
|
||
|
return telNum
|
||
|
}
|
||
|
chatUserRes, err := service.AccountFieeProvider.GetChatUserDetail(ctx, &accountFiee.GetChatUserByIdRequest{Id: userId})
|
||
|
if err != nil {
|
||
|
return fmt.Sprintf("未实名用户:%d", userId)
|
||
|
} else {
|
||
|
if userRes, errs := service.AccountFieeProvider.Info(ctx, &accountFiee.InfoRequest{
|
||
|
Domain: chatUserRes.Origin,
|
||
|
ID: uint64(chatUserRes.OriginId),
|
||
|
Scene: "",
|
||
|
}); errs != nil {
|
||
|
return fmt.Sprintf("未实名用户:%d", userId)
|
||
|
} else {
|
||
|
userIdMapPhone[userId] = userRes.TelNum
|
||
|
return userRes.TelNum
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return name
|
||
|
}
|