package com.izouma.dingdong.domain.user;

import com.izouma.dingdong.domain.BaseEntity;
import com.izouma.dingdong.domain.OrderGoodsSpec;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Data
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Where(clause = "enabled = 1")
@ApiModel(value = "购物车")
public class ShoppingCart extends BaseEntity implements Serializable {
    @ApiModelProperty(value = "用户ID", name = "userId")
    private Long userId;

    @ApiModelProperty(value = "商户ID", name = "merchantId")
    private Long merchantId;

    @ApiModelProperty(value = "配送费", name = "deliveryAmount")
    private BigDecimal deliveryAmount;

//    @ApiModelProperty(value = "总价", name = "totalAmount")
//    private BigDecimal totalAmount;

    @ApiModelProperty(value = "已减优惠")
    private BigDecimal reducedAmount;

    @ApiModelProperty(value = "包装价格", name = "packingPrice")
    private BigDecimal packingPrice;

    @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "shoppingCartId")
    List<OrderGoodsSpec> orderGoodsSpecs;

    @ApiModelProperty(value = "优惠券ID", name = "couponId")
    private Long couponId;

    @ApiModelProperty(value = "满减", name = "fullReduction")
    private BigDecimal fullReduction;

    @ApiModelProperty(value = "首单", name = "firstBuy")
    private BigDecimal firstBuy;

    @ApiModelProperty(value = "红包", name = "redBag")
    private BigDecimal redBag;

//    @ApiModelProperty(value = "新用户", name = "newUser")
//    private BigDecimal newUser;

    private BigDecimal goodsTotal;

    @ApiModelProperty(value = "实付金额", name = "realAmount")
    private BigDecimal realAmount;

    @Builder.Default
    @Column(nullable = false)
    private Boolean enabled = true;

}
