1. 202009bug单
1.1.1. P1
枚举类与string直接比较了。应获取枚举类的参数。
错误示例
orderStatusFront为”1“。
if(OrderFrontStatusEnum.TO_PAY.equals(orderStatusFront)){
orderStatus = OrderSelfStatusEnum.TO_PAY.getValue();
}
应该是
if(OrderFrontStatusEnum.TO_PAY.getValue().equals(orderStatusFront)){
orderStatus = OrderSelfStatusEnum.TO_PAY.getValue();
}
OrderSelfStatusEnum类
public enum OrderSelfStatusEnum {
TO_PAY("0","待支付"),
HAS_PAY("1","已支付"),
PAYING("2","支付中"),
FAIL_PAY("3","支付失败");
private String value;
private String description;
OrderSelfStatusEnum(String value, String description) {
this.value = value;
this.description = description;
}
public String getValue() {
return value;
}
public String getDescription() {
return description;
}
public static String getDescriptionByValue(String value) {
if (StringUtils.isEmpty(value)) {
return null;
}
for (OrderSelfStatusEnum element : OrderSelfStatusEnum.values()) {
if (element.getValue().equals(value)) {
return element.getDescription();
}
}
return null;
}
public static OrderSelfStatusEnum getEnumByValue(String value){
for(OrderSelfStatusEnum oenum : OrderSelfStatusEnum.values()){
if(oenum.getValue().equals(value)){
return oenum;
}
}
return null;
}
}