scoresection.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package upcrm
  2. import (
  3. "time"
  4. "go-common/app/admin/main/up/model/upcrmmodel"
  5. "go-common/library/ecode"
  6. )
  7. const (
  8. //ScoreTypeQuality 质量分
  9. ScoreTypeQuality = 1
  10. //ScoreTypePr 影响力
  11. ScoreTypePr = 2
  12. //ScoreTypeCredit 信用分
  13. ScoreTypeCredit = 3
  14. //ScoreSectionTableName table name
  15. ScoreSectionTableName = "score_section_history"
  16. )
  17. //ScoreQueryHistory get history
  18. func (d *Dao) ScoreQueryHistory(scoreType int, date time.Time) (result upcrmmodel.ScoreSectionHistory, err error) {
  19. err = d.crmdb.Model(&result).
  20. Where("score_type=? AND generate_date = ?", scoreType, date.Format("2006-01-02")).
  21. Find(&result).Error
  22. if err == ecode.NothingFound {
  23. err = nil
  24. }
  25. return
  26. }
  27. //GetLastHistory get last update date
  28. func (d *Dao) GetLastHistory(scoreType int) (lastHistoryDate time.Time, err error) {
  29. var model upcrmmodel.ScoreSectionHistory
  30. err = d.crmdb.Table(ScoreSectionTableName).Select("generate_date").Where("score_type=?", scoreType).Order("generate_date desc").Limit(1).Find(&model).Error
  31. if err != nil {
  32. return
  33. }
  34. lastHistoryDate = model.GenerateDate.Time()
  35. return
  36. }