package com.izouma.nineth.event;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.CollectionSerializer;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.NoArgsConstructor;

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

@Data
@NoArgsConstructor
public class CreateOrderEvent implements Serializable {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long    id;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long    userId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long    collectionId;
    private int     qty;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long    addressId;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userCouponId;

    @JsonSerialize(using = CollectionSerializer.class)
    private List<Long> userCouponIds;
    @JsonSerialize(using = ToStringSerializer.class)
    private Long    invitor;

    /**
     * 来源ip
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private String fromIp;

    public CreateOrderEvent(Long id, Long userId, Long collectionId, int qty, Long addressId, List<Long> couponIds, Long invitor, String ipAddr) {
        this.id = id;
        this.userId = userId;
        this.collectionId = collectionId;
        this.qty = qty;
        this.addressId = addressId;
        this.userCouponIds = couponIds;
        this.invitor = invitor;
        this.fromIp = ipAddr;
    }

    public CreateOrderEvent(Long id, Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor, String ipAddr) {
        this.id = id;
        this.userId = userId;
        this.collectionId = collectionId;
        this.qty = qty;
        this.addressId = addressId;
        this.userCouponId = userCouponId;
        this.invitor = invitor;
        this.fromIp = ipAddr;
    }
}
