package cn.freemud.entities.dto.coupon;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

@Data
@ApiModel
public class PreCheckAndLockReq {
    @ApiModelProperty(value = "商户号", required = true)
    private String partnerId;

    @ApiModelProperty(value = "请求流水号，需保证唯一", required = true)
    private String transId;

    @ApiModelProperty(value = "核销门店信息", required = true)
    private StoreInfo storeInfo;

    @ApiModelProperty(value = "点餐方式, pickup:自提；delivery:外卖；saasmall:微商城", required = true)
    private String redeemScene;

    @ApiModelProperty(value = "核销小程序Id", required = true)
    private String appId;

    @ApiModelProperty(value = "订单总金额（分）", required = true)
    private Integer orderTotalAmount;

    @ApiModelProperty(value = "实付金额：支付时的合计金额（分）", required = true)
    private Integer orderPaymentAmount;

    @ApiModelProperty(value = "券信息列表", required = true)
    private List<CouponInfo> couponInfoList;

    @ApiModelProperty(value = "用户微信openid")
    private String openId;

    /**
     * 交易渠道，支付宝商家券核销必传
     */
    @ApiModelProperty(value = "交易渠道，支付宝商家券核销必传")
    private AlipayCouponRedeemTradeChannelEnum tradeChannel;

    /**
     * 该交易在支付宝系统中的交易流水号。
     * 注意：若用户使用支付宝为交易的渠道，本参数必填。
     */
    @ApiModelProperty(value = "该交易在支付宝系统中的交易流水号。若用户使用支付宝为交易的渠道，本参数必填")
    private String tradeNo;

    @Data
    public static class StoreInfo {
        @ApiModelProperty(value = "核销门店编号", required = true)
        private String storeId;

        @ApiModelProperty(value = "核销门店名称", required = true)
        private String storeName;

        @ApiModelProperty(value = "核销门店所属渠道Id列表")
        private List<String> channelIdList = Lists.newArrayList();
    }

    @Data
    public static class CouponInfo {
        @ApiModelProperty(value = "券号", required = true)
        private String code;

        @ApiModelProperty(value = "券优惠总金额（分）", required = true)
        private Integer discountAmount;

        @ApiModelProperty(value = "券抵扣的商品信息，配送券可不传", required = true)
        private List<ProductInfo> productList = Lists.newArrayList();
    }

    @Data
    public static class ProductInfo {
        @ApiModelProperty(value = "商品编号", required = true)
        private String productId;

        @ApiModelProperty(value = "商品名称", required = true)
        private String productName;

        @ApiModelProperty(value = "商品总原价（分）", required = true)
        private Integer totalPrice;

        @ApiModelProperty(value = "商品数量，最小为1", required = true)
        private Integer qty;

        @ApiModelProperty(value = "券在本商品上的优惠总金额（分）", required = true)
        private Integer couponDiscountTotalAmount;
    }


}