up_rank.go 979 B

1234567891011121314151617181920212223242526272829
  1. package upcrm
  2. import (
  3. "time"
  4. "go-common/app/admin/main/up/model/upcrmmodel"
  5. )
  6. //QueryUpRank query up rank
  7. func (d *Dao) QueryUpRank(rankType int, date time.Time) (result []upcrmmodel.UpRank, err error) {
  8. err = d.crmdb.Model(&upcrmmodel.UpRank{}).Where("type=? and generate_date=?", rankType, date.Format(upcrmmodel.TimeFmtDate)).Find(&result).Error
  9. return
  10. }
  11. //QueryUpRankAll query up rank all
  12. func (d *Dao) QueryUpRankAll(date time.Time) (result []upcrmmodel.UpRank, err error) {
  13. err = d.crmdb.Model(&upcrmmodel.UpRank{}).Where("generate_date=?", date.Format(upcrmmodel.TimeFmtDate)).Find(&result).Error
  14. return
  15. }
  16. //GetUpRankLatestDate get last generate date
  17. func (d *Dao) GetUpRankLatestDate() (date time.Time, err error) {
  18. var rankInfo = upcrmmodel.UpRank{}
  19. err = d.crmdb.Model(&rankInfo).Select("generate_date").Order("generate_date desc").Limit(1).Find(&rankInfo).Error
  20. if err == nil {
  21. date, err = time.Parse(time.RFC3339, rankInfo.GenerateDate)
  22. }
  23. return
  24. }