package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.ProjectType;
import com.tourism.common.core.util.MyCommonUtil;
import com.tourism.common.core.annotation.*;
import com.tourism.common.core.base.model.BaseModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * 门户预定管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_book_info")
public class TourBookInfo extends BaseModel {

    /**
     * 主键id。
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 预定电话。
     */
    @TableField(value = "book_mobile")
    private String bookMobile;

    /**
     * 预定姓名。
     */
    @TableField(value = "book_name")
    private String bookName;

    /**
     * 预定的ip。
     */
    @TableField(value = "book_ip")
    private String bookIp;

    /**
     * 预定时间。
     */
    @TableField(value = "book_time")
    private Date bookTime;

    /**
     * 是否处理(0:未处理 1:已处理)。
     */
    @TableField(value = "is_handle")
    private Integer isHandle;

    /**
     * 预定的种类(1:旅游 2:劳务)。
     */
    @TableField(value = "type")
    private Integer type;

    /**
     * 预定种类的id。
     */
    @TableField(value = "project_id")
    private Long projectId;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "deleted_flag")
    private Integer deletedFlag;

    /**
     * 成人价格。
     */
    @TableField(value = "adult_price")
    private BigDecimal adultPrice;

    /**
     * 儿童价格。
     */
    @TableField(value = "children_price")
    private BigDecimal childrenPrice;

    /**
     * 成人人数。
     */
    @TableField(value = "adult_number")
    private Integer adultNumber;

    /**
     * 儿童人数。
     */
    @TableField(value = "children_number")
    private Integer childrenNumber;

    /**
     * 总价格。
     */
    @TableField(value = "total_price")
    private BigDecimal totalPrice;

    /**
     * book_mobile / book_name LIKE搜索字符串。
     */
    @TableField(exist = false)
    private String searchString;

    public void setSearchString(String searchString) {
        this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
    }

    @RelationOneToOne(
            masterIdField = "projectId",
            slaveModelClass = TourismProject.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourismProject tourismProject;

    @RelationConstDict(
            masterIdField = "type",
            constantDictClass = ProjectType.class)
    @TableField(exist = false)
    private Map<String, Object> typeDictMap;

    @RelationGlobalDict(
            masterIdField = "isHandle",
            dictCode = "IsHandle")
    @TableField(exist = false)
    private Map<String, Object> isHandleDictMap;

    @TableField(exist = false)
    private Date startTime;

    @TableField(exist = false)
    private Date endTime;


    public String getString() {
        return type + "_" + projectId + "_" + adultNumber + "_" + childrenNumber + "_" + startTime;
    }
}
