package com.jeesharp.business.modules.trade.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 创建统一交易订单（待支付）入参，供应用服务编排；不对外暴露 HTTP 时仍可用于模块间调用。
 *
 * @author jeesharp
 * @since 2026-05-08
 */
@Data
@Schema(description = "统一交易订单创建参数")
public class TradeOrderCreateDTO {

    @NotBlank(message = "会员ID不能为空")
    @Schema(description = "会员ID", requiredMode = Schema.RequiredMode.REQUIRED)
    private String memberId;

    /** @see com.jeesharp.business.modules.trade.enums.TradeBizTypeEnum */
    @NotBlank(message = "业务类型不能为空")
    @Schema(description = "业务类型", requiredMode = Schema.RequiredMode.REQUIRED)
    private String bizType;

    @Schema(description = "列表摘要")
    private String title;

    @NotNull(message = "订单总额不能为空")
    @Schema(description = "订单总额", requiredMode = Schema.RequiredMode.REQUIRED)
    private BigDecimal totalAmount;

    @Schema(description = "优惠总额")
    private BigDecimal discountAmount;

    @NotNull(message = "实付金额不能为空")
    @Schema(description = "实付金额", requiredMode = Schema.RequiredMode.REQUIRED)
    private BigDecimal payAmount;

    @Schema(description = "币种，默认CNY")
    private String currency;

    @Schema(description = "未支付过期时间")
    private LocalDateTime expireTime;

    @Schema(description = "垂直业务单ID")
    private String verticalOrderId;

    @Schema(description = "租户编码")
    private String tenantCode;

    @Schema(description = "租户ID")
    private String tenantId;

    @Schema(description = "扩展JSON")
    private String extJson;

    @Valid
    @Schema(description = "明细行，可为空表示无行级拆单")
    private List<TradeOrderLineCreateDTO> lines = new ArrayList<>();
}
