SinceReceive.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\frontend\modules\coupon\services\models\TimeLimit;
  3. use Carbon\Carbon;
  4. /**
  5. * Created by PhpStorm.
  6. * Author: 芸众商城 www.yunzshop.com
  7. * Date: 2017/3/29
  8. * Time: 下午5:17
  9. */
  10. class SinceReceive extends TimeLimit
  11. {
  12. public function valid()
  13. {
  14. if ($this->dbCoupon->time_days == false) {
  15. return true;
  16. }
  17. if ($this->coupon->getMemberCoupon()->get_time->addDays($this->dbCoupon->time_days)->lessThan(Carbon::now())) {
  18. return false;
  19. }
  20. return true;
  21. }
  22. private function receiveDays()
  23. {
  24. return $this->coupon->getMemberCoupon()->get_time->diffInDays();
  25. }
  26. public function expiredTime()
  27. {
  28. $time_end_time = $this->coupon->getMemberCoupon()->get_time->timestamp;
  29. if ($this->dbCoupon->time_days == 0) {
  30. $days = 9999;
  31. } else {
  32. $days = $this->dbCoupon->time_days;
  33. }
  34. $d = date("Y-m-d", $time_end_time);
  35. return strtotime("{$d} +{$days} day");
  36. }
  37. }