package cn.iocoder.yudao.module.order.listener;

import cn.iocoder.yudao.framework.apollo.core.event.warehouseIn.WarehouseInOrderChangeChannelEvent;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.service.orderWarehouseIn.OrderWarehouseInService;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 入仓订单变更渠道审批通过监听
 *
 * @author zhengYi
 */
@Component("WarehouseInOrderChangeChannelListener")
@AllArgsConstructor
public class WarehouseInOrderChangeChannelListener {

    private final OrderWarehouseInService orderWarehouseInService;
    /**
     * 入仓订单变更渠道审批通过后更新入仓业务
     *
     * @param event 订单id
     */
    @EventListener(WarehouseInOrderChangeChannelEvent.class)
    public void warehouseInOrderChangeTransportEvent(WarehouseInOrderChangeChannelEvent event) {
        OrderDO orderDO = new OrderDO();
        BeanUtils.copyProperties(event.getOrderDto(), orderDO);
        orderWarehouseInService.processChannelPackagingOverWeightException(orderDO);
    }
}
