package com.ruoyi.bst.bonus.domain;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 分成对象 bst_bonus
 *
 * @author ruoyi
 * @date 2025-03-26
 */
@Data
public class Bonus extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    private Long id;

    @Excel(name = "业务ID")
    @ApiModelProperty("业务ID")
    private Long bstId;

    @Excel(name = "业务类型", readConverterExp = "1=订单")
    @ApiModelProperty("业务类型")
    private String bstType;

    @Excel(name = "状态")
    @ApiModelProperty("状态")
    private String status;

    @Excel(name = "分成方ID")
    @ApiModelProperty("分成方ID")
    private Long arrivalId;

    @Excel(name = "分成方名称")
    @ApiModelProperty("分成方名称")
    private String arrivalName;

    @Excel(name = "收款方类型")
    @ApiModelProperty("收款方类型")
    private String arrivalType;

    @Excel(name = "分成比例")
    @ApiModelProperty("分成比例")
    private BigDecimal point;

    @Excel(name = "分成总金额")
    @ApiModelProperty("分成总金额")
    private BigDecimal amount;

    @Excel(name = "未出账金额")
    @ApiModelProperty("未出账金额")
    private BigDecimal invalidAmount;

    @Excel(name = "待分成金额")
    @ApiModelProperty("待分成金额")
    private BigDecimal waitAmount;

    @Excel(name = "已分成金额")
    @ApiModelProperty("已分成金额")
    private BigDecimal payedAmount;

    @Excel(name = "已退款金额")
    @ApiModelProperty("已退款金额")
    private BigDecimal refundAmount;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "预计分成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("预计分成时间")
    private LocalDateTime prePayTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "实际分成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("实际分成时间")
    private LocalDateTime payTime;

    @Excel(name = "是否修改余额")
    @ApiModelProperty("是否修改余额")
    private Boolean toBalance;

    @Excel(name = "原因")
    @ApiModelProperty("原因")
    private String reason;

    @Excel(name = "运营区ID")
    @ApiModelProperty("运营区ID")
    private Long areaId;

    @Excel(name = "其他可见用户ID列表")
    @ApiModelProperty("其他可见用户ID列表")
    private List<Long> viewUserIds;


    public void addViewUserId(Long userId) {
        if (userId == null) {
            return;
        }
        if (this.viewUserIds == null) {
            this.viewUserIds = new ArrayList<>();
        }
        if (viewUserIds.contains(userId)) {
            return;
        }
        viewUserIds.add(userId);

    }
}
