package com.iformall.domain.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.*;
import javax.persistence.Transient;
import java.util.List;
import javax.persistence.Id;
import java.io.Serializable;

@Table(name = "wx_merchant_subsidy")
@Data
public class WxMerchantSubsidy implements Serializable {
	private static final long serialVersionUID = 1L;


	@Id
    protected Long id;
    
    @Transient
    protected List<Long> ids;

	@Transient
	protected String idStr;

    @Transient
    protected String sortColumns;

	/**租户ID**/
	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;

	/**订单ID*/
	@Excel(name="交易单号",width = 20,orderNum = "1")
	@io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId")
	private Long orderId;

	/**订单支付类型(0:券1:付款码支付,2:C扫码支付,3,储值卡)*/
	@io.swagger.annotations.ApiModelProperty(value="订单支付类型(0:券1:付款码支付,2:C扫码支付,3,储值卡)",name="orderType")
	private Integer orderType;

	/**商户ID*/
	@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
	private Long merchantId;
	/**券包ID/存储卡ID*/
	@io.swagger.annotations.ApiModelProperty(value="券包ID/存储卡ID",name="couponOrderId")
	private Long couponOrderId;
	/**券包类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)*/
	@io.swagger.annotations.ApiModelProperty(value="券包类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)",name="couponType")
	private Integer couponType;

	/**订单金额*/
	@io.swagger.annotations.ApiModelProperty(value="订单金额",name="orderPayment")
	private Integer orderPayment;
	/**接收金额（包含通道费）*/
	@io.swagger.annotations.ApiModelProperty(value="接收金额（包含通道费）",name="receiverPayment")
	private Integer receiverPayment;

	/**订单金额*/
	@Transient
	@Excel(name="本次消费(元)",width = 20,orderNum = "4")
	private String orderPaymentStr;
	/**接收金额（包含通道费）*/
	@Transient
	@Excel(name="商户应收(元)",width = 20,orderNum = "5")
	private String receiverPaymentStr;

	/** 实收金额(不包含通道费)*/
	@io.swagger.annotations.ApiModelProperty(value=" 实收金额(不包含通道费)",name="realPayment")
	private Integer realPayment;
	/**补贴额（包含通道费）*/
	@Excel(name="补贴(元)",width = 20,orderNum = "6")
	@io.swagger.annotations.ApiModelProperty(value="补贴额（包含通道费）",name="subsidy")
	private Integer subsidy;
	/**线上补贴额/实收补贴额（通道费扣除）*/
	@io.swagger.annotations.ApiModelProperty(value="线上补贴额/实收补贴额（通道费扣除）",name="realSubsidy")
	private Integer realSubsidy;
	/**状态(0:未补贴, 1:已自动补贴, 2:已手工补贴)*/
	@Excel(name="补贴状态",width = 20,orderNum = "7",replace = { "未补贴_0", "已自动补贴_1","已手工补贴_2"})
	@io.swagger.annotations.ApiModelProperty(value="状态(0:未补贴, 1:已补贴, 2:已手工补贴)",name="status")
	private Integer status;
	/**创建时间*/
	@Excel(name="交易时间",width = 20,orderNum = "3",format="yyyy-MM-dd HH:mm")
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
	private Date createDate;
	/**更新时间*/
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	private Date updateDate;

	@Transient
	private Date startdate;

	@Transient
	private Date enddate;

	@Transient
	protected List<Integer> statusS;

	@Transient
	protected String statusStr;

	public String getOrderPaymentStr() {

		if(getOrderPayment()!=null) {
			orderPaymentStr = new BigDecimal(getOrderPayment()).divide(new BigDecimal(100)).toString();
		}
		return orderPaymentStr;
	}

	public void setOrderPaymentStr(String orderPaymentStr) {
		this.orderPaymentStr = orderPaymentStr;
	}

	public String getReceiverPaymentStr() {
		if(getReceiverPayment()!=null) {
			receiverPaymentStr = new BigDecimal(getReceiverPayment()).divide(new BigDecimal(100)).toString();
		}
		return receiverPaymentStr;
	}

	public void setReceiverPaymentStr(String receiverPaymentStr) {
		this.receiverPaymentStr = receiverPaymentStr;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,OrderId_ASC("`order_id` ASC"),OrderId_DESC("`order_id` DESC")
			,OrderType_ASC("`order_type` ASC"),OrderType_DESC("`order_type` DESC")
			,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC")
			,CouponOrderId_ASC("`coupon_order_id` ASC"),CouponOrderId_DESC("`coupon_order_id` DESC")
			,CouponType_ASC("`coupon_type` ASC"),CouponType_DESC("`coupon_type` DESC")
			,OrderPayment_ASC("`order_payment` ASC"),OrderPayment_DESC("`order_payment` DESC")
			,ReceiverPayment_ASC("`receiver_payment` ASC"),ReceiverPayment_DESC("`receiver_payment` DESC")
			,RealPayment_ASC("`real_payment` ASC"),RealPayment_DESC("`real_payment` DESC")
			,Subsidy_ASC("`subsidy` ASC"),Subsidy_DESC("`subsidy` DESC")
			,RealSubsidy_ASC("`real_subsidy` ASC"),RealSubsidy_DESC("`real_subsidy` DESC")
			,Status_ASC("`status` ASC"),Status_DESC("`status` 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(WxMerchantSubsidy.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));
		}
	}
}
