package com.yc.ship.module.trade.api.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Schema(description = "RPC 服务 - 退款创建 Request DTO")
@Data
public class TradeRefundCreateReqDTO implements Serializable {


    @Schema(description = "订单ID", example = "")
    @NotNull(message = "订单ID不能为空")
    private Long orderId;

    @Schema(description = "分销退单号", example = "")
    private String otaRefundNo;

    @Schema(description = "退款金额（元）", example = "100")
    @NotNull(message = "退款金额不能为空")
    private BigDecimal refundAmount;

    @Schema(description = "手续费")
    private BigDecimal fee;

    @Schema(description = "退款原始金额")
    private BigDecimal originRefundAmount;

    @Schema(description = "退款项列表，整单退时为空", example = "")
    private List<RefundItem> itemlList;

    @Schema(description = "退款方式0正常退票 1强制退票 2改签退款", example = "")
    @NotNull(message = "退款方式不能为空")
    private Integer refundMethod;

    @Schema(description = "退款归还类型 0原路返回 1线下退款", example = "")
    @NotNull(message = "退款归还类型不能为空")
    private Integer refundBackType;

    @Schema(description = "退款渠道", example = "")
    @NotNull(message = "退款渠道不能为空")
    private Integer refundChannel;

    @Schema(description = "退款用户，平台退款时为分销商ID，旅行社端退款时为售票员、会员ID", example = "")
    @NotNull(message = "退款用户不能为空")
    private Long refundUser;

    @Schema(description = "门店ID", example = "")
    private Long storeId;
    
    @Schema(description = "门店名称", example = "")
    private String storeName;

    @Schema(description = "设备ID", example = "")
    private Long machineId;

    @Schema(description = "设备名称", example = "")
    private String machineName;

    @Schema(description = "退款原因", example = "")
    private String refundReason;

    @Schema(description = "忽略平台退款", example = "")
    private boolean ignorePlatRefund;

    @Schema(description = "退单时有效，退剩下所有可退的", example = "")
    private Boolean isRefundRemaining;

    @Schema(description = "退款项")
    @Data
    @Valid
    public static class RefundItem{

        @Schema(description = "订单ID", example = "")
        private Long orderId;

        @Schema(description = "订单明细ID", example = "")
        @NotNull(message = "订单明细ID不能为空")
        private Long orderDetailId;
        @Schema(description = "券码", example = "")
        private String voucherCode;

        @Schema(description = "退款金额（元）", example = "100")
        @NotNull(message = "退款金额不能为空")
        private BigDecimal refundAmount;
        @Schema(description = "手续费")
        private BigDecimal fee;
        @Schema(description = "退款原始金额")
        private BigDecimal originRefundAmount;

        @Schema(description = "订单明细子项列表,全部退时为空", example = "")
        private List<RefundSubItem> detailList;

    }

    @Schema(description = "退款子项")
    @Data
    @Valid
    public static class RefundSubItem{

        @Schema(description = "产品ID", example = "")
        private Long orderDetailBaseId;
        @Schema(description = "退款金额（元）", example = "100")
        private BigDecimal refundAmount;
        @Schema(description = "手续费")
        private BigDecimal fee;
        @Schema(description = "退款原始金额")
        private BigDecimal originRefundAmount;

    }
}
