OrderRefund.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\console\task;
  4. use app\console\service\OrderRefund as OrderRefundService;
  5. /**
  6. * 定时任务:设置优惠券过期状态
  7. * Class UserCoupon
  8. * @package app\console\task
  9. */
  10. class OrderRefund extends Task
  11. {
  12. // 当前任务唯一标识
  13. private $taskKey = 'OrderRefund';
  14. // 任务执行间隔时长 (单位:秒)
  15. protected $taskExpire = 60 * 5;
  16. // 当前商城ID
  17. private $storeId;
  18. /**
  19. * 任务处理
  20. * @param array $param
  21. */
  22. public function handle(array $param)
  23. {
  24. if(env('SERVE_ENV')=='test'){
  25. $this->taskExpire = 30;
  26. }
  27. ['storeId' => $this->storeId] = $param;
  28. $this->setInterval($this->storeId, $this->taskKey, $this->taskExpire, function () {
  29. // echo $this->taskKey . PHP_EOL;
  30. // 批量操作超时未退货的售后单
  31. $this->deliveryEvent();
  32. });
  33. }
  34. /**
  35. * 已同意退货退款售后单自动超时关闭售后单
  36. * 超过7天用户未退货,售后申请自动关闭,修改成超时未发货状态
  37. */
  38. private function deliveryEvent()
  39. {
  40. $commentDays = 7;
  41. if ($commentDays > 0) {
  42. $service = new OrderRefundService;
  43. $service->deliveryEvent($this->storeId, $commentDays);
  44. }
  45. }
  46. }