package com.qs.mp.channel.domain.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.qs.mp.common.enums.ChannelOrderTypeEnum;
import com.qs.mp.common.enums.TicketPkgSaleStatusEnum;
import com.qs.mp.common.enums.TicketTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;
import java.util.Objects;

/**
 * 经销商我的盲票出参类
 * @author Cup
 * @date 2022/4/21
 */
@ApiModel("经销商我的盲票出参类")
@Data
public class ChannelMyTicketVO {

    @ApiModelProperty("id")
    private Long id;

    @ApiModelProperty("盲票组ID")
    private String boxId;

    @ApiModelProperty("盲票包ID")
    private String pkgId;


    @ApiModelProperty("票包编号")
    public String pkgNo;

    @ApiModelProperty("主图")
    private String picUrl;

    @ApiModelProperty("票包名称")
    private String title;

    @ApiModelProperty("票的规格")
    private Integer pkgUnit;

    @ApiModelProperty("销售状态 1待售,2销售中,3已售罄")
    @JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
    private TicketPkgSaleStatusEnum saleStatus;

    @ApiModelProperty("销售数量")
    private Integer saleQty;

    @ApiModelProperty("面值")
    private Integer facePrice;

    @ApiModelProperty("盲票类型")
    private TicketTypeEnum ticketType;

    @ApiModelProperty("是否预付票,0否,1是")
    private Integer isPre;

    @ApiModelProperty("创建时间")
    private Date createdTime;

    @ApiModelProperty("票包类型")
    public ChannelOrderTypeEnum getType() {
        if (Objects.isNull(this.isPre) || this.isPre == 0){
            return ChannelOrderTypeEnum.RETAIL;
        } else {
            if (TicketTypeEnum.OFFLINE.equals(this.ticketType)){
                return ChannelOrderTypeEnum.OFFLINE_PRE;
            }else {
                return ChannelOrderTypeEnum.ONLINE_PRE;
            }
        }
    }

}
