income.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package http
  2. import (
  3. "time"
  4. "go-common/library/ecode"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func archiveIncome(c *bm.Context) {
  9. v := new(struct {
  10. Type int `form:"type"`
  11. Page int `form:"page" default:"1" validate:"min=1"`
  12. Size int `form:"size" default:"20" validate:"min=1"`
  13. All int `form:"all" default:"0"`
  14. })
  15. if err := c.Bind(v); err != nil {
  16. return
  17. }
  18. midI, ok := c.Get("mid")
  19. if !ok {
  20. c.JSON(nil, ecode.NoLogin)
  21. return
  22. }
  23. mid, _ := midI.(int64)
  24. data, err := svc.ArchiveIncome(c, mid, v.Type, v.Page, v.Size, v.All)
  25. if err != nil {
  26. log.Error("growup svc.ArchiveIncome error(%v)", err)
  27. c.JSON(nil, err)
  28. return
  29. }
  30. c.JSON(data, nil)
  31. }
  32. func upSummary(c *bm.Context) {
  33. midI, ok := c.Get("mid")
  34. if !ok {
  35. c.JSON(nil, ecode.NoLogin)
  36. return
  37. }
  38. mid, _ := midI.(int64)
  39. data, err := svc.UpSummary(c, mid)
  40. if err != nil {
  41. log.Error("growup svc.UpSummary error(%v)", err)
  42. c.JSON(nil, err)
  43. return
  44. }
  45. c.JSON(data, nil)
  46. }
  47. func archiveSummary(c *bm.Context) {
  48. v := new(struct {
  49. Type int `form:"type"`
  50. })
  51. if err := c.Bind(v); err != nil {
  52. return
  53. }
  54. midI, ok := c.Get("mid")
  55. if !ok {
  56. c.JSON(nil, ecode.NoLogin)
  57. return
  58. }
  59. mid, _ := midI.(int64)
  60. data, err := svc.ArchiveSummary(c, v.Type, mid)
  61. if err != nil {
  62. log.Error("growup svc.ArchiveSummary error(%v)", err)
  63. c.JSON(nil, err)
  64. return
  65. }
  66. c.JSON(data, nil)
  67. }
  68. func archiveDetail(c *bm.Context) {
  69. v := new(struct {
  70. Type int `form:"type"`
  71. ArchiveID int64 `form:"archive_id" validate:"required"`
  72. })
  73. if err := c.Bind(v); err != nil {
  74. return
  75. }
  76. data, err := svc.ArchiveDetail(c, v.Type, v.ArchiveID)
  77. if err != nil {
  78. log.Error("growup svc.ArchiveDetail error(%v)", err)
  79. c.JSON(nil, err)
  80. return
  81. }
  82. c.JSON(data, nil)
  83. }
  84. func archiveBreach(c *bm.Context) {
  85. v := new(struct {
  86. Type int `form:"type"`
  87. Page int `form:"page" default:"1" validate:"min=1"`
  88. Size int `form:"size" default:"20" validate:"min=1"`
  89. All int `form:"all" default:"0"`
  90. })
  91. if err := c.Bind(v); err != nil {
  92. return
  93. }
  94. midI, ok := c.Get("mid")
  95. if !ok {
  96. c.JSON(nil, ecode.NoLogin)
  97. return
  98. }
  99. mid, _ := midI.(int64)
  100. data, err := svc.ArchiveBreach(c, mid, v.Type, v.Page, v.Size, v.All)
  101. if err != nil {
  102. log.Error("growup svc.ArchiveBreach error(%v)", err)
  103. c.JSON(nil, err)
  104. return
  105. }
  106. c.JSON(data, nil)
  107. }
  108. func upIncomeStat(c *bm.Context) {
  109. v := new(struct {
  110. Type int `form:"type"`
  111. })
  112. if err := c.Bind(v); err != nil {
  113. return
  114. }
  115. midI, ok := c.Get("mid")
  116. if !ok {
  117. c.JSON(nil, ecode.NoLogin)
  118. return
  119. }
  120. mid, _ := midI.(int64)
  121. data, err := svc.UpIncomeStat(c, v.Type, mid, time.Now())
  122. if err != nil {
  123. log.Error("growup svc.UpIncomeStat error(%v)", err)
  124. c.JSON(nil, err)
  125. return
  126. }
  127. c.JSON(data, nil)
  128. }