package com.liquidnet.service.kylin.dto.vo.middle;

import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.kylin.entity.KylinTicketStatus;
import com.liquidnet.service.kylin.entity.KylinTickets;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;

@Data
@ApiModel
public class KylinTicketVo {

    private Integer mid;
    @ApiModelProperty(value = "主键")
    private String ticketsId;
    @ApiModelProperty(value = "场次id")
    private String timeId;
    @ApiModelProperty(value = "名称")
    private String title;
    @ApiModelProperty(value = "类型 1单日 2通票")
    private Integer type;
    @ApiModelProperty(value = "价格")
    private BigDecimal price;
    @ApiModelProperty(value = "快递费")
    private BigDecimal priceExpress;
    @ApiModelProperty(value = "会员价格")
    private BigDecimal memberPrice;
    @ApiModelProperty(value = "优惠价格")
    private BigDecimal discountPrice;
    @ApiModelProperty(value = "票种描述")
    private String describes;
    @ApiModelProperty(value = "快递票说明")
    private String describeExpress;
    @ApiModelProperty(value = "电子票说明")
    private String describeElectronic;
    @ApiModelProperty(value = "购票开始时间")
    private String timeStart;
    @ApiModelProperty(value = "购票结束时间")
    private String timeEnd;
    @ApiModelProperty(value = "会员购票开始时间")
    private String memberTimeStart;
    @ApiModelProperty(value = "快递票结束时间")
    private String timeEndExpress;
    @ApiModelProperty(value = "适用开始时间")
    private String useStart;
    @ApiModelProperty(value = "适用结束时间")
    private String useEnd;
    @ApiModelProperty(value = "开票倒计时(分钟数)")
    private Integer saleRemindMinute;
    @ApiModelProperty(value = "是否学生票 0 1")
    private Integer isStudent;
    @ApiModelProperty(value = "是否电子票 0 1")
    private Integer isElectronic;
    @ApiModelProperty(value = "是否快递票 0 1")
    private Integer isExpress;
    @ApiModelProperty(value = "是否同步大麦 0 1")
    private Integer sysDamai;
    @ApiModelProperty(value = "可验证次数")
    private Integer counts;
    @ApiModelProperty(value = "状态 -2新建 -1删除;0未提交;1审核中;2审核中（自动在售）;3审核通过;4审核未通过;6在售;7停售;8售罄;9未开始;10已结束")
    private Integer status;
    @ApiModelProperty(value = "兑换状态 6可兑换 7不可兑换")
    private Integer statusExchange;
    @ApiModelProperty(value = "是否缺票登记 0 2")
    private Integer isLackRegister;
    @ApiModelProperty(value = "快递状态 1寄付 2到付")
    private Integer expressType;
    @ApiModelProperty(value = "是否实名 0 1")
    private Integer isTrueName;
    @ApiModelProperty(value = "限购张数")
    private Integer limitCount;
    @ApiModelProperty(value = "会员限购张数")
    private Integer limitCountMember;
    @ApiModelProperty(value = "是否会员专属 0 1")
    private Integer isExclusive;
    @ApiModelProperty(value = "是否会员 0 1")
    private Integer isMember;
    @ApiModelProperty(value = "会员购买状态 0不能购买 1可以购买")
    private Integer isMemberStatus;
    @ApiModelProperty(value = "是否分销 0否 1是")
    private Integer isAgent;
    @ApiModelProperty(value = "是否显示二维码 0否 1是")
    private Integer isShowCode;
    @ApiModelProperty(value = "二维码显示时间")
    private String qrCodeShowTime;
    @ApiModelProperty(value = "会员提前分钟")
    private Integer advanceMinuteMember;

    public void setTicket(KylinTickets ticket) {
        this.mid=ticket.getMid();
        this.ticketsId = ticket.getTicketsId();
        this.title = ticket.getTitle();
        this.type = ticket.getType();
        this.price = ticket.getPrice();
        this.priceExpress = ticket.getPriceExpress();
        this.memberPrice = ticket.getPrice().subtract(ticket.getPriceDiscountMember());
        this.discountPrice = ticket.getPrice().subtract(ticket.getPriceDiscount());
        this.describes = ticket.getDescribes();
        this.describeExpress = ticket.getDescribeExpress();
        this.describeElectronic = ticket.getDescribeElectronic();
        this.timeStart = DateUtil.Formatter.yyyyMMddHHmmss.format(ticket.getTimeStart());
        this.timeEnd = DateUtil.Formatter.yyyyMMddHHmmss.format(ticket.getTimeEnd());
        this.advanceMinuteMember = ticket.getAdvanceMinuteMember();
        this.memberTimeStart = DateUtil.Formatter.yyyyMMddHHmmss.format(ticket.getTimeStart().plusMinutes(-ticket.getAdvanceMinuteMember()));
        if (ticket.getTimeEndExpress() != null) {
            this.timeEndExpress = DateUtil.Formatter.yyyyMMddHHmmss.format(ticket.getTimeEndExpress());
        } else {
            this.timeEndExpress = null;
        }
        this.useStart = DateUtil.Formatter.yyyyMMddHHmmss.format(ticket.getUseStart());
        this.useEnd = DateUtil.Formatter.yyyyMMddHHmmss.format(ticket.getUseEnd());
        this.saleRemindMinute = ticket.getSaleRemindMinute();
    }

    public void setTicketStatus(KylinTicketStatus ticketStatus) {
        this.isMember = ticketStatus.getIsMember();
        this.isAgent = ticketStatus.getIsAgent();
        this.isExclusive = ticketStatus.getIsExclusive();
        this.isTrueName = ticketStatus.getIsTrueName();
        this.expressType = ticketStatus.getExpressType();
        this.isLackRegister = ticketStatus.getIsLackRegister();
        this.statusExchange = ticketStatus.getStatusExchange();
        this.status = ticketStatus.getStatus();
        this.isElectronic = ticketStatus.getIsElectronic();
        this.isExpress = ticketStatus.getIsExpress();
        this.isStudent = ticketStatus.getIsStudent();
        this.limitCountMember = ticketStatus.getMemberLimitCount();
        this.limitCount = ticketStatus.getLimitCount();
        this.counts = ticketStatus.getCounts();
        this.sysDamai = ticketStatus.getSyncDamai();
        this.isShowCode = ticketStatus.getIsShowCode();
        this.qrCodeShowTime = DateUtil.Formatter.yyyyMMddHHmmss.format(ticketStatus.getQrCodeShowTime());

    }

}
