package com.sonic.lion.domain.output;

import com.sonic.lion.domain.enums.CallChannelStatus;
import com.sonic.lion.domain.enums.TradeEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @author: code
 * @date: 2025/05/14
 * @Description:
 * @version: 1.0.0
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ChannelCheckOutput {

    private String batchId;

    private String transactionId;

    private TradeEvent channelEvent;

    private CallChannelStatus status;

    private String result;

    private String errorMessage;

    private String statusCode;

    private Map<String, Object> extendInfo;

    /**
     * 支付的payerId 是否 在黑名单里面
     */
    private boolean inBlackList;

    public CallChannelStatus getStatus() {
        //如果被标记为 已经成功了  需要判断 是否有 transactionId 必须同时存在才是真正成功
        if (StringUtils.isEmpty(transactionId) && CallChannelStatus.SUCC.equals(status)) {
            return CallChannelStatus.PROCESSING;
        }
        return status;
    }
}
