
package com.tmerclub.cloud.order.vo;

import com.tmerclub.cloud.common.order.vo.RefundOrderItemVO;
import com.tmerclub.cloud.common.vo.BaseVO;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.ToString;

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

/**
 * 订单退款记录信息VO
 *
 * @author tmerclub
 * @date 2020-12-05 14:13:50
 */
@Data
@ToString
public class OrderRefundVO extends BaseVO implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    @Schema(description = "记录ID")
    private Long refundId;

    @Schema(description = "支付系统 0默认1通联")
    private Integer paySysType;

    @Schema(description = "店铺ID")
    private Long shopId;

    @Schema(description = "买家ID")
    private Long userId;

    @Schema(description = "订单号")
    private Long orderId;

    @Schema(description = "订单项ID(0:为全部订单项)")
    private Long orderItemId;

    @Schema(description = "退货数量(0:为全部订单项)")
    private Integer refundCount;

    @Schema(description = "退还积分")
    private Long refundScore;

    @Schema(description = "退款金额")
    private Long refundAmount;

    @Schema(description = "退回的商家采购金额，通联支付独有")
    private Long allinpayRefundPurchaseAmount;

    @Schema(description = "平台退款金额（退款时将这部分钱退回给平台，所以商家要扣除从平台这里获取的金额）")
    private Long platformRefundAmount;

    @Schema(description = "平台佣金退款金额")
    private Long platformRefundCommission;

    @Schema(description = "退款单总分销金额")
    private Long distributionTotalAmount;

    @Schema(description = "退款单类型（1:整单退款,2:单个物品退款）")
    private Integer refundType;

    @Schema(description = "申请类型:1,仅退款,2退款退货")
    private Integer applyType;

    @Schema(description = "是否接收到商品(1:已收到,0:未收到)")
    private Integer isReceived;

    @Schema(description = "退款关闭原因(1.买家撤销退款 2.卖家拒绝退款 3.退款申请超时被系统关闭)")
    private Integer closeType;

    @Schema(description = "处理退款状态:(1.买家申请 2.卖家接受 3.买家发货 4.卖家收货 5.退款成功  -1.退款关闭)详情见ReturnMoneyStsType")
    private Integer returnMoneySts;

    @Schema(description = "申请原因")
    private Integer buyerReason;

    @Schema(description = "申请原因 中文描述")
    private String buyerReasonValue;

    @Schema(description = "申请说明")
    private String buyerDesc;

    @Schema(description = "联系方式（退款时留下的手机号码）")
    private String buyerMobile;

    @Schema(description = "文件凭证(逗号隔开)")
    private String imgUrls;

    @Schema(description = "店铺/供应商文件凭证(逗号隔开)")
    private String shopImgUrls;

    @Schema(description = "超时时间（超过该时间不处理，系统将自动处理）（保留字段）")
    private Date overTime;

    @Schema(description = "拒绝原因")
    private String rejectMessage;

    @Schema(description = "卖家备注")
    private String sellerMsg;

    @Schema(description = "受理时间")
    private Date handelTime;

    @Schema(description = "发货时间")
    private Date deliveryTime;

    @Schema(description = "收货时间")
    private Date receiveTime;

    @Schema(description = "关闭时间")
    private Date closeTime;

    @Schema(description = "移交供应商时间")
    private Date supplierTime;

    @Schema(description = "确定时间(确定退款时间)")
    private Date decisionTime;

    @Schema(description = "退款时间")
    private Date refundTime;

    @Schema(description = "付款时间")
    private Date payTime;

    @Schema(description = "订单实付金额")
    private Long actualTotal;

    @Schema(description = "订单实付积分")
    private Long orderScore;

    @Schema(description = "订单状态")
    private Integer orderStatus;

    @Schema(description = "退款状态")
    private Integer refundStatus;

    @Schema(description = "店铺名称")
    private String shopName;

    @Schema(description = "支付的时候，支付id")
    private Long payId;

    @Schema(description = "订单支付ids")
    private String payIds;

    @Schema(description = "支付方式")
    private Integer payType;

    @Schema(description = "订单项")
    private List<RefundOrderItemVO> orderItems;

    @Schema(description = "退款地址信息")
    private OrderRefundAddrVO orderRefundAddr;

    /**
     * 是否为未成团而退款的团购订单
     */
    private Integer unSuccessGroupOrder;

    @NotNull(message = "供应商id")
    private Long supplierId;

    @Schema(description = "供应商处理状态， -1.商家自行处理 0.待供应商处理 1.供应商已同意 2.供应商已拒绝")
    private Integer supplierHandleStatus;

    @Schema(description = "采购退款金额")
    private Long purchaseRefundAmount;

    @Schema(description = "采购的平台佣金退款金额")
    private Long purPlatformRefundCommission;

    @Schema(description = "订单运费")
    private Long freightAmount;

    @Schema(description = "供应商订单运费")
    private Long supplierFreightAmount;

    @Schema(description = "是否待采购 1.是 0.否")
    private Integer waitPurchase;

    @Schema(description = "订单项采购价")
    private Long itemPurchaseAmount;


    @Schema(description = "退款退回的赠品订单项ids")
    private String returnGiveawayIds;

    @Schema(description = "当前退款的实付金额（实付金额减去不退回赠品的金额）")
    private Long refundActualTotal;

    @Schema(description = "平台运费减免金额")
    private Long platformFreeFreightAmount;

    @Schema(description = "预售类型 -1.未开启预售 0.全款预售类型 1.定金预售")
    private Integer preSaleType;

    /**
     * 最后一单
     */
    private Boolean lastOrder;

    /**
     * 商家备注信息（退款单移交供应商处理时保存）
     */
    @Hidden
    private String shopSellerMsg;

    @Schema(description = "平台介入状态 -1.没有介入 1.用户申请介入 2.平台同意介入 3.平台拒绝介入 5.平台同意退款成功")
    private Integer platformInterventionStatus;

    @Schema(description = "用户申请介入理由")
    private String applyInterventionReason;

    @Schema(description = "用户申请介入凭证")
    private String applyInterventionImgUrls;

    @Schema(description = "平台介入退款方式 1.商家承担 2.商家供应商承担（供应商发货订单） 3.不同意退款")
    private Integer interventionRefundType;

    @Schema(description = "平台介入前的退款金额")
    private Long afterInterventionRefundAmount;

    @Schema(description = "平台留言")
    private String platformMessage;

    @Schema(description = "申请介入时间")
    private Date applyInterventionTime;

    @Schema(description = "用户/商家/供应商补充凭证截至时间，平台开始处理时间")
    private Date interventionEndTime;

    @Schema(description = "平台介入处理截至时间")
    private Date platformProcessingEndTime;

    @Schema(description = "介入完成时间")
    private Date interventionFinishTime;

    @Schema(description = "平台介入凭证列表")
    private List<OrderRefundInterventionVO> orderRefundInterventionList;

    @Schema(description = "能否申请平台介入or申请退款")
    private Boolean canApplyRefund;

    public Boolean isLastOrder() {
        return lastOrder;
    }
}
