最新服务器上的版本,以后用这个
commit | author | age
2207d6 1 <?php
W 2 /**
3  * @copyright ©2018 浙江禾匠信息科技
4  * @author Lu Wei
5  * @link http://www.zjhejiang.com/
6  * Created by IntelliJ IDEA
7  * Date Time: 2019/1/23 16:31
8  */
9
10
11 namespace app\handlers;
12
13
14 use app\events\OrderEvent;
15 use app\forms\common\order\CommonOrder;
16 use app\models\Order;
17
18 class OrderCreatedHandler extends HandlerBase
19 {
20     /**
21      * 事件处理
22      */
23     public function register()
24     {
25         \Yii::$app->on(Order::EVENT_CREATED, function ($event) {
26             /** @var OrderEvent $event */
27             \Yii::$app->setMchId($event->order->mch_id);
28             $commonOrder = CommonOrder::getCommonOrder($event->order->sign);
29             $orderHandler = $commonOrder->getOrderHandler();
30             $handler = $orderHandler->orderCreatedHandlerClass;
31             $handler->orderConfig = $commonOrder->getOrderConfig();
32             $handler->event = $event;
33             $handler->setMall()->handle();
34         });
35     }
36 }