http.go 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. package http
  2. import (
  3. "go-common/app/job/main/vip/conf"
  4. "go-common/app/job/main/vip/model"
  5. "go-common/app/job/main/vip/service"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. var (
  10. s *service.Service
  11. )
  12. // Init init http sever instance.
  13. func Init(c *conf.Config, ss *service.Service) {
  14. // init inner router
  15. engine := bm.DefaultServer(c.BM)
  16. innerRouter(engine)
  17. // init inner server
  18. if err := engine.Start(); err != nil {
  19. log.Error("engine start error(%v)", err)
  20. panic(err)
  21. }
  22. s = ss
  23. }
  24. // innerRouter init inner router.
  25. func innerRouter(r *bm.Engine) {
  26. r.Ping(ping)
  27. r.GET("/scanUserInfo", checkscanUserInfo)
  28. r.GET("/handlerOrder", handlerOrder)
  29. r.GET("/handlerChangeHistory", handlerVipChangeHistory)
  30. r.GET("/handlerVipSendBcoin", handlerVipSendBcoin)
  31. r.GET("/sendBcoinJob", sendBcoinJob)
  32. r.GET("/hadExpiredJob", hadExpireJob)
  33. r.GET("/willExpiredJob", willExpireJob)
  34. r.GET("/sendMessageJob", sendMessageJob)
  35. r.GET("/autoRenewJob", autoRenewJob)
  36. r.GET("/syncvipdata", syncVipInfoData)
  37. r.GET("/clearcache", clearUserCache)
  38. r.GET("/scansalarylog", scanSalaryLog)
  39. r.GET("/checkuserdata", checkUserData)
  40. r.GET("/checkBcoinSalary", checkBcoinSalary)
  41. r.GET("/checkChangeHistory", checkHistory)
  42. r.GET("/sync/all/user", syncAllUser)
  43. r.GET("/frozen", frozen)
  44. }
  45. func syncAllUser(c *bm.Context) {
  46. log.Info("syncAllUser start........................................")
  47. s.SyncAllUser(c)
  48. log.Info("syncAllUser end........................................")
  49. }
  50. func checkHistory(c *bm.Context) {
  51. log.Info("check history info start........................................")
  52. mids, err := s.CheckChangeHistory(c)
  53. log.Info("check history info end..............error mids(%+v) error(%+v)", mids, err)
  54. c.JSON(mids, err)
  55. }
  56. func checkBcoinSalary(c *bm.Context) {
  57. log.Info("check bcoin info start........................................")
  58. mids, err := s.CheckBcoinData(c)
  59. log.Info("check bcoin info end..............error mids(%+v) error(%+v)", mids, err)
  60. c.JSON(mids, err)
  61. }
  62. func autoRenewJob(c *bm.Context) {
  63. //s.AutoRenewJob()
  64. }
  65. func sendBcoinJob(c *bm.Context) {
  66. //s.SendBcoinJob()
  67. }
  68. func hadExpireJob(c *bm.Context) {
  69. //s.HadExpiredMsgJob()
  70. }
  71. func willExpireJob(c *bm.Context) {
  72. //s.WillExpiredMsgJob()
  73. }
  74. func sendMessageJob(c *bm.Context) {
  75. //s.SendMessageJob()
  76. }
  77. // ping check server ok.
  78. func ping(c *bm.Context) {}
  79. func handlerOrder(c *bm.Context) {
  80. log.Info("handler order start.........................................")
  81. s.HandlerPayOrder()
  82. log.Info("handler order end ............................................")
  83. }
  84. func handlerVipChangeHistory(c *bm.Context) {
  85. log.Info("handler vip change history start ...................... ")
  86. s.HandlerVipChangeHistory()
  87. log.Info("handler vip change history end ...................... ")
  88. }
  89. func handlerVipSendBcoin(c *bm.Context) {
  90. log.Info(" handler vip send bcoin start ..............")
  91. s.HandlerBcoin()
  92. log.Info("handler vip send bcoin end ...............")
  93. }
  94. func checkscanUserInfo(c *bm.Context) {
  95. log.Info("scan user info start ..........................")
  96. s.ScanUserInfo(c)
  97. log.Info("scan user info end ...........................")
  98. }
  99. func syncVipInfoData(c *bm.Context) {
  100. var err error
  101. arg := new(struct {
  102. Mid int64 `form:"mid" validate:"required"`
  103. })
  104. if err = c.Bind(arg); err != nil {
  105. log.Error("c.Bind err(%+v)", err)
  106. return
  107. }
  108. if err = s.SyncUserInfoByMid(c, arg.Mid); err != nil {
  109. c.JSON(nil, err)
  110. return
  111. }
  112. c.JSON(nil, nil)
  113. }
  114. func clearUserCache(c *bm.Context) {
  115. var err error
  116. arg := new(struct {
  117. Mid int64 `form:"mid" validate:"required"`
  118. })
  119. if err = c.Bind(arg); err != nil {
  120. log.Error("c.Bind err(%+v)", err)
  121. return
  122. }
  123. s.ClearUserCache(arg.Mid)
  124. c.JSON(nil, nil)
  125. }
  126. func scanSalaryLog(c *bm.Context) {
  127. log.Info("scan salary log start ..........................")
  128. var err error
  129. if err = s.ScanSalaryLog(c); err != nil {
  130. log.Error("scan salary log err(%+v)", err)
  131. c.JSON(nil, err)
  132. return
  133. }
  134. log.Info("scan salary log end ...........................")
  135. c.JSON(nil, nil)
  136. }
  137. func checkUserData(c *bm.Context) {
  138. log.Info("check vip_user_info data start ..........................")
  139. var (
  140. err error
  141. diffs map[int64]string
  142. )
  143. if diffs, err = s.CheckUserData(c); err != nil {
  144. c.JSON(diffs, err)
  145. return
  146. }
  147. log.Info("check vip_user_info data end diffs(%v) size(%d)...........................", diffs, len(diffs))
  148. c.JSON(diffs, err)
  149. }
  150. func frozen(c *bm.Context) {
  151. var err error
  152. arg := new(model.LoginLog)
  153. if err = c.Bind(arg); err != nil {
  154. log.Error("c.Bind err(%+v)", err)
  155. return
  156. }
  157. c.JSON(nil, s.Frozen(c, arg))
  158. }