初始化仓库
This commit is contained in:
37
common/handlers/orderHandler/BaseOrderHandler.php
Normal file
37
common/handlers/orderHandler/BaseOrderHandler.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace common\handlers\orderHandler;
|
||||
|
||||
use common\core\BaseModel;
|
||||
use common\events\OrderEvent;
|
||||
use common\models\Mall;
|
||||
|
||||
/**
|
||||
* @property OrderEvent $event
|
||||
* @property Mall $mall
|
||||
*/
|
||||
abstract class BaseOrderHandler extends BaseModel
|
||||
{
|
||||
public $event;
|
||||
public $mall;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* 事件处理
|
||||
*/
|
||||
abstract public function handle();
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setMall()
|
||||
{
|
||||
try {
|
||||
$this->mall = \Yii::$app->mall;
|
||||
} catch (\Exception $exception) {
|
||||
$mall = Mall::findOne(['id' => $this->event->order->mall_id]);
|
||||
\Yii::$app->setMall($mall);
|
||||
$this->mall = \Yii::$app->mall;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user