package com.haha.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@TableName("t_user")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    private String openid;

    private String phone;

    private String nickname;
    
    private String avatar;
    
    private Integer creditScore;
    
    private Integer status;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime createTime;
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
    private LocalDateTime updateTime;
    
    // ========== 以下为非数据库字段，用于前端展示 ==========
    
    @TableField(exist = false)
    private String statusLabel;
    
    @TableField(exist = false)
    private String statusColor;

    /** 用户消费标签：new-新用户, regular-老用户, frequent-常客 */
    @TableField(exist = false)
    private String userTag;

    /** 用户消费标签中文描述 */
    @TableField(exist = false)
    private String userTagLabel;

    @TableField(exist = false)
    private Long totalOrders;

    @TableField(exist = false)
    private java.math.BigDecimal totalSpent;
}
