income.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package http
  2. import (
  3. "strconv"
  4. api "go-common/app/interface/main/ugcpay/api/http"
  5. "go-common/app/interface/main/ugcpay/model"
  6. "go-common/library/ecode"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func incomeAssetOverview(ctx *bm.Context) {
  10. var (
  11. err error
  12. resp *api.RespIncomeAssetOverview
  13. inc *model.IncomeAssetOverview
  14. mid, _ = ctx.Get("mid")
  15. )
  16. if inc, err = srv.IncomeAssetOverview(ctx, mid.(int64)); err != nil {
  17. ctx.JSON(nil, err)
  18. return
  19. }
  20. resp = &api.RespIncomeAssetOverview{
  21. Total: inc.Total,
  22. TotalBuyTimes: inc.TotalBuyTimes,
  23. MonthNew: inc.MonthNew,
  24. DayNew: inc.DayNew,
  25. }
  26. ctx.JSON(resp, err)
  27. }
  28. func incomeAssetMonthly(ctx *bm.Context) {
  29. var (
  30. err error
  31. arg = &api.ArgIncomeAssetList{}
  32. resp = &api.RespIncomeAssetList{List: make([]*api.RespIncomeAsset, 0)}
  33. inc *model.IncomeAssetMonthly
  34. page *model.Page
  35. ver int64
  36. mid, _ = ctx.Get("mid")
  37. )
  38. if err = ctx.Bind(arg); err != nil {
  39. return
  40. }
  41. if arg.PS == 0 {
  42. arg.PS = 20
  43. }
  44. if arg.PN == 0 {
  45. arg.PN = 1
  46. }
  47. if arg.Ver != "" {
  48. if ver, err = strconv.ParseInt(arg.Ver, 10, 64); err != nil {
  49. ctx.JSON(nil, ecode.RequestErr)
  50. return
  51. }
  52. } else {
  53. // ver=0 代表总计
  54. ver = 0
  55. }
  56. if inc, page, err = srv.IncomeAssetList(ctx, mid.(int64), ver, arg.PS, arg.PN); err != nil {
  57. ctx.JSON(nil, err)
  58. return
  59. }
  60. resp.Page = api.RespPage{
  61. Num: page.Num,
  62. Size: page.Size,
  63. Total: page.Total,
  64. }
  65. for _, i := range inc.List {
  66. resp.List = append(resp.List, &api.RespIncomeAsset{
  67. OID: i.OID,
  68. OType: i.OType,
  69. Title: i.Title,
  70. Currency: i.Currency,
  71. Price: i.Price,
  72. TotalBuyTimes: i.TotalBuyTimes,
  73. NewBuyTimes: i.NewBuyTimes,
  74. TotalErrTimes: i.TotalErrTimes,
  75. NewErrTimes: i.NewErrTimes,
  76. })
  77. }
  78. ctx.JSON(resp, err)
  79. }