|
@@ -26,6 +26,7 @@ import org.springframework.security.oauth2.provider.OAuth2Authentication;
|
|
|
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.security.Principal;
|
|
|
import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -135,9 +136,26 @@ public class UserCenterController {
|
|
|
List<PrizeVO> filteredList = list.stream()
|
|
|
.filter(prize -> {
|
|
|
Date endDate = prize.getEndDate();
|
|
|
+
|
|
|
LocalDate endLocalDate = endDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
return endLocalDate.isAfter(today);
|
|
|
})
|
|
|
+ .sorted((prize1, prize2) -> {
|
|
|
+ BigDecimal price1 = prize1.getUsdPrice();
|
|
|
+ BigDecimal price2 = prize2.getUsdPrice();
|
|
|
+
|
|
|
+ // 处理 null 值,null 排在最后,按价格降序排序
|
|
|
+ if (price1 == null && price2 == null) {
|
|
|
+ return 0;
|
|
|
+ } else if (price1 == null) {
|
|
|
+ return 1; // 如果 price1 是 null,则排在后面
|
|
|
+ } else if (price2 == null) {
|
|
|
+ return -1; // 如果 price2 是 null,则排在后面
|
|
|
+ } else {
|
|
|
+ // 正常情况下比较 BigDecimal,降序排序
|
|
|
+ return price2.compareTo(price1);
|
|
|
+ }
|
|
|
+ })
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
result.setGiftList(filteredList);
|