package com.liquidnet.service.kylin.dto.vo.returns;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.service.kylin.dao.KylinOrderRefundsEntitiesDao;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderRefundEntitiesVo;
import com.liquidnet.service.kylin.dto.vo.mongo.KylinOrderRefundPicVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * refund返回给前端的数据字段
 * </p>
 *
 * @author jiangxiulong
 * @since 2021-05-31 11:19 上午
 */

@Data
@ApiModel
public class KylinOrderRefundsAdminVo implements Serializable,Cloneable {

    private static final long serialVersionUID = -7910948111093638877L;

    @ApiModelProperty(value = "主键ID")
    private String orderRefundsId;

    @ApiModelProperty(value = "票务订单id")
    private String orderTicketsId;

    @ApiModelProperty(value = "退款编号")
    private String orderRefundCode;

    @ApiModelProperty(value = "批量退款id")
    private String orderRefundBatchesId;

    @ApiModelProperty(value = "退款中心退款编号")
    private String refundCode;

    @ApiModelProperty(value = "成功退款时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime refundAt;

    @ApiModelProperty(value = "第三方退款编号")
    private String refundId;

    @ApiModelProperty(value = "退款失败原因")
    private String refundError;

    @ApiModelProperty(value = "退款票总金额")
    private BigDecimal price;

    @ApiModelProperty(value = "退款快递总金额")
    private BigDecimal priceExpress;

    @ApiModelProperty(value = "退款扣除的手续费金额")
    private BigDecimal priceCharges;

    @ApiModelProperty(value = "纸质票号")
    private String ticketNum;

    @ApiModelProperty(value = "退款状态: 0请求退款 2取消退款 1审核通过 5驳回退款 7等待退款 3正在退款 4完成退款 6退款失败")
    private Integer status;

    private String statusName;
    private Integer refundCate;

    @ApiModelProperty(value = "退款差异: 0申请退款返还库存 1自动退款无法取消退款不返还库存")
    private Integer type;

    @ApiModelProperty(value = "退款差异: 0申请退款返还库存 1自动退款无法取消退款不返还库存")
    private String typeName;

    @ApiModelProperty(value = "申请人id")
    private String applicantId;

    @ApiModelProperty(value = "申请人名称")
    private String applicantName;

    @ApiModelProperty(value = "申请时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime applicantAt;

    @ApiModelProperty(value = "退款原因")
    private String reason;

    @ApiModelProperty(value = "审核人id")
    private String auditorId;

    @ApiModelProperty(value = "审核人名称")
    private String auditorName;

    @ApiModelProperty(value = "审核时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime auditorAt;

    @ApiModelProperty(value = "驳回原因")
    private String reject;

    @ApiModelProperty(value = "执行人id")
    private String executorId;

    @ApiModelProperty(value = "执行人名称")
    private String executorName;

    @ApiModelProperty(value = "执行时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime executorAt;

    @ApiModelProperty(value = "回绝原因")
    private String refuse;

    @ApiModelProperty(value = "票务审核人id")
    private String ticketAuditId;

    @ApiModelProperty(value = "票务审核人名称")
    private String ticketAuditName;

    @ApiModelProperty(value = "票务审核时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime ticketAuditAt;

    @ApiModelProperty(value = "票务审核备注")
    private String ticketAuditRemark;

    @ApiModelProperty(value = "票务/快递费/票和快递费")
    private String refundType;

    @ApiModelProperty(value = "添加时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime createdAt;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern= DateUtil.DATE_FULL_STR)
    private LocalDateTime updatedAt;

    List<KylinOrderRefundsEntitiesDao> entities;

    private List<KylinOrderRefundEntitiesVo> orderRefundEntitiesVoList;
    private List<KylinOrderRefundPicVo> orderRefundPicVos;
    private List<String> picList;
    private String payType;
    private String getTicketType;

    public void setStatus(Integer status){
        try {
            this.status = status;
            switch (status) {
                case 0:
                    this.statusName = "请求退款";
                    break;
                case 1:
                    this.statusName = "运营审核通过";
                    break;
                case 2:
                    this.statusName = "取消退款";
                    break;
                case 3:
                    this.statusName = "正在退款";
                    break;
                case 4:
                    this.statusName = "完成退款";
                    break;
                case 5:
                    this.statusName = "运营审核驳回退款";
                    break;
                case 6:
                    this.statusName = "退款失败";
                    break;
                case 7:
                    this.statusName = "财务通过等待退款";
                    break;
                case 8:
                    this.statusName = "财务驳回退款";
                    break;
                default:
                    this.statusName = "其他";
                    break;
            }
        }catch (Exception e){
            e.printStackTrace();
            this.statusName = "其他";
        }
    }

    private static final KylinOrderRefundsAdminVo obj = new KylinOrderRefundsAdminVo();
    public static KylinOrderRefundsAdminVo getNew() {
        try {
            return (KylinOrderRefundsAdminVo) obj.clone();
        } catch (CloneNotSupportedException e) {
            return new KylinOrderRefundsAdminVo();
        }
    }

}
