package com.iformall.domain.po;

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_pay_order")
public class WxPayOrder 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;
	/**创建时间**/
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
	private Date createTime;
	/**更新时间**/
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
	private Date updateTime;
	/**订单ID**/
	@io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId")
	private Long orderId;
	/**用户ID**/
	@io.swagger.annotations.ApiModelProperty(value="用户ID",name="cUserId")
	private Long cUserId;
    /**B端用户ID**/
    @io.swagger.annotations.ApiModelProperty(value="B端用户ID",name="bUserId")
    private Long bUserId;
    /**扫码授权编码**/
    @io.swagger.annotations.ApiModelProperty(value="扫码授权编码",name="authCode")
    private String authCode;
	/**ip地址**/
	@io.swagger.annotations.ApiModelProperty(value="ip地址",name="ip")
	private String ip;
	/**支付金额(分)**/
	@io.swagger.annotations.ApiModelProperty(value="支付金额(分)",name="payAmount")
	private Integer payAmount;
	/**支付发起时间**/
	@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="transactionId")
	private String transactionId;
	/**支付渠道: 0-微信 1-支付宝 2-银联 **/
	@io.swagger.annotations.ApiModelProperty(value="支付渠道: 0-微信 1-支付宝 2-银联 ",name="payVendor")
	private Integer payVendor;
	/**支付订单号**/
	@io.swagger.annotations.ApiModelProperty(value="支付订单号",name="payOrderNo")
	private String payOrderNo;
	/**支付状态: 0-支付中;1-支付成功;2-支付失败**/
	@io.swagger.annotations.ApiModelProperty(value="支付状态: 0-支付中;1-支付成功;2-支付失败",name="payOrderStatus")
	private Integer payOrderStatus;
	/**分账状态: 0-未分账;1-分账**/
	@io.swagger.annotations.ApiModelProperty(value="分账状态: 0-未分账;1-分账",name="payOrderStatus")
	private Integer share;
	/**分账金额(总金额扣除手续费后的金额)**/
	@io.swagger.annotations.ApiModelProperty(value="分账金额",name="shareAmount")
	private Integer shareAmount;
	/**支付失败原因**/
	@io.swagger.annotations.ApiModelProperty(value="支付失败原因",name="failReason")
	private String failReason;
    @io.swagger.annotations.ApiModelProperty(value="支付后结果来源(0:callback, 1:query)",name="payEndFrom")
    private Integer payEndFrom;
	public String  getTenantId() {
		return tenantId;
	}
	public void setTenantId(String _tenantId) {
		tenantId = _tenantId;
	}
	public Date  getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date _createTime) {
		createTime = _createTime;
	}
	public Date  getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date _updateTime) {
		updateTime = _updateTime;
	}
	public Long  getOrderId() {
		return orderId;
	}
	public void setOrderId(Long _orderId) {
		orderId = _orderId;
	}

	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 String getAuthCode() {
        return authCode;
    }

    public void setAuthCode(String authCode) {
        this.authCode = authCode;
    }

    public String  getIp() {
		return ip;
	}
	public void setIp(String _ip) {
		ip = _ip;
	}
	public Integer  getPayAmount() {
		return payAmount;
	}
	public void setPayAmount(Integer _payAmount) {
		payAmount = _payAmount;
	}
	public Date  getPayTimeStart() {
		return payTimeStart;
	}
	public void setPayTimeStart(Date _payTimeStart) {
		payTimeStart = _payTimeStart;
	}
	public Date  getPayTimeEnd() {
		return payTimeEnd;
	}
	public void setPayTimeEnd(Date _payTimeEnd) {
		payTimeEnd = _payTimeEnd;
	}

	public String getPrepayId() {
		return prepayId;
	}

	public void setPrepayId(String prepayId) {
		this.prepayId = prepayId;
	}

	public String  getTransactionId() {
		return transactionId;
	}
	public void setTransactionId(String _transactionId) {
		transactionId = _transactionId;
	}
	public Integer  getPayVendor() {
		return payVendor;
	}
	public void setPayVendor(Integer _payVendor) {
		payVendor = _payVendor;
	}
	public String  getPayOrderNo() {
		return payOrderNo;
	}
	public void setPayOrderNo(String _payOrderNo) {
		payOrderNo = _payOrderNo;
	}
	public Integer  getPayOrderStatus() {
		return payOrderStatus;
	}
	public void setPayOrderStatus(Integer _payOrderStatus) {
		payOrderStatus = _payOrderStatus;
	}

	public Integer getShare() {
		return share;
	}
	public void setShare(Integer share) {
		this.share = share;
	}

	public Integer getShareAmount() {
		return shareAmount;
	}

	public void setShareAmount(Integer shareAmount) {
		this.shareAmount = shareAmount;
	}

	public String  getFailReason() {
		return failReason;
	}
	public void setFailReason(String _failReason) {
		failReason = _failReason;
	}

    public Integer getPayEndFrom() {
        return payEndFrom;
    }

    public void setPayEndFrom(Integer payEndFrom) {
        this.payEndFrom = payEndFrom;
    }

    public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC")
			,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC")
			,OrderId_ASC("`order_id` ASC"),OrderId_DESC("`order_id` DESC")
			,CUserId_ASC("`c_user_id` ASC"),CUserId_DESC("`c_user_id` DESC")
            ,BUserId_ASC("`b_user_id` ASC"),BUserId_DESC("`b_user_id` DESC")
            ,AuthCode_ASC("`auth_code` ASC"),AuthCode_DESC("`auth_code` DESC")
			,Ip_ASC("`ip` ASC"),Ip_DESC("`ip` DESC")
			,PayAmount_ASC("`pay_amount` ASC"),PayAmount_DESC("`pay_amount` 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("`transaction_id` DESC")
			,TransactionId_ASC("`transaction_id` ASC"),TransactionId_DESC("`prepay_id` DESC")
			,PayVendor_ASC("`pay_vendor` ASC"),PayVendor_DESC("`pay_vendor` DESC")
			,PayOrderNo_ASC("`pay_order_no` ASC"),PayOrderNo_DESC("`pay_order_no` DESC")
			,PayOrderStatus_ASC("`pay_order_status` ASC"),PayOrderStatus_DESC("`pay_order_status` DESC")
			,Share_ASC("`share` ASC"),Share_DESC("`share` DESC")
			,ShareAmount_ASC("`share_amount` ASC"),ShareAmount_DESC("`share_amount` DESC")
			,FailReason_ASC("`fail_reason` ASC"),FailReason_DESC("`fail_reason` DESC")
            ,PayEndFrom_ASC("`pay_end_from` ASC"),PayEndFrom_DESC("`pay_end_from` 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(WxPayOrder.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));
		}
	}
}
