licailing 3 anos atrás
pai
commit
0a0791d993

+ 3 - 0
src/main/java/com/izouma/nineth/repo/TokenHistoryRepo.java

@@ -37,6 +37,9 @@ public interface TokenHistoryRepo extends JpaRepository<TokenHistory, Long>, Jpa
     @Query("select sum(t.price) from TokenHistory t where t.toUserId = ?1 and t.price is not null")
     BigDecimal userBuy(Long userId);
 
+    @Query("select sum(t.price) from TokenHistory t where t.fromUserId = ?1 and t.price is not null")
+    BigDecimal userSale(Long userId);
+
     @Transactional
     @Modifying
     int deleteByTokenId(String tokenId);

+ 1 - 1
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -684,7 +684,7 @@ public class AssetService {
 //                .map(TokenHistory::getPrice)
 //                .reduce(BigDecimal.ZERO, BigDecimal::add);
         Map<String, BigDecimal> map = new HashMap<>();
-        map.put("sale", BigDecimal.ZERO);
+        map.put("sale", tokenHistoryRepo.userSale(userId));
         map.put("buy", rockRecordRepo.findRecordByUserIdOrderByIdDesc(userId));
         return map;
     }