统计的 一些报错

This commit is contained in:
2025-11-22 14:20:04 +08:00
parent 381ae80eeb
commit f8d8f50c66
3 changed files with 45 additions and 8 deletions

View File

@@ -27,6 +27,8 @@ public interface ShopTableOrderStatisticMapper extends BaseMapper<ShopTableOrder
*/
@Select("SELECT " +
" `table`.id AS tableId, " +
" #{shopId} AS shopId, " +
" #{tradeDay} AS createDay, " +
" `table`.table_code AS tableCode, " +
" `table`.`name` AS tableName, " +
" `area`.`name` AS areaName, " +
@@ -44,7 +46,8 @@ public interface ShopTableOrderStatisticMapper extends BaseMapper<ShopTableOrder
" `order`.shop_id = #{shopId} " +
" AND `order`.trade_day = #{tradeDay} " +
" AND `order`.paid_time IS NOT NULL " +
" AND `order`.pay_mode != 'no-table'")
" AND `order`.pay_mode != 'no-table'" +
" group by `table`.id")
List<ShopTableOrderStatistic> getOnlineData(Long shopId, LocalDate tradeDay);
/**

View File

@@ -68,7 +68,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
}
@Override
public List<CountPayTypeVo> getSummaryPayTypeData(Long shopId, Integer day) {
public List<CountPayTypeVo> getSummaryPayTypeData(Long shopId, Integer day) {
LocalDate currentDate = LocalDate.now();
LocalDate startDate = currentDate;
if (day == 7) {
@@ -106,9 +106,15 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
Long newMemberCount = mapper.countNewMember(shopId, day);
BigDecimal productCostAmount = mapper.countProductCostAmount(shopId, day);
// 合并结果
BeanUtils.copyProperties(onlineStat, result);
BeanUtils.copyProperties(orderStat, result);
BeanUtils.copyProperties(userFlowStat, result);
if (onlineStat != null) {
BeanUtils.copyProperties(onlineStat, result);
}
if (orderStat != null) {
BeanUtils.copyProperties(orderStat, result);
}
if (userFlowStat != null) {
BeanUtils.copyProperties(userFlowStat, result);
}
result.setShopId(shopId);
result.setStatisticDate(day);
@@ -120,9 +126,37 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
result.setProductCostAmount(productCostAmount);
//会员充值退款 充值退款金额(线上退款+现金退款)
result.setRechargeRefundAmount(onlineStat.getOnlineRechargeRefundAmount().add(userFlowStat.getCashRechargeRefundAmount()));
BigDecimal onlineAmount = Objects.requireNonNullElse(
(onlineStat != null) ? onlineStat.getOnlineRechargeRefundAmount() : null,
BigDecimal.ZERO
);
BigDecimal userFlowAmount = Objects.requireNonNullElse(
(userFlowStat != null) ? userFlowStat.getCashRechargeRefundAmount() : null,
BigDecimal.ZERO
);
BigDecimal total = onlineAmount.add(userFlowAmount);
result.setRechargeRefundAmount(total);
//实付金额 (线上付款 现金支付 会员支付 挂账)
result.setPayAmount(onlineStat.getOnlinePayAmount().add(orderStat.getCashPayAmount()).add(orderStat.getMemberPayAmount()).add(orderStat.getCreditPayAmount()));
BigDecimal onlinePayAmount = (onlineStat != null)
? Objects.requireNonNullElse(onlineStat.getOnlinePayAmount(), BigDecimal.ZERO)
: BigDecimal.ZERO;
BigDecimal cashPayAmount = (orderStat != null)
? Objects.requireNonNullElse(orderStat.getCashPayAmount(), BigDecimal.ZERO)
: BigDecimal.ZERO;
BigDecimal memberPayAmount = (orderStat != null)
? Objects.requireNonNullElse(orderStat.getMemberPayAmount(), BigDecimal.ZERO)
: BigDecimal.ZERO;
BigDecimal creditPayAmount = (orderStat != null)
? Objects.requireNonNullElse(orderStat.getCreditPayAmount(), BigDecimal.ZERO)
: BigDecimal.ZERO;
BigDecimal totalPayAmount = onlinePayAmount
.add(cashPayAmount)
.add(memberPayAmount)
.add(creditPayAmount);
result.setPayAmount(totalPayAmount);
//毛利润(订单实付金额-商品成本)
result.setProfitAmount(result.getPayAmount().subtract(productCostAmount));
//毛利率(订单实付金额-商品成本)/订单实付金额*100%

View File

@@ -18,7 +18,7 @@
LEFT JOIN tb_product prod ON detail.product_id = prod.id
WHERE
`order`.shop_id = #{shopId}
AND `order`.trade_day = #{tradeDay}
AND `order`.trade_day = #{day}
AND `order`.paid_time IS NOT NULL
<if test="productName != null and productName != ''">
AND detail.name LIKE CONCAT('%',#{productName},'%')