package com.sifang.modules.customer.constant;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 合同状态映射
 */
public enum GFContractStateKM {

    //    合同状态(0、删除 1.待签约 2.已签约 3.待审核 4.签署驳回 5.已审核 6.待生成 a.承租人已签 b.签署中 c.待盖章 d.盖章中 e.已完成 f. 待上传 g.已上传 h.作废 i.已撤销 j.已过期 k.已拒签 )
    ZF("作废", "", "h", -2),
    WAIT("待签约", "", "1", 10),
    QSZ("签署中", "", "b", 15),
    YWC("已完成", "", "e", 20),
    YCX("已撤销", "", "i", 3),
    YGQ("已过期", "", "j", 5),
    YJQ("已拒签", "", "k", 7),
    DGZ("待盖章", "", "c", 110),
    GZZ("盖章中", "", "d", 120);

    private String name;//状态名称
    private String internalCode;//内部编码
    private Integer externalCode;//外部编码
    private String code;

    public String getName() {
        return name;
    }

    public String getInternalCode() {
        return internalCode;
    }

    public Integer getExternalCode() {
        return externalCode;
    }

    public String getCode() {
        return code;
    }

    private GFContractStateKM(String name, String code, String internalCode, Integer externalCode) {
        this.name = name;
        this.code = code;
        this.internalCode = internalCode;
        this.externalCode = externalCode;
    }

    public static GFContractStateKM externalOf(Integer externalCode) {
        return Optional.ofNullable(externalCode)
                .map(v -> Stream.of(values())
                        .filter(s -> s.externalCode == v)
                        .findFirst()
                        .orElse(null))
                .orElse(null);
    }
}
