package com.fzm.mall.server.admin.pay.dto;

import com.fzm.mall.server.admin.pay.WeiXinProties;
import com.fzm.mall.server.admin.util.UUIDUtil;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author wulixian
 * @since 2021/10/18
 */
@Data
public class WxPayRefundDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    private static final BigDecimal CONVERSION = new BigDecimal(100);

    private String transaction_id;

    private String out_refund_no;

    private String notify_url;

    private WxAmountDTO amount;

    public void init(BigDecimal paidAmount, String outBizNo) {
        int total = paidAmount.multiply(CONVERSION).intValue();
        WxAmountDTO dto = new WxAmountDTO();
        dto.setRefund(total);
        dto.setCurrency("CNY");
        dto.setTotal(total);

        setAmount(dto);
        setTransaction_id(outBizNo);
        setOut_refund_no(UUIDUtil.getUUID());
        setNotify_url(WeiXinProties.getREFUND_NOTIFY_URL());
    }
}
