package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.common.SortColumn;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCouponType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Date;
import java.util.List;

@TableName(value = "wx_coupon_channel")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxCouponChannel extends BaseEntity {

	protected Long id;

	@TableField(exist = false)
	protected List<Long> ids;

	@TableField(exist = false)
	private Date startdate;

	@TableField(exist = false)
	private Date enddate;

    @TableField(exist = false)
    private Integer supportTransfer;

	@TableField(exist = false)
	protected List<Long> couponIds;

	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;
	@io.swagger.annotations.ApiModelProperty(value="卡券id",name="couponId")
	private Long couponId;

	@io.swagger.annotations.ApiModelProperty(value="券类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券)",name="type")
	private Integer type;
	@io.swagger.annotations.ApiModelProperty(value="券名称",name="title")
	private String title;
	@io.swagger.annotations.ApiModelProperty(value="投放频道位置（1.列表, 2.限时抢购）",name="targetAd")
	private Integer targetAd;
	@io.swagger.annotations.ApiModelProperty(value="业态",name="business")
	private Integer business;
	@io.swagger.annotations.ApiModelProperty(value="子业态",name="subBusiness")
	private Integer subBusiness;
	@io.swagger.annotations.ApiModelProperty(value="开始时间",name="beginTime")
	private Date beginTime;
	@io.swagger.annotations.ApiModelProperty(value="结束时间",name="endTime")
	private Date endTime;
	@io.swagger.annotations.ApiModelProperty(value="0:上架 1:下架",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="子频道ID",name="subTargetId")
	private Long subTargetId;
	@io.swagger.annotations.ApiModelProperty(value="二维码",name="qrCode")
	private String qrCode;

	@TableField(exist = false)
	@io.swagger.annotations.ApiModelProperty(value="卷状态 0:可投放 1:作废",name="couponStatus")
	private Integer couponStatus;

	@TableField(exist = false)
	@io.swagger.annotations.ApiModelProperty(value="积分售价（适用于类型10,11）",name="creditPrice")
	private Integer creditPrice;

	@TableField(exist = false)
	@SortColumn(column = "sale_price")
	private String salePriceStr;

	@TableField(exist = false)
	@SortColumn(column = "use_price")
	private String usePriceStr;

	@TableField(exist = false)
	@SortColumn(column = "price")
	private String priceStr;

	@TableField(exist = false)
	private Long merchantId;

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value = "用户积分", name = "userCredit")
    private Integer userCredit;

	public String getWeappPath() {
	    if(type == null)
	        return "pages/index/index";
        if(!type.equals(EnumCouponType.COUPON_GROUP.getCode())) {
            return "pages/index/index?type=cd&couponChannelId=" + id;
        } else {
            return "pages/index/index?type=sd&couponChannelId=" + id;
        }
    }

    public String getWeappScene() {
        if(type == null)
            return "";
        if(!type.equals(EnumCouponType.COUPON_GROUP.getCode())) {
            return "t:cd:" + id;
        } else {
            return "t:sd:" + id;
        }
    }

}
