PaySuccess.php 1.4 KB

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