vip.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package tvvip
  2. import (
  3. "context"
  4. tvmdl "go-common/app/interface/main/tv/model/tvvip"
  5. pb "go-common/app/service/main/tv/api"
  6. )
  7. const (
  8. ystSystemError = "999"
  9. )
  10. // VipInfo implementation
  11. func (s *Service) VipInfo(ctx context.Context, mid int64) (resp *pb.UserInfoReply, err error) {
  12. return s.tvVipClient.UserInfo(ctx, &pb.UserInfoReq{Mid: mid})
  13. }
  14. func (s *Service) YstVipInfo(ctx context.Context, mid int64, sign string) (resp *pb.YstUserInfoReply, err error) {
  15. return s.tvVipClient.YstUserInfo(ctx, &pb.YstUserInfoReq{Mid: mid, Sign: sign})
  16. }
  17. // ChangeHistory implementation
  18. func (s *Service) ChangeHistory(ctx context.Context, id int32) (resp *pb.ChangeHistoryReply, err error) {
  19. return s.tvVipClient.ChangeHistory(ctx, &pb.ChangeHistoryReq{Id: id})
  20. }
  21. // ChangeHistorys implementation
  22. func (s *Service) ChangeHistorys(ctx context.Context, mid int64, from, to, pn, ps int32) (resp *pb.ChangeHistorysReply, err error) {
  23. return s.tvVipClient.ChangeHistorys(ctx, &pb.ChangeHistorysReq{Mid: mid, From: from, To: to, Pn: pn, Ps: ps})
  24. }
  25. // PanelInfo implemention
  26. func (s *Service) PanelInfo(ctx context.Context, mid int64) (resp *pb.PanelInfoReply, err error) {
  27. resp, err = s.tvVipClient.PanelInfo(ctx, &pb.PanelInfoReq{Mid: mid})
  28. return
  29. }
  30. // GuestPanelInfo implemention
  31. func (s *Service) GuestPanelInfo(ctx context.Context) (resp *pb.GuestPanelInfoReply, err error) {
  32. return s.tvVipClient.GuestPanelInfo(ctx, &pb.GuestPanelInfoReq{})
  33. }
  34. // CreateQr implemention
  35. func (s *Service) CreateQr(ctx context.Context, req *tvmdl.CreateQrReq) (resp *pb.CreateQrReply, err error) {
  36. pr := new(pb.CreateQrReq)
  37. req.CopyIntoPbCreateOrReq(pr)
  38. return s.tvVipClient.CreateQr(ctx, pr)
  39. }
  40. // CreateGuestQr implemention
  41. func (s *Service) CreateGuestQr(ctx context.Context, req *tvmdl.CreateGuestQrReq) (resp *pb.CreateGuestQrReply, err error) {
  42. pr := new(pb.CreateGuestQrReq)
  43. req.CopyIntoPbCreateGuestQrReq(pr)
  44. return s.tvVipClient.CreateGuestQr(ctx, pr)
  45. }
  46. // TokenInfo implemention
  47. func (s *Service) TokenInfo(ctx context.Context, tokens []string) (resp *pb.TokenInfoReply, err error) {
  48. req := &pb.TokenInfoReq{
  49. Token: tokens,
  50. }
  51. return s.tvVipClient.TokenInfo(ctx, req)
  52. }
  53. // CreateOrder implementation
  54. func (s *Service) CreateOrder(ctx context.Context, clientIp string, req *tvmdl.CreateOrderReq) (resp *pb.CreateOrderReply, err error) {
  55. pr := new(pb.CreateOrderReq)
  56. req.CopyIntoPbCreateOrderReq(pr)
  57. return s.tvVipClient.CreateOrder(ctx, pr)
  58. }
  59. // CreateGuestOrder implementation
  60. func (s *Service) CreateGuestOrder(ctx context.Context, mid int64, clientIp string, req *tvmdl.CreateGuestOrderReq) (resp *pb.CreateGuestOrderReply, err error) {
  61. pr := new(pb.CreateGuestOrderReq)
  62. pr.Mid = mid
  63. req.CopyIntoPbCreateGuestOrderReq(pr)
  64. return s.tvVipClient.CreateGuestOrder(ctx, pr)
  65. }
  66. // PayCallback implementation
  67. func (s *Service) PayCallback(ctx context.Context, req *tvmdl.YstPayCallbackReq) (resp *pb.PayCallbackReply) {
  68. var err error
  69. pr := new(pb.PayCallbackReq)
  70. req.CopyIntoPbPayCallbackReq(pr)
  71. resp, err = s.tvVipClient.PayCallback(ctx, pr)
  72. if err != nil {
  73. resp = new(pb.PayCallbackReply)
  74. resp.Result = ystSystemError
  75. resp.Msg = err.Error()
  76. }
  77. return
  78. }
  79. // ContractCallback implementation
  80. func (s *Service) WxContractCallback(ctx context.Context, req *tvmdl.WxContractCallbackReq) (resp *pb.WxContractCallbackReply) {
  81. var err error
  82. wc := new(pb.WxContractCallbackReq)
  83. req.CopyIntoPbWxContractCallbackReq(wc)
  84. resp, err = s.tvVipClient.WxContractCallback(ctx, wc)
  85. if err != nil {
  86. resp = new(pb.WxContractCallbackReply)
  87. resp.Result = ystSystemError
  88. resp.Msg = err.Error()
  89. }
  90. return
  91. }