定时任务修改

This commit is contained in:
张松 2025-03-18 09:52:29 +08:00
parent 1a297840bd
commit 1e0e8f251c
3 changed files with 11 additions and 4 deletions

View File

@ -21,6 +21,7 @@ public class StatisticTask {
@Resource
private ShopOrderStatisticService shopOrderStatisticService;
// @Scheduled(cron = "1/6 * * * * ? ")
@Scheduled(cron = "0 0 9 * * ?")
public void run() {
long start = System.currentTimeMillis();

View File

@ -1,6 +1,7 @@
package com.czg.order.entity;
import com.alibaba.fastjson2.annotation.JSONField;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
@ -136,6 +137,7 @@ public class ShopOrderStatistic implements Serializable {
/**
* 新增会员数
*/
@Column(ignore = true)
private Long newMemberCount = 0L;
/**
* 店铺id

View File

@ -60,8 +60,8 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
// 统计充值记录
Map<Long, BigDecimal> flowMap = shopUserFlowService.list(new QueryWrapper()
.ge(ShopUserFlow::getCreateTime, startOfDay)
.le(ShopUserFlow::getCreateTime, endOfDay)
.ge(ShopUserFlow::getCreateTime, startOfDay.toLocalDateTime())
.le(ShopUserFlow::getCreateTime, endOfDay.toLocalDateTime())
.in(ShopUserFlow::getBizCode, CollUtil.newArrayList("cashIn", "wechatIn", "alipayIn", "awardIn"))).stream()
.collect(Collectors.groupingBy(
ShopUserFlow::getShopId,
@ -138,13 +138,17 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
// 充值金额
// statistic.setRechargeAmount(BigDecimal.ZERO);
//客单价
statistic.setCustomerUnitPrice(totalAmount.divide(totalCount, 2, RoundingMode.DOWN));
if (totalAmount.compareTo(BigDecimal.ZERO) != 0) {
statistic.setCustomerUnitPrice(totalAmount.divide(totalCount, 2, RoundingMode.DOWN));
}
// 查询台桌数量
long count = shopTableService.count(new QueryWrapper().eq(ShopTable::getShopId, shopId));
//翻台率
statistic.setTableTurnoverRate(totalCount.subtract(BigDecimal.valueOf(count)).divide(BigDecimal.valueOf(count), 2, RoundingMode.DOWN).multiply(BigDecimal.valueOf(100)));
if (count > 0) {
statistic.setTableTurnoverRate(totalCount.subtract(BigDecimal.valueOf(count)).divide(BigDecimal.valueOf(count), 2, RoundingMode.DOWN).multiply(BigDecimal.valueOf(100)));
}
statistic.setUpdateTime(LocalDateTime.now());
BeanUtil.copyProperties(info, statistic);
saveOrUpdate(statistic);