withdraw.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package http
  2. import (
  3. "fmt"
  4. "net/http"
  5. "time"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/http/blademaster/render"
  9. )
  10. func upWithdraw(c *bm.Context) {
  11. v := new(struct {
  12. MIDs []int64 `form:"mids,split"`
  13. IsDeleted int `form:"is_deleted"`
  14. Page int `form:"page" validate:"min=1" default:"1"`
  15. Size int `form:"size" validtae:"min=1" default:"20"`
  16. })
  17. if err := c.Bind(v); err != nil {
  18. return
  19. }
  20. from := (v.Page - 1) * v.Size
  21. data, total, err := incomeSvr.UpWithdraw(c, v.MIDs, v.IsDeleted, from, v.Size)
  22. if err != nil {
  23. log.Error("growup incomeSvr.UpWithdraw error(%v)", err)
  24. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  25. "code": err,
  26. "status": "fail",
  27. }))
  28. return
  29. }
  30. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  31. "code": 0,
  32. "message": "0",
  33. "result": map[string]interface{}{
  34. "data": data,
  35. "page": v.Page,
  36. "total_count": total,
  37. },
  38. "status": "success",
  39. }))
  40. }
  41. func upWithdrawExport(c *bm.Context) {
  42. v := new(struct {
  43. MIDs []int64 `form:"mids,split"`
  44. IsDeleted int `form:"is_deleted"`
  45. Page int `form:"page" validate:"min=1" default:"1"`
  46. Size int `form:"size" validtae:"min=1" default:"20"`
  47. })
  48. if err := c.Bind(v); err != nil {
  49. return
  50. }
  51. from := (v.Page - 1) * v.Size
  52. content, err := incomeSvr.UpWithdrawExport(c, v.MIDs, v.IsDeleted, from, v.Size)
  53. if err != nil {
  54. c.JSON(nil, err)
  55. log.Error("growup incomeSvr.UpWithdrawExport error(%v)", err)
  56. return
  57. }
  58. c.Render(http.StatusOK, CSV{
  59. Content: content,
  60. Title: fmt.Sprintf("%s-%s", time.Now().Format("2006-01-02"), "up_withdraw"),
  61. })
  62. }
  63. func upWithdrawStatis(c *bm.Context) {
  64. v := new(struct {
  65. FromTime int64 `form:"from_time"`
  66. ToTime int64 `form:"to_time"`
  67. IsDeleted int `form:"is_deleted"`
  68. })
  69. if err := c.Bind(v); err != nil {
  70. return
  71. }
  72. data, err := incomeSvr.UpWithdrawStatis(c, v.FromTime, v.ToTime, v.IsDeleted)
  73. if err != nil {
  74. log.Error("growup incomeSvr.UpWithdrawStatis error(%v)", err)
  75. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  76. "code": err,
  77. "status": "fail",
  78. }))
  79. return
  80. }
  81. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  82. "code": 0,
  83. "message": "0",
  84. "result": data,
  85. "status": "success",
  86. }))
  87. }
  88. func upWithdrawDetail(c *bm.Context) {
  89. v := new(struct {
  90. MID int64 `form:"mid" validate:"required"`
  91. })
  92. if err := c.Bind(v); err != nil {
  93. return
  94. }
  95. data, err := incomeSvr.UpWithdrawDetail(c, v.MID)
  96. if err != nil {
  97. log.Error("growup incomeSvr.UpWithdrawStatis error(%v)", err)
  98. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  99. "code": err,
  100. "status": "fail",
  101. }))
  102. return
  103. }
  104. c.Render(http.StatusOK, render.MapJSON(map[string]interface{}{
  105. "code": 0,
  106. "message": "0",
  107. "result": data,
  108. "status": "success",
  109. }))
  110. }
  111. func upWithdrawDetailExport(c *bm.Context) {
  112. v := new(struct {
  113. MID int64 `form:"mid" validate:"required"`
  114. })
  115. if err := c.Bind(v); err != nil {
  116. return
  117. }
  118. content, err := incomeSvr.UpWithdrawDetailExport(c, v.MID)
  119. if err != nil {
  120. c.JSON(nil, err)
  121. log.Error("growup svr.UpWithdrawDetailExport error(%v)", err)
  122. return
  123. }
  124. c.Render(http.StatusOK, CSV{
  125. Content: content,
  126. Title: fmt.Sprintf("%s-%s", time.Now().Format("2006-01-02"), "up_withdraw_detail"),
  127. })
  128. }