user_card.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/bbq/user/internal/model"
  5. acc "go-common/app/service/main/account/api"
  6. "go-common/library/log"
  7. "go-common/library/net/metadata"
  8. )
  9. // RawUserCard 从主站获取用户基础信息
  10. func (d *Dao) RawUserCard(c context.Context, mid int64) (userCard *model.UserCard, err error) {
  11. req := &acc.MidReq{
  12. Mid: mid,
  13. RealIp: metadata.String(c, metadata.RemoteIP),
  14. }
  15. res, err := d.accountClient.Card3(c, req)
  16. if err != nil {
  17. log.Error("user card rpc error(%v)", err)
  18. return
  19. }
  20. vipInfo := model.VIPInfo{
  21. Type: res.Card.Vip.Type,
  22. Status: res.Card.Vip.Status,
  23. DueDate: res.Card.Vip.DueDate,
  24. }
  25. userCard = &model.UserCard{
  26. MID: res.Card.Mid,
  27. Name: res.Card.Name,
  28. Sex: res.Card.Sex,
  29. Rank: res.Card.Rank,
  30. Face: res.Card.Face,
  31. Sign: res.Card.Sign,
  32. Level: res.Card.Level,
  33. VIPInfo: vipInfo,
  34. }
  35. return
  36. }
  37. // RawUserCards 从主站获取用户基础信息
  38. func (d *Dao) RawUserCards(c context.Context, mids []int64) (userCards map[int64]*model.UserCard, err error) {
  39. req := &acc.MidsReq{
  40. Mids: mids,
  41. RealIp: metadata.String(c, metadata.RemoteIP),
  42. }
  43. res, err := d.accountClient.Cards3(c, req)
  44. if err != nil {
  45. log.Error("user card rpc error(%v)", err)
  46. return
  47. }
  48. userCards = make(map[int64]*model.UserCard, len(mids))
  49. for _, card := range res.Cards {
  50. vipInfo := model.VIPInfo{
  51. Type: card.Vip.Type,
  52. Status: card.Vip.Status,
  53. DueDate: card.Vip.DueDate,
  54. }
  55. userCard := &model.UserCard{
  56. MID: card.Mid,
  57. Name: card.Name,
  58. Sex: card.Sex,
  59. Rank: card.Rank,
  60. Face: card.Face,
  61. Sign: card.Sign,
  62. Level: card.Level,
  63. VIPInfo: vipInfo,
  64. }
  65. userCards[card.Mid] = userCard
  66. }
  67. return
  68. }
  69. // RawUserAccCards 批量获取账号信息
  70. func (d *Dao) RawUserAccCards(c context.Context, mids []int64) (res *acc.CardsReply, err error) {
  71. req := &acc.MidsReq{
  72. Mids: mids,
  73. RealIp: metadata.String(c, metadata.RemoteIP),
  74. }
  75. res, err = d.accountClient.Cards3(c, req)
  76. if err != nil {
  77. log.Error("d.accountClient.Cards3 err [%v]", err)
  78. }
  79. return
  80. }