package com.fjhx.params.stock;

import com.fjhx.entity.stock.ManualVo;
import com.fjhx.enums.stock.InTypeEnum;
import com.fjhx.enums.stock.OutTypeEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class StockChangeVo {

    public StockChangeVo() {

    }

    public StockChangeVo(ManualVo manualVo) {
        defaultWarehouseId = manualVo.getWarehouseId();
        defaultRemarks = manualVo.getRemarks();
        typeEnum = OutTypeEnum.getEnumByKey(manualVo.getType());
        changeDetailsList = manualVo.getChangeProductList();
    }

    /**
     * 手动入库 初始
     */
    public StockChangeVo(ManualInStockVo entity) {
        defaultWarehouseId = entity.getWarehouseId();
        defaultRemarks = entity.getRemarks();
        typeEnum = InTypeEnum.MANUAL;
        changeDetailsList = entity.getChangeProductList();
    }

    /**
     * 默认业务ID
     * 未指定业务ID时，会使用此业务ID
     */
    private Long defaultBusinessId;

    /**
     * 默认出库或入库的仓库id
     * 未指定仓库id时，会使用此仓库id
     */
    private Long defaultWarehouseId;

    /**
     * 默认备注
     * 未指定备注时，会使用此备注
     */
    private String defaultRemarks;

    /**
     * InTypeEnum or OutTypeEnum
     */
    private Enum<?> typeEnum;

    /**
     * 变更明细
     */
    private List<? extends ChangeDetails> changeDetailsList;

    public interface ChangeDetails {

        /**
         * 物品id
         */
        Long getGoodsId();

        /**
         * 变更数量
         */
        BigDecimal getChangeQuantity();

        /**
         * 业务id
         */
        default Long getBusinessId() {
            return null;
        }

        /**
         * 仓库id
         */
        default Long getWarehouseId() {
            return null;
        }

        /**
         * 备注
         */
        default String getRemarks() {
            return null;
        }

    }

}
