Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	eladmin-system/src/main/java/cn/ysk/cashier/repository/order/TbOrderInfoRepository.java
This commit is contained in:
韩鹏辉 2024-07-09 10:51:55 +08:00
commit 497d0a7b12
3 changed files with 52 additions and 6 deletions

View File

@ -5,11 +5,14 @@ import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
import cn.ysk.cashier.enums.PayTypeEnum;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import cn.ysk.cashier.repository.ShopUserDutyDetailRepository;
import cn.ysk.cashier.repository.ShopUserDutyRepository;
import cn.ysk.cashier.repository.TbTokenRepository;
import cn.ysk.cashier.repository.order.TbOrderDetailRepository;
import cn.ysk.cashier.repository.order.TbOrderInfoRepository;
import cn.ysk.cashier.repository.shop.TbShopAreaRepository;
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
import cn.ysk.cashier.repository.shop.TbShopUserRepository;
import cn.ysk.cashier.service.SummaryService;
import cn.ysk.cashier.utils.DateUtil;
@ -56,6 +59,12 @@ public class SummaryServiceImpl implements SummaryService {
@Resource
private TbShopUserFlowService tbShopUserFlowService;
@Resource
private TbShopTableRepository shopTableRepository;
@Resource
TbShopAreaRepository tbShopAreaRepository;
@Override
public SummaryVO selectSummary(Integer shopId) {
@ -475,13 +484,50 @@ public class SummaryServiceImpl implements SummaryService {
@Override
public List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime) {
List<String> shopTableCodes = tbOrderInfoRepository.queryShopTableIds(shopId);
long start = 1704038400000L;
long end = Instant.now().toEpochMilli();
if (startTime != null && endTime != null) {
start = startTime.getTime();
end = endTime.getTime();
}
return tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), start, end);
List<ShopTableSaleInfoVo> list = new ArrayList<>();
for (String shopTableCode : shopTableCodes) {
ShopTableSaleInfoVo shopTableSaleInfoVo = tbOrderInfoRepository.queryShopTableSaleInfo(shopId.toString(), shopTableCode, start, end);
if (shopTableSaleInfoVo.getTableId() == null) {
TbShopTable table = shopTableRepository.findByQrcode(shopTableCode);
if (table != null) {
shopTableSaleInfoVo.setShopId(shopId);
shopTableSaleInfoVo.setTableId(table.getId());
shopTableSaleInfoVo.setTableName(table.getName());
shopTableSaleInfoVo.setAreaId(table.getAreaId());
shopTableSaleInfoVo.setAreaName(tbShopAreaRepository.findById(table.getAreaId()).get().getName());
}
}
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 = bAmount.compareTo(aAmount);
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 bCount - aCount;
});
}
return list;
}
@Override

View File

@ -32,7 +32,7 @@ public class ShopTableSaleInfoVo {
this.tableName = tableName;
this.areaId = areaId;
this.areaName = areaName;
this.orderCount = orderCount;
this.orderAmount = orderAmount;
this.orderCount = orderCount == null ? 0 : orderCount;
this.orderAmount = orderAmount == null ? 0 : orderAmount;
}
}