UserCoupon.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\console\task;
  13. use app\console\service\UserCoupon as UserCouponService;
  14. /**
  15. * 定时任务:设置优惠券过期状态
  16. * Class UserCoupon
  17. * @package app\console\task
  18. */
  19. class UserCoupon extends Task
  20. {
  21. // 当前任务唯一标识
  22. private $taskKey = 'UserCoupon';
  23. // 任务执行间隔时长 (单位:秒)
  24. protected $taskExpire = 60 * 30;
  25. // 当前商城ID
  26. private $storeId;
  27. /**
  28. * 任务处理
  29. * @param array $param
  30. */
  31. public function handle(array $param)
  32. {
  33. ['storeId' => $this->storeId] = $param;
  34. $this->setInterval($this->storeId, $this->taskKey, $this->taskExpire, function () {
  35. // echo $this->taskKey . PHP_EOL;
  36. // 设置优惠券过期状态
  37. $this->setExpired();
  38. });
  39. }
  40. /**
  41. * 设置优惠券过期状态
  42. */
  43. private function setExpired()
  44. {
  45. $service = new UserCouponService;
  46. $service->setExpired($this->storeId);
  47. }
  48. }