From 60f4775cbc2dc146145e1efa43324a97863ad257 Mon Sep 17 00:00:00 2001 From: lzh <1625167628@qq.com> Date: Tue, 21 Oct 2025 14:50:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=9A=84=E6=9D=A1=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleExtend.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index d4ed906..266ba95 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -521,6 +521,8 @@ inner join ( user_id from bundle_balance bb + where + bb.deleted_at is null group by bb.user_id ) newest on From 60d56109fe815d222cd5e5596f13c87783803a47 Mon Sep 17 00:00:00 2001 From: lzh <1625167628@qq.com> Date: Tue, 21 Oct 2025 15:43:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=99=E9=87=8F=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E6=9C=88=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleExtend.go | 7 ++++++- internal/logic/bundleExtendLogic.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index 266ba95..e72171d 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -93,7 +93,6 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun Joins("LEFT JOIN bundle_activate bc on bc.user_id = u.id"). Where("rn.name IS NOT NULL"). Where("u.deleted_at = 0"). - Where("bb.month = ?", req.Month). Where("bor.deleted_at IS NULL"). Order("bor.expiration_time desc") if req.UserName != "" { @@ -121,6 +120,12 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun if req.Bought == 1 { session = session.Where("bor.uuid IS NULL") } + if req.Month == "" { + newestMonthQuery := app.ModuleClients.BundleDB.Model(&model.BundleBalance{}).Select("max(month) as month,user_id").Group("user_id") + session.Joins("LEFT JOIN (?) as newest_month on newest_month.user_id = bb.user_id", newestMonthQuery).Where("") + } else { + session = session.Where("bb.month = ?", req.Month) + } err = session.Count(&total).Error if err != nil { return diff --git a/internal/logic/bundleExtendLogic.go b/internal/logic/bundleExtendLogic.go index c1d26a4..473ed1c 100644 --- a/internal/logic/bundleExtendLogic.go +++ b/internal/logic/bundleExtendLogic.go @@ -66,7 +66,7 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (*bundle.GetBundl resp.Total = total date, err := time.Parse("2006-01", req.Month) if err != nil { - return nil, errors.New("请求时间有误") + date = time.Now() } resp.Data = lo.Map(data, func(m model.BundleBalancePo, _ int) *bundle.BundleBalanceItem { result := &bundle.BundleBalanceItem{