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 lombok.Data;
import lombok.EqualsAndHashCode;

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

@TableName(value = "wx_game")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxGame extends BaseEntity {
    private static final long serialVersionUID = 1L;

    protected Long id;

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

    @io.swagger.annotations.ApiModelProperty(value = "游戏模板ID", name = "gameId")
    private Long gameId;

    @io.swagger.annotations.ApiModelProperty(value = "游戏状态(0:上架，1：下架)", name = "status")
    private Integer status;

    @io.swagger.annotations.ApiModelProperty(value = "券列表", name = "couponIds")
    private String couponIds;

    @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 = "触发条件（-1:不受限制，1:登录触发, 2:主页固定入口,3:购买触发,4:核销触发,5:公众号链接触发,6:二维码触发）", name = "triggleAction")
    private Integer triggleAction;

    @io.swagger.annotations.ApiModelProperty(value = "限玩次数（0:不受限制，n：限玩次数）", name = "playLimit")
    private Integer playLimit;

    @io.swagger.annotations.ApiModelProperty(value = "限奖次数（0:不受限制，n：限奖次数）", name = "awardLimit")
    private Integer awardLimit;

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value = "已投放券信息")
    protected List<Object> couponIdsList;  // couponChannel

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="游戏名称",name="name")
    private String name;
    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="游戏链接",name="url")
    private String url;
    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="游戏logo，c端游戏入口使用",name="imgUrl")
    private String imgUrl;
    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="选项限制（-1：不做限制)",name="optionLimit")
    private Integer optionLimit;
    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="游戏规则说明",name="rules")
    private String rules;
    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="游戏类型(1：卡牌),目前无用",name="type")
    private Integer type;

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="小程序路径",name="weappPath")
    private String weappPath;

    @TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="小程序二维码Scene",name="weappScene")
    private String weappScene;

    public String getWeappPath() {
        if (id == null)
            return "pages/index/index";
        return "pages/index/index?type=gm&id="+id;
    }

    public String getWeappScene() {
        if(id == null)
            return "";
        return "t:gm:"+id;
    }

    public void setGameTemplate(WxGameTemplate gameTemplate) {
        if (gameTemplate != null) {
            this.imgUrl = gameTemplate.getImgUrl();
            this.url = gameTemplate.getUrl();
            this.name = gameTemplate.getName();
            this.optionLimit = gameTemplate.getOptionLimit();
            this.rules = gameTemplate.getRules();
            this.type = gameTemplate.getType();
        }
    }
}
