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 topic）
 *
 * @author Claude Code
 * @date 2025-01-11
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderMessage {

    /**
     * 订单ID
     */
    @JsonProperty("order_id")
    private String orderId;

    /**
     * 景区ID
     */
    @JsonProperty("scenic_id")
    private Long scenicId;

    /**
     * 总金额（单位：元）
     */
    @JsonProperty("total_amount")
    private Double totalAmount;

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

    /**
     * 支付订单ID
     */
    @JsonProperty("payment_order_id")
    private String paymentOrderId;

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

    /**
     * 快速创建订单消息
     */
    public static OrderMessage of(String orderId, Long scenicId, Double totalAmount, String paymentSystem, String paymentOrderId) {
        return OrderMessage.builder()
                .orderId(orderId)
                .scenicId(scenicId)
                .totalAmount(totalAmount)
                .paymentSystem(paymentSystem)
                .paymentOrderId(paymentOrderId)
                .timestamp(System.currentTimeMillis() / 1000)
                .build();
    }
}
