package com.iformall.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.iformall.domain.po.WxCouponChannel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.io.Serializable;
import java.math.BigDecimal;

import java.util.Date;
import java.util.List;

/**
 * Created by syf on 2018/8/22.
 */
@JsonIgnoreProperties(value = {"handler"})
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxCouponChannelVo extends WxCouponChannel implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableField(exist = false)
    private Integer activityStatus;

    @io.swagger.annotations.ApiModelProperty(value="总库存",name="inventory")
    private Integer inventory;
    @io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory")
    private Integer remainInventory;
    @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg")
    private String coverImg;
    @io.swagger.annotations.ApiModelProperty(value="券名称",name="title")
    private String title;
    @io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle")
    private String subTitle;
    @io.swagger.annotations.ApiModelProperty(value="售价（适用于类型2，3，4，5）",name="salePrice")
    private Integer salePrice;
    @io.swagger.annotations.ApiModelProperty(value="使用条件金额（适用于类型1,2,3,4）",name="usePrice")
    private Integer usePrice;
    @io.swagger.annotations.ApiModelProperty(value="面额",name="price")
    private Integer price;
    @io.swagger.annotations.ApiModelProperty(value="单位0:钱分，1:小时",name="unit")
    private Integer unit;

    @io.swagger.annotations.ApiModelProperty(value="限领张数",name="useLimitQuantity")
    private Integer useLimitQuantity;

    @io.swagger.annotations.ApiModelProperty(value="1.主动领取2.定向投放",name="sendType")
    private Integer sendType;

    @io.swagger.annotations.ApiModelProperty(value="过期退款(0:正常,1不退)",name="autoRefund")
    private Integer autoRefund;

    @io.swagger.annotations.ApiModelProperty(value="有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)",name="validType")
    private Integer validType;
    @io.swagger.annotations.ApiModelProperty(value="有效日期-开始",name="validStartDate")
    private Date validStartDate;
    @io.swagger.annotations.ApiModelProperty(value="有效日期-结束",name="validEndDate")
    private Date validEndDate;
    @io.swagger.annotations.ApiModelProperty(value="自领取之日几日有效，（停车券当天有效）",name="validDays")
    private Integer validDays;

    @io.swagger.annotations.ApiModelProperty(value="积分售价（适用于类型10,11）",name="creditPrice")
    private Integer creditPrice;

    @io.swagger.annotations.ApiModelProperty(value="领取条件",name="condition")
    private String conditions;

    @TableField(exist = false)
    private String salePriceStr;

    @TableField(exist = false)
    private String usePriceStr;

    @TableField(exist = false)
    private String priceStr;

    @TableField(exist = false)
    private String qrCode;

    @io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList")
    private List<WxMerchantVo> merchantVoList;

    @TableField(exist = false)
    private Integer gameWeight;

    @io.swagger.annotations.ApiModelProperty(value = "是否可转赠", name = "supportTransfer")
    private Integer supportTransfer;

    @io.swagger.annotations.ApiModelProperty(value = "砍价/拼团人数", name = "pressLimitNum")
    private Integer pressLimitNum;

    @Override
    public String getSalePriceStr() {
        if(salePrice!=null) {
            salePriceStr = new BigDecimal(salePrice).divide(new BigDecimal(100)).toString();
        }
        return salePriceStr;
    }
    @Override
    public String getUsePriceStr() {
        if(usePrice!=null) {
            usePriceStr = new BigDecimal(usePrice).divide(new BigDecimal(100)).toString();
        }
        return usePriceStr;
    }

    @Override
    public String getPriceStr() {
        if(price!=null) {
            priceStr = new BigDecimal(price).divide(new BigDecimal(100)).toString();
        }
        return priceStr;
    }

    @Override
    public String getTitle() {
        return title;
    }

    @Override
    public void setTitle(String title) {
        this.title = title;
    }
}
