package org.hzhub.crm.domain.bo;

import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hzhub.common.core.xss.Xss;
import org.hzhub.common.mybatis.core.domain.BaseEntity;
import org.hzhub.crm.domain.CrmOpportunity;

import java.math.BigDecimal;
import java.util.Date;

/**
 * CRM商机业务对象 crm_opportunity
 *
 * @author hzhub
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = CrmOpportunity.class, reverseConvertGenerate = false)
public class CrmOpportunityBo extends BaseEntity {

    /**
     * 商机ID
     */
    private Long opportunityId;

    /**
     * 经销商ID
     */
    @NotNull(message = "经销商ID不能为空")
    private Long dealerId;

    /**
     * 商机名称
     */
    @Xss(message = "商机名称不能包含脚本字符")
    @NotBlank(message = "商机名称不能为空")
    @Size(min = 0, max = 200, message = "商机名称长度不能超过{max}个字符")
    private String opportunityName;

    /**
     * 商机阶段（字典：crm_opportunity_stage）
     */
    private String stage;

    /**
     * 商机金额
     */
    @DecimalMax(value = "99999999999999.99", message = "商机金额不能超过{value}")
    @DecimalMin(value = "0", message = "商机金额不能小于{value}")
    private BigDecimal amount;

    /**
     * 成功概率（百分比）
     */
    @DecimalMin(value = "0", message = "成功概率不能小于{value}")
    @DecimalMax(value = "100", message = "成功概率不能超过{value}")
    private Integer probability;

    /**
     * 预计成交日期
     */
    private Date expectedCloseDate;

    /**
     * 实际成交日期
     */
    private Date actualCloseDate;

    /**
     * 负责人（关联 sys_user）
     */
    private Long ownerUserId;

    /**
     * 产品名称
     */
    @Xss(message = "产品名称不能包含脚本字符")
    @Size(min = 0, max = 200, message = "产品名称长度不能超过{max}个字符")
    private String productName;

    /**
     * 商机描述
     */
    @Xss(message = "商机描述不能包含脚本字符")
    @Size(min = 0, max = 500, message = "商机描述长度不能超过{max}个字符")
    private String description;

    /**
     * 来源线索ID
     */
    private Long sourceLeadId;

    /**
     * 状态（字典：crm_opportunity_status）
     */
    private String status;

    public CrmOpportunityBo(Long opportunityId) {
        this.opportunityId = opportunityId;
    }
}