package com.mcwl.pay.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

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

/**
 * @Author：ChenYan
 * @Project：McWl
 * @Package：com.mcwl.pay.domain
 * @Filename：PaymentResult
 * @Description TODO
 * @Date：2025/1/3 17:30
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class PaymentResult {
    private boolean success;
    private String message;
    private String transactionId;
    private String errorCode;
    private BigDecimal amount;
    private String currency;
    private String paymentMethod;
    private LocalDateTime timestamp;
    private Map<String, Object> extraData;


    public static class Builder {
        private final PaymentResult result = new PaymentResult();

        public Builder setSuccess(boolean success) {
            result.success = success;
            return this;
        }

        public Builder setMessage(String message) {
            result.message = message;
            return this;
        }

        public Builder setTransactionId(String transactionId) {
            result.transactionId = transactionId;
            return this;
        }

        public Builder setErrorCode(String errorCode) {
            result.errorCode = errorCode;
            return this;
        }

        public Builder setAmount(BigDecimal amount) {
            result.amount = amount;
            return this;
        }

        public Builder setCurrency(String currency) {
            result.currency = currency;
            return this;
        }

        public Builder setPaymentMethod(String paymentMethod) {
            result.paymentMethod = paymentMethod;
            return this;
        }

        public Builder setTimestamp(LocalDateTime timestamp) {
            result.timestamp = timestamp;
            return this;
        }

        public Builder setExtraData(Map<String, Object> extraData) {
            result.extraData = extraData;
            return this;
        }

        public PaymentResult build() {
            return result;
        }
    }

    @Override
    public String toString() {
        return "PaymentResult{" +
                "success=" + success +
                ", message='" + message + '\'' +
                ", transactionId='" + transactionId + '\'' +
                ", errorCode='" + errorCode + '\'' +
                ", amount=" + amount +
                ", currency='" + currency + '\'' +
                ", paymentMethod='" + paymentMethod + '\'' +
                ", timestamp=" + timestamp +
                ", extraData=" + extraData +
                '}';
    }
}
