package com.iformall.domain.po;

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

@Table(name = "wx_order")
public class WxOrder 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;
	}

	@Transient
	private String merchantName;

	@Transient
	private String cUserName;

	@Transient
	private String phone;

	/**订单码;正反向交易保持一致。**/
	@io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber")
	private Long orderNumber;
	/**租户ID**/
	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;
	/**c端用户id**/
	@io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId")
	private Long cUserId;
    /**渠道ID**/
    @io.swagger.annotations.ApiModelProperty(value="渠道ID",name="couponChannelId")
    private Long couponChannelId;
	/**产品ID,根据order type**/
	@io.swagger.annotations.ApiModelProperty(value="产品ID(type-0:couponId, 1:buserId, 3:merchantId)",name="productId")
	private Long productId;
	/**类型0:券,1:B刷卡支付,2:C扫码支付,3:储值卡**/
	@io.swagger.annotations.ApiModelProperty(value="类型",name="type")
	private Integer type;
	/**0: 付款 1: 退款**/
	@io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType")
	private Integer paymentType;
	/**支付金额(分)：允许有负数，退款时为负值。**/
	@io.swagger.annotations.ApiModelProperty(value="支付金额(分)：允许有负数，退款时为负值。",name="payment")
	private Integer payment;
	/**支付时间**/
	@io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime")
	private Date paymentTime;
	/**订单状态：-1全部;正向交易：0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易：3-待退款;4-已退款,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败**/
	@io.swagger.annotations.ApiModelProperty(value="订单状态：-1全部;正向交易：0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易：3-已退款; 4-退款失败,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败",name="orderStatus")
	private Integer orderStatus;
	/**创建时间/砍价开始时间**/
	@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="支付描述，订单支付时用",name="detail")
	private String detail;

	/**砍价结束时间**/
	@io.swagger.annotations.ApiModelProperty(value="砍价结束时间",name="pressEndDate")
	private Date pressEndDate;

	/**砍价人数**/
	@io.swagger.annotations.ApiModelProperty(value="砍价人数",name="pressCurrentNum")
	private Integer pressCurrentNum;
	/**已砍价格**/
	@io.swagger.annotations.ApiModelProperty(value="已砍价格",name="pressCurrentValue")
	private Integer pressCurrentValue;

    @Transient
    protected List<Integer> statusS;

    @Transient
    protected String statusStr;

	@io.swagger.annotations.ApiModelProperty(value = "拼团ID", name = "orderGroupId")
	private Long orderGroupId;

	public Long  getOrderNumber() {
		return orderNumber;
	}
	public void setOrderNumber(Long _orderNumber) {
		orderNumber = _orderNumber;
	}
	public String  getTenantId() {
		return tenantId;
	}
	public void setTenantId(String _tenantId) {
		tenantId = _tenantId;
	}

	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}

	public Integer  getPaymentType() {
		return paymentType;
	}
	public void setPaymentType(Integer _paymentType) {
		paymentType = _paymentType;
	}
	public Integer  getPayment() {
		return payment;
	}
	public void setPayment(Integer _payment) {
		payment = _payment;
	}
	public Date  getPaymentTime() {
		return paymentTime;
	}
	public void setPaymentTime(Date _paymentTime) {
		paymentTime = _paymentTime;
	}
	public Integer  getOrderStatus() {
		return orderStatus;
	}
	public void setOrderStatus(Integer _orderStatus) {
		orderStatus = _orderStatus;
	}
	public Date  getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date _createDate) {
		createDate = _createDate;
	}
	public Date  getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date _updateDate) {
		updateDate = _updateDate;
	}
	public String  getDetail() {
		return detail;
	}
	public void setDetail(String _detail) {
		detail = _detail;
	}

	public String getMerchantName() {
		return merchantName;
	}

	public void setMerchantName(String merchantName) {
		this.merchantName = merchantName;
	}

	public Long getcUserId() {
		return cUserId;
	}

	public void setcUserId(Long cUserId) {
		this.cUserId = cUserId;
	}

	public Long getCUserId() {
		return cUserId;
	}

	public void setCUserId(Long _cUserId) {
		cUserId = _cUserId;
	}

	public Long getCouponChannelId() {
        return couponChannelId;
    }

    public void setCouponChannelId(Long couponChannelId) {
        this.couponChannelId = couponChannelId;
    }

    public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public String getcUserName() {
		return cUserName;
	}

	public void setcUserName(String cUserName) {
		this.cUserName = cUserName;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public Date getPressEndDate() {
		return pressEndDate;
	}

	public void setPressEndDate(Date pressEndDate) {
		this.pressEndDate = pressEndDate;
	}

	public Integer getPressCurrentNum() {
		return pressCurrentNum;
	}

	public void setPressCurrentNum(Integer pressCurrentNum) {
		this.pressCurrentNum = pressCurrentNum;
	}

	public Integer getPressCurrentValue() {
		return pressCurrentValue;
	}

	public void setPressCurrentValue(Integer pressCurrentValue) {
		this.pressCurrentValue = pressCurrentValue;
	}

    public List<Integer> getStatusS() {
        return statusS;
    }

    public void setStatusS(List<Integer> statusS) {
        this.statusS = statusS;
    }

    public String getStatusStr() {
        return statusStr;
    }

    public void setStatusStr(String statusStr) {
        this.statusStr = statusStr;
    }

	public Long getOrderGroupId() {
		return orderGroupId;
	}

	public void setOrderGroupId(Long orderGroupId) {
		this.orderGroupId = orderGroupId;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,OrderNumber_ASC("`order_number` ASC"),OrderNumber_DESC("`order_number` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,CUserId_ASC("`c_user_id` ASC"),CUserId_DESC("`c_user_id` DESC")
			,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC")
			,BUserId_ASC("`b_user_id` ASC"),BUserId_DESC("`b_user_id` DESC")
            ,CouponChannelId_ASC("`coupon_channel_id` ASC"),CouponChannelId_DESC("`coupon_channel_id` DESC")
			,ProductId_ASC("`product_id` ASC"),ProductId_DESC("`product_id` DESC")
			,Type_ASC("`type` ASC"),Type_DESC("`type` DESC")
			,PaymentType_ASC("`payment_type` ASC"),PaymentType_DESC("`payment_type` DESC")
			,Payment_ASC("`payment` ASC"),Payment_DESC("`payment` DESC")
			,PaymentTime_ASC("`payment_time` ASC"),PaymentTime_DESC("`payment_time` DESC")
			,OrderStatus_ASC("`order_status` ASC"),OrderStatus_DESC("`order_status` DESC")
			,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC")
			,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC")
			,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` 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(WxOrder.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));
		}
	}
}
