income.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/interface/main/ugcpay/model"
  5. "go-common/library/log"
  6. )
  7. // IncomeAssetOverview 获得收入总览数据
  8. func (s *Service) IncomeAssetOverview(ctx context.Context, mid int64) (inc *model.IncomeAssetOverview, err error) {
  9. inc, err = s.dao.IncomeAssetOverview(ctx, mid)
  10. return
  11. }
  12. // IncomeAssetList 获得稿件维度的收入数据
  13. func (s *Service) IncomeAssetList(ctx context.Context, mid int64, ver int64, ps, pn int64) (inc *model.IncomeAssetMonthly, page *model.Page, err error) {
  14. if inc, err = s.dao.IncomeUserAssetList(ctx, mid, ver, ps, pn); err != nil {
  15. return
  16. }
  17. // 获得稿件标题信息
  18. var (
  19. aids = make([]int64, 0)
  20. titleMap = make(map[int64]string)
  21. )
  22. for _, l := range inc.List {
  23. aids = append(aids, l.OID)
  24. }
  25. if titleMap, err = s.dao.ArchiveTitles(ctx, aids); err != nil {
  26. log.Error("s.dao.ArchiveTitles aids: %+v, err: %+v", aids, err)
  27. err = nil
  28. }
  29. for _, l := range inc.List {
  30. l.Title = titleMap[l.OID]
  31. }
  32. page = &model.Page{
  33. Size: inc.Page.Size,
  34. Num: inc.Page.Num,
  35. Total: inc.Page.Total,
  36. }
  37. return
  38. }