package com.iformall.domain.po;

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

@Table(name = "wx_subsidy")
@Data
public class WxSubsidy 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="operatorUserId")
	private Long operatorUserId;
	/**创建时间*/
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
	private Date createTime;
	/**更新时间*/
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
	private Date updateTime;
	/**微信商户订单号/商品ID,同ID一致*/
	@io.swagger.annotations.ApiModelProperty(value="微信商户订单号/商品ID,同ID一致",name="orderNo")
	private String orderNo;
	/**商品描述*/
	@io.swagger.annotations.ApiModelProperty(value="商品描述",name="body")
	private String body;
	/**终端IP*/
	@io.swagger.annotations.ApiModelProperty(value="终端IP",name="ip")
	private String ip;
	/**支付状态: 0-支付中;1-支付成功;2-支付失败*/
	@io.swagger.annotations.ApiModelProperty(value="支付状态: 0-支付中;1-支付成功;2-支付失败",name="status")
	private Integer status;
	/**支付发起时间*/
	@io.swagger.annotations.ApiModelProperty(value="支付发起时间",name="payTimeStart")
	private Date payTimeStart;
	/**支付结束时间*/
	@io.swagger.annotations.ApiModelProperty(value="支付结束时间",name="payTimeEnd")
	private Date payTimeEnd;
	/**预支付交易会话标识*/
	@io.swagger.annotations.ApiModelProperty(value="预支付交易会话标识",name="prepayId")
	private String prepayId;
	/***/
	@io.swagger.annotations.ApiModelProperty(value="",name="codeUrl")
	private String codeUrl;
	/***/
	@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="shareAmount")
	private Integer shareAmount;
	/**可分账剩余总金额*/
	@io.swagger.annotations.ApiModelProperty(value="可分账剩余总金额",name="shareRemainAmount")
	private Integer shareRemainAmount;
	/**支付失败原因*/
	@io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason")
	private String failReason;
	/**支付者openId*/
	@io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="openId")
	private String openId;



	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,OperatorUserId_ASC("`operator_user_id` ASC"),OperatorUserId_DESC("`operator_user_id` DESC")
			,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC")
			,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC")
			,OrderNo_ASC("`order_no` ASC"),OrderNo_DESC("`order_no` DESC")
			,Body_ASC("`body` ASC"),Body_DESC("`body` DESC")
			,TotalFee_ASC("`total_fee` ASC"),TotalFee_DESC("`total_fee` DESC")
			,Ip_ASC("`ip` ASC"),Ip_DESC("`ip` DESC")
			,Status_ASC("`status` ASC"),Status_DESC("`status` DESC")
			,PayTimeStart_ASC("`pay_time_start` ASC"),PayTimeStart_DESC("`pay_time_start` DESC")
			,PayTimeEnd_ASC("`pay_time_end` ASC"),PayTimeEnd_DESC("`pay_time_end` DESC")
			,PrepayId_ASC("`prepay_id` ASC"),PrepayId_DESC("`prepay_id` DESC")
			,CodeUrl_ASC("`code_url` ASC"),CodeUrl_DESC("`code_url` DESC")
			,TransactionId_ASC("`transaction_id` ASC"),TransactionId_DESC("`transaction_id` DESC")
			,Amount_ASC("`amount` ASC"),Amount_DESC("`amount` DESC")
			,ShareAmount_ASC("`share_amount` ASC"),ShareAmount_DESC("`share_amount` DESC")
			,ShareRemainAmount_ASC("`share_remain_amount` ASC"),ShareRemainAmount_DESC("`share_remain_amount` DESC")
			,FailReason_ASC("`fail_reason` ASC"),FailReason_DESC("`fail_reason` DESC")
			,OpenId_ASC("`open_id` ASC"),OpenId_DESC("`open_id` 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(WxSubsidy.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));
		}
	}
}
