package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.WxCouponChannelVo;
import com.iformall.enums.EnumCampaignType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

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

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

	protected Long id;

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

	@io.swagger.annotations.ApiModelProperty(value="",name="tenantId")
	private String tenantId;
	@io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg")
	private String coverImg;
    @io.swagger.annotations.ApiModelProperty(value="多封面图",name="coverPicture")
    private String coverPicture;
    @io.swagger.annotations.ApiModelProperty(value="详情多图",name="detailPicture")
    private String detailPicture;
	@io.swagger.annotations.ApiModelProperty(value="主标题",name="title")
	private String title;
	@io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle")
	private String subTitle;
	@io.swagger.annotations.ApiModelProperty(value="满x可用",name="usePrice")
	private Integer usePrice;
	@io.swagger.annotations.ApiModelProperty(value="折扣",name="discountPrice")
	private Integer discountPrice;
	@io.swagger.annotations.ApiModelProperty(value="活动说明",name="detail")
	private String detail;
	@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="imgDetail")
	private String imgDetail;
	@io.swagger.annotations.ApiModelProperty(value="类型：1-固定格式,2-自由图文,3-小程序路径",name="type")
	private Integer type;
	@io.swagger.annotations.ApiModelProperty(value="优惠券ids",name="couponIds")
	private String couponIds;
	@io.swagger.annotations.ApiModelProperty(value="门店id",name="mechantId")
	private Long mechantId;
	@io.swagger.annotations.ApiModelProperty(value="排序",name="sortNum")
	private Integer sortNum;
	@io.swagger.annotations.ApiModelProperty(value="0上线 1下线",name="status")
	private Integer status;
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
	private Date createTime;
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
	private Date updateTime;
	@io.swagger.annotations.ApiModelProperty(value="富文本,类型2适用",name="html")
	private String html;

    @io.swagger.annotations.ApiModelProperty(value = "产品类型,类型3适用(1-券,2-报名)", name = "produceType")
    private Integer produceType;
    @io.swagger.annotations.ApiModelProperty(value = "产品ID,类型3适用", name = "produceId")
    private Long produceId;
    @io.swagger.annotations.ApiModelProperty(value = "小程序跳转路径,类型3适用", name = "pagePath")
    private String pagePath;
    @io.swagger.annotations.ApiModelProperty(value = "小程序跳转二维码,类型3适用", name = "pageScene")
    private String pageScene;

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="营销物料-小程序路径",name="weappPath")
    protected String weappPath;

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="营销物料-小程序二维码Scene",name="weappScene")
    protected String weappScene;

    public String getWeappPath() {
        if(type == null)
            return "pages/index/index";
        if(type.equals(EnumCampaignType.PAGEPATH.getCode())) {
            return pagePath;
        }
        return "pages/index/index?type=bd&bt="+type+"&id="+id;
    }

    public String getWeappScene() {
        if(type == null)
            return "";
        if(type.equals(EnumCampaignType.PAGEPATH.getCode())) {
            return pageScene;
        }
        return "t:bd:" + type + ":" +id;
    }

}
