package com.tzy.common.dto.pay;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Classname StockParam
 * @Description 库存,售卖数量变动
 * @Date 2024/7/18 15:07
 * @Created by Administrator
 */
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@NoArgsConstructor
public class StockParam implements Serializable {
    public final static String STOCK_SUB_TYPE_ORDER = "order";
    public final static String SKU_NUM_TYPE_SOLD = "sold_num";
    public final static String SKU_NUM_TYPE_STOCK = "stock_num";
    /**type类型: 已售数量:sold_num, 库存:stock_num */
    private String type;
    /**subType子类型: 订单:order*/
    private String subType;
    /**skuId*/
    private Long id;
    /**变动数量*/
    private int num;

    public StockParam(String type, String subType, Long id) {
        this.type = type;
        this.subType = subType;
        this.id = id;
    }

    public StockParam(String type, Long id, int num) {
        this.type = type;
        this.id = id;
        this.num = num;
    }

    public static StockParam buildOrderParam(Long orderId, String type) {
        return new StockParam(type, STOCK_SUB_TYPE_ORDER, orderId);
    }
}