package com.gxwebsoft.cms.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 客资跟进记录实体
 *
 * @author 科技小王子
 * @since 2026-04-14
 */
@Data
@TableName("lead_follow_log")
@Schema(name = "LeadFollowLog", description = "客资跟进记录")
public class LeadFollowLog implements Serializable {

    private static final long serialVersionUID = 1L;

    @Schema(description = "跟进ID")
    @TableId(type = IdType.AUTO)
    private Integer followId;

    @Schema(description = "客资ID")
    private Integer leadId;

    @Schema(description = "跟进人ID")
    private Integer userId;

    @Schema(description = "跟进方式: 1电话 2微信 3上门 4短信 5其他")
    private Integer followType;

    @Schema(description = "跟进内容")
    private String followContent;

    @Schema(description = "下次跟进时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime nextFollowTime;

    @Schema(description = "下次跟进计划")
    private String nextFollowPlan;

    @Schema(description = "附件URLs(JSON数组)")
    private String attachmentUrls;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    // ========== 关联信息（非数据库字段）==========
    @Schema(description = "跟进人昵称")
    private String userName;

    @Schema(description = "客资客户姓名")
    private String customerName;

    @Schema(description = "客资客户电话")
    private String customerPhone;

    // ========== 跟进方式常量 ==========
    public static final int TYPE_PHONE = 1;    // 电话
    public static final int TYPE_WECHAT = 2;   // 微信
    public static final int TYPE_VISIT = 3;    // 上门
    public static final int TYPE_SMS = 4;      // 短信
    public static final int TYPE_OTHER = 5;    // 其他

    public String getFollowTypeText() {
        if (this.followType == null) return "";
        return switch (this.followType) {
            case TYPE_PHONE -> "电话";
            case TYPE_WECHAT -> "微信";
            case TYPE_VISIT -> "上门";
            case TYPE_SMS -> "短信";
            case TYPE_OTHER -> "其他";
            default -> "";
        };
    }
}
