package com.iformall.domain.po;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;

@Table(name = "wx_coupon_order")
public class WxCouponOrder implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    protected Long id;

    @Transient
    protected List<Long> ids;
    @Transient
    protected String sortColumns;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSortColumns() {
        return sortColumns;
    }

    public List<Long> getIds() {
        return ids;
    }

    public void setIds(List<Long> ids) {
        this.ids = ids;
    }


    /**租户ID*/
    @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId")
    private String tenantId;
    /**卡券ID**/
    @io.swagger.annotations.ApiModelProperty(value = "卡券ID", name = "couponId")
    private Long couponId;
    /**券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡) */
    @io.swagger.annotations.ApiModelProperty(value = "券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)", name = "couponType")
    private Integer couponType;
    /*c端用户id**/
    @io.swagger.annotations.ApiModelProperty(value = "c端用户id", name = "cUserId")
    private Long cUserId;
    /**持有者ID*/
    @io.swagger.annotations.ApiModelProperty(value = "持有者ID", name = "ownerId")
    private Long ownerId;
    /**操作券B端小程序用户ID**/
    @io.swagger.annotations.ApiModelProperty(value = "操作券B端小程序用户ID", name = "bUserId")
    private Long bUserId;
    /**用户订单ID**/
    @io.swagger.annotations.ApiModelProperty(value = "用户订单ID", name = "orderId")
    private Long orderId;
    /**该订单对应券的实际过期时间**/
    @io.swagger.annotations.ApiModelProperty(value = "该订单对应券的实际过期时间 ", name = "expiredTime")
    private Date expiredTime;
    /**状态：0-待使用 1-已核销 2-已过期 3-已作废 4-卡使用中 5-卡已过期 6-卡已用完 7-卡已线下退款**/
    @io.swagger.annotations.ApiModelProperty(value = "状态：0-待使用 1-已核销 2-已过期 3-已作废 4-卡使用中 5-卡已过期 6-卡已用完 7-卡已线下退款", name = "couponOrderStatus")
    private Integer couponOrderStatus;
    /**创建时间*/
    @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createDate")
    private Date createDate;
    /**更新时间*/
    @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateDate")
    private Date updateDate;
    /**单券实际购买价格**/
    @io.swagger.annotations.ApiModelProperty(value = "单券实际购买价格", name = "couponPrice")
    private Integer couponPrice;

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

    @Transient
    private String couponName;
    @Transient
    private String couponPriceStr;
   
    @Transient
    private String salePriceStr;
    @Transient
    private Integer salePrice; 
    
    public String getCouponPriceStr() {
    	if(couponPrice!=null) {
			DecimalFormat df=new DecimalFormat("0.00");
			couponPriceStr = df.format((float)couponPrice/100);
		}
		return couponPriceStr;
	}

	public void setCouponPriceStr(String couponPriceStr) {
		this.couponPriceStr = couponPriceStr;
	}

	public String getSalePriceStr() {
		if(salePrice!=null) {
			DecimalFormat df=new DecimalFormat("0.00");
			salePriceStr = df.format((float)salePrice/100);
		}
		return salePriceStr;
	}

	public void setSalePriceStr(String salePriceStr) {
		this.salePriceStr = salePriceStr;
	}

	public Integer getSalePrice() {
		return salePrice;
	}

	public void setSalePrice(Integer salePrice) {
		this.salePrice = salePrice;
	}

	public String getCouponName() {
		return couponName;
	}

	public void setCouponName(String couponName) {
		this.couponName = couponName;
	}

	public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String _tenantId) {
        tenantId = _tenantId;
    }

    public Long getCouponId() {
        return couponId;
    }

    public void setCouponId(Long _couponId) {
        couponId = _couponId;
    }

    public Integer getCouponType() {
        return couponType;
    }

    public void setCouponType(Integer couponType) {
        this.couponType = couponType;
    }

    public Long getOwnerId() {
        return ownerId;
    }

    public void setOwnerId(Long ownerId) {
        this.ownerId = ownerId;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long _orderId) {
        orderId = _orderId;
    }

    public Date getExpiredTime() {
        return expiredTime;
    }

    public void setExpiredTime(Date _expiredTime) {
        expiredTime = _expiredTime;
    }

    public Integer getCouponOrderStatus() {
        return couponOrderStatus;
    }

    public void setCouponOrderStatus(Integer _couponOrderStatus) {
        couponOrderStatus = _couponOrderStatus;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date _createDate) {
        createDate = _createDate;
    }

    public Date getUpdateDate() {
        return updateDate;
    }

    public void setUpdateDate(Date _updateDate) {
        updateDate = _updateDate;
    }

    public Integer getCouponPrice() {
        return couponPrice;
    }

    public void setCouponPrice(Integer _couponPrice) {
        couponPrice = _couponPrice;
    }

    public Long getcUserId() {
        return cUserId;
    }

    public void setcUserId(Long cUserId) {
        this.cUserId = cUserId;
    }

    public Long getbUserId() {
        return bUserId;
    }

    public void setbUserId(Long bUserId) {
        this.bUserId = bUserId;
    }

    public Integer getAutoRefund() {
        return autoRefund;
    }

    public void setAutoRefund(Integer autoRefund) {
        this.autoRefund = autoRefund;
    }

    public static enum Field {
        Id_ASC("`id` ASC"), Id_DESC("`id` DESC"),
        TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"),
        CouponId_ASC("`coupon_id` ASC"), CouponId_DESC("`coupon_id` DESC"),
        CouponType_ASC("`coupon_type` ASC"), CouponType_DESC("`coupon_type` DESC"),
        CUserId_ASC("`c_user_id` ASC"), CUserId_DESC("`c_user_id` DESC"),
        OwnerId_ASC("`owner_id` ASC"), OwnerId_DESC("`owner_id` DESC"),
        BUserId_ASC("`b_user_id` ASC"), BUserId_DESC("`b_user_id` DESC"),
        OrderId_ASC("`order_id` ASC"), OrderId_DESC("`order_id` DESC"),
        ExpiredTime_ASC("`expired_time` ASC"), ExpiredTime_DESC("`expired_time` DESC"),
        CouponOrderStatus_ASC("`coupon_order_status` ASC"), CouponOrderStatus_DESC("`coupon_order_status` DESC"),
        CreateDate_ASC("`create_date` ASC"), CreateDate_DESC("`create_date` DESC"),
        UpdateDate_ASC("`update_date` ASC"), UpdateDate_DESC("`update_date` DESC"),
        CouponPrice_ASC("`coupon_price` ASC"), CouponPrice_DESC("`coupon_price` DESC");
        private String value;

        Field(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        public void setCol(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return this.getValue();
        }
    }

    public void setSortColumns(WxCouponOrder.Field... fields) {
        if (fields == null || fields.length == 0) {
            return;
        }
        for (int k = 0; k < fields.length; k++) {
            if (fields[k] == null) {
                return;
            }
        }
        StringBuilder sb = new StringBuilder(fields[0].toString());
        for (int k = 1; k < fields.length; k++) {
            sb.append(",");
            sb.append(fields[k].toString());
        }
        this.sortColumns=sb.toString();

    }

    public void setSortColumns(String sortColumns) {
        if (sortColumns == null || "".equals(sortColumns.trim())) {
            return;
        }
        if (sortColumns.contains(",")) {
            String[] cols = sortColumns.split(",");
            java.util.List<Field> fList = new java.util.ArrayList();
            for (int k = 0; k < cols.length; k++) {
                fList.add(Field.valueOf(cols[k]));
            }
            this.setSortColumns(fList.toArray(new Field[fList.size()]));
        } else {
            this.setSortColumns(Field.valueOf(sortColumns));
        }
    }
}
