package com.yami.shop.bean.param;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author wy
 */
@Data
public class OrderDto {

    @ApiModelProperty(value = "商城系统订单号 (退单仍取原订单号),不能重复", required = true)
    private String channelSheetno;

    @ApiModelProperty(value = "渠道简称，如：美团外卖（MTWM）；京东到家（JDDJ）；饿百零售（EBLS）", required = true)
    private String channelKeyword;

    @ApiModelProperty(value = "值为true表示已经付款；值为false表示货到付款", required = true)
    private Boolean payOver;

    @ApiModelProperty(value = "单据类型 1: 订单；2:退单；7:礼金卡订单", required = true)
    private String billtype;

    @ApiModelProperty("退单单号，退单必传，传值必须与5.7接口apply_sheetno一样")
    private String returnOrderSn;

    @ApiModelProperty(value = "收入金额（订单总额）", required = true)
    private BigDecimal totalSaleValue;

    @ApiModelProperty(value = "订单总优惠额 = (商家订单总优惠+平台订单总优惠)", required = true)
    private BigDecimal totalDiscValue;

    @ApiModelProperty(value = "商家订单总优惠", required = true)
    private BigDecimal totalSjDisc;

    @ApiModelProperty(value = "平台订单总优惠", required = true)
    private BigDecimal totalPtDisc;

    @ApiModelProperty(value = "商家单品总优惠", required = true)
    private BigDecimal totalSjDp;

    @ApiModelProperty(value = "平台单品总优惠", required = true)
    private BigDecimal totalPtDp;

    @ApiModelProperty(value = "订单收取佣金", required = true)
    private BigDecimal commissionValue;

    @ApiModelProperty(value = "付款金额", required = true)
    private BigDecimal payableValue;

    @ApiModelProperty(value = "商品售价总金额", required = true)
    private BigDecimal totalItemValue;

    @ApiModelProperty(value = "配送费,必须是大于0的数字", required = true)
    private BigDecimal payableLogisticsValue;

    @ApiModelProperty("订单配送方式 可选值：0 配送，1 自提，2 商家自送； billtype=1时该字段必填，bill_type 为 2 7 时不做必填校验")
    private String logisticsModeKeyword;

    @ApiModelProperty("订单自提码")
    private String selfPickCode;

    @ApiModelProperty("提货点编码")
    private String pickupOrgCode;

    @ApiModelProperty("是否预约单")
    private Boolean preOrder;

    @ApiModelProperty("是否线下订单")
    private Boolean offlineOrder;

    @ApiModelProperty("预计送达开始时间")
    private String startDeliveryTime;

    @ApiModelProperty("预计送达结束时间")
    private String endDeliveryTime;

    @ApiModelProperty("包装费,必须是大于等于0的数字")
    private BigDecimal packageFee;

    @ApiModelProperty("订单状态 默认订单为1 已接收状态")
    private String status;

    @ApiModelProperty("订单序号")
    private Integer orderSeq;

    @ApiModelProperty(value = "订单总重量 必须是正整数,单位 克 g", required = true)
    private Integer weight;

    @ApiModelProperty("餐盒费")
    private BigDecimal lunchboxFee;

    @ApiModelProperty(value = "门店编码", required = true)
    private String orgCode;

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

    @ApiModelProperty(value = "下单时间 yyyy-MM-dd HH:mm:ss", required = true)
    private String orderTime;

    @ApiModelProperty(value = "订单类型 0 普通订单 1 拼团订单(废弃) 2 团长代收(废弃) 3 团购订单", required = true)
    private Integer groupId;

    @ApiModelProperty("备注")
    private String note;

    @ApiModelProperty("扩展信息")
    private String extend;

    @ApiModelProperty("退单-是否需要退货 true 退货 ,fasle 不退货")
    private String goodsReturn;

    @ApiModelProperty("收件人信息")
    private Receiver receiver;

    @ApiModelProperty("买家信息")
    private Buyer buyer;

    @ApiModelProperty("发票信息")
    private Invoice invoice;

    @ApiModelProperty("订单商品列表")
    private List<OrderDetails> orderDetails;

    @ApiModelProperty("支付信息")
    private OrderPayments orderPayments;

    @ApiModelProperty("优惠明细")
    private DiscDetails discDetails;


    @Data
    public static class Receiver {

        @ApiModelProperty(value = "收件人姓名", required = true)
        private String name;

        @ApiModelProperty("收件人性别 1：男 2：女")
        private String gender;

        @ApiModelProperty(value = "收件人手机", required = true)
        private String mobile;

        @ApiModelProperty(value = "收件人地址", required = true)
        private String address;

        @ApiModelProperty(value = "经度", required = true)
        private String longitude;

        @ApiModelProperty(value = "纬度", required = true)
        private String latitude;

        @ApiModelProperty("坐标类型，0：火星坐标（高德） 1：百度坐标 （默认值为0）")
        private String type;
    }

    @Data
    public static class Buyer {

        @ApiModelProperty("买家电话，不传时取收货人手机号填充")
        private String tel;

        @ApiModelProperty("买家备注")
        private String note;

