Merge branch 'dev-lzh-0905' into dev

This commit is contained in:
lzh 2025-10-21 15:43:55 +08:00
commit a47421f758
2 changed files with 9 additions and 2 deletions

View File

@ -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
@ -521,6 +526,8 @@ inner join (
user_id
from
bundle_balance bb
where
bb.deleted_at is null
group by
bb.user_id
) newest on

View File

@ -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{