package com.ruoyi.bst.pay.domain;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import org.springframework.format.annotation.DateTimeFormat;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.pay.Payable;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 支付订单对象 bst_pay
 *
 * @author ruoyi
 * @date 2025-03-26
 */
@Data
public class Pay extends BaseEntity implements Payable
{
    private static final long serialVersionUID = 1L;

    private Long id;

    @Excel(name = "支付订单编号")
    @ApiModelProperty("支付订单编号")
    private String no;

    @Excel(name = "业务类型")
    @ApiModelProperty("业务类型")
    private String bstType;

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

    @Excel(name = "支付金额")
    @ApiModelProperty("支付金额")
    private BigDecimal amount;

    @Excel(name = "支付渠道ID")
    @ApiModelProperty("支付渠道ID")
    private Long channelId;

    @Excel(name = "支付状态", readConverterExp = "W=AIT_PAY待支付,P=AYING支付中,P=AYED支付成功,C=ANCEL已取消")
    @ApiModelProperty("支付状态")
    private String status;

    @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 String description;

    @Excel(name = "支付账号")
    @ApiModelProperty("支付账号")
    private String account;

    @Excel(name = "渠道成本")
    @ApiModelProperty("渠道成本")
    private BigDecimal channelCost;

    @Excel(name = "已退款金额", readConverterExp = "元=")
    @ApiModelProperty("已退款金额")
    private BigDecimal refunded;

    @Excel(name = "退款中金额", readConverterExp = "元=")
    @ApiModelProperty("退款中金额")
    private BigDecimal refunding;

    @Excel(name = "付款人IP")
    @ApiModelProperty("付款人IP")
    private String ip;

    @Excel(name = "应用ID")
    @ApiModelProperty("应用ID")
    private Long appId;

    @Excel(name = "渠道支付单号")
    @ApiModelProperty("渠道支付单号")
    private String channelNo;

    @Excel(name = "过期时间")
    @ApiModelProperty("过期时间")
    private LocalDateTime expireTime;

    @ApiModelProperty("应用名称")
    private String appName;

    @ApiModelProperty("渠道名称")
    private String channelName;

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

    @Excel(name = "自动退款金额", readConverterExp = "元=")
    @ApiModelProperty("自动退款金额")
    private BigDecimal autoRefund;

    @Excel(name = "管理员退款金额", readConverterExp = "元=")
    @ApiModelProperty("管理员退款金额")
    private BigDecimal adminRefund;

    /**
     * 获取价格（分）
     */
    @Override
    public BigDecimal payableFen() {
        return amount.multiply(BigDecimal.valueOf(100));
    }

    /**
     * 获取描述
     */
    @Override
    public String payableDescription() {
        return description;
    }

    /**
     * 获取附加信息
     */
    @Override
    public String payableAttach() {
        return "";
    }

    /**
     * 获取外部订单号
     */
    @Override
    public String payableOutTradeNo() {
        return no;
    }

    /**
     * 获取openId
     */
    @Override
    public String payableAccount() {
        return account;
    }

    /**
     * 获取支付者IP
     */
    @Override
    public String payableIp() {
        return ip;
    }
}
