From 86435e9707df1bac5f5c50d85c1ef51eb6567e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 22 Nov 2023 10:10:36 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=9C=88=E5=BA=A6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/month.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/month.go b/tasks/month.go index 631ce45f..088faf86 100644 --- a/tasks/month.go +++ b/tasks/month.go @@ -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)