package com.iformall.domain.po;

import org.apache.commons.lang3.StringUtils;

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

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

	@Id
    protected Long id;

    @Transient
    protected List<Long> ids;

	@Transient
	protected List<Long> notinTypes;
    @Transient
    protected String sortColumns;

	@Transient
	protected String channels;
  
	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 salePriceStr;

	@Transient
	private String usePriceStr;

	@Transient
	private String priceStr;

	@Transient
	private String subsidyNumStr;

	@Transient
	private Date startdate;

	@Transient
	private Date enddate;

	/**租户ID**/
	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;
	/**券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)**/
	@io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)",name="type")
	private Integer type;
	/**封面图**/
	@io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg")
	private String coverImg;
	/**券名称**/
	@io.swagger.annotations.ApiModelProperty(value="券名称",name="title")
	private String title;
	/**副标题**/
	@io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle")
	private String subTitle;
	/**售价（适用于类型2，3，4，5, 6, 8, 100）**/
	@io.swagger.annotations.ApiModelProperty(value="售价（适用于类型2，3，4，5, 6, 8, 9, 100）",name="salePrice")
	private Integer salePrice;
	/**使用条件金额（适用于类型1,2,3,4）**/
	@io.swagger.annotations.ApiModelProperty(value="使用条件金额（适用于类型1,2,3,4）",name="usePrice")
	private Integer usePrice;
	/**限领张数**/
	@io.swagger.annotations.ApiModelProperty(value="限领张数",name="useLimitQuantity")
	private Integer useLimitQuantity;
	/**1.主动领取2.定向投放**/
	@io.swagger.annotations.ApiModelProperty(value="1.主动领取2.定向投放",name="sendType")
	private Integer sendType;
	/**有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)**/
	@io.swagger.annotations.ApiModelProperty(value="有效时间类型1.时间范围(valid_start_date,valid_end_date). 2领取后几日有效(valid_days)",name="validType")
	private Integer validType;
	/**有效日期-开始**/
	@io.swagger.annotations.ApiModelProperty(value="有效日期-开始",name="validStartDate")
	private Date validStartDate;
	/**有效日期-结束**/
	@io.swagger.annotations.ApiModelProperty(value="有效日期-结束",name="validEndDate")
	private Date validEndDate;
	/**自领取之日几日有效，（停车券当天有效）**/
	@io.swagger.annotations.ApiModelProperty(value="自领取之日几日有效，（停车券当天有效）",name="validDays")
	private Integer validDays;
	/**须知**/
	@io.swagger.annotations.ApiModelProperty(value="须知",name="detail")
	private String detail;
	/**面额**/
	@io.swagger.annotations.ApiModelProperty(value="面额",name="price")
	private Integer price;
	/**单位**/
	@io.swagger.annotations.ApiModelProperty(value="单位(0:rmb分 1:小时)",name="unit")
	private Integer unit;
	/**剩余库存**/
	@io.swagger.annotations.ApiModelProperty(value="剩余库存",name="remainInventory")
	private Integer remainInventory;
	/**总库存**/
	@io.swagger.annotations.ApiModelProperty(value="总库存",name="inventory")
	private Integer inventory;
	/**购买须知**/
	@io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark")
	private String remark;
	/**状态（-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废）**/
	@io.swagger.annotations.ApiModelProperty(value="状态（-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废）",name="status")
	private Integer status;
	/**创建时间**/
	@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="business")
	private Integer business;
	/**是否支持转送(0:不支持,1支持)**/
	@io.swagger.annotations.ApiModelProperty(value="是否支持转送(0:不支持,1支持)",name="supportTransfer")
	private Integer supportTransfer;

	/**过期退款(0:正常,1不退)**/
	@io.swagger.annotations.ApiModelProperty(value="过期退款(0:正常,1不退)",name="autoRefund")
	private Integer autoRefund;

	/**补贴类型(0:不支持, 1:微信支付立减与折扣, 2:线下结算, 3:微信付款到银行卡 )**/
	@io.swagger.annotations.ApiModelProperty(value="补贴类型(0:不支持, 1:微信支付立减与折扣, 2:线下结算, 3:微信付款到银行卡)",name="subsidyType")
	private Integer subsidyType;
	/**补贴额**/
	@io.swagger.annotations.ApiModelProperty(value="补贴额",name="subsidyNum")
	private Integer subsidyNum;

	/**砍价/团购限制人数**/
	@io.swagger.annotations.ApiModelProperty(value="砍价/团购限制人数",name="pressLimitNum")
	private Integer pressLimitNum;

	/**砍价限制时间**/
	@io.swagger.annotations.ApiModelProperty(value="砍价限制时间",name="pressLimitHours")
	private Integer pressLimitHours;

	@Transient
	private String merchantParams;

	//营销分析-----start-----
	@Transient
	private String xtime;
	@Transient
	private String xcount;
	/**售出卡数量**/
	@io.swagger.annotations.ApiModelProperty(value="售出卡数量",name="saleCount")
    @Transient
	private Long saleCount;
	/**转增数量**/
	@io.swagger.annotations.ApiModelProperty(value="转增数量",name="transferCount")
    @Transient
	private Long transferCount;
	/**售出金额**/
	@io.swagger.annotations.ApiModelProperty(value="售出金额",name="saleAmount")
    @Transient
	private Integer saleAmount;
	/**核销数量**/
	@io.swagger.annotations.ApiModelProperty(value="核销数量",name="sumPayment")
    @Transient
	private Integer sumPayment;
	/**退款数量**/
	@io.swagger.annotations.ApiModelProperty(value="退款数量",name="backpayCount")
	@Transient
	private Integer backpayCount;

	/**砍价发起次数**/
	@io.swagger.annotations.ApiModelProperty(value="砍价发起次数",name="pressSendCount")
	@Transient
	private Integer pressSendCount;
	/**砍价成功次数**/
	@io.swagger.annotations.ApiModelProperty(value="砍价成功次数",name="pressSuccCount")
	@Transient
	private Integer pressSuccCount;
	/**砍价参与人数**/
	@io.swagger.annotations.ApiModelProperty(value="砍价参与人数",name="pressJoinCount")
	@Transient
	private Integer pressJoinCount;

	/**商场补贴**/
	@io.swagger.annotations.ApiModelProperty(value="商场补贴",name="sumSubsidy")
	@Transient
	private Integer sumSubsidy;
	/**核销比**/
	@io.swagger.annotations.ApiModelProperty(value="核销比",name="paymentRate")
	@Transient
	private String paymentRate;

	//营销分析-----end-----

    public Integer getSumSubsidy() {
		return sumSubsidy;
	}

	public void setSumSubsidy(Integer sumSubsidy) {
		this.sumSubsidy = sumSubsidy;
	}

	public String getPaymentRate() {
		return paymentRate;
	}

	public void setPaymentRate(String paymentRate) {
		if(StringUtils.isNotBlank(paymentRate)) {
			if ("0.00".equals(paymentRate)) {
				this.paymentRate = "0%";
			} else {
				this.paymentRate = paymentRate + "%";
			}
		}
	}

	public Integer getPressSendCount() {
		return pressSendCount;
	}

	public void setPressSendCount(Integer pressSendCount) {
		this.pressSendCount = pressSendCount;
	}

	public Integer getPressSuccCount() {
		return pressSuccCount;
	}

	public void setPressSuccCount(Integer pressSuccCount) {
		this.pressSuccCount = pressSuccCount;
	}

	public Integer getPressJoinCount() {
		return pressJoinCount;
	}

	public void setPressJoinCount(Integer pressJoinCount) {
		this.pressJoinCount = pressJoinCount;
	}

	public String getXcount() {
		return xcount;
	}

	public void setXcount(String xcount) {
		this.xcount = xcount;
	}

	public Integer getBackpayCount() {
		return backpayCount;
	}

	public void setBackpayCount(Integer backpayCount) {
		this.backpayCount = backpayCount;
	}

	public Long getSaleCount() {
		return saleCount;
	}

	public void setSaleCount(Long saleCount) {
		this.saleCount = saleCount;
	}

	public Long getTransferCount() {
		return transferCount;
	}

	public void setTransferCount(Long transferCount) {
		this.transferCount = transferCount;
	}

	public Integer getSaleAmount() {
		return saleAmount;
	}

	public void setSaleAmount(Integer saleAmount) {
		this.saleAmount = saleAmount;
	}

	public Integer getSumPayment() {
		return sumPayment;
	}

	public void setSumPayment(Integer sumPayment) {
		this.sumPayment = sumPayment;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public String  getTenantId() {
		return tenantId;
	}
	public void setTenantId(String _tenantId) {
		tenantId = _tenantId;
	}
	public Integer  getType() {
		return type;
	}
	public void setType(Integer _type) {
		type = _type;
	}
	public String  getCoverImg() {
		return coverImg;
	}
	public void setCoverImg(String _coverImg) {
		coverImg = _coverImg;
	}
	public String  getTitle() {
		return title;
	}
	public void setTitle(String _title) {
		title = _title;
	}
	public String  getSubTitle() {
		return subTitle;
	}
	public void setSubTitle(String _subTitle) {
		subTitle = _subTitle;
	}
	public Integer  getSalePrice() {
		return salePrice;
	}
	public void setSalePrice(Integer _salePrice) {
		salePrice = _salePrice;
	}
	public Integer  getUsePrice() {
		return usePrice;
	}
	public void setUsePrice(Integer _usePrice) {
		usePrice = _usePrice;
	}
	public Integer  getUseLimitQuantity() {
		return useLimitQuantity;
	}
	public void setUseLimitQuantity(Integer _useLimitQuantity) {
		useLimitQuantity = _useLimitQuantity;
	}
	public Integer  getSendType() {
		return sendType;
	}
	public void setSendType(Integer _sendType) {
		sendType = _sendType;
	}
	public Integer  getValidType() {
		return validType;
	}
	public void setValidType(Integer _validType) {
		validType = _validType;
	}
	public Date  getValidStartDate() {
		return validStartDate;
	}
	public void setValidStartDate(Date _validStartDate) {
		validStartDate = _validStartDate;
	}
	public Date  getValidEndDate() {
		return validEndDate;
	}
	public void setValidEndDate(Date _validEndDate) {
		validEndDate = _validEndDate;
	}
	public Integer  getValidDays() {
		return validDays;
	}
	public void setValidDays(Integer _validDays) {
		validDays = _validDays;
	}
	public String  getDetail() {
		return detail;
	}
	public void setDetail(String _detail) {
		detail = _detail;
	}
	public Integer  getPrice() {
		return price;
	}
	public void setPrice(Integer _price) {
		price = _price;
	}
	public Integer  getUnit() {
		return unit;
	}
	public void setUnit(Integer _unit) {
		unit = _unit;
	}
	public Integer  getRemainInventory() {
		return remainInventory;
	}
	public void setRemainInventory(Integer _remainInventory) {
		remainInventory = _remainInventory;
	}
	public Integer  getInventory() {
		return inventory;
	}
	public void setInventory(Integer _inventory) {
		inventory = _inventory;
	}
	public String  getRemark() {
		return remark;
	}
	public void setRemark(String _remark) {
		remark = _remark;
	}
	public Integer  getStatus() {
		return status;
	}
	public void setStatus(Integer _status) {
		status = _status;
	}
	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 Integer  getBusiness() {
		return business;
	}
	public void setBusiness(Integer _business) {
		business = _business;
	}

	public Integer getSupportTransfer() {
		return supportTransfer;
	}

	public void setSupportTransfer(Integer supportTransfer) {
		this.supportTransfer = supportTransfer;
	}

	public String getSalePriceStr() {
		if(salePrice!=null) {
            salePriceStr = new BigDecimal(salePrice).divide(new BigDecimal(100)).toString();
		}
		return salePriceStr;
	}

	public void setSalePriceStr(String salePriceStr) {
		this.salePriceStr = salePriceStr;
	}

	public String getUsePriceStr() {
		if(usePrice!=null) {
			usePriceStr = new BigDecimal(usePrice).divide(new BigDecimal(100)).toString();
		}
		return usePriceStr;
	}

	public void setUsePriceStr(String usePriceStr) {
		this.usePriceStr = usePriceStr;
	}

	public String getPriceStr() {
		if(price!=null) {
			priceStr = new BigDecimal(price).divide(new BigDecimal(100)).toString();
		}
		return priceStr;
	}

	public String getSubsidyNumStr() {
		if(subsidyNum!=null) {
			subsidyNumStr = new BigDecimal(subsidyNum).divide(new BigDecimal(100)).toString();
		}
		return subsidyNumStr;
	}

	public void setSubsidyNumStr(String subsidyNumStr) {
		this.subsidyNumStr = subsidyNumStr;

	}

	public void setPriceStr(String priceStr) {
		this.priceStr = priceStr;
	}

	public String getChannels() {
		return channels;
	}

	public void setChannels(String channels) {
		this.channels = channels;
	}

	public Date getStartdate() {
		return startdate;
	}

	public void setStartdate(Date startdate) {
		this.startdate = startdate;
	}

	public Date getEnddate() {
		return enddate;
	}

	public void setEnddate(Date enddate) {
		this.enddate = enddate;
	}

	public String getMerchantParams() {
		return merchantParams;
	}

	public void setMerchantParams(String merchantParams) {
		this.merchantParams = merchantParams;
	}

	public Integer getSubsidyType() {
		return subsidyType;
	}

	public void setSubsidyType(Integer subsidyType) {
		this.subsidyType = subsidyType;
	}

	public Integer getSubsidyNum() {
		return subsidyNum;
	}

	public void setSubsidyNum(Integer subsidyNum) {
		this.subsidyNum = subsidyNum;
	}

	public Integer getPressLimitNum() {
		return pressLimitNum;
	}

	public void setPressLimitNum(Integer pressLimitNum) {
		this.pressLimitNum = pressLimitNum;
	}

	public Integer getPressLimitHours() {
		return pressLimitHours;
	}

	public void setPressLimitHours(Integer pressLimitHours) {
		this.pressLimitHours = pressLimitHours;
	}

	public Integer getAutoRefund() {
		return autoRefund;
	}

	public void setAutoRefund(Integer autoRefund) {
		this.autoRefund = autoRefund;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
		,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
		,MerchantId_ASC("`merchant_id` ASC"),MerchantId_DESC("`merchant_id` DESC")
		,Type_ASC("`type` ASC"),Type_DESC("`type` DESC")
		,CoverImg_ASC("`cover_img` ASC"),CoverImg_DESC("`cover_img` DESC")
		,Title_ASC("`title` ASC"),Title_DESC("`title` DESC")
		,SubTitle_ASC("`sub_title` ASC"),SubTitle_DESC("`sub_title` DESC")
		,SalePrice_ASC("`sale_price` ASC"),SalePrice_DESC("`sale_price` DESC")
		,UsePrice_ASC("`use_price` ASC"),UsePrice_DESC("`use_price` DESC")
		,UseLimitQuantity_ASC("`use_limit_quantity` ASC"),UseLimitQuantity_DESC("`use_limit_quantity` DESC")
		,SendType_ASC("`send_type` ASC"),SendType_DESC("`send_type` DESC")
		,SendStartDate_ASC("`send_start_date` ASC"),SendStartDate_DESC("`send_start_date` DESC")
		,SendEndDate_ASC("`send_end_date` ASC"),SendEndDate_DESC("`send_end_ate` DESC")
		,ValidType_ASC("`valid_type` ASC"),ValidType_DESC("`valid_type` DESC")
		,ValidStartDate_ASC("`valid_start_date` ASC"),ValidStartDate_DESC("`valid_start_date` DESC")
		,ValidEndDate_ASC("`valid_end_date` ASC"),ValidEndDate_DESC("`valid_end_date` DESC")
		,ValidDays_ASC("`valid_days` ASC"),ValidDays_DESC("`valid_days` DESC")
		,Detail_ASC("`detail` ASC"),Detail_DESC("`detail` DESC")
		,Price_ASC("`price` ASC"),Price_DESC("`price` DESC")
		,RemainInventory_ASC("`remain_inventory` ASC"),RemainInventory_DESC("`remain_inventory` DESC")
		,Inventory_ASC("`inventory` ASC"),Inventory_DESC("`inventory` DESC")
		,Remark_ASC("`remark` ASC"),Remark_DESC("`remark` 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")
		,Business_ASC("`business` ASC"),Business_DESC("`business` DESC")
		,SupportTransfer_ASC("`support_transfer` ASC"),SupportTransfer_DESC("`support_transfer` DESC")
		,SubsidyType_ASC("`subsidy_type` ASC"),SubsidyType_DESC("`subsidy_type` DESC")
		,SubsidyNum_ASC("`subsidy_num` ASC"),SubsidyNum_DESC("`subsidy_num` 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(WxCoupon.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));
		}
	}

	public String getXtime() {
		return xtime;
	}

	public void setXtime(String xtime) {
		this.xtime = xtime;
	}

	public List<Long> getNotinTypes() {
		return notinTypes;
	}

	public void setNotinTypes(List<Long> notinTypes) {
		this.notinTypes = notinTypes;
	}
}
