diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index a5fb168..064f145 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -480,3 +480,33 @@ func GetValueAddByOrderUUID(orderUUID string) (data []model.BundleOrderValueAdd, err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).Where("order_uuid = ?", orderUUID).Find(&data).Error return } + +func UpdateBundleBalance() error { + bl := []model.BundleBalance{} + if err := app.ModuleClients.BundleDB.Raw(`select + * +from + bundle_balance bb +inner join ( + select + max(bb.month) as month , + user_id + from + bundle_balance bb + group by + bb.user_id +) newest on + newest.month = bb.month + and bb.user_id = newest.user_id`).Find(&bl).Error; err != nil { + return err + } + + month := time.Now().Format("2006-01") + for _, v := range bl { + v.MonthlyLimitVideoConsumptionNumber = 0 + v.MonthlyLimitImageConsumptionNumber = 0 + v.MonthlyLimitDataAnalysisConsumptionNumber = 0 + // v.MonthlyInvalidBundleVideoNumber + } + +} \ No newline at end of file