Просмотр исходного кода

history 页面的timestamp,不读*history 的timestamp,读pending 的timestamp

skyfffire 2 лет назад
Родитель
Сommit
1004e3df78

+ 18 - 1
src/main/java/modules/tx/history/HistoryService.java

@@ -10,6 +10,7 @@ import common.utils.http.MyPaginate;
 import modules.tx.TxService;
 import modules.tx.transfer.TransferService;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public class HistoryService {
@@ -27,6 +28,22 @@ public class HistoryService {
 	}
 
 	public List<Record> findByChainId(int chainId, MyPaginate p, JSONObject conditionMap) throws Exception {
-		return txService.findByChainId(chainId, p, conditionMap, History.class, HistoryTransfer.class);
+		List<Record> records = txService.findByChainId(chainId, p, conditionMap, History.class, HistoryTransfer.class);
+		
+		// 2022-12-19 410: *history 页面的timestamp,不读*history 的timestamp,读pending 的timestamp
+		putPendingTimestamp(records);
+		
+		return records;
+	}
+	
+	private void putPendingTimestamp(List<Record> records) {
+		for (Record historyTxData : records) {
+			int chainId = historyTxData.getInt("chainId");
+			String hash = historyTxData.getStr("hash");
+			
+			BigDecimal timestamp = Db.template("pending.findTimestamp", chainId, hash).queryBigDecimal();
+			
+			historyTxData.put("timestamp", timestamp);
+		}
 	}
 }

+ 5 - 0
src/main/java/modules/tx/pending/pending.sqlt

@@ -0,0 +1,5 @@
+#sql("findTimestamp")
+	select timestamp
+	from t_pending
+	where chainId=#para(0) and hash=#para(1)
+#end