package net.cnki.editor.costcenter.pojo.enums;
import lombok.Getter;
import java.util.Arrays;
/**
* 费用枚举接口
*/
public interface CosttypeEnumInterface {
/**
* 费用类型和费用信息-> 费用性质, 支付人 , 收取人, 费用信息状态
*/
@Getter
enum CosttypePayerAndReceiveEnum implements CosttypeEnumInterface {
//当前类 ; sql语句
//1 审稿费;作者->编辑部 2 版面费;作者->编辑部 3 作者稿费;编辑部->作者 4 专家审稿费;编辑部->审稿专家 5 编辑稿费;编辑部->编辑
REVIEWERS_FEE((short) 1, "审稿费", "作者", "编辑部", "待通知交费", "待作者交费", "待确认到款", "待开票完成", "己完成"),
PAPER_FREE((short) 2, "版面费", "作者", "编辑部", "待通知交费", "待作者交费", "待确认到款", "待开票完成", "己完成"),
AUTHOR_FREE((short) 3, "作者稿费", "编辑部", "作者", "待通知作者", "待作者确认信息", "信息已确认待支付", "作者稿费已支付", ""),
EXPERT_FREE((short) 4, "专家审稿费", "编辑部", "审稿专家", "编辑部未登记", "编辑部已登记", "", "", ""),
COPYREADER_FREE((short) 5, "编辑稿费", "编辑部", "编辑", "编辑部未登记", "编辑部已登记", "", "", ""),
NULL(null, "", "", "", "", "", "", "", "");
private final Short type;
private final String name;
//支付人
private final String payerMan;
//收取人
private final String receiveMan;
//费用信息状态
private final String status0;
private final String status1;
private final String status2;
private final String status3;
private final String status4;
CosttypePayerAndReceiveEnum(Short type, String name, String payerMan, String receiveMan, String status0, String status1, String status2, String status3, String status4) {
this.type = type;
this.name = name;
this.payerMan = payerMan;
this.receiveMan = receiveMan;
this.status0 = status0;
this.status1 = status1;
this.status2 = status2;
this.status3 = status3;
this.status4 = status4;
}
/**
* 获取 费用性质
*
* @param type
* @return
*/
public static CosttypePayerAndReceiveEnum getValue(short type) {
CosttypePayerAndReceiveEnum costtypePayerAndReceiveEnum = Arrays.stream(CosttypePayerAndReceiveEnum.values()).filter(x -> x.getType() == type).findAny().orElse(CosttypePayerAndReceiveEnum.NULL);
return costtypePayerAndReceiveEnum;
}
/**
* 根据 费用性质 获取 当前费用信息 的 信息状态
*
* @param typeCode 费用性质
* @param statusCode 费用性质
* @return
*/
public static String getStatusName(short typeCode, int statusCode) {
CosttypePayerAndReceiveEnum costtypePayerAndReceiveEnum = Arrays.stream(CosttypePayerAndReceiveEnum.values()).filter(x -> x.getType() == typeCode).findAny().orElse(CosttypePayerAndReceiveEnum.NULL);
switch (statusCode) {
case 0:
return costtypePayerAndReceiveEnum.getStatus0();
case 1:
return costtypePayerAndReceiveEnum.getStatus1();
case 2:
return costtypePayerAndReceiveEnum.getStatus2();
case 3:
return costtypePayerAndReceiveEnum.getStatus3();
case 4:
return costtypePayerAndReceiveEnum.getStatus4();
default:
return "";
}
}
}
/**
* 结算方式: 结算方式 0 第三方转账 1 邮局汇款 2银行汇款 3现金支付 4内部转账 5其他
*/
@Getter
enum PayMethod implements CosttypeEnumInterface {
METHOD("第三方转账", "邮局汇款", "银行汇款", "现金支付", "内部转账", "其他");
// 结算方式 0
private final String payMethod0;
// 结算方式 1
private final String payMethod1;
private final String payMethod2;
private final String payMethod3;
private final String payMethod4;
private final String payMethod5;
PayMethod(String payMethod0, String payMethod1, String payMethod2, String payMethod3, String payMethod4, String payMethod5) {
this.payMethod0 = payMethod0;
this.payMethod1 = payMethod1;
this.payMethod2 = payMethod2;
this.payMethod3 = payMethod3;
this.payMethod4 = payMethod4;
this.payMethod5 = payMethod5;
}
public static String getMethod(String payMethodCode) {
switch (payMethodCode) {
case "0":
return PayMethod.METHOD.getPayMethod0();
case "1":
return PayMethod.METHOD.getPayMethod1();
case "2":
return PayMethod.METHOD.getPayMethod2();
case "3":
return PayMethod.METHOD.getPayMethod3();
case "4":
return PayMethod.METHOD.getPayMethod4();
case "5":
return PayMethod.METHOD.getPayMethod5();
default:
return "";
}
}
}
/**
* 发票类型 0 普票 1 专票
*/
@Getter
enum InvoiceType implements CosttypeEnumInterface {
INVOICETYPE("普票", "专票");
//分票类型0
private final String invoiceType0;
//分票类型1
private final String invoiceType1;
InvoiceType(String invoiceType0, String invoiceType1) {
this.invoiceType0 = invoiceType0;
this.invoiceType1 = invoiceType1;
}
public static String getInvoiceType(String invoiceTypeCode) {
switch (invoiceTypeCode) {
case "0":
return InvoiceType.INVOICETYPE.getInvoiceType0();
case "1":
return InvoiceType.INVOICETYPE.getInvoiceType1();
default:
return "";
}
}
}
}
测试类
vo.setPayMethod(CosttypeEnumInterface.PayMethod.getMethod(StringUtils.defaultString(vo.getPayMethod())));
vo.setInvoiceType(CosttypeEnumInterface.InvoiceType.getInvoiceType(StringUtils.defaultString(vo.getInvoiceType())));
vo.setStatus(CosttypeEnumInterface.CosttypePayerAndReceiveEnum.getStatusName(Short.parseShort(vo.getCosttype()), Integer.parseInt(vo.getStatus())));