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

import cn.iocoder.yudao.framework.apollo.core.event.AutoProcessLineChannelOverWeightExceptionEvent;
import cn.iocoder.yudao.module.order.service.orderException.OrderExceptionService;
import cn.iocoder.yudao.module.order.vo.orderException.additional.ChannelPackagingOverWeightAdditionalBo;
import lombok.AllArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 自动处理路线渠道超重异常
 *
 * @author yanghao
 */
@Component("AutoProcessLineChannelOverWeightExceptionListener")
@AllArgsConstructor
public class AutoProcessLineChannelOverWeightExceptionListener {

    private final OrderExceptionService orderExceptionService;

    /**
     * 添加客户分配确认监听
     *
     * @param event 客户id
     */
    @EventListener(AutoProcessLineChannelOverWeightExceptionEvent.class)
    public void autoProcess(AutoProcessLineChannelOverWeightExceptionEvent event) {
        ChannelPackagingOverWeightAdditionalBo additionalBoOld = new ChannelPackagingOverWeightAdditionalBo()
                .setLineId(event.getLineId())
                .setChannelId(event.getChannelId())
                .setPackingType(event.getPackingType())
                .setOverWeightLimit(event.getAirWeightLimit())
                ;
        orderExceptionService.autoProcessLineChannelPackageWeightException(additionalBoOld, null);
    }
}
