http.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package http
  2. import (
  3. "net/http"
  4. "go-common/app/service/main/vip/conf"
  5. "go-common/app/service/main/vip/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/http/blademaster/middleware/verify"
  9. )
  10. var (
  11. vipSvc *service.Service
  12. vrfSvr *verify.Verify
  13. )
  14. // Init init http sever instance.
  15. func Init(c *conf.Config, s *service.Service) {
  16. vrfSvr = verify.New(nil)
  17. vipSvc = service.New(c)
  18. // init router
  19. engineOuter := bm.DefaultServer(c.BM)
  20. innerRouter(engineOuter)
  21. if err := engineOuter.Start(); err != nil {
  22. log.Error("engineOuter.Start() error(%v)", err)
  23. panic(err)
  24. }
  25. }
  26. // innerRouter init inner router.
  27. func innerRouter(e *bm.Engine) {
  28. e.Ping(ping)
  29. e.Register(register)
  30. //internal api
  31. big := e.Group("/x/internal/big", vrfSvr.Verify)
  32. {
  33. big.GET("/batchInfo", batchInfo)
  34. big.POST("/useBatchInfo", useBatchInfo)
  35. }
  36. vip := e.Group("/x/internal/vip", vrfSvr.Verify)
  37. {
  38. // bcoin
  39. vip.GET("/bcoin/list", bpList)
  40. // point
  41. vip.POST("/point/exchange_vip", buyVipWithPoint)
  42. vip.POST("/point/rule", rule)
  43. // user
  44. vip.GET("/user/info", byMid)
  45. vip.GET("/user/list", vipInfos)
  46. vip.GET("/user/history", vipHistory)
  47. vip.GET("/user/history/h5", vipH5History)
  48. vip.GET("/user/infobo", vipInfo) // for old service.
  49. // order
  50. vip.GET("/order/status", status)
  51. vip.GET("/order/list", orders)
  52. vip.POST("/order/create", createOrder)
  53. vip.POST("/order/oldcreate", createOldOrder) // for old service
  54. vip.GET("/order/mng", orderMng)
  55. vip.GET("/order/rescision", rescision)
  56. //panel
  57. vip.GET("/panel", pannelInfoNew)
  58. // panel
  59. vip.GET("/panel/single/info", vipUserMonthPanel)
  60. vip.GET("/panel/pirce", vipPirce)
  61. // price
  62. vip.GET("/price/by_product_id", priceceByProductID)
  63. vip.GET("/price/by_id", priceceByID)
  64. // code
  65. vip.GET("/code/verify", webToken)
  66. vip.POST("/code/open", openCode)
  67. vip.GET("/code/info", codeInfo)
  68. vip.GET("/code/infos", codeInfos)
  69. vip.POST("/code/belong", belong)
  70. vip.POST("/active/infos", actives)
  71. vip.GET("/code/opened", codeOpened)
  72. // tips
  73. vip.GET("/tips", tips)
  74. //coupon
  75. vip.POST("/coupon/cancel", cancelUseCoupon)
  76. vip.GET("/coupon/info", allowanceInfo)
  77. // FIXME: sync user
  78. vip.POST("/sync/user", syncUser)
  79. vip.POST("/order/create/qr", createQrCodeOrder)
  80. //act
  81. vip.POST("/activity/prize/grant", thirdPrizeGrant)
  82. vip.POST("/ele/vip/grant", grantAssociateVip)
  83. }
  84. vip2 := e.Group("/x/internal/vip/v2", vrfSvr.Verify)
  85. {
  86. vip2.POST("/order/create", createOrder2)
  87. }
  88. vipNotSign := e.Group("/x/internal/vip")
  89. {
  90. // notify
  91. vipNotSign.GET("/notify", notify)
  92. vipNotSign.GET("/notify/v2", notify2)
  93. vipNotSign.GET("/notify/sign", signNotify)
  94. vipNotSign.GET("/notify/refund", refundOrderNotify)
  95. }
  96. }
  97. // ping check server ok.
  98. func ping(c *bm.Context) {
  99. var err error
  100. if err = vipSvc.Ping(c); err != nil {
  101. log.Error("service ping error(%v)", err)
  102. c.AbortWithStatus(http.StatusServiceUnavailable)
  103. }
  104. }
  105. // register check server ok.
  106. func register(c *bm.Context) {
  107. c.JSON(map[string]interface{}{}, nil)
  108. }