subscibe_service.go 734B

1234567891011121314151617181920212223242526272829303132333435
  1. package service
  2. import (
  3. "XT_New/models"
  4. "errors"
  5. "time"
  6. )
  7. func GetOrgSubscibeState(subscibe *models.ServeSubscibe) (err error) {
  8. if subscibe == nil {
  9. err = errors.New("没有订阅信息")
  10. return
  11. }
  12. //免费试用版2,永久免费版9 不过期
  13. if subscibe.State == 9 || subscibe.State == 2 {
  14. return
  15. }
  16. timeNow := time.Now().Unix()
  17. if timeNow < subscibe.PeriodStart || timeNow > subscibe.PeriodEnd {
  18. subscibe.State = 3
  19. }
  20. if subscibe.State != 1 && subscibe.State != 8 {
  21. subscibe.State = 3
  22. }
  23. return
  24. }
  25. func GetOrgSubscibe(org_id int64) (subscibe models.ServeSubscibe, err error) {
  26. err = readUserDb.Model(&models.ServeSubscibe{}).Where("org_id = ? AND status = 1", org_id).First(&subscibe).Error
  27. return
  28. }