初始化仓库
This commit is contained in:
34
common/handlers/ProductOrderCreatedHandlerClass.php
Normal file
34
common/handlers/ProductOrderCreatedHandlerClass.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace common\handlers;
|
||||
|
||||
use common\jobs\ProductOrderCancelJob;
|
||||
|
||||
class ProductOrderCreatedHandlerClass extends BaseProductOrderHandler
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
self::execute();
|
||||
}
|
||||
|
||||
protected function execute()
|
||||
{
|
||||
$this->autoCancel();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function autoCancel()
|
||||
{
|
||||
$config = \Yii::$app->params;
|
||||
$orderAutoCancelMinute = isset($config['product_order']['over_time']) ? $config['product_order']['over_time'] : 900;
|
||||
if (is_numeric($orderAutoCancelMinute) && $orderAutoCancelMinute >= 0) {
|
||||
// 订单自动取消任务
|
||||
\Yii::$app->queue->delay($orderAutoCancelMinute)->push(new ProductOrderCancelJob([
|
||||
'orderId' => $this->event->order->id,
|
||||
]));
|
||||
$autoCancelTime = $this->event->order->created_at + $orderAutoCancelMinute;
|
||||
$this->event->order->auto_cancel_time = $autoCancelTime;
|
||||
$this->event->order->save();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user