vip_associate.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. package http
  2. import (
  3. "go-common/app/interface/main/account/model"
  4. v1 "go-common/app/service/main/vip/api"
  5. vipmol "go-common/app/service/main/vip/model"
  6. "go-common/library/ecode"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/metadata"
  9. )
  10. func bindInfoByMid(c *bm.Context) {
  11. var err error
  12. mid, exists := c.Get("mid")
  13. if !exists {
  14. c.JSON(nil, ecode.AccountNotLogin)
  15. return
  16. }
  17. a := new(model.ArgBindInfo)
  18. if err = c.Bind(a); err != nil {
  19. return
  20. }
  21. a.Mid = mid.(int64)
  22. a.AppID = vipmol.EleAppID
  23. c.JSON(vipSvc.BindInfoByMid(c, a))
  24. }
  25. func createAssociateOrder(c *bm.Context) {
  26. var err error
  27. mid, exists := c.Get("mid")
  28. if !exists {
  29. c.JSON(nil, ecode.AccountNotLogin)
  30. return
  31. }
  32. a := new(model.ArgCreateAssociateOrder)
  33. if err = c.Bind(a); err != nil {
  34. return
  35. }
  36. a.Mid = mid.(int64)
  37. a.IP = metadata.String(c, metadata.RemoteIP)
  38. c.JSON(vipSvc.CreateAssociateOrder(c, a))
  39. }
  40. func associatePanel(c *bm.Context) {
  41. var err error
  42. mid, exists := c.Get("mid")
  43. if !exists {
  44. c.JSON(nil, ecode.AccountNotLogin)
  45. return
  46. }
  47. a := new(vipmol.ArgAssociatePanel)
  48. if err = c.Bind(a); err != nil {
  49. return
  50. }
  51. a.Mid = mid.(int64)
  52. a.IP = metadata.String(c, metadata.RemoteIP)
  53. res := new(struct {
  54. PriceList []*v1.AssociatePanelInfo `json:"price_list"`
  55. })
  56. res.PriceList, err = vipSvc.AssociatePanel(c, a)
  57. if res.PriceList == nil {
  58. res.PriceList = []*v1.AssociatePanelInfo{}
  59. }
  60. c.JSON(res, err)
  61. }
  62. func redpackets(c *bm.Context) {
  63. c.JSON(vipSvc.EleRedPackages(c))
  64. }
  65. func specailfoods(c *bm.Context) {
  66. c.JSON(vipSvc.EleSpecailFoods(c))
  67. }
  68. func actlimit(ctx *bm.Context) {
  69. var mid int64
  70. midi, exists := ctx.Get("mid")
  71. if exists {
  72. mid = midi.(int64)
  73. }
  74. if err := vipSvc.ActivityTimeLimit(mid); err != nil {
  75. ctx.JSON(nil, err)
  76. ctx.Abort()
  77. return
  78. }
  79. }
  80. func iplimit(ctx *bm.Context) {
  81. req := ctx.Request
  82. params := req.Form
  83. sappkey := params.Get("appkey")
  84. ip := metadata.String(ctx, metadata.RemoteIP)
  85. if err := vipSvc.ActivityWhiteIPLimit(sappkey, ip); err != nil {
  86. ctx.JSON(nil, err)
  87. ctx.Abort()
  88. return
  89. }
  90. }
  91. func openlimit(ctx *bm.Context) {
  92. req := ctx.Request
  93. params := req.Form
  94. outOpenID := params.Get("out_open_id")
  95. if err := vipSvc.ActivityWhiteOutOpenIDLimit(outOpenID); err != nil {
  96. ctx.JSON(nil, err)
  97. ctx.Abort()
  98. return
  99. }
  100. }