|
@@ -1,14 +1,17 @@
|
|
|
package thyyxxk.wxservice_server.utils;
|
|
|
|
|
|
import java.util.Vector;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
public class TradeVectorUtil {
|
|
|
- private final static Vector<String> tradeNosBeingQuery = new Vector<>();
|
|
|
+
|
|
|
+ private final static ConcurrentHashMap<String, Long> tradeNosBeingQuery = new ConcurrentHashMap<>();
|
|
|
private final static Vector<String> tradeNoBeingRefund = new Vector<>();
|
|
|
private final static Vector<String> tradeNoRefunded = new Vector<>();
|
|
|
|
|
|
public static void addBeingQuery(String tradeNo) {
|
|
|
- tradeNosBeingQuery.add(tradeNo);
|
|
|
+ long now = System.currentTimeMillis() / 1000;
|
|
|
+ tradeNosBeingQuery.put(tradeNo, now);
|
|
|
}
|
|
|
|
|
|
public static void removeBeingQuery(String tradeNo) {
|
|
@@ -16,7 +19,16 @@ public class TradeVectorUtil {
|
|
|
}
|
|
|
|
|
|
public static boolean tradeNoBeingQuery(String tradeNo) {
|
|
|
- return tradeNosBeingQuery.contains(tradeNo);
|
|
|
+ Long insertTime = tradeNosBeingQuery.get(tradeNo);
|
|
|
+ if (insertTime == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ long now = System.currentTimeMillis() / 1000;
|
|
|
+ if (now - insertTime >= 60) {
|
|
|
+ tradeNosBeingQuery.remove(tradeNo);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public static void addBeingRefund(String tradeNo) {
|