package com.ycwl.basic.integration.profitshare.dto.message;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 退款消息（发送到 zt-profitshare-refund topic）
 *
 * @author Claude Code
 * @date 2025-01-11
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RefundMessage {

    /**
     * 退款订单ID
     */
    @JsonProperty("refund_order_id")
    private String refundOrderId;

    /**
     * 原订单ID
     */
    @JsonProperty("original_order_id")
    private String originalOrderId;

    /**
     * 退款金额（单位：元）
     */
    @JsonProperty("refund_amount")
    private Double refundAmount;

    /**
     * 退款类型（full: 全额退款, partial: 部分退款）
     */
    @JsonProperty("refund_type")
    private String refundType;

    /**
     * 支付系统（alipay, wechat, union）
     */
    @JsonProperty("payment_system")
    private String paymentSystem;

    /**
     * Unix 时间戳（秒）
     */
    @JsonProperty("timestamp")
    private Long timestamp;

    /**
     * 快速创建退款消息
     */
    public static RefundMessage of(String refundOrderId, String originalOrderId, Double refundAmount, String refundType, String paymentSystem) {
        return RefundMessage.builder()
                .refundOrderId(refundOrderId)
                .originalOrderId(originalOrderId)
                .refundAmount(refundAmount)
                .refundType(refundType)
                .paymentSystem(paymentSystem)
                .timestamp(System.currentTimeMillis() / 1000)
                .build();
    }
}
