WxDelivery.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. /**
  14. * 定时获取微信订单状态
  15. * Class WxDelivery
  16. * @package app\console\task
  17. */
  18. class WxDelivery extends Task
  19. {
  20. // 当前任务唯一标识
  21. private $taskKey = 'WxMpDelivery';
  22. // 任务执行间隔时长 (单位:秒)
  23. protected $taskExpire = 3600;
  24. // 当前商城ID
  25. private $storeId;
  26. /**
  27. * 任务处理
  28. * @param array $param
  29. */
  30. public function handle(array $param)
  31. {
  32. ['storeId' => $this->storeId] = $param;
  33. $this->setInterval($this->storeId, $this->taskKey, $this->taskExpire, function () {
  34. echo $this->taskKey . PHP_EOL;
  35. // 获取微信订单状态
  36. $this->fetchWxOrderStatus();
  37. });
  38. }
  39. /**
  40. * 设置优惠券过期状态
  41. */
  42. private function fetchWxOrderStatus()
  43. {
  44. $service = new \app\console\service\WxDelivery();
  45. $flag = $service->pullOrderStatus($this->storeId);
  46. }
  47. }