销量记录导出

This commit is contained in:
2025-11-25 17:35:51 +08:00
parent fe16139446
commit 9af596b93c
3 changed files with 57 additions and 20 deletions

View File

@@ -108,23 +108,23 @@ public class ShopProdStatisticServiceImpl extends ServiceImpl<ShopProdStatisticM
public void statisticAndInsert(Long shopId, LocalDate day) {
List<ShopProdStatistic> realTimeData = getRealTimeDataByDay(shopId, day, null);
if (CollUtil.isNotEmpty(realTimeData)) {
// 过滤掉没有有效数据的记录
realTimeData = realTimeData.stream()
.filter(ShopProdStatistic::isValid)
.toList();
if (CollUtil.isNotEmpty(realTimeData)) {
boolean exists = exists(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
if (exists) {
remove(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
}
saveBatch(realTimeData);
boolean exists = exists(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
if (exists) {
remove(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
}
saveBatch(realTimeData);
}
}
@Override
public List<ShopProdStatistic> getRealTimeDataByDay(Long shopId, LocalDate day, String productName) {
return mapper.selectProStatByDay(shopId, day, productName);
List<ShopProdStatistic> shopProdStatistics = mapper.selectProStatByDay(shopId, day, productName);
// 过滤掉没有有效数据的记录
shopProdStatistics = shopProdStatistics.stream()
.filter(ShopProdStatistic::isValid)
.peek(ShopProdStatistic::initValidData)
.toList();
return shopProdStatistics;
}
@Override

View File

@@ -90,10 +90,10 @@
</select>
<select id="summaryCountSingleDate" resultType="com.czg.order.vo.SaleSummaryCountVo">
SELECT
sum(tb_shop_prod_statistic.sale_count) AS saleCount,
sum(tb_shop_prod_statistic.sale_amount) AS saleAmount,
sum(tb_shop_prod_statistic.refund_count) AS refundCount,
sum(tb_shop_prod_statistic.refund_amount) AS refundAmount
sum(statistic.sale_count) AS saleCount,
sum(statistic.sale_amount) AS saleAmount,
sum(statistic.refund_count) AS refundCount,
sum(statistic.refund_amount) AS refundAmount
FROM
tb_shop_prod_statistic statistic
INNER JOIN tb_product prod ON tb_shop_prod_statistic.prod_id = prod.id
@@ -107,10 +107,10 @@
<select id="summaryCountDateRange" resultType="com.czg.order.vo.SaleSummaryCountVo">
SELECT
sum(tb_shop_prod_statistic.sale_count) AS saleCount,
sum(tb_shop_prod_statistic.sale_amount) AS totalAmount,
sum(tb_shop_prod_statistic.refund_count) AS refundCount,
sum(tb_shop_prod_statistic.refund_amount) AS refundAmount
sum(statistic.sale_count) AS saleCount,
sum(statistic.sale_amount) AS totalAmount,
sum(statistic.refund_count) AS refundCount,
sum(statistic.refund_amount) AS refundAmount
FROM
tb_shop_prod_statistic statistic
INNER JOIN tb_product prod ON statistic.prod_id = prod.id