package com.jeequan.jeepay.core.model.openapi.biz;

import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.PayOrder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * TODO
 *
 * @author crystal
 * @date 2024/4/10 10:47
 */
@Data
@NoArgsConstructor
public class PayResultResp {

    protected String payOrderId;

    private String state;

    private String mchOrderNo;

    protected String ifCode;

    protected String mercNo;

    private Long amount;

    private String payType;

    protected String channelTradeNo;

    protected String channelSendNo;

//    private String wayCode;

    private String userId;

    protected String extParam;

    protected String note;

    private Long tradeFee;

    private String drType;

    private String storeId;

    private Date payTime;

    private String subject;

    private Long cashFee;

    private Long refundAmt;

    private Byte refundState;

    private String msgType;

    private String currency;

    private String settlementType;

    public PayResultResp(PayOrder order) {
        this.payOrderId = order.getPayOrderId();
        this.state = CS.OpenOrderState.getVal(order.getState()).getCode();
        this.note = CS.OpenOrderState.getVal(order.getState()).getDesc();
        this.mchOrderNo = order.getMchOrderNo();
        this.ifCode = order.getIfCode();
        this.mercNo = order.getMchExtNo();
        this.amount = order.getFindAmt();
        this.payType = order.getWayCodeType();
        this.channelTradeNo = order.getPlatformOrderNo();
        this.channelSendNo = order.getPlatformMchOrderNo();
        this.userId = order.getChannelUser();
        this.extParam = order.getExtParam();
        this.drType = order.getDrType();
        this.payTime = order.getSuccessTime();
        this.subject = order.getSubject();
        this.tradeFee = order.getMchFeeAmount();
        this.cashFee = order.getCashFee();
        this.storeId = order.getStoreId();
        this.refundAmt = order.getRefundAmount();
        this.refundState = order.getRefundState();
        this.currency = order.getCurrency();
        this.settlementType = order.getSettleType();
    }

    public PayResultResp(Long amount, String mchOrderNo, String payOrderId, String state, String mchExtNo) {
        this.amount = amount;
        this.mchOrderNo = mchOrderNo;
        this.payOrderId = payOrderId;
        this.state = state;
        this.mercNo = mchExtNo;
    }
}
