Authored by 胡古飞

fix AggProductListHelper

... ... @@ -99,13 +99,10 @@ public class AggProductListHelper {
try {
double value1 = getDouble(o1.get(orderField));
double value2 = getDouble(o2.get(orderField));
if (value1 == value2) {
return 0;
}
if (isDesc) {
return value1 - value2 > 0 ? -1 : 1;
return value1 > value2 ? -1 : value1 < value2 ? 1 : 0;
} else {
return value1 - value2 > 0 ? 1 : -1;
return value1 > value2 ? 1 : value1 < value2 ? -1 : 0;
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ... @@ -120,24 +117,10 @@ public class AggProductListHelper {
}
private double getDouble(Object value) {
if (value == null) {
return 0;
}
if (value instanceof Float) {
return ((Float) value).floatValue();
}
if (value instanceof Integer) {
return ((Integer) value);
}
if (value instanceof Long) {
return ((Long) value);
}
if (value instanceof String) {
return Double.valueOf(value.toString());
}
if (value instanceof Double) {
try {
return Double.valueOf(value.toString());
} catch (Exception e) {
return 0;
}
return 0;
}
}
... ...