增加排序

This commit is contained in:
GYJ 2024-07-09 09:29:02 +08:00
parent 52ebdfa90b
commit de049b5791
1 changed files with 19 additions and 0 deletions

View File

@ -489,6 +489,25 @@ public class SummaryServiceImpl implements SummaryService {
ShopTableSaleInfoVo shopTableSaleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), shopTableCode, start, end);
list.add(shopTableSaleInfoVo);
}
if (!list.isEmpty()) {
list.sort((a, b) -> {
// 先比较 orderAmount
BigDecimal aAmount = a.getOrderAmount() == null ? BigDecimal.ZERO : new BigDecimal(a.getOrderAmount().toString());
BigDecimal bAmount = b.getOrderAmount() == null ? BigDecimal.ZERO : new BigDecimal(b.getOrderAmount().toString());
int compareAmount = aAmount.compareTo(bAmount);
if (compareAmount != 0) {
return compareAmount;
}
// 如果 orderAmount 相等再比较 orderCount
Integer aCount = a.getOrderCount() == null ? 0 : Integer.parseInt(a.getOrderCount().toString());
Integer bCount = b.getOrderCount() == null ? 0 : Integer.parseInt(b.getOrderCount().toString());
return aCount - bCount;
});
}
return list;
}