1
This commit is contained in:
parent
6907e59e2e
commit
bcc418a55f
@ -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
|
err = app.ModuleClients.BundleDB.Model(&model.BundleOrderValueAdd{}).Where("order_uuid = ?", orderUUID).Find(&data).Error
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user