package com.xunhong.erp.turbo.api.biz.dto.vo;

import com.alibaba.cola.dto.DTO;
import com.xunhong.erp.turbo.api.biz.dto.common.*;
import com.xunhong.erp.turbo.api.biz.dto.enums.PurchaseOrderPricingMethodEnum;
import com.xunhong.erp.turbo.api.biz.dto.enums.PurchaseOrderStateEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * @author shenyifei
 */
@Data
@Schema(title = "采购订单")
@EqualsAndHashCode(callSuper = true)
public class PurchaseOrderVO extends DTO {

	/**
	 * 订单ID
	 */
	@Schema(title = "订单ID", type = "string", requiredMode = Schema.RequiredMode.REQUIRED)
	private Long orderId;

	/**
	 * 订单编号
	 */
	@Schema(title = "订单编号", type = "string", requiredMode = Schema.RequiredMode.REQUIRED)
	private String orderSn;

	/**
	 * 是否是草稿
	 */
	@Schema(title = "是否是草稿", type = "boolean", requiredMode = Schema.RequiredMode.REQUIRED)
	private Boolean draft;

	/**
	 * 步骤标识
	 */
	@Schema(title = "步骤标识")
	private Integer active;

	/**
	 * 产地负责人
	 */
	@Schema(title = "产地负责人")
	private String originPrincipal;

	/**
	 * 报价方式：1_按毛重报价；2_按净重报价；
	 */
	@Schema(title = "报价方式：1_按毛重报价；2_按净重报价；")
	private PurchaseOrderPricingMethodEnum pricingMethod;

	/**
	 * 销售金额
	 */
	@Schema(title = "销售金额")
	private BigDecimal saleAmount;

	/**
	 * 包装费
	 */
	@Schema(title = "包装费")
	private BigDecimal packageFee;

	/**
	 * 平均单价(元/斤)
	 */
	@Schema(title = "平均单价(元/斤)")
	private BigDecimal avgUnitPrice;

	/**
	 * 是否返点
	 */
	@Schema(title = "是否返点")
	private Boolean rebate;

	/**
	 * 毛重(斤)
	 */
	@Schema(title = "毛重(斤)")
	private BigDecimal grossWeight;

	/**
	 * 净重(斤)
	 */
	@Schema(title = "净重(斤)")
	private BigDecimal netWeight;

	/**
	 * 成本合计
	 */
	@Schema(title = "成本合计")
	private BigDecimal totalCost;

	/**
	 * 运费
	 */
	@Schema(title = "运费")
	private BigDecimal freightCharge;

	/**
	 * 瓜农数量
	 */
	@Schema(title = "瓜农数量")
	private Integer supplierCount;

	/**
	 * 订单状态: 0-草稿, 1-待审核, 2-待老板审核, 3-已发货(待付款), 4-已付款, 5-已完结
	 */
	@Schema(title = "订单状态: 0-草稿, 1-待审核, 2-待老板审核, 3-已发货(待付款), 4-已付款, 5-已完结")
	private PurchaseOrderStateEnum state;

	/**
	 * 备注
	 */
	@Schema(title = "备注")
	private String remark;

	/**
	 * 创建人ID
	 */
	@Schema(title = "创建人ID", type = "string", requiredMode = Schema.RequiredMode.REQUIRED)
	private Long createdBy;

	/**
	 * 创建人姓名
	 */
	@Schema(title = "创建人姓名")
	private String createdByName;

	/**
	 * 创建时间
	 */
	@Schema(title = "创建时间")
	private LocalDateTime createdAt;

	@Schema(title = "返点信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private OrderRebate orderRebate;

	@Schema(title = "车辆信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private OrderVehicle orderVehicle;

	@Schema(title = "公司信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private OrderCompany orderCompany;

	@Schema(title = "经销商信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private OrderDealer orderDealer;

	@Schema(title = "供应商信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private List<OrderSupplier> orderSupplierList;

	@Schema(title = "采购订单费用信息", requiredMode = Schema.RequiredMode.REQUIRED)
	private List<OrderCost> orderCostList;

	@SuppressWarnings("unused")
	public Boolean getDraft() {
		return state == PurchaseOrderStateEnum.DRAFT;
	}
}

