package com.iformall.domain.po;

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

/**
 * @author gongbiao
 */
@Table(name = "wx_pay_account_bill")
public class WxPayAccountBill 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="mchId")
	private String mchId;
	/**微信服务商号*/
	@io.swagger.annotations.ApiModelProperty(value="微信服务商号",name="subMchId")
	private String subMchId;
	/**支付密钥**/
	@io.swagger.annotations.ApiModelProperty(value="支付密钥",name="apiKey")
	private String apiKey;
	/**微信回调,支持3种回调，（1.url/pay 2.url/refund3.url/separate）**/
	@io.swagger.annotations.ApiModelProperty(value="微信回调,支持3种回调，（1.url/pay 2.url/refund3.url/separate）",name="notifyUrl")
	private String notifyUrl;
	/**证书本地存放位置**/
	@io.swagger.annotations.ApiModelProperty(value="证书本地存放位置",name="certPath")
	private String certPath;
	/**商户模式**/
	@io.swagger.annotations.ApiModelProperty(value="商户模式-0:普通商户模式1:服务商模式",name="type")
	private Integer type;
	/**是否开启分账**/
	@io.swagger.annotations.ApiModelProperty(value="0:未开启分账1:开启分账",name="type")
	private boolean share;
	/**手续费**/
	@io.swagger.annotations.ApiModelProperty(value="手续费",name="rate")
	private Integer rate;

	public String getTenantId() {
		return tenantId;
	}

	public void setTenantId(String tenantId) {
		this.tenantId = tenantId;
	}

	public String  getMchId() {
		return mchId;
	}
	public void setMchId(String _mchId) {
		mchId = _mchId;
	}

	public String getSubMchId() {
		return subMchId;
	}

	public void setSubMchId(String subMchId) {
		this.subMchId = subMchId;
	}

	public String  getApiKey() {
		return apiKey;
	}
	public void setApiKey(String _apiKey) {
		apiKey = _apiKey;
	}
	public String  getNotifyUrl() {
		return notifyUrl;
	}
	public void setNotifyUrl(String _notifyUrl) {
		notifyUrl = _notifyUrl;
	}
	public String  getCertPath() {
		return certPath;
	}
	public void setCertPath(String _certPath) {
		certPath = _certPath;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public boolean isShare() {
		return share;
	}
	public void setShare(boolean share) {
		this.share = share;
	}

	public Integer getRate() {
		return rate;
	}

	public void setRate(Integer rate) {
		this.rate = rate;
	}

	public String getPayNotifyUrl() {
		return notifyUrl + "/pay";
	}
	public String getRefundNotifyUrl() {
		return notifyUrl + "/refund";
	}
	public String getSeparateNotifyUrl() {
		return notifyUrl + "/separate";
	}


	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
		,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
		,MchId_ASC("`mch_id` ASC"),MchId_DESC("`mch_id` DESC")
		,SubMchId_ASC("`sub_mch_id` ASC"),SubMchId_DESC("`sub_mch_id` DESC")
		,ApiKey_ASC("`api_key` ASC"),ApiKey_DESC("`api_key` DESC")
		,NotifyUrl_ASC("`notify_url` ASC"),NotifyUrl_DESC("`notify_url` DESC")
		,CertPath_ASC("`cert_path` ASC"),CertPath_DESC("`cert_path` DESC")
		,Type_ASC("`type` ASC"),Type_DESC("`type` DESC")
		,Share_ASC("`share` ASC"),Share_DESC("`share` DESC")
		,Rate_ASC("`rate` ASC"),Rate_DESC("`rate` 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(WxPayAccountBill.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(",");
			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));
		}
	}
}
