quanwei
2025-12-25 a47b138c7455dee981af9b4fac431a16c0eee675
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
 
 
namespace app\api\event;
 
use app\common\enum\order\OrderTypeEnum;
use app\common\service\message\MessageService;
use app\common\service\order\OrderPrinterService;
use app\api\model\order\Order;
use app\api\service\order\paysuccess\source\PaySourceSuccessFactory;
use app\api\model\product\Product as ProductModel;
 
class PaySuccess
{
    public $order;
    public $appId;
    public $orderType;
 
 
    public function handle(Order $order)
    {
        $this->order = $order;
        $this->appId = $order['app_id'];
        $this->orderType = OrderTypeEnum::MASTER;
        // 订单公共业务
        $this->onCommonEvent();
        // 订单来源回调业务
        $this->onSourceCallback();
        return true;
    }
 
    /**
     * 订单公共业务
     */
    private function onCommonEvent()
    {
        // 发送用户消息通知
        (new MessageService)->payment($this->order, $this->orderType);
        // 发送商家消息通知
        (new MessageService)->supplier($this->order, $this->orderType);
        // 小票打印
        (new OrderPrinterService)->printTicket($this->order);
        // 更新供应商销量
        (new ProductModel)->reSupplierTotalSales($this->order['shop_supplier_id']);
    }
 
    /**
     * 订单来源回调业务
     */
    private function onSourceCallback()
    {
        $model = PaySourceSuccessFactory::getFactory($this->order['order_source']);
        return $model->onPaySuccess($this->order);
    }
}