forked from lxh/go-wxhelper
🐛 修复月度数据统计错误的BUG
This commit is contained in:
parent
b4470b0888
commit
86435e9707
@ -29,7 +29,7 @@ func dealMonth(gid string) {
|
|||||||
err := client.MySQL.Model(&entity.Message{}).
|
err := client.MySQL.Model(&entity.Message{}).
|
||||||
Where("from_user = ?", gid).
|
Where("from_user = ?", gid).
|
||||||
Where("`type` < 10000").
|
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
|
Count(&yesterdayMsgCount).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("获取上月消息总数失败, 错误信息: %v", err)
|
log.Printf("获取上月消息总数失败, 错误信息: %v", err)
|
||||||
@ -56,7 +56,7 @@ func dealMonth(gid string) {
|
|||||||
Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`").
|
Select("tm.group_user", "tgu.nickname", "count( 1 ) AS `count`").
|
||||||
Where("tm.from_user = ?", gid).
|
Where("tm.from_user = ?", gid).
|
||||||
Where("tm.type < 10000").
|
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").
|
Group("tm.group_user, tgu.nickname").Order("`count` DESC").
|
||||||
Limit(10)
|
Limit(10)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user