package cn.iocoder.yudao.module.asset.service.event;

import cn.iocoder.yudao.module.asset.service.delivery.event.DeliveryCompletedEvent;
import cn.iocoder.yudao.module.asset.service.replacement.event.ReplacementReturnConfirmedEvent;
import cn.iocoder.yudao.module.asset.service.returnorder.event.ReturnApprovedEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * 车辆状态事件监听器
 * 负责在业务事件发生时更新车辆状态
 *
 * @author 芋道源码
 */
@Component
@Slf4j
public class VehicleStatusEventListener {

    @TransactionalEventListener
    public void onDeliveryCompleted(DeliveryCompletedEvent event) {
        log.info("[onDeliveryCompleted] vehicleId={}", event.getVehicleId());
        // TODO: update vehicle status to DELIVERED when vehicle status management is implemented
    }

    @TransactionalEventListener
    public void onReturnApproved(ReturnApprovedEvent event) {
        log.info("[onReturnApproved] vehicleIds={}", event.getVehicleIds());
        // TODO: update vehicle status to AVAILABLE when vehicle status management is implemented
    }

    @TransactionalEventListener
    public void onReplacementReturnConfirmed(ReplacementReturnConfirmedEvent event) {
        log.info("[onReplacementReturnConfirmed] vehicleId={}", event.getOriginalVehicleId());
        // TODO: update vehicle status to AVAILABLE
    }

}
