Authored by 胡古飞

fix AggProductListHelper

@@ -99,13 +99,10 @@ public class AggProductListHelper { @@ -99,13 +99,10 @@ public class AggProductListHelper {
99 try { 99 try {
100 double value1 = getDouble(o1.get(orderField)); 100 double value1 = getDouble(o1.get(orderField));
101 double value2 = getDouble(o2.get(orderField)); 101 double value2 = getDouble(o2.get(orderField));
102 - if (value1 == value2) {  
103 - return 0;  
104 - }  
105 if (isDesc) { 102 if (isDesc) {
106 - return value1 - value2 > 0 ? -1 : 1; 103 + return value1 > value2 ? -1 : value1 < value2 ? 1 : 0;
107 } else { 104 } else {
108 - return value1 - value2 > 0 ? 1 : -1; 105 + return value1 > value2 ? 1 : value1 < value2 ? -1 : 0;
109 } 106 }
110 } catch (Exception e) { 107 } catch (Exception e) {
111 logger.error(e.getMessage(), e); 108 logger.error(e.getMessage(), e);
@@ -120,24 +117,10 @@ public class AggProductListHelper { @@ -120,24 +117,10 @@ public class AggProductListHelper {
120 } 117 }
121 118
122 private double getDouble(Object value) { 119 private double getDouble(Object value) {
123 - if (value == null) {  
124 - return 0;  
125 - }  
126 - if (value instanceof Float) {  
127 - return ((Float) value).floatValue();  
128 - }  
129 - if (value instanceof Integer) {  
130 - return ((Integer) value);  
131 - }  
132 - if (value instanceof Long) {  
133 - return ((Long) value);  
134 - }  
135 - if (value instanceof String) {  
136 - return Double.valueOf(value.toString());  
137 - }  
138 - if (value instanceof Double) { 120 + try {
139 return Double.valueOf(value.toString()); 121 return Double.valueOf(value.toString());
140 - } 122 + } catch (Exception e) {
141 return 0; 123 return 0;
142 } 124 }
  125 + }
143 } 126 }