package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.GroupPurchaseRebate;
import com.tourism.common.core.annotation.*;
import com.tourism.common.core.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

/**
 * 拼团返利记录实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_project_group_purchase_rebate")
public class TourProjectGroupPurchaseRebate extends BaseModel {

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

    /**
     * 用户id。
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 拼团的id。
     */
    @TableField(value = "group_purchase_progress_id")
    private Long groupPurchaseProgressId;

    /**
     * 订单id。
     */
    @TableField(value = "order_id")
    private Long orderId;

    /**
     * 返利的金额(+为增加;-为减少)。
     */
    @TableField(value = "price")
    private BigDecimal price;

    /**
     * 返利的金额的单位。
     */
    @TableField(value = "price_unit")
    private String priceUnit;

    /**
     * 返利变化的原因(0.邀请用户;1.邀请的用户取消;2.清空返利)。
     */
    @TableField(value = "reason")
    private Integer reason;

    /**
     * 返利变化的关联用户。
     */
    @TableField(value = "reason_relation_userId")
    private Long reasonRelationUserid;

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

    /**
     * price 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private BigDecimal priceStart;

    /**
     * price 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private BigDecimal priceEnd;

    @RelationOneToOne(
            masterIdField = "userId",
            slaveModelClass = TourUser.class,
            slaveIdField = "userId")
    @TableField(exist = false)
    private TourUser tourUser;

    @RelationOneToOne(
            masterIdField = "reasonRelationUserid",
            slaveModelClass = TourUser.class,
            slaveIdField = "userId")
    @TableField(exist = false)
    private TourUser reasonRelationUser;

    @RelationOneToOne(
            masterIdField = "groupPurchaseProgressId",
            slaveModelClass = TourProjectGroupPurchase.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourProjectGroupPurchase tourProjectGroupPurchase;

    @RelationOneToOne(
            masterIdField = "orderId",
            slaveModelClass = TourOrder.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourOrder tourOrder;

    @RelationConstDict(
            masterIdField = "reason",
            constantDictClass = GroupPurchaseRebate.class)
    @TableField(exist = false)
    private Map<String, Object> reasonDictMap;
}
