market.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/job/openplatform/open-market/model"
  5. "go-common/library/log"
  6. )
  7. //fetch market data ,from db to es
  8. func (s *Service) marketProc() (err error) {
  9. var projectList []*model.Project
  10. if projectList, err = s.dao.FetchProject(context.TODO()); err != nil {
  11. log.Error("pull project list error (%v)", err)
  12. return
  13. }
  14. for _, project := range projectList {
  15. var orderData, wishData, favoriteData, commentData, pvData, uvData map[int32]int64
  16. if orderData, err = s.dao.OrderData(context.TODO(), project.ID, project.StartTime); err != nil {
  17. log.Error("fetch project_order_data [%d] error (%v)", project.ID, err)
  18. }
  19. if commentData, err = s.dao.CommentData(context.TODO(), project.ID, project.StartTime); err != nil {
  20. log.Error("fetch project_comment_data [%d] error (%v)", project.ID, err)
  21. }
  22. if wishData, err = s.dao.WishData(context.TODO(), project.ID, project.StartTime); err != nil {
  23. log.Error("fetch project_wish_data [%d] error (%v)", project.ID, err)
  24. }
  25. if favoriteData, err = s.dao.FavoriteData(context.TODO(), project.ID, project.StartTime); err != nil {
  26. log.Error("fetch project_favorite_data [%d] error (%v)", project.ID, err)
  27. }
  28. if pvData, uvData, err = s.dao.QueryPUVCount(context.TODO(), project.ID); err != nil {
  29. log.Error("fetch project_puv_data [%d] error (%v)", project.ID, err)
  30. }
  31. project.PV = pvData
  32. project.UV = uvData
  33. project.SaleInfo = orderData
  34. project.CommentInfo = commentData
  35. project.WishInfo = wishData
  36. project.FavoriteInfo = favoriteData
  37. if err = s.dao.SaveData(context.TODO(), project); err != nil {
  38. log.Error("save [%d]data to es error (%v)", project.ID, err)
  39. }
  40. }
  41. return
  42. }