
package com.tmerclub.cloud.api.product.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author tmerclub
 * @date 2020/12/22
 */
@Data
public class SkuStockVO implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    @Schema(description = "skuId")
    private Long skuId;

    @Schema(description = "产品ID")
    private Long spuId;


    @Schema(description = "shopId")
    private Long shopId;

    @Schema(description = "orderId")
    private Long orderId;

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

    @Schema(description = "锁定库存数量")
    private Integer lockStock;

    @Schema(description = "销量")
    private Integer sale;

    @Schema(description = "sku和商品的状态，1.商品为上架且sku非禁用  0.商品非上架， 或者sku禁用")
    private Integer status;

    /**
     * 库存分片序号
     * 记录扣除分片的id，回调解锁的时候找到这个分片去扣锁定库存
     */
    @Schema(description = "库存分片序号")
    private Integer zoneNo;

    @Schema(description = "库存点id")
    private Long stockPointId;

    @Schema(description = "库存点类型 1仓库 2门店")
    private Integer stockPointType;

    @Schema(description = "操作类型 LuaOperateEnum")
    private Integer operateType;

    @Schema(description = "组合商品关联的主skuId")
    private Long mainSkuId;

    @Schema(description = "组合数量")
    private Integer comboCount;


    public SkuStockVO() {
    }

    public SkuStockVO(Long skuId) {
        this.skuId = skuId;
        this.stock = 0;
        this.lockStock = 0;
        this.sale = 0;
        this.stockPointId = 0L;
    }

    public SkuStockVO(Long skuId, Long stockPointId) {
        this.skuId = skuId;
        this.stockPointId = stockPointId;
        this.stock = 0;
        this.lockStock = 0;
        this.sale = 0;
    }

    public SkuStockVO(Long skuId, Integer stock, Long stockPointId, Integer stockPointType) {
        this.skuId = skuId;
        this.stock = stock;
        this.stockPointId = stockPointId;
        this.stockPointType = stockPointType;
        this.sale = 0;
    }

    public SkuStockVO(Long skuId, Integer stock, Integer lockStock, Integer sale, Long stockPointId) {
        this.skuId = skuId;
        this.stock = stock;
        this.lockStock = lockStock;
        this.sale = sale;
        this.stockPointId = stockPointId;
    }


    public SkuStockVO(Long skuId, Integer stock) {
        this.skuId = skuId;
        this.stock = stock;
        this.sale = 0;
    }

    @Override
    public String toString() {
        return "SkuStockVO{" +
                "skuId=" + skuId +
                ", spuId=" + spuId +
                ", shopId=" + shopId +
                ", orderId=" + orderId +
                ", stock=" + stock +
                ", lockStock=" + lockStock +
                ", sale=" + sale +
                ", status=" + status +
                ", zoneNo=" + zoneNo +
                ", stockPointId=" + stockPointId +
                ", stockPointType=" + stockPointType +
                ", operateType=" + operateType +
                ", mainSkuId=" + mainSkuId +
                ", comboCount=" + comboCount +
                '}';
    }
}