        @ApiModelProperty("买家邮箱")
        private String email;

        @ApiModelProperty("买家账号")
        private String account;

        @ApiModelProperty("会员卡号")
        private String cardCode;

        @ApiModelProperty("买家昵称")
        private String nick;

        @ApiModelProperty("买家地址")
        private String address;
    }

    @Data
    public static class Invoice {

        @ApiModelProperty("发票类型 0：个人、1：企业")
        private String type;

        @ApiModelProperty("发票抬头")
        private String title;

        @ApiModelProperty("发票税号")
        private String dutyNo;

        @ApiModelProperty("发票内容")
        private String content;

        @ApiModelProperty("发票金额")
        private BigDecimal money;
    }

    @Data
    public static class OrderDetails {

        @ApiModelProperty(value = "商品ERP编码（POS渠道接入设置值为空）", required = true)
        private String itemCode;

        @ApiModelProperty("商品SKU编码（POS渠道接入必填，其他渠道值为空）")
        private String skuId;

        @ApiModelProperty(value = "商品条码（POS渠道接入设置值为空", required = true)
        private String barcode;

        @ApiModelProperty(value = "订单行ID 新接入商家必填，用于区分相同商品不同活动等情况，同一订单或退单内的order_item_id不能相同", required = true)
        private String orderItemId;

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

        @ApiModelProperty("商品属性，如加冰、少冰等")
        private List<String> properties;

        @ApiModelProperty(value = "商品原价", required = true)
        private BigDecimal originalPrice;

        @ApiModelProperty(value = "单个商品重量 克", required = true)
        private Integer weight;

        @ApiModelProperty(value = "商品售价", required = true)
        private BigDecimal salePrice;

        @ApiModelProperty("商家订单优惠⾦额")
        private BigDecimal discValue;

        @ApiModelProperty("平台订单优惠⾦额")
        private BigDecimal discValuePt;

        @ApiModelProperty("商家单品补贴")
        private BigDecimal discBtSj;

        @ApiModelProperty("平台单品补贴")
        private BigDecimal discBt;

        @ApiModelProperty("佣金")
        private BigDecimal commissionValue;

        @ApiModelProperty(value = "数量", required = true)
        private Integer qty;

        @ApiModelProperty(value = "商品售价金额= 商品售价（sale_price)* 数量（qty）", required = true)
        private BigDecimal money;

        @ApiModelProperty("ERP核销数量")
        private BigDecimal posQty;

        @ApiModelProperty("是否称重品商品 默认false")
        private Boolean electronicGoods;

        @ApiModelProperty("系数 = 线上一份多少克/线下按照什么单位")
        private BigDecimal coefficient;

        @ApiModelProperty("活动id （只支持单活动 ）")
        private String activityId;

        @ApiModelProperty("应商分摊比例 默认0")
        private BigDecimal supplierRate;

        @ApiModelProperty("核销价格")
        private BigDecimal posPrice;

    }

    @Data
    public static class OrderPayments {

        @ApiModelProperty(value = "支付方式编码 （10001：支付宝；10002：微信；10003：银联；10004：钱包；10008：储值卡；10009：积分；10010：劵；99999：其他）", required = true)
        private String keyword;

        @ApiModelProperty(value = "支付方式名称 默认：商城系统支付", required = true)
        private String name;

        @ApiModelProperty(value = "支付金额", required = true)
        private BigDecimal payment;

        @ApiModelProperty("{“key”: “value”}，扩展map，用来传输支付方式扩展 示例：1、积分 {“point”: “1000”}")
        private JSONObject attributes;
    }

    @Data
    public static class DiscDetails {

        @ApiModelProperty(value = "商品编码", required = true)
        private String itemCode;

        @ApiModelProperty(value = "商品条码", required = true)
        private String barcode;

        @ApiModelProperty(value = "参与活动商品数量", required = true)
        private Double itemNum;

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

        @ApiModelProperty(value = "优惠类型", required = true)
        /**
         * op-10001	单品直降	例如：某商品原价 10元 促销价 8元
         * op-10002	秒杀	例如：某商品原价 10元 促销价 2元
         * op-10003	满减	例如：满60减20元
         * op-10004	优惠券	例如：满49减5元券
         * op-10005	买赠	例如：买a送b或 买A送A
         * op-10006	满赠	例如：满100元赠送某商品
         * op-10007	减运费	例如：满59减4元运费
         * op-10008	新客立减	例如：新客首单立减8元
         * op-10009	其他	例如：其他的未对应上的优惠
         */
        private String discType;

        @ApiModelProperty(value = "活动id", required = true)
        private String activityId;

        @ApiModelProperty(value = "活动名称", required = true)
        private String activityName;

        @ApiModelProperty(value = "商家承担补贴", required = true)
        private BigDecimal sjDisc;

        @ApiModelProperty(value = "平台承担补贴", required = true)
        private BigDecimal ptDisc;

        @ApiModelProperty(value = "原价", required = true)
        private BigDecimal originalPrice;

        @ApiModelProperty(value = "售价", required = true)
        private BigDecimal salePrice;
    }
}
