setRequest(); $order = Order::findOne([ 'id' => $this->orderId, 'is_pay' => 0, 'pay_type' => 0, 'is_delete' => 0, ]); if (!$order) { return; } if ($order->cancel_status == 1) { return ; } \Yii::warning('----订单自动取消----'); $mall = Mall::findOne(['id' => $order->mall_id]); \Yii::$app->setMall($mall); $t = \Yii::$app->db->beginTransaction(); try { $order->cancel_status = 1; $order->cancel_time = mysql_timestamp(); if ($order->save()) { $event = new OrderEvent([ 'order' => $order, ]); \Yii::$app->trigger(Order::EVENT_CANCELED, $event); $t->commit(); } else { throw new \Exception((new Model())->getErrorMsg($order)); } } catch (\Exception $exception) { $t->rollBack(); } } }