rpc.go 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. package client
  2. import (
  3. "context"
  4. col "go-common/app/service/main/coupon/model"
  5. "go-common/app/service/main/vip/model"
  6. "go-common/library/net/rpc"
  7. )
  8. const (
  9. _vipInfo = "RPC.VipInfo"
  10. _vipInfos = "RPC.VipInfos"
  11. _bcoinList = "RPC.BcoinList"
  12. _history = "RPC.History"
  13. _createOrder = "RPC.CreateOrder"
  14. _orderInfo = "RPC.OrderInfo"
  15. _tips = "RPC.Tips"
  16. _couponBySuitID = "RPC.CouponBySuitID"
  17. _couponBySuitIDV2 = "RPC.CouponBySuitIDV2"
  18. _couponsForPanel = "RPC.CouponsForPanel"
  19. _couponsForPanelV2 = "RPC.CouponsForPanelV2"
  20. _cancelUseCoupon = "RPC.CancelUseCoupon"
  21. _privilegeBySid = "RPC.PrivilegeBySid"
  22. _privilegeByType = "RPC.PrivilegeByType"
  23. _panelExplain = "RPC.PanelExplain"
  24. _jointly = "RPC.Jointly"
  25. _resourceBatchOpenVip = "RPC.ResourceBatchOpenVip"
  26. _orderPayResult = "RPC.OrderPayResult"
  27. _surplusFrozenTime = "RPC.SurplusFrozenTime"
  28. _unfrozen = "RPC.Unfrozen"
  29. _associateVips = "RPC.AssociateVips"
  30. )
  31. const (
  32. _appid = "account.service.vip"
  33. )
  34. var (
  35. _noArg = &struct{}{}
  36. )
  37. // Service is a question service.
  38. type Service struct {
  39. client *rpc.Client2
  40. }
  41. // New new rpc service.
  42. func New(c *rpc.ClientConfig) (s *Service) {
  43. s = &Service{}
  44. s.client = rpc.NewDiscoveryCli(_appid, c)
  45. return
  46. }
  47. // Ping def.
  48. func (s *Service) Ping(c context.Context) (res *int, err error) {
  49. err = s.client.Call(c, "RPC.Ping", nil, res)
  50. return
  51. }
  52. // VipInfo def.
  53. func (s *Service) VipInfo(c context.Context, arg *model.ArgRPCMid) (res *model.VipInfoResp, err error) {
  54. res = new(model.VipInfoResp)
  55. err = s.client.Call(c, _vipInfo, arg, &res)
  56. return
  57. }
  58. // VipInfos vipinfo list.
  59. func (s *Service) VipInfos(c context.Context, arg *model.ArgRPCMids) (res map[int64]*model.VipInfoResp, err error) {
  60. err = s.client.Call(c, _vipInfos, arg, &res)
  61. return
  62. }
  63. // BcoinList bcoin list.
  64. func (s *Service) BcoinList(c context.Context, arg *model.ArgRPCMid) (res *model.BcoinSalaryResp, err error) {
  65. res = new(model.BcoinSalaryResp)
  66. err = s.client.Call(c, _bcoinList, arg, &res)
  67. return
  68. }
  69. // History user change history.
  70. func (s *Service) History(c context.Context, arg *model.ArgRPCHistory) (res []*model.VipChangeHistoryVo, err error) {
  71. err = s.client.Call(c, _history, arg, &res)
  72. return
  73. }
  74. // CreateOrder create order.
  75. func (s *Service) CreateOrder(c context.Context, arg *model.ArgRPCCreateOrder) (res map[string]interface{}, err error) {
  76. err = s.client.Call(c, _createOrder, arg, &res)
  77. return
  78. }
  79. // OrderInfo order info.
  80. func (s *Service) OrderInfo(c context.Context, arg *model.ArgRPCOrderNo) (res *model.OrderInfo, err error) {
  81. res = new(model.OrderInfo)
  82. err = s.client.Call(c, _orderInfo, arg, &res)
  83. return
  84. }
  85. // Tips info.
  86. func (s *Service) Tips(c context.Context, arg *model.ArgTips) (res []*model.TipsResp, err error) {
  87. err = s.client.Call(c, _tips, arg, &res)
  88. return
  89. }
  90. //CouponBySuitID by suit info.
  91. func (s *Service) CouponBySuitID(c context.Context, arg *model.ArgCouponPanel) (res *col.CouponAllowancePanelInfo, err error) {
  92. res = new(col.CouponAllowancePanelInfo)
  93. err = s.client.Call(c, _couponBySuitID, arg, &res)
  94. return
  95. }
  96. //CouponBySuitIDV2 by suit info.
  97. func (s *Service) CouponBySuitIDV2(c context.Context, arg *model.ArgCouponPanelV2) (res *col.CouponAllowancePanelInfo, err error) {
  98. res = new(col.CouponAllowancePanelInfo)
  99. err = s.client.Call(c, _couponBySuitIDV2, arg, &res)
  100. return
  101. }
  102. //CouponsForPanel by suit info.
  103. func (s *Service) CouponsForPanel(c context.Context, arg *model.ArgCouponPanel) (res *col.CouponAllowancePanelResp, err error) {
  104. res = new(col.CouponAllowancePanelResp)
  105. err = s.client.Call(c, _couponsForPanel, arg, &res)
  106. return
  107. }
  108. //CouponsForPanelV2 by suit info.
  109. func (s *Service) CouponsForPanelV2(c context.Context, arg *model.ArgCouponPanelV2) (res *col.CouponAllowancePanelResp, err error) {
  110. res = new(col.CouponAllowancePanelResp)
  111. err = s.client.Call(c, _couponsForPanelV2, arg, &res)
  112. return
  113. }
  114. //CancelUseCoupon cancel use coupon.
  115. func (s *Service) CancelUseCoupon(c context.Context, arg *model.ArgCouponCancel) (err error) {
  116. err = s.client.Call(c, _cancelUseCoupon, arg, _noArg)
  117. return
  118. }
  119. // PrivilegeBySid privileges by sid.
  120. func (s *Service) PrivilegeBySid(c context.Context, arg *model.ArgPrivilegeBySid) (res *model.PrivilegesResp, err error) {
  121. res = new(model.PrivilegesResp)
  122. err = s.client.Call(c, _privilegeBySid, arg, &res)
  123. return
  124. }
  125. // PrivilegeByType privileges by type.
  126. func (s *Service) PrivilegeByType(c context.Context, arg *model.ArgPrivilegeDetail) (res []*model.PrivilegeDetailResp, err error) {
  127. err = s.client.Call(c, _privilegeByType, arg, &res)
  128. return
  129. }
  130. // PanelExplain panel explain.
  131. func (s *Service) PanelExplain(c context.Context, arg *model.ArgPanelExplain) (res *model.VipPanelExplain, err error) {
  132. res = new(model.VipPanelExplain)
  133. err = s.client.Call(c, _panelExplain, arg, &res)
  134. return
  135. }
  136. //Jointly jointly info.
  137. func (s *Service) Jointly(c context.Context) (res []*model.JointlyResp, err error) {
  138. err = s.client.Call(c, _jointly, _noArg, &res)
  139. return
  140. }
  141. //SurplusFrozenTime surplus frozen.
  142. func (s *Service) SurplusFrozenTime(c context.Context, mid int64) (stime int64, err error) {
  143. err = s.client.Call(c, _surplusFrozenTime, &model.ArgRPCMid{Mid: mid}, &stime)
  144. return
  145. }
  146. //Unfrozen unfrozen
  147. func (s *Service) Unfrozen(c context.Context, mid int64) (err error) {
  148. err = s.client.Call(c, _unfrozen, &model.ArgRPCMid{Mid: mid}, _noArg)
  149. return
  150. }
  151. //ResourceBatchOpenVip resource batch open.
  152. func (s *Service) ResourceBatchOpenVip(c context.Context, arg *model.ArgUseBatch) (err error) {
  153. err = s.client.Call(c, _resourceBatchOpenVip, arg, _noArg)
  154. return
  155. }
  156. //OrderPayResult .
  157. func (s *Service) OrderPayResult(c context.Context, arg *model.ArgDialog) (res *model.OrderResult, err error) {
  158. res = new(model.OrderResult)
  159. err = s.client.Call(c, _orderPayResult, arg, &res)
  160. return
  161. }
  162. // AssociateVips associate vips.
  163. func (s *Service) AssociateVips(c context.Context, arg *model.ArgAssociateVip) (res []*model.AssociateVipResp, err error) {
  164. err = s.client.Call(c, _associateVips, arg, &res)
  165. return
  166. }