初始化仓库
This commit is contained in:
39
common/handlers/orderHandler/BaseOrderCreatedHandler.php
Normal file
39
common/handlers/orderHandler/BaseOrderCreatedHandler.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace common\handlers\orderHandler;
|
||||
|
||||
use common\forms\order\CommonLog;
|
||||
use common\jobs\OrderCancelJob;
|
||||
use common\models\Cart;
|
||||
|
||||
/**
|
||||
* @property User $user
|
||||
*/
|
||||
abstract class BaseOrderCreatedHandler extends BaseOrderHandler
|
||||
{
|
||||
public $user;
|
||||
|
||||
protected function setAutoCancel()
|
||||
{
|
||||
$orderAutoCancelMinute = \Yii::$app->mall->getMallSettingOne('over_time');
|
||||
if (is_numeric($orderAutoCancelMinute) && $orderAutoCancelMinute >= 0) {
|
||||
CommonLog::saveLog($this->event->order->id,'添加自动取消延迟队列');
|
||||
// 订单自动取消任务
|
||||
\Yii::$app->queue->delay($orderAutoCancelMinute * 60)->push(new OrderCancelJob([
|
||||
'orderId' => $this->event->order->id,
|
||||
]));
|
||||
$autoCancelTime = $this->event->order->created_at + $orderAutoCancelMinute * 60;
|
||||
$this->event->order->auto_cancel_time = $autoCancelTime;
|
||||
$this->event->order->save();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车商品购买后删除
|
||||
*/
|
||||
protected function deleteCartGoods()
|
||||
{
|
||||
Cart::deleteAll(['id' => $this->event->cartIds]);
|
||||
CommonLog::saveLog($this->event->order->id,'删除购物车');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user