// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\console\task; /** * 定时获取微信订单状态 * Class WxDelivery * @package app\console\task */ class WxDelivery extends Task { // 当前任务唯一标识 private $taskKey = 'WxMpDelivery'; // 任务执行间隔时长 (单位:秒) protected $taskExpire = 3600; // 当前商城ID private $storeId; /** * 任务处理 * @param array $param */ public function handle(array $param) { ['storeId' => $this->storeId] = $param; $this->setInterval($this->storeId, $this->taskKey, $this->taskExpire, function () { echo $this->taskKey . PHP_EOL; // 获取微信订单状态 $this->fetchWxOrderStatus(); }); } /** * 设置优惠券过期状态 */ private function fetchWxOrderStatus() { $service = new \app\console\service\WxDelivery(); $flag = $service->pullOrderStatus($this->storeId); } }