package com.wzj.soopin.goods.domain.bo;

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

import java.math.BigDecimal;

@Data
@Schema(description = "SKU信息 查询 对象")
public class SkuBo {

    @Schema(description = "主键")
    private Long id;

    @Schema(description = "PRODUCT_ID 精确匹配")
    private Long productId;

    @Schema(description = "sku编码 精确匹配")
    private String outSkuId;

    @Schema(description = "PRICE 精确匹配")
    private BigDecimal price;

    @Schema(description = "展示图片 精确匹配")
    private String pic;

    @Schema(description = "商品销售属性，json格式 精确匹配")
    private String spData;

    @Schema(description = "商品名称")
    private String productName;

    @Schema(description = "库存")
    private Integer stock;

    @Schema(description = "租户id")
    private String tenantId;

    public Wrapper<Sku> toWrapper() {
        return new LambdaQueryWrapper<Sku>()
            .eq(productId != null, Sku::getProductId, productId)
            .eq(outSkuId != null && !outSkuId.isEmpty(), Sku::getOutSkuId, outSkuId)
            .eq(price != null, Sku::getPrice, price)
            .eq(pic != null && !pic.isEmpty(), Sku::getPic, pic)
            .eq(tenantId != null && !tenantId.isEmpty(), Sku::getTenantId, tenantId)
            .eq(spData != null && !spData.isEmpty(), Sku::getSpData, spData);
    }
}
