package com.izouma.dingdong.domain;

import com.alibaba.excel.annotation.ExcelIgnore;

import com.izouma.dingdong.enums.RefundReason;
import com.izouma.dingdong.enums.RefundStatus;
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.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Builder
@Where(clause = "enabled = 1")
@ApiModel(value = "退款申请", description = "退款申请")
public class OrderRefundApply extends BaseEntity {

    @ApiModelProperty(value = "订单ID", name = "orderId")
    private Long orderId;

    @ApiModelProperty(value = "备注", name = "remark")
    private String remark;

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

    @ApiModelProperty(value = "图片")
    private String img;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "理由", name = "reason")
    private RefundReason reason;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "状态", name = "status")
    private RefundStatus status;

    @ApiModelProperty(value = "申请时间", name = "applyTime")
    private LocalDateTime applyTime;

    //商家审核时间
    @ApiModelProperty(value = "商家审核时间", name = "auditTime")
    private LocalDateTime auditTime;

    @ApiModelProperty(value = "退款时间", name = "refundTime")
    private LocalDateTime refundTime;

    @ApiModelProperty(value = "退款单号", name = "refundId")
    private String refundId;

    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "orderId", insertable = false, updatable = false, foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
    @NotFound(action = NotFoundAction.IGNORE)
    @ExcelIgnore
    private OrderInfo orderInfo;

    /**
     * 上报
     */
    @ApiModelProperty(value = "上报", name = "report")
    private Boolean report;

    @ApiModelProperty(value = "沟通结果", name = "context")
    private String context;

    @ApiModelProperty(value = "商家责任", name = "merchantLiability")
    private BigDecimal merchantLiability;

    @ApiModelProperty(value = "骑手责任", name = "riderLiability")
    private BigDecimal riderLiability;

    @ApiModelProperty(value = "平台责任", name = "platformLiability")
    private BigDecimal platformLiability;

    //付款流水Id
    //private Long feeId;


    @ApiModelProperty(value = "商家是否同意", name = "merchantAgree")
    private Boolean merchantAgree;

    @ApiModelProperty(value = "平台是否同意", name = "platformAgree")
    private Boolean platformAgree;

    @ApiModelProperty(value = "审核时间", name = "platformAuditTime")
    private LocalDateTime platformAuditTime;

    @Column(nullable = false)
    private Boolean enabled = true;
}
