package com.iformall.domain.po;

import lombok.Data;

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

@Table(name = "wx_card_info")
@Data
public class WxCardInfo implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
    protected Long id; /**主键ID-与coupon_order_id一致*/
    
    @Transient
    protected List<Long> ids;
    @Transient
    protected String sortColumns;

	/**租户ID*/
	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;
    /**券ID*/
    @io.swagger.annotations.ApiModelProperty(value = "券ID", name = "couponId")
    private Long couponId;
	/**微信订单号-购买类储值卡时的订单号*/
	@io.swagger.annotations.ApiModelProperty(value="微信订单号-购买类储值卡时的订单号",name="transactionId")
	private String transactionId;
	/**面额总金额*/
	@io.swagger.annotations.ApiModelProperty(value="面额总金额",name="amount")
	private Integer amount;
    /**购买总金额*/
    @io.swagger.annotations.ApiModelProperty(value="购买总金额",name="saleAmount")
    private Integer saleAmount;
	/**剩余面额*/
	@io.swagger.annotations.ApiModelProperty(value="剩余面额",name="remainingAmount")
	private Integer remainingAmount;
	/**分账总手续费*/
	@io.swagger.annotations.ApiModelProperty(value="分账总手续费",name="serviceFeeAmount")
	private Integer serviceFeeAmount;
	/**分账总金额*/
	@io.swagger.annotations.ApiModelProperty(value="分账总金额",name="shareFeeAmount")
	private Integer shareFeeAmount;
	/**分账剩余总金额*/
	@io.swagger.annotations.ApiModelProperty(value="分账剩余总金额",name="remainingShareFeeAmount")
	private Integer remainingShareFeeAmount;
	/**创建时间*/
	@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 = "是否支持转送(0:不支持,1支持)", name = "supportTransfer")
    private Integer supportTransfer;

	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")
			,TransactionId_ASC("`transaction_id` ASC"),TransactionId_DESC("`transaction_id` DESC")
			,Amount_ASC("`amount` ASC"),Amount_DESC("`amount` DESC")
            ,SaleAmount_ASC("`sale_amount` ASC"),SaleAmount_DESC("`sale_amount` DESC")
			,RemainingAmount_ASC("`remaining_amount` ASC"),RemainingAmount_DESC("`remaining_amount` DESC")
			,ServiceFeeAmount_ASC("`service_fee_amount` ASC"),ServiceFeeAmount_DESC("`service_fee_amount` DESC")
			,ShareFeeAmount_ASC("`share_fee_amount` ASC"),ShareFeeAmount_DESC("`share_fee_amount` DESC")
			,RemainingShareFeeAmount_ASC("`remaining_share_fee_amount` ASC"),RemainingShareFeeAmount_DESC("`remaining_share_fee_amount` DESC")
			,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC")
			,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` 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(WxCardInfo.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));
		}
	}
}
