<?php

namespace Modules\Mall\Listeners;

use Illuminate\Contracts\Queue\ShouldQueue;
use Modules\Mall\Events\RefundCompleted;

class RefundCompletedListener implements ShouldQueue
{

    public string $queue = 'LISTENER';

    /**
     * Notes: description
     * @Author: 玄尘
     * @Date  : 2021/6/9 12:04
     * @param  \Modules\Mall\Events\RefundCompleted  $event
     */
    public function handle(RefundCompleted $event)
    {
        $refund = $event->refund->refresh();
        $order  = $refund->order->refresh();

        if ($order->refund_items_count == $order->items()->count()) {
            $order->completed();
        }
    }

}
