package com.fjhx.service;

import com.fjhx.base.BaseService;
import com.fjhx.entity.Stock;

import java.math.BigDecimal;

/**
 * <p>
 * 库存 服务类
 * </p>
 *
 * @author ${author}
 * @since 2022-08-10
 */
public interface StockService extends BaseService<Stock> {

    /**
     * 变更数量
     * 入库正数，出库负数
     *
     * @param goodsId     物品id
     * @param warehouseId 仓库id
     * @param quantity    数量
     * @param detailsType 出入库详细类型
     * @param remarks     备注
     */
    void changeQuantity(Long goodsId, Long warehouseId, BigDecimal quantity, Integer detailsType, String remarks);

    /**
     * 入库变更数量
     */
    default void inChangeQuantity(Long goodsId, Long warehouseId, BigDecimal quantity, Integer detailsType, String remarks) {
        changeQuantity(goodsId, warehouseId, quantity, detailsType, remarks);
    }

    /**
     * 入库变更数量(无备注)
     */
    default void inChangeQuantity(Long goodsId, Long warehouseId, BigDecimal quantity, Integer detailsType) {
        changeQuantity(goodsId, warehouseId, quantity, detailsType, null);
    }

    /**
     * 出库变更数量，quantity传入出库数量即可（无需传入负数）
     */
    default void outChangeQuantity(Long goodsId, Long warehouseId, BigDecimal quantity, Integer detailsType, String remarks) {
        changeQuantity(goodsId, warehouseId, BigDecimal.ZERO.subtract(quantity), detailsType, remarks);
    }

    /**
     * 出库变更数量(无备注)
     */
    default void outChangeQuantity(Long goodsId, Long warehouseId, BigDecimal quantity, Integer detailsType) {
        changeQuantity(goodsId, warehouseId, BigDecimal.ZERO.subtract(quantity), detailsType, null);
    }

}
