server_award.go 779 B

12345678910111213141516171819202122232425262728293031
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/award"
  5. "bet24.com/servers/coreservice/client"
  6. item "bet24.com/servers/micros/item_inventory/proto"
  7. "context"
  8. "encoding/json"
  9. "errors"
  10. )
  11. // 发送奖励
  12. func (s *Server) SendAward(ctx context.Context, args *client.Request, reply *client.Reply) error {
  13. var req client.Award_req
  14. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  15. log.Debug("Server.SendAward unmarshal fail %v", err)
  16. return errors.New("unmarshal error")
  17. }
  18. var info struct {
  19. RetCode int
  20. Awards []item.ItemPack
  21. }
  22. info.RetCode, info.Awards = award.SendAward(req.UserId, req.ActiveId, req.HallType, req.IpAddress)
  23. d, _ := json.Marshal(info)
  24. reply.Resp.RetCode = 1
  25. reply.Resp.Data = string(d)
  26. return nil
  27. }