package com.cyksj.model.views;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * @author chan
 * @date 2022/12/8 2:55 PM
 */
@Getter
@Setter
public class StatisticsStockView {

    /**
     * 商品
     */
    @ExcelProperty("商品名称")
    private String title;

    /**
     * 当前总数
     */
    @ExcelProperty("当前库存数量")
    private Integer thenTotal = 0;

    /**
     * 当前价值
     */
    @ExcelProperty("当前库存价值")
    private BigDecimal thenPrice = BigDecimal.ZERO;

    /**
     * 入库总数
     */
    @ExcelProperty("入库")
    private Integer putTotal = 0;

    /**
     * 入库总额
     */
    @ExcelProperty("入库价值")
    private BigDecimal putPrice = BigDecimal.ZERO;

    /**
     * 出库总数
     */
    @ExcelProperty("出库")
    private Integer outTotal = 0;

    /**
     * 出库金额
     */
    @ExcelProperty("出库价值")
    private BigDecimal outPrice = BigDecimal.ZERO;

//    /**
//     * 不可用总数
//     */
//    @ExcelProperty("不可用总数")
//    private Integer unavailable;

    /**
     * 不可用金额
     */
    @ExcelIgnore
    private BigDecimal unavailablePrice = BigDecimal.ZERO;

    /**
     * 退货总数
     */
    @ExcelProperty("退货库存")
    private Integer refundTotal = 0;

    /**
     * 退货金额
     */
    @ExcelProperty("退货库存价值")
    private BigDecimal refundPrice = BigDecimal.ZERO;

    /**
     * put
     * out
     * clean
     * refund
     * transport
     */
    public void setTotalWithPrice(String type, Integer num, BigDecimal price) {
        switch (type){
            case "put":
                this.putTotal += num;
                this.putPrice = this.putPrice.add(price);
                break;
            case "transport":
                this.outTotal += num;
                this.outPrice = this.outPrice.add(price);
                break;
            case "out":
                this.outTotal += num;
                this.outPrice = this.outPrice.add(price);
                break;
            case "refund":
                this.refundTotal += num;
                this.refundPrice = this.refundPrice.add(price);
                break;
            default:
        }
    }
}