coupon.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. package client
  2. import (
  3. "context"
  4. "go-common/app/service/main/coupon/model"
  5. "go-common/library/net/rpc"
  6. )
  7. var (
  8. _noRes = &struct{}{}
  9. )
  10. const (
  11. _salaryCoupon = "RPC.SalaryCoupon"
  12. _salaryCouponForThird = "RPC.SalaryCouponForThird"
  13. _couponPage = "RPC.CouponPage"
  14. _couponCartoonPage = "RPC.CouponCartoonPage"
  15. _usableAllowanceCoupon = "RPC.UsableAllowanceCoupon"
  16. _allowanceCouponPanel = "RPC.AllowanceCouponPanel"
  17. _multiUsableAllowanceCoupon = "RPC.MultiUsableAllowanceCoupon"
  18. _judgeCouponUsable = "RPC.JudgeCouponUsable"
  19. _allowanceInfo = "RPC.AllowanceInfo"
  20. _cancelUseCoupon = "RPC.CancelUseCoupon"
  21. _couponNotify = "RPC.CouponNotify"
  22. _allowanceList = "RPC.AllowanceList"
  23. _useAllowance = "RPC.UseAllowance"
  24. _allowanceCount = "RPC.AllowanceCount"
  25. _receiveAllowance = "RPC.ReceiveAllowance"
  26. _prizeCards = "RPC.PrizeCards"
  27. _prizeDraw = "RPC.PrizeDraw"
  28. )
  29. const (
  30. _appid = "account.service.coupon"
  31. )
  32. var (
  33. _noArg = &struct{}{}
  34. )
  35. // Service struct info.
  36. type Service struct {
  37. client *rpc.Client2
  38. }
  39. // New create instance of service and return.
  40. func New(c *rpc.ClientConfig) (s *Service) {
  41. s = &Service{}
  42. s.client = rpc.NewDiscoveryCli(_appid, c)
  43. return s
  44. }
  45. // SalaryCoupon salary coupon.
  46. func (s *Service) SalaryCoupon(c context.Context, arg *model.ArgSalaryCoupon) (err error) {
  47. err = s.client.Call(c, _salaryCoupon, arg, _noRes)
  48. return
  49. }
  50. // SalaryCouponForThird salary coupon.
  51. func (s *Service) SalaryCouponForThird(c context.Context, arg *model.ArgSalaryCoupon) (res *model.SalaryCouponForThirdResp, err error) {
  52. res = new(model.SalaryCouponForThirdResp)
  53. err = s.client.Call(c, _salaryCouponForThird, arg, res)
  54. return
  55. }
  56. // CouponPage coupon page.
  57. func (s *Service) CouponPage(c context.Context, arg *model.ArgRPCPage) (res *model.CouponPageRPCResp, err error) {
  58. res = new(model.CouponPageRPCResp)
  59. err = s.client.Call(c, _couponPage, arg, res)
  60. return
  61. }
  62. // CouponCartoonPage coupon cartoon page.
  63. func (s *Service) CouponCartoonPage(c context.Context, arg *model.ArgRPCPage) (res *model.CouponCartoonPageResp, err error) {
  64. res = new(model.CouponCartoonPageResp)
  65. err = s.client.Call(c, _couponCartoonPage, arg, res)
  66. return
  67. }
  68. // UsableAllowanceCoupon get usable allowance coupon.
  69. func (s *Service) UsableAllowanceCoupon(c context.Context, arg *model.ArgAllowanceCoupon) (res *model.CouponAllowancePanelInfo, err error) {
  70. res = new(model.CouponAllowancePanelInfo)
  71. err = s.client.Call(c, _usableAllowanceCoupon, arg, res)
  72. return
  73. }
  74. // AllowanceCouponPanel get allowance coupon.
  75. func (s *Service) AllowanceCouponPanel(c context.Context, arg *model.ArgAllowanceCoupon) (res *model.CouponAllowancePanelResp, err error) {
  76. res = new(model.CouponAllowancePanelResp)
  77. err = s.client.Call(c, _allowanceCouponPanel, arg, res)
  78. return
  79. }
  80. // MultiUsableAllowanceCoupon get usable allowance coupon by muti pirce.
  81. func (s *Service) MultiUsableAllowanceCoupon(c context.Context, arg *model.ArgUsablePirces) (res map[float64]*model.CouponAllowancePanelInfo, err error) {
  82. err = s.client.Call(c, _multiUsableAllowanceCoupon, arg, &res)
  83. return
  84. }
  85. // JudgeCouponUsable judge coupon is usable.
  86. func (s *Service) JudgeCouponUsable(c context.Context, arg *model.ArgJuageUsable) (res *model.CouponAllowanceInfo, err error) {
  87. res = new(model.CouponAllowanceInfo)
  88. err = s.client.Call(c, _judgeCouponUsable, arg, res)
  89. return
  90. }
  91. // AllowanceInfo allowance info.
  92. func (s *Service) AllowanceInfo(c context.Context, arg *model.ArgAllowance) (res *model.CouponAllowanceInfo, err error) {
  93. res = new(model.CouponAllowanceInfo)
  94. err = s.client.Call(c, _allowanceInfo, arg, res)
  95. return
  96. }
  97. // CancelUseCoupon cancel use coupon.
  98. func (s *Service) CancelUseCoupon(c context.Context, arg *model.ArgAllowance) (err error) {
  99. err = s.client.Call(c, _cancelUseCoupon, arg, _noArg)
  100. return
  101. }
  102. // CouponNotify notify coupon.
  103. func (s *Service) CouponNotify(c context.Context, arg *model.ArgNotify) (err error) {
  104. err = s.client.Call(c, _couponNotify, arg, _noArg)
  105. return
  106. }
  107. // AllowanceList allowance list.
  108. func (s *Service) AllowanceList(c context.Context, arg *model.ArgAllowanceList) (res []*model.CouponAllowancePanelInfo, err error) {
  109. err = s.client.Call(c, _allowanceList, arg, &res)
  110. return
  111. }
  112. // UseAllowance use allowance.
  113. func (s *Service) UseAllowance(c context.Context, arg *model.ArgUseAllowance) (err error) {
  114. err = s.client.Call(c, _useAllowance, arg, _noArg)
  115. return
  116. }
  117. // AllowanceCount allowance count.
  118. func (s *Service) AllowanceCount(c context.Context, arg *model.ArgAllowanceMid) (res int, err error) {
  119. err = s.client.Call(c, _allowanceCount, arg, &res)
  120. return
  121. }
  122. //ReceiveAllowance receive allowance
  123. func (s *Service) ReceiveAllowance(c context.Context, arg *model.ArgReceiveAllowance) (res string, err error) {
  124. err = s.client.Call(c, _receiveAllowance, arg, &res)
  125. return
  126. }
  127. // PrizeCards .
  128. func (s *Service) PrizeCards(c context.Context, arg *model.ArgCount) (res []*model.PrizeCardRep, err error) {
  129. err = s.client.Call(c, _prizeCards, arg, &res)
  130. return
  131. }
  132. // PrizeDraw .
  133. func (s *Service) PrizeDraw(c context.Context, arg *model.ArgPrizeDraw) (res *model.PrizeCardRep, err error) {
  134. err = s.client.Call(c, _prizeDraw, arg, &res)
  135. return
  136. }