pendingcharge.go 545 B

123456789101112131415161718192021222324252627282930313233
  1. package gift
  2. import (
  3. "time"
  4. )
  5. const max_pending_time = 300
  6. type pendingcharge struct {
  7. userId int
  8. toUserId int
  9. productId string
  10. createTime int64
  11. }
  12. func (pc *pendingcharge) isTimeout() bool {
  13. return time.Now().Unix()-pc.createTime >= max_pending_time
  14. }
  15. func (pc *pendingcharge) isSame(userId, toUserId int, productId string) bool {
  16. if userId != pc.userId {
  17. return false
  18. }
  19. if toUserId != 0 && toUserId != pc.toUserId {
  20. return false
  21. }
  22. if productId != "" && productId != pc.productId {
  23. return false
  24. }
  25. return true
  26. }