package com.jeesharp.business.modules.member.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.jeesharp.framework.mybatis.core.dataobject.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 会员实体类
 *
 * @author jeesharp
 * @version 2024-01-24
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("app_member")
@Schema(description = "会员实体")
public class Member extends BaseEntity<Member> {

    // ==================== 基本信息 ====================

    /**
     * 会员编号（对外展示的唯一编号）
     */
    @Schema(description = "会员编号")
    private String memberNo;

    /**
     * 关联用户ID
     */
    @Schema(description = "关联用户ID")
    private String userId;

    /**
     * 会员昵称
     */
    @Schema(description = "会员昵称")
    private String nickname;

    /**
     * 真实姓名
     */
    @Schema(description = "真实姓名")
    private String realName;

    /**
     * 头像URL
     */
    @Schema(description = "头像URL")
    private String avatar;

    /**
     * 性别：0-未知 1-男 2-女
     */
    @Schema(description = "性别：0-未知 1-男 2-女")
    private Integer gender;

    /**
     * 手机号（加密存储）
     */
    @Schema(description = "手机号")
    private String mobile;

    /**
     * 邮箱
     */
    @Schema(description = "邮箱")
    private String email;

    /**
     * 身份证号（加密存储）
     */
    @Schema(description = "身份证号")
    private String idCard;

    /**
     * 生日
     */
    @Schema(description = "生日")
    private LocalDate birthday;

    /**
     * 省份
     */
    @Schema(description = "省份")
    private String province;

    /**
     * 城市
     */
    @Schema(description = "城市")
    private String city;

    /**
     * 区县
     */
    @Schema(description = "区县")
    private String district;

    /**
     * 详细地址
     */
    @Schema(description = "详细地址")
    private String address;

    // ==================== 会员等级相关 ====================

    /**
     * 当前会员等级ID
     */
    @Schema(description = "当前会员等级ID")
    private String levelId;

    /**
     * 当前会员等级编码
     */
    @Schema(description = "当前会员等级编码")
    private String levelCode;

    /**
     * 成长值
     */
    @Schema(description = "成长值")
    private Integer growthValue;

    /**
     * 等级过期时间
     */
    @Schema(description = "等级过期时间")
    private LocalDateTime levelExpireDate;

    /**
     * 当前有效付费等级编码（冗余，与 app_member_vip 同步维护）
     */
    @Schema(description = "当前有效付费等级编码")
    private String vipLevelCode;

    /**
     * 付费到期时间（冗余）
     */
    @Schema(description = "付费到期时间")
    private LocalDateTime vipExpireDate;

    /**
     * 是否付费会员：0-否 1-是（冗余）
     */
    @Schema(description = "是否付费会员：0-否 1-是")
    private Integer isVip;

    // ==================== 积分相关 ====================

    /**
     * 累计获得积分
     */
    @Schema(description = "累计获得积分")
    private Integer totalPoints;

    /**
     * 可用积分
     */
    @Schema(description = "可用积分")
    private Integer availablePoints;

    /**
     * 冻结积分
     */
    @Schema(description = "冻结积分")
    private Integer frozenPoints;

    /**
     * 已使用积分
     */
    @Schema(description = "已使用积分")
    private Integer usedPoints;

    /**
     * 已过期积分
     */
    @Schema(description = "已过期积分")
    private Integer expiredPoints;

    // ==================== 消费统计 ====================

    /**
     * 累计消费金额
     */
    @Schema(description = "累计消费金额")
    private BigDecimal totalConsumeAmount;

    /**
     * 累计消费次数
     */
    @Schema(description = "累计消费次数")
    private Integer totalConsumeCount;

    /**
     * 最后消费时间
     */
    @Schema(description = "最后消费时间")
    private LocalDateTime lastConsumeDate;

    /**
     * 平均消费金额
     */
    @Schema(description = "平均消费金额")
    private BigDecimal avgConsumeAmount;

    // ==================== 账户相关 ====================

    /**
     * 账户余额
     */
    @Schema(description = "账户余额")
    private BigDecimal balance;

    /**
     * 冻结余额
     */
    @Schema(description = "冻结余额")
    private BigDecimal frozenBalance;

    // ==================== 邀请相关 ====================

    /**
     * 邀请人会员ID
     */
    @Schema(description = "邀请人会员ID")
    private String inviterId;

    /**
     * 邀请码
     */
    @Schema(description = "邀请码")
    private String inviteCode;

    /**
     * 成功邀请人数
     */
    @Schema(description = "成功邀请人数")
    private Integer inviteCount;

    // ==================== 状态与标签 ====================

    /**
     * 会员状态：0-禁用 1-正常 2-待审核 3-已注销
     */
    @Schema(description = "会员状态：0-禁用 1-正常 2-待审核 3-已注销")
    private Integer status;

    /**
     * 会员来源
     */
    @Schema(description = "会员来源")
    private String source;

    /**
     * 来源渠道
     */
    @Schema(description = "来源渠道")
    private String sourceChannel;

    /**
     * 会员标签（JSON数组）
     */
    @Schema(description = "会员标签")
    private String tags;

    /**
     * 是否实名认证
     */
    @Schema(description = "是否实名认证：0-否 1-是")
    private Integer isRealName;

    /**
     * 实名认证时间
     */
    @Schema(description = "实名认证时间")
    private LocalDateTime realNameDate;

    /**
     * 是否完善资料
     */
    @Schema(description = "是否完善资料：0-否 1-是")
    private Integer isCompleteProfile;

    // ==================== 登录相关 ====================

    /**
     * 注册时间
     */
    @Schema(description = "注册时间")
    private LocalDateTime registerDate;

    /**
     * 注册IP
     */
    @Schema(description = "注册IP")
    private String registerIp;

    /**
     * 最后登录时间
     */
    @Schema(description = "最后登录时间")
    private LocalDateTime lastLoginDate;

    /**
     * 最后登录IP
     */
    @Schema(description = "最后登录IP")
    private String lastLoginIp;

    /**
     * 最后登录方式
     */
    @Schema(description = "最后登录方式")
    private String lastLoginType;

    /**
     * 登录次数
     */
    @Schema(description = "登录次数")
    private Integer loginCount;
}
