| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Module\Transfer\Events;
- use App\Module\Transfer\Models\TransferOrder;
- use Illuminate\Broadcasting\InteractsWithSockets;
- use Illuminate\Foundation\Events\Dispatchable;
- use Illuminate\Queue\SerializesModels;
- /**
- * 划转订单创建事件
- */
- class TransferOrderCreated
- {
- use Dispatchable, InteractsWithSockets, SerializesModels;
- public TransferOrder $order;
- public array $context;
- /**
- * 创建事件实例
- */
- public function __construct(TransferOrder $order, array $context = [])
- {
- $this->order = $order;
- $this->context = $context;
- }
- /**
- * 获取订单信息
- */
- public function getOrder(): TransferOrder
- {
- return $this->order;
- }
- /**
- * 获取上下文信息
- */
- public function getContext(): array
- {
- return $this->context;
- }
- /**
- * 判断是否为转入订单
- */
- public function isTransferIn(): bool
- {
- return $this->order->isTransferIn();
- }
- /**
- * 判断是否为转出订单
- */
- public function isTransferOut(): bool
- {
- return $this->order->isTransferOut();
- }
- /**
- * 获取事件数据
- */
- public function toArray(): array
- {
- return [
- 'order_id' => $this->order->id,
- 'transfer_app_id' => $this->order->transfer_app_id,
- 'user_id' => $this->order->user_id,
- 'type' => $this->order->type->value,
- 'amount' => $this->order->amount,
- 'out_amount' => $this->order->out_amount,
- 'status' => $this->order->status->value,
- 'created_at' => $this->order->created_at->toDateTimeString(),
- 'context' => $this->context,
- ];
- }
- }
|