package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tourism.common.core.annotation.*;
import com.tourism.common.core.base.model.BaseModel;
import com.tourism.common.core.upload.UploadStoreTypeEnum;
import com.tourism.common.core.util.MyCommonUtil;
import com.tourism.webadmin.back.model.constant.TourCarOrderState;
import com.tourism.webadmin.back.model.constant.TourCarType;
import com.tourism.webadmin.upms.model.SysUser;
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_car_order")
public class TourCarOrder extends BaseModel {

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

    /**
     * 订单号。
     */
    @TableField(value = "order_no")
    private String orderNo;

    /**
     * 包车车型id。
     */
    @TableField(value = "category_id")
    private Long categoryId;

    /**
     * 司机id。
     */
    @UserFilterColumn
    @TableField(value = "driver_id")
    private Long driverId;

    /**
     * 开始时间。
     */
    @TableField(value = "start_time")
    private String startTime;

    /**
     * 结束时间。
     */
    @TableField(value = "end_time")
    private String endTime;

    /**
     * 包车天数。
     */
    @TableField(value = "days")
    private Integer days;

    /**
     * 起点。
     */
    @TableField(value = "start_place_id")
    private Long startPlaceId;

    /**
     * 联系电话。
     */
    @TableField(value = "connect_phone")
    private String connectPhone;

    /**
     * 联系姓名。
     */
    @TableField(value = "connect_name")
    private String connectName;

    /**
     * 联系人性别。
     */
    @TableField(value = "connect_sex")
    private Integer connectSex;

    /**
     * 备注。
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 订单状态(1.已下单;2.已取消;3. 已完成)。
     */
    @TableField(value = "state")
    private Integer state;

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

    /**
     * 车型评分。
     */
    @TableField(value = "category_mark")
    private Integer categoryMark;

    /**
     * 司机评分。
     */
    @TableField(value = "drive_mark")
    private Integer driveMark;

    /**
     * 乘车人微信。
     */
    @TableField(value = "connect_wechat")
    private String connectWechat;

    /**
     * 司机名称。
     */
    @TableField(value = "driver_name")
    private String driverName;

    /**
     * 司机性别。
     */
    @TableField(value = "driver_sex")
    private Integer driverSex;

    /**
     * 司机年龄。
     */
    @TableField(value = "driver_age")
    private Integer driverAge;

    /**
     * 司机驾龄。
     */
    @TableField(value = "driving_years")
    private Integer drivingYears;

    /**
     * 司机联系方式。
     */
    @TableField(value = "driver_mobile")
    private String driverMobile;

    /**
     * 司机照片。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "driver_image")
    private String driverImage;

    /**
     * 车型种类。
     */
    @TableField(value = "car_model")
    private Long carModel;

    /**
     * 车型车名。
     */
    @TableField(value = "car_name")
    private String carName;

    /**
     * 车型座位数。
     */
    @TableField(value = "car_seat_number")
    private Integer carSeatNumber;

    /**
     * 车型行李数。
     */
    @TableField(value = "car_luggage_number")
    private Integer carLuggageNumber;

    /**
     * 车型照片。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "car_image")
    private String carImage;

    /**
     * 包车每天的价格。
     */
    @TableField(value = "day_price")
    private BigDecimal dayPrice;

    /**
     * 包车每天的单位。
     */
    @TableField(value = "day_price_unit")
    private String dayPriceUnit;

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

    /**
     * 订单总价格的单位。
     */
    @TableField(value = "total_price_unit")
    private String totalPriceUnit;

    /**
     * 车型归属(1.平台自营;2.三方个人)。
     */
    @TableField(value = "category_type")
    private Integer categoryType;

    @TableField(value = "marking")
    private Integer marking;

    /**
     * 车主用户id。
     */
    @UserFilterColumn
    @TableField(value = "driver_sys_id")
    private Long driverSysId;

    /**
     * 车主部门id。
     */
    @DeptFilterColumn
    @TableField(value = "driver_dept_id")
    private Long driverDeptId;

    /**
     * startTime 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private String startTimeStart;

    /**
     * startTime 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private String startTimeEnd;

    /**
     * endTime 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private String endTimeStart;

    /**
     * endTime 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private String endTimeEnd;

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

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

    @RelationOneToOne(
            masterIdField = "categoryId",
            slaveModelClass = TourCarCategory.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourCarCategory tourCarCategory;

    @RelationOneToOne(
            masterIdField = "driverId",
            slaveModelClass = TourCarDriver.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourCarDriver tourCarDriver;

    @RelationDict(
            masterIdField = "categoryId",
            slaveModelClass = TourCarModel.class,
            slaveIdField = "id",
            slaveNameField = "typeName")
    @TableField(exist = false)
    private Map<String, Object> categoryIdDictMap;

    @RelationDict(
            masterIdField = "startPlaceId",
            slaveModelClass = TourCarContractMenu.class,
            slaveIdField = "id",
            slaveNameField = "menuName")
    @TableField(exist = false)
    private Map<String, Object> startPlaceIdDictMap;

    @RelationDict(
            masterIdField = "carModel",
            slaveModelClass = TourCarModel.class,
            slaveIdField = "id",
            slaveNameField = "typeName")
    @TableField(exist = false)
    private Map<String, Object> carModelDictMap;

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

    @RelationConstDict(
            masterIdField = "categoryType",
            constantDictClass = TourCarType.class)
    @TableField(exist = false)
    private Map<String, Object> categoryTypeDictMap;

    @RelationGlobalDict(
            masterIdField = "connectSex",
            dictCode = "UserSex")
    @TableField(exist = false)
    private Map<String, Object> connectSexDictMap;

    @RelationGlobalDict(
            masterIdField = "driverSex",
            dictCode = "UserSex")
    @TableField(exist = false)
    private Map<String, Object> driverSexDictMap;

    @RelationOneToOne(
            masterIdField = "driverSysId",
            slaveModelClass = SysUser.class,
            slaveIdField = "userId")
    @TableField(exist = false)
    private SysUser sysUser;

}
