package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.VisaOrderState;
import com.tourism.webadmin.back.model.constant.VisaPayState;
import com.tourism.common.core.util.MyCommonUtil;
import com.tourism.common.core.upload.UploadStoreTypeEnum;
import com.tourism.common.core.annotation.*;
import com.tourism.common.core.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * 签证订单类型信息实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_visa_order")
public class TourVisaOrder extends BaseModel {

    /**
     * 签证类型id。
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 文件列表json。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "file")
    private String file;

    /**
     * 下单人姓名。
     */
    @TableField(value = "order_name")
    private String orderName;

    /**
     * 下单人电话。
     */
    @TableField(value = "order_phone")
    private String orderPhone;

    /**
     * 下单身份证。
     */
    @TableField(value = "order_id_card")
    private String orderIdCard;

    /**
     * 签证商品id。
     */
    @TableField(value = "visa_id")
    private Long visaId;

    /**
     * 订单状态 0待审核。
     */
    @TableField(value = "state")
    private Integer state;

    /**
     * 支付状态 0未支付 1已支付。
     */
    @TableField(value = "pay_state")
    private Integer payState;

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

    /**
     * 订单价格。
     */
    @TableField(value = "order_price")
    private String orderPrice;

    /**
     * 负责顾问。
     */
    @TableField(value = "counselor_id")
    private Long counselorId;

    /**
     * 订单地址。
     */
    @TableField(value = "order_address")
    private String orderAddress;

    /**
     * 服务费。
     */
    @TableField(value = "service_price")
    private String servicePrice;

    /**
     * 税费。
     */
    @TableField(value = "price")
    private String price;

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

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

    @RelationDict(
            masterIdField = "visaId",
            slaveModelClass = TourVisa.class,
            slaveIdField = "id",
            slaveNameField = "visaTitle")
    @TableField(exist = false)
    private Map<String, Object> visaIdDictMap;

    @RelationDict(
            masterIdField = "counselorId",
            slaveModelClass = TourVisaCounselor.class,
            slaveIdField = "id",
            slaveNameField = "counselorName")
    @TableField(exist = false)
    private Map<String, Object> counselorIdDictMap;

    @RelationConstDict(
            masterIdField = "state",
            constantDictClass = VisaOrderState.class)
    @TableField(exist = false)
    private Map<String, Object> stateDictMap;

    @RelationConstDict(
            masterIdField = "payState",
            constantDictClass = VisaPayState.class)
    @TableField(exist = false)
    private Map<String, Object> payStateDictMap;
}
