用餐人数问题

This commit is contained in:
2025-11-22 15:13:42 +08:00
parent d244d70fbd
commit ebab6523dd

View File

@@ -8,6 +8,7 @@ import com.czg.order.vo.TotalVo;
import com.czg.service.order.mapper.ShopOrderStatisticMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@@ -23,6 +24,7 @@ import java.util.*;
* @author ww
* @since 2025-11-20
*/
@Slf4j
@Service
public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisticMapper, ShopOrderStatistic> implements ShopOrderStatisticService {
@@ -98,8 +100,11 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
ShopOrderStatistic result = new ShopOrderStatistic();
ShopOrderStatistic onlineStat = mapper.getOnlineStatSingleDate(shopId, day);
log.info("onlineStat:{}", onlineStat);
ShopOrderStatistic orderStat = mapper.getOrderStatSingleDate(shopId, day);
log.info("orderStat:{}", orderStat);
ShopOrderStatistic userFlowStat = mapper.getShopUserFlowStatSingleDate(shopId, day);
log.info("userFlowStat:{}", userFlowStat);
Long discountCount = mapper.countDiscountOrder(shopId, day);
BigDecimal discountAmount = mapper.countDiscountAmount(shopId, day);
Long tableCount = mapper.countShopTable(shopId);
@@ -172,7 +177,11 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
result.setNetProfitAmount(BigDecimal.ZERO);
}
//客单价 实付金额(包括线上支付 包含现金支付 包含会员支付 包含挂账)/就餐人数
result.setAvgPayAmount(result.getPayAmount().divide(new BigDecimal(result.getCustomerCount()), 2, RoundingMode.HALF_DOWN));
if (result.getCustomerCount() > 0) {
result.setAvgPayAmount(result.getPayAmount().divide(new BigDecimal(result.getCustomerCount()), 2, RoundingMode.HALF_DOWN));
}else {
result.setAvgPayAmount(result.getPayAmount());
}
//翻台率 (订单数-桌台数)/桌台数*100%
if (tableCount > 0) {
BigDecimal turnoverRate = new BigDecimal(result.getOrderCount()).subtract(new BigDecimal(tableCount)).divide(new BigDecimal(tableCount), 4, RoundingMode.HALF_DOWN).multiply(BigDecimal.valueOf(100));