package com.wzj.soopin.order.domain.query;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzj.soopin.order.domain.entity.OrderDeliveryHistory;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * 订单发货记录 查询 对象
 *
 * @author zcc
 */
@Schema(description = "订单发货记录 查询 对象")
@Data
public class OrderDeliveryHistoryQuery {
    @Schema(description = "订单id 精确匹配")
    private Long orderId;

    @Schema(description = "物流公司 精确匹配")
    private String deliveryCompany;

    @Schema(description = "物流单号 精确匹配")
    private String deliverySn;

    public Wrapper<OrderDeliveryHistory> toWrapper() {
        LambdaQueryWrapper<OrderDeliveryHistory> queryWrapper = new LambdaQueryWrapper<>();

        if (orderId != null) {
            queryWrapper.eq(OrderDeliveryHistory::getOrderId, orderId);
        }

        if (deliveryCompany != null && !deliveryCompany.isEmpty()) {
            queryWrapper.eq(OrderDeliveryHistory::getDeliveryCompany, deliveryCompany);
        }

        if (deliverySn != null && !deliverySn.isEmpty()) {
            queryWrapper.eq(OrderDeliveryHistory::getDeliverySn, deliverySn);
        }

        return queryWrapper;
    }
}
