package cn.iocoder.yudao.module.order.dal.dataobject.orderSplitItem;

import cn.iocoder.yudao.module.order.vo.orderSplitItem.OrderSpiltItemSpecsRecordVO;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.math.BigDecimal;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import org.apache.commons.lang3.StringUtils;

/**
 * 订单拆单产品项 DO
 *
 * @author yanghao
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("ecw_order_split_item")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OrderSplitItemDO extends BaseDO {

    /**
     * 主键ID
     */
    @TableId
    private Long id;
    /**
     * 拆单id
     */
    private Long orderSplitId;
    /**
     * 订单项id
     */
    private Long orderItemId;
    /**
     * 商品ID
     */
    private Long prodId;
    /**
     * 产品类型
     */
    private Integer prodType;
    /**
     * 产品中文标题
     */
    private String prodTitleZh;
    /**
     * 产品英文标题
     */
    private String prodTitleEn;
    /**
     * 品牌
     */
    private String brand;
    /**
     * 0 无牌 1 有牌 2 中性
     */
    private Integer brandType;

    /**
     * 0 无牌价  1有牌价 2中性价
     */
    private Integer feeType;
    /**
     * 件数
     */
    private Integer num;
    /**
     * 数量
     */
    private Integer quantity;
    /**
     * 单位
     */
    private String unit;
    /**
     * 箱规
     */
    private String boxGauge;
    /**
     * 体积
     */
    private java.math.BigDecimal volume;
    /**
     * 重量
     */
    private java.math.BigDecimal weight;
    /**
     * 货值
     */
    private java.math.BigDecimal worth;

    @ApiModelProperty(value = "是否拆单自定义价格")
    private Boolean splitCustomPriceType;

    @ApiModelProperty(value = "运费成交单价")
    private BigDecimal oneSeaFreight = BigDecimal.ZERO;

    @ApiModelProperty(value = "运费货币单位ID")
    private Integer seaFreightCurrency;

    @ApiModelProperty(value = "运费计量单位")
    private Long seaFreightVolume;

    @ApiModelProperty(value = "清关费单价(成交)")
    private BigDecimal oneClearanceFreight = BigDecimal.ZERO;

    @ApiModelProperty(value = "清关费货币单位ID")
    private Integer clearanceFreightCurrency;

    @ApiModelProperty(value = "清关费计量单位")
    private Long clearanceFreightVolume;

    @ApiModelProperty(value = "计费方式：0 运费/清关费 1 全包价")
    private Integer charging;

    @ApiModelProperty(value = "收费重量")
    private BigDecimal chargeWeight;

    @ApiModelProperty(value = "收费体积")
    private BigDecimal chargeVolume;

    @ApiModelProperty(value = "收费个数")
    private BigDecimal chargeQuantity;

    /**
     * 备注
     */
    private String remark;

    /**
     * 是否已使用
     */
    private Boolean used;

    /**
     * 规格记录
     */
    private String specsRecord;

    @ApiModelProperty(value = "规格记录")
    @TableField(exist = false)
    private List<OrderSpiltItemSpecsRecordVO> specsRecordVOList;

    /**
     * 品牌名
     */
    @TableField(exist = false)
    private String brandName;


    public List<OrderSpiltItemSpecsRecordVO> getSpecsRecordVOList() {
        if (StringUtils.isNotBlank(this.specsRecord)){
            return JSONObject.parseArray(this.specsRecord, OrderSpiltItemSpecsRecordVO.class);
        }
        return specsRecordVOList;
    }
}
