package com.ruoyi.ss.refund.domain;

import com.ruoyi.common.pay.Refundable;
import com.wechat.pay.java.service.refund.model.AmountReq;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author wjh
 * 2024/7/9
 */
@Data
public class RefundVO extends Refund implements Refundable {

    @ApiModelProperty("原订单编号")
    private String payNo;

    @ApiModelProperty("原订单交易总额")
    private BigDecimal payAmount;


    @Override
    public String refundOutTradeNo() {
        return getPayNo();
    }

    @Override
    public String refundOutRefundNo() {
        return this.getRefundNo();
    }

    @Override
    public String refundReason() {
        return this.getReason();
    }

    @Override
    public AmountReq refundAmount() {
        BigDecimal decimal100 = new BigDecimal(100);
        AmountReq amount = new AmountReq();
        amount.setRefund(this.getAmount().multiply(decimal100).longValue());
        amount.setTotal(getPayAmount().multiply(decimal100).longValue());
        amount.setCurrency("CNY");
        return amount;
    }
}
