package com.ruoyi.frequency.orderoperatorhistory.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.vo.UserInfo;
import com.ruoyi.vo.UserVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * 订单操作记录对象 t_order_operator_history
 *
 * @author liwenlong
 * @date 2024-06-12
 */
@Data
@Accessors(chain = true)
@TableName("t_order_operator_history")
public class OrderOperatorHistory extends BaseEntity {
    private static final long serialVersionUID = 1L;


    @ApiModelProperty("租户号")
    private Long id;

    @ApiModelProperty("删除标志;1 正常 2 删除 3 禁用")
    private Integer delFlag;

    @ApiModelProperty("订单id")
    @Excel(name = "订单id")
    private Long orderId;

    @ApiModelProperty("操作类型")
    @Excel(name = "操作类型")
    private String type;

    @ApiModelProperty("操作内容")
    @Excel(name = "操作内容")
    private String content;

    @ApiModelProperty("用户id")
    @Excel(name = "用户id")
    private Long userId;

    @ApiModelProperty("用户类型")
    @Excel(name = "用户类型")
    private Integer userType;

    @ApiModelProperty("操作端口 1 app 2 管理后台")
    private Integer ports;

    @ApiModelProperty("用户信息")
    @TableField(exist = false)
    private UserInfo userInfo;

    @ApiModelProperty("操作人")
    @TableField(exist = false)
    private String operatorUser;

    @ApiModelProperty("开始时间")
    @TableField(exist = false)
    private Date beginTime;

    @ApiModelProperty("结束时间")
    @TableField(exist = false)
    private Date endTime;

    public static OrderOperatorHistory addAppHistory(Long orderId,String type, String content, UserVo userVo) {
        OrderOperatorHistory orderOperatorHistory = new OrderOperatorHistory();
        orderOperatorHistory.setPorts(1);
        orderOperatorHistory.setType(type);
        orderOperatorHistory.setContent(content);
        orderOperatorHistory.setUserId(userVo.getUserId());
        orderOperatorHistory.setUserType(userVo.getUserType());
        orderOperatorHistory.setOrderId(orderId);
        return orderOperatorHistory;
    }

    public static OrderOperatorHistory addBackHistory(Long orderId,String type, String content) {
        OrderOperatorHistory orderOperatorHistory = new OrderOperatorHistory();
        orderOperatorHistory.setPorts(2);
        orderOperatorHistory.setType(type);
        orderOperatorHistory.setContent(content);
        orderOperatorHistory.setOrderId(orderId);
        return orderOperatorHistory;
    }
}
