余量查询最新月份
This commit is contained in:
parent
60f4775cbc
commit
60d56109fe
@ -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
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user