package shop.alien.entity.store.dto;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * alipay.trade.settle.confirm — 统一收单确认结算请求体。
 *
 * @see <a href="https://opendocs.alipay.com/open/028xq9">确认结算</a>
 */
@Data
@ApiModel("支付宝确认结算（trade.settle.confirm）")
public class AlipayTradeSettleConfirmDto implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "确认结算请求流水号（商户侧唯一）", required = true)
    @JsonProperty("out_request_no")
    @JsonAlias("outRequestNo")
    private String outRequestNo;

    @ApiModelProperty(value = "支付宝交易号", required = true)
    @JsonProperty("trade_no")
    @JsonAlias("tradeNo")
    private String tradeNo;

    @ApiModelProperty(value = "结算信息", required = true)
    @JsonProperty("settle_info")
    @JsonAlias("settleInfo")
    private SettleInfo settleInfo;

    @ApiModelProperty("扩展参数（如 royalty_freeze）")
    @JsonProperty("extend_params")
    @JsonAlias("extendParams")
    private ExtendParams extendParams;

    @ApiModelProperty("应用授权令牌 app_auth_token（第三方代调用时选填）")
    @JsonProperty("app_auth_token")
    @JsonAlias("appAuthToken")
    private String appAuthToken;

    @Data
    @ApiModel("结算信息")
    public static class SettleInfo implements Serializable {

        private static final long serialVersionUID = 1L;

        @ApiModelProperty(value = "结算明细列表", required = true)
        @JsonProperty("settle_detail_infos")
        @JsonAlias("settleDetailInfos")
        private List<SettleDetailInfo> settleDetailInfos;
    }

    @Data
    @ApiModel("结算明细")
    public static class SettleDetailInfo implements Serializable {

        private static final long serialVersionUID = 1L;

        @ApiModelProperty("结算金额")
        private String amount;

        @ApiModelProperty("收入方账号")
        @JsonProperty("trans_in")
        @JsonAlias("transIn")
        private String transIn;

        @ApiModelProperty("结算主体类型，如 SecondMerchant")
        @JsonProperty("settle_entity_type")
        @JsonAlias("settleEntityType")
        private String settleEntityType;

        @ApiModelProperty("汇总维度")
        @JsonProperty("summary_dimension")
        @JsonAlias("summaryDimension")
        private String summaryDimension;

        @ApiModelProperty("实际结算金额")
        @JsonProperty("actual_amount")
        @JsonAlias("actualAmount")
        private String actualAmount;

        @ApiModelProperty("结算主体标识")
        @JsonProperty("settle_entity_id")
        @JsonAlias("settleEntityId")
        private String settleEntityId;

        @ApiModelProperty("收入方类型，如 cardAliasNo、defaultSettle")
        @JsonProperty("trans_in_type")
        @JsonAlias("transInType")
        private String transInType;
    }

    @Data
    @ApiModel("确认结算扩展参数")
    public static class ExtendParams implements Serializable {

        private static final long serialVersionUID = 1L;

        @ApiModelProperty("是否冻结分账，如 true / false")
        @JsonProperty("royalty_freeze")
        @JsonAlias("royaltyFreeze")
        private String royaltyFreeze;
    }
}
