
package com.tmerclub.cloud.common.mongodb.bo.order;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;

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

/**
 * @author YXF
 * @date 2022/8/23
 */
@CompoundIndexes({
        @CompoundIndex(name = "user_idx", def = "{'userId':1}"),
        @CompoundIndex(name = "shop_idx", def = "{'shopId':1}"),
        @CompoundIndex(name = "supplier_idx", def = "{'supplierId':1}"),
        @CompoundIndex(name = "station_idx", def = "{'stationId':1}")
})
@Document("order")
@Data
@ToString
public class MongoOrderBO implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    @Id
    @Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long orderId;
    @Schema(description = "订单项", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<MongoOrderItemBO> orderItems;

    @Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long userId;

    @Schema(description = "支付系统类型 0默认 1通联支付", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer paySysType;

    @Schema(description = "总价", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long actualTotal;

    @Schema(description = "使用积分", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long orderScore;

    @Schema(description = "订单状态", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer status;

    @Schema(description = "订单类型(0普通订单 1团购订单 2秒杀订单)", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer orderType;

    @Schema(description = "订单退款状态（1:申请退款 2:退款成功 3:部分退款成功 4:退款失败）", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer refundStatus;

    @Schema(description = "配送类型 1:快递 2:自提 3：无需快递", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer deliveryType;

    @Schema(description = "店铺名称", requiredMode = Schema.RequiredMode.REQUIRED)
    private String shopName;

    @Schema(description = "店铺id", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long shopId;

    @Schema(description = "订单运费", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long freightAmount;

    @Schema(description = "订单创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private Date createTime;

    @Schema(description = "商品总数", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer allCount;

    @Schema(description = "订单发票id")
    private Long orderInvoiceId;

    @Schema(description = "用户备注信息")
    private String remarks;

    @Schema(description = "收货人姓名")
    private String consignee;

    @Schema(description = "收货人手机号")
    private String mobile;

    /**
     * 供应商id
     */
    private Long supplierId;
    /**
     * 是否待采购 1.是 0.否
     */
    private Integer waitPurchase;

    /**
     * 平台运费减免金额
     */
    private Long platformFreeFreightAmount;

    /**
     * 分销金额
     */
    private Long distributionAmount;

    /**
     * 平台佣金
     */
    private Long platformCommission;

    /**
     * 用户订单地址Id
     */
    private Long orderAddrId;

    /**
     * 总值
     */
    private Long total;


    /**
     * 卖家备注
     */
    private String shopRemarks;

    /**
     * 支付方式 请参考枚举PayType
     */
    private Integer payType;

    /**
     * 订单关闭原因 1-超时未支付 2-退款关闭 4-买家取消 15-已通过货到付款交易
     */
    private Integer closeType;

    /**
     * 发货时间
     */
    private Date updateTime;

    /**
     * 付款时间
     */
    private Date payTime;

    /**
     * 发货时间
     */
    private Date deliveryTime;

    /**
     * 完成时间
     */
    private Date finallyTime;

    /**
     * 取消时间
     */
    private Date cancelTime;

    /**
     * 预售发货时间
     */
    private Date bookTime;

    /**
     * 是否已支付，1.已支付0.未支付
     */
    private Integer isPayed;

    /**
     * 用户订单删除状态，0：没有删除， 1：回收站， 2：永久删除
     */
    private Integer deleteStatus;

    /**
     * 积分抵扣金额
     */
    private Long scoreAmount;

    /**
     * 会员折扣金额
     */
    private Long memberAmount;

    /**
     * 平台优惠券优惠金额
     */
    private Long platformCouponAmount;

    /**
     * 商家优惠券优惠金额
     */
    private Long shopCouponAmount;

    /**
     * 满减优惠金额
     */
    private Long discountAmount;

    /**
     * 平台优惠金额
     */
    private Long platformAmount;

    /**
     * 优惠总额
     */
    private Long reduceAmount;

    /**
     * 店铺改价优惠金额
     */
    private Long shopChangeFreeAmount;

    /**
     * 商家运费减免金额
     */
    private Long freeFreightAmount;

    /**
     * 供应商商品发货方式 1.供应商发货 2.仓库发货
     */
    private Integer supplierDeliveryType;
    /**
     * 商家采购价差（需要商家从结算金额补上采购价的金额）
     */
    private Long purchaseSpreadAmount;
    /**
     * 商品编码
     */
    private String spuCodes;
    /**
     * sku编码
     */
    private String partyCodes;
    /**
     * 是否已经进行结算
     */
    private Integer isSettled;

    /**
     * 省ID
     */
    private Long provinceId;

    /**
     * 省
     */
    private String province;

    /**
     * 城市ID
     */
    private Long cityId;

    /**
     * 城市
     */
    private String city;

    /**
     * 区域ID
     */
    private Long areaId;

    /**
     * 区
     */
    private String area;

    /**
     * 地址
     */
    private String addr;

    /**
     * 邮编
     */
    private String postCode;

    /**
     * 用户类型 0:普通会员 1:付费会员
     * 用于会员统计时，判断订单是属于普通会员还是付费会员
     */
    private Integer userType;

    /**
     * 新成交订单 1:新成交订单 0：旧用户再次消费订单
     * 用于会员统计时，判断用户是否为新成交用户
     */
    private Integer firstOrder;

    /**
     * 新成交供应商订单 1:新成交供应商订单 0：旧用户再次消费订单
     * 用于供应商新用户统计时，判断用户是否为该供应商的新用户
     */
    private Integer firstSupplierOrder;

    /**
     * 预售类型 -1.未开启预售 0.全款预售类型 1.定金预售
     */
    private Integer preSaleType;
    /**
     * 是否为虚拟商品订单 1.是 0.否
     */
    private Integer orderMold;

    /**
     * 定金金额
     */
    private Long depositAmount;
    /**
     * 尾款金额
     */
    private Long balanceAmount;
    /**
     * 预售发货类型 -1.固定时间  x.尾款支付后x天发货
     */
    private Integer preSaleDeliveryType;
    /**
     * 预售发货时间
     */
    private Date preSaleDeliveryTime;
    /**
     * 尾款支付开始时间
     */
    private Date balanceStartTime;
    /**
     * 尾款支付结束时间
     */
    private Date balanceEndTime;

    /**
     * 自提点id
     */
    private Long stationId;

    /**
     * 支付单号，可能有多条所以用字符
     */
    private String payId;

    /**
     * 自提点提货码
     */
    private String stationCode;

    /**
     * 核销次数 -1.多次核销 0.无需核销 1.单次核销
     */
    private Integer writeOffNum;

    /**
     * 多次核销次数 -1.无限次
     */
    private Integer writeOffMultipleCount;

    /**
     * 核销开始时间
     */
    private Date writeOffStart;

    /**
     * 核销结束时间
     */
    private Date writeOffEnd;

    /**
     * 订单核销状态 0.待核销 1.核销完成
     */
    private Integer writeOffStatus;

    /**
     * 订单被核销次数
     */
    private Integer writeOffCount;

    /**
     * 套餐优惠金额
     */
    private Long shopComboAmount;

    @Schema(description = "核销订单", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<MongoOrderVirtualInfoBO> orderVirtualInfoList;


}
