package com.tmerclub.cloud.product.bo.mongo;

import com.tmerclub.cloud.common.model.BaseModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 对应MongoDB存储出入库日志emp
 *
 * @author track
 */
@Data
@ToString
@CompoundIndexes({
        @CompoundIndex(name = "shop_idx", def = "{'shopId':1}"),
        @CompoundIndex(name = "source_order_no_idx", def = "{'sourceOrderNo':1}"),
        @CompoundIndex(name = "id_order_no", def = "{'stockBillNo':1, 'type':1}")
})
@Document("stock_bill_log")
public class MongoStockBillLogBO extends BaseModel implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    @Id
    @Schema(description = "出入库明细id")
    private Long stockBillLogId;

    @Schema(description = "出入库单号")
    private String stockBillNo;

    @Schema(description = "关联订单号")
    private String sourceOrderNo;

    @Schema(description = "单据类型")
    private Integer stockBillType;

    @Schema(description = "出入库原因id")
    private Long stockChangeReasonId;

    @Schema(description = "其他出/入库原因" )
    private String reason;

    @Schema(description = "操作员工id")
    private Long employeeId;

    @Schema(description = "状态，0：已作废，1：已出/入库，2：待提交")
    private Integer status;

    @Schema(description = "出入库时间")
    private Date businessTime;

    @Schema(description = "总出入库数量")
    private Integer totalCount;

    @Schema(description = "总出入库金额")
    private Long totalAmount;

    @Schema(description = "出入库凭证")
    private String qualifications;

    @Schema(description = "店铺id")
    private Long shopId;

    @Schema(description = "供应商id")
    private Long supplierId;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "单位")
    private String measureUnit;

    @Schema(description = "类型，1：出库 2：入库")
    private Integer type;

    @Schema(description = "制单人手机号")
    private String makerMobile;

    @Schema(description = "制单人姓名")
    private String makerName;

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

    @Schema(description = "库存点名称")
    private String stockPointName;

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

    @Schema(description = "出入库项列表")
    List<MongoStockBillLogItemBO> stockBillItemLogs;

    public MongoStockBillLogBO() {
    }

    public MongoStockBillLogBO(Long shopId, Date businessTime, Integer stockBillLogType, Integer stockType, String stockBillNo, Integer status, String sourceOrderNo) {
        Date now = new Date();
        this.setShopId(shopId);
        this.setEmployeeId(null);
        this.setCreateTime(now);
        this.setUpdateTime(now);
        this.setBusinessTime(businessTime);
        this.setStockBillType(stockBillLogType);
        this.setType(stockType);
        this.setStockBillNo(stockBillNo);
        this.setStatus(status);
        this.setSourceOrderNo(sourceOrderNo);
    }


}
