1
0
forked from lxh/go-wxhelper

🐛 修复月度数据统计错误的BUG

This commit is contained in:
李寻欢 2023-11-22 10:10:36 +08:00
parent b4470b0888
commit 86435e9707

View File

@ -29,7 +29,7 @@ func dealMonth(gid string) {
err := client.MySQL.Model(&entity.Message{}).
Where("from_user = ?", gid).
Where("`type` < 10000").
Where("YEARWEEK(date_format(create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1").
Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1").
Count(&yesterdayMsgCount).Error
if err != nil {
log.Printf("获取上月消息总数失败, 错误信息: %v", err)
@ -56,7 +56,7 @@ func dealMonth(gid string) {
Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`").
Where("tm.from_user = ?", gid).
Where("tm.type < 10000").
Where("YEARWEEK(date_format(tm.create_at, '%Y-%m-%d')) = YEARWEEK(now()) - 1").
Where("PERIOD_DIFF(date_format(now(), '%Y%m'), date_format(create_at, '%Y%m')) = 1").
Group("tm.group_user, tgu.nickname").Order("`count` DESC").
Limit(10)