package com.iformall.domain.po;

import lombok.Data;
import javax.persistence.*;
import java.util.*;
import javax.persistence.Transient;
import java.util.List;
import javax.persistence.Id;
import java.io.Serializable;

@Table(name = "wx_card_spend")
@Data
public class WxCardSpend implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
    protected Long 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="cardId")
	private Long cardId;
	/**持有人ID*/
	@io.swagger.annotations.ApiModelProperty(value="持有人ID",name="ownerId")
	private Long ownerId;
	/**商户ID*/
	@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
	private Long merchantId;
	/**订单账号*/
	@io.swagger.annotations.ApiModelProperty(value="订单账号",name="orderId")
	private Long orderId;
    /**ip地址*/
    @io.swagger.annotations.ApiModelProperty(value="ip地址",name="ip")
    private String ip;
	/**抵扣金额*/
	@io.swagger.annotations.ApiModelProperty(value="抵扣金额",name="deductionAmount")
	private Integer deductionAmount;
	/**支付金额(包含通道费)*/
	@io.swagger.annotations.ApiModelProperty(value="支付金额(包含通道费)",name="payment")
	private Integer payment;
	/**实收金额(不包含通道费)*/
	@io.swagger.annotations.ApiModelProperty(value="实收金额(不包含通道费)",name="realPayment")
	private Integer realPayment;
	/**卡剩余总金额*/
	@io.swagger.annotations.ApiModelProperty(value="卡剩余总金额",name="cardRemainAmount")
	private Integer cardRemainAmount;
	/**卡支付前总金额*/
	@io.swagger.annotations.ApiModelProperty(value="卡支付前总金额",name="cardBeforeAmount")
	private Integer cardBeforeAmount;
	/**卡剩余实际总金额*/
	@io.swagger.annotations.ApiModelProperty(value="卡剩余总金额",name="cardRemainRealAmount")
	private Integer cardRemainRealAmount;
	/**卡支付前实际总金额*/
	@io.swagger.annotations.ApiModelProperty(value="卡支付前总金额",name="cardBeforeRealAmount")
	private Integer cardBeforeRealAmount;
	/**创建时间*/
	@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:已分账, 2:已人工分账)",name="payStatus")
	private Integer payStatus;

	@Transient
	protected List<Integer> payStatusS;

	@Transient
	protected String payStatusStr;

	@Transient
	@io.swagger.annotations.ApiModelProperty(value="开始时间",name="startdate")
	private Date startdate;

	@Transient
	@io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate")
	private Date enddate;

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,CardId_ASC("`card_id` ASC"),CardId_DESC("`card_id` DESC")
			,OwnerId_ASC("`owner_id` ASC"),OwnerId_DESC("`owner_id` DESC")
			,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC")
			,OrderId_ASC("`order_id` ASC"),OrderId_DESC("`order_id` DESC")
            ,Ip_ASC("`ip` ASC"),Ip_DESC("`ip` DESC")
			,Payment_ASC("`payment` ASC"),Payment_DESC("`payment` DESC")
			,RealPayment_ASC("`real_payment` ASC"),RealPayment_DESC("`real_payment` DESC")
			,CardRemainAmount_ASC("`card_remain_amount` ASC"),CardRemainAmount_DESC("`card_remain_amount` DESC")
			,CardBeforeAmount_ASC("`card_before_amount` ASC"),CardBeforeAmount_DESC("`card_before_amount` DESC")
			,CardRemainRealAmount_ASC("`card_remain_real_amount` ASC"),CardRemainRealAmount_DESC("`card_remain_real_amount` DESC")
			,CardBeforeRealAmount_ASC("`card_before_real_amount` ASC"),CardBeforeRealAmount_DESC("`card_before_real_amount` DESC")
			,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC")
			,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC")
			,Status_ASC("`pay_status` ASC"),Status_DESC("`pay_status` 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(WxCardSpend.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));
		}
	}
}
