server_subsidy.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/client"
  5. "bet24.com/servers/coreservice/subsidy"
  6. "context"
  7. "encoding/json"
  8. "errors"
  9. )
  10. // 获取补助信息
  11. func (s *Server) SubsidyGetInfo(ctx context.Context, args *client.Request, reply *client.Reply) error {
  12. var req client.Subsidy_req
  13. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  14. log.Debug("Server.SubsidyGetInfo unmarshal fail %v", err)
  15. return errors.New("unmarshal error")
  16. }
  17. info := subsidy.GetSubsidyInfo(req.UserId, req.LowerAmount, req.MaxTimes)
  18. if info != nil {
  19. reply.Resp.RetCode = 1
  20. d, _ := json.Marshal(info)
  21. reply.Resp.Data = string(d)
  22. }
  23. return nil
  24. }
  25. // 领取补助
  26. func (s *Server) SubsidyGift(ctx context.Context, args *client.Request, reply *client.Reply) error {
  27. var req client.Subsidy_req
  28. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  29. log.Debug("Server.SubsidyGift unmarshal fail %v", err)
  30. return errors.New("unmarshal error")
  31. }
  32. ret, msg := subsidy.GiftSubsidy(req.UserId, req.LowerAmount, req.MaxTimes, req.CoolSeconds)
  33. reply.Resp.RetCode = 1
  34. d, _ := json.Marshal(struct {
  35. RetCode int
  36. ErrorMsg string
  37. }{
  38. RetCode: ret,
  39. ErrorMsg: msg,
  40. })
  41. reply.Resp.Data = string(d)
  42. return nil
  43. }
  44. // 领取元宝补助
  45. func (s *Server) SubsidyGiftChip(ctx context.Context, args *client.Request, reply *client.Reply) error {
  46. var req client.Subsidy_req
  47. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  48. log.Debug("Server.SubsidyGiftChip unmarshal fail %v", err)
  49. return errors.New("unmarshal error")
  50. }
  51. info := struct {
  52. RetCode bool
  53. Amount int
  54. }{
  55. RetCode: false,
  56. Amount: req.LowerAmount,
  57. }
  58. info.RetCode = subsidy.GiftChipSubsidy(req.UserId, req.LowerAmount, req.IpAddress)
  59. reply.Resp.RetCode = 1
  60. d, _ := json.Marshal(info)
  61. reply.Resp.Data = string(d)
  62. return nil
  63. }
  64. // 领取回归奖励
  65. func (s *Server) GiftReturnAward(ctx context.Context, args *client.Request, reply *client.Reply) error {
  66. var req client.Request_base
  67. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  68. log.Debug("Server.GiftReturnAward unmarshal fail %v", err)
  69. return errors.New("unmarshal error")
  70. }
  71. subsidy.GiftReturnAward(req.UserId)
  72. return nil
  73. }