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.AftersaleItem;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 订单售后 查询 对象
 *
 * @author zcc
 */
@Schema(description = "订单售后 查询 对象")
@Data
public class AftersaleItemQuery {
    @Schema(description = "MEMBER_ID 精确匹配")
    private Long memberId;

    @Schema(description = "订单id 精确匹配")
    private Long orderId;

    @Schema(description = "子订单id 精确匹配")
    private Long orderItemId;

    @Schema(description = "退款金额 精确匹配")
    private BigDecimal returnAmount;

    @Schema(description = "退货数量 精确匹配")
    private Integer quantity;

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

        if (memberId != null) {
            queryWrapper.eq(AftersaleItem::getMemberId, memberId);
        }

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

        if (orderItemId != null) {
            queryWrapper.eq(AftersaleItem::getOrderItemId, orderItemId);
        }

        if (returnAmount != null) {
            queryWrapper.eq(AftersaleItem::getReturnAmount, returnAmount);
        }

        if (quantity != null) {
            queryWrapper.eq(AftersaleItem::getQuantity, quantity);
        }

        return queryWrapper;
    }
}
