package com.cyksj.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.ejlchina.searcher.bean.DbIgnore;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/*
 *项目名: netflix
 *文件名: Coupon
 *创建者: JavaZou
 *创建时间:2022/11/17 15:49
 */
@Getter
@Setter
public class Coupon extends BaseEntity {
	/**
	 * 优惠券名称
	 */
	@NotEmpty(message = "优惠券名称不能为空")
	private String name;

	/**
	 * 优惠券分类id
	 */
	private Long classificationId;

	/**
	 * 优惠券平台类型
	 */
	@NotNull(message = "优惠券平台类型不能为空")
	private GoodsType goodsType;

	/**
	 * 优惠券类型
	 */
	@NotNull(message = "优惠券类型不能为空")
	private Type type;

	/**
	 * 可用满减卷金额条件
	 */
	private BigDecimal reduceCondition;

	/**
	 * 抵扣金额
	 */
	private BigDecimal reduceMoney;

	/**
	 * 折扣
	 */
	private BigDecimal discount;

	/**
	 * 领取人范围
	 */
	@NotNull(message = "领取人不能为空")
	private Scope scope;

	/**
	 * 平台规格集合
	 */
	@NotEmpty
	private String goodsSkuIds;

	/**
	 * 是否是有效时间
	 */
	private Boolean isValidTime;

	/**
	 * 起始有效时间
	 */
	private Date validStartTime;

	/**
	 * 截止有效时间
	 */
	private Date validEndTime;

	/**
	 * 领取有效天数
	 */
	private Integer validDays;

	/**
	 * 领取有效小时
	 */
	private Integer validHours;

	/**
	 * 使用范围
	 */
	private UseScope useScope;

	/**
	 * 兑换码
	 */
	private String exCode;

	/**
	 * 发放状态
	 */
	private Boolean sendStatus;

	/**
	 * 推荐状态
	 */
	private Boolean hotStatus;

	@TableLogic(value = "1", delval = "0")
	private Boolean deleted;

	@DbIgnore
	@TableField(exist = false)
	private BigDecimal couponMoney;

	@Getter
	public enum GoodsType {
		realGoods("实物"),
		virtualGoods("虚物"),
		;
		String type;

		GoodsType(String type) {
			this.type = type;
		}
	}

	@Getter
	public enum Type {
		reduce("立减卷"),
		discount("折扣卷"),
		;
		String desc;

		Type(String desc) {
			this.desc = desc;
		}
	}

	@Getter
	public enum Scope {
		everyone("所有人"),
		newUser("新用户"),
		;
		String desc;

		Scope(String desc) {
			this.desc = desc;
		}
	}

	@Getter
	public enum UseScope {
		orders("下单可用"),
		renew("续费可用"),
		all("所有")
		;
		String desc;

		UseScope(String desc) {
			this.desc = desc;
		}
	}

	@Getter
	@Setter
	public static class CouponGoodsSku {
		private Long goodsId;

		private Long skuId;
	}
}
